我有一个在本地工作正常的Spring Web应用程序。 我在RDS上有我的MySQL数据库,我还在S3存储桶中存储了一些图像。 然后我尝试使用Elastic Beanstalk部署War,当我输入URL时,我得到的唯一一件事是404错误。
然后我去查看日志,我认为这是造成问题的原因:
javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution
所以我认为我的数据源配置存在问题,但实际上找不到解决方案。
这是我的application.properties:
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto = update
spring.datasource.url = jdbc:mysql://mysql-instance.rrgatg5flqq6.us-east-2.rds.amazonaws.com:3306/mydb
spring.datasource.username = ****
spring.datasource.password = ****
spring.datasource.driver-class-name = com.mysql.jdbc.Driver
这是pom.xml:
<groupId>com.spring</groupId>
<artifactId>gabphoto</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>gabphoto</name>
<description>Exam project 5 sem</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.133</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
先谢谢你们!