除了在 AWS Elastic Beanstalk 中,我得到了这个,但该应用程序在本地运行。01-Aug-2018 07:44:54.815 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Unable to obtain Jdbc connection from DataSourceCaused by: org.flywaydb.core.api.FlywayException: Unable to obtain Jdbc connection from DataSourceCaused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://d-use1-xx.xxxxxxxxxxx.us-east-1.rds.amazonaws.com:3306/xxxxxxxxxxx正确指定了 JDBC URL。我有这个file.war/WEB-INF/classes/application.propertiesspring.datasource.url = jdbc:mysql://d-use1-xx.xxxxxxxxxx.us-east-1.rds.amazonaws.com:3306/xxxxxxxxxspring.datasource.username = xxxxspring.datasource.password = xxxxxxxxx我确实\WEB-INF\lib\mysql-connector-java-5.1.46.jar在 WAR 文件中。我不知道这是否重要,但我最近为 Spring Security OAuth2 添加了一个 JDBC TokenStore 并将其添加到主类中。@SpringBootApplication@MapperScan("com.xxxxxx.xxxxxx.mapper")public class XxxxxxxxxxxxApplication extends SpringBootServletInitializer { @Bean(name = "OAuth") @ConfigurationProperties(prefix="spring.datasource") public DataSource secondaryDataSource() { return DataSourceBuilder.create().build(); }我不知道这是否重要(以前从未这样做过)但有一个空的环境变量集01-Aug-2018 07:44:38.290 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数:-DJDBC_CONNECTION_STRING=
2 回答
![?](http://img1.sycdn.imooc.com/533e51f30001edf702000200-100-100.jpg)
aluckdog
TA贡献1847条经验 获得超7个赞
您需要添加spring.datasource.driver-class-name
配置属性:
spring.datasource.driver-class-name = com.mysql.jdbc.Driver
JDBC 自动驱动加载仅适用于应用程序初始(系统)类路径上的驱动程序,但位于其中的驱动程序WEB-INF/lib
稍后添加到上下文类路径中,无法自动加载。
这意味着您需要显式加载它们,如果您指定spring.datasource.driver-class-name
(或SPRING_DATASOURCE_DRIVER_CLASS_NAME
您发现的环境变量),这就是 Spring Boot 所做的。
添加回答
举报
0/150
提交
取消