为了账号安全,请及时绑定邮箱和手机立即绑定

Spring Boot + Flyway + AWS:

Spring Boot + Flyway + AWS:

月关宝盒 2021-06-15 17:35:16
除了在 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 回答

?
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 所做的。


查看完整回答
反对 回复 2021-06-23
  • 2 回答
  • 0 关注
  • 151 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信