应用程序属性
spring.jpa.hibernate.ddl-auto=update
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/RESERVATION?useSSL=false
spring.datasource.data-username=sam
spring.datasource.data-password=admin123 spring.jpa.show-sql=true
spring.mvc.view.prefix=/WEB-INF/jsps/ spring.mvc.view.suffix=.jsp
server.servlet.context-path=/flightreservation2
spring.jpa.database=MYSQL spring.datasource.tomcat.max-wait=10000
spring.datasource.tomcat.max-active=50
spring.datasource.tomcat.test-on-borrow=true
应用程序主要
package com.sam.flightreservation;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication public class Flightreservation2Application {
public static void main(String[] args) {
SpringApplication.run(Flightreservation2Application.class, args);
}
}
错误
启动ApplicationContext时出错。显示条件报告 在启用“调试”的情况下重新运行您的应用程序。 2019-03-03 17:42:47.183 错误10344 --- [restartedMain] o.s.boot.SpringApplication
:应用程序运行失败org.springframework.beans.factory.UnsatisfiedDependencyException: 创建名称为“ inMemoryDatabaseShutdownExecutor”的bean时出错 在类路径资源中定义 [org / springframework / boot / devtools / autoconfigure / DevToolsDataSourceAutoConfiguration.class]: 通过方法表达的不满意依赖性 'inMemoryDatabaseShutdownExecutor'参数0;嵌套异常为 org.springframework.beans.factory.BeanCreationException:错误 创建在类路径资源中定义的名称为“ dataSource”的bean [org / springframework / boot / autoconfigure / jdbc / DataSourceConfiguration $ Hikari.class]: 通过工厂方法实例化Bean失败;嵌套异常为 org.springframework.beans.BeanInstantiationException:失败 实例化[com.zaxxer.hikari.HikariDataSource]:工厂方法 'dataSource'引发异常;嵌套异常为 java.lang.IllegalStateException:无法加载驱动程序类: com.mysql.cj.jdbc.Driver位于 org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769) 〜[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]在 org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509) 〜[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1305) 〜[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1144) 〜[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) 〜[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) 〜[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]在 org.springframework.beans.factory.support.AbstractBeanFactory.lambda $ doGetBean $ 0(AbstractBeanFactory.java:320) 〜[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]在 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) 〜[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) 〜[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) 〜[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:307) 〜[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) 〜[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]在 org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1105) 〜[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]在 org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) 〜[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]在 org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) 〜[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]在 org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) 〜[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]在 org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]位于 org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]位于 org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]位于 org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]位于 org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]位于 com.sam.flightreservation.Flightreservation2Application.main(Flightreservation2Application.java:10) [classes /:na]位于sun.reflect.NativeMethodAccessorImpl.invoke0(Native 方法)〜[na:1.8.0_161]在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 〜[na:1.8.0_161]在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 〜[na:1.8.0_161] at java.lang.reflect.Method.invoke(Method.java:498) 〜[na:1.8.0_161]在 org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.3.RELEASE.jar:2.1.3.RELEASE]
我几乎尝试了每个网站/ YouTube,但问题仍然存在。
答案 0 :(得分:1)
spring.datasource.driverClassName: com.mysql.jdbc.Driver
将为您工作,并且在pom.xml
中具有以下依赖关系
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
答案 1 :(得分:0)