无法生成jar文件

yyyllmsg  于 2021-07-03  发布在  Java
关注(0)|答案(2)|浏览(285)

我是springboot的新手,我不能用mysql制作springboot的jar文件,用eclipseide在aws中部署。
我创建了一个在localhost中运行良好的应用程序,当我想将它部署到aws中时,我会注解我的application.properties文件,该文件的代码如下


# spring.jpa.hibernate.ddl-auto=update

# spring.datasource.url=jdbc:mysql://localhost:3306/db_digitalprofile?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

# spring.datasource.username=root

# spring.datasource.password=

# server.port=9090

# spring.jpa.show-sql = true

# spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

并在src/main/resource中创建一个名为application-prod.properties的新文件,其代码为:

server.port=5000 
spring.datasource.url=jdbc:mysql://${RDS_HOSTNAME}:${RDS_PORT}/${RDS_DB_NAME} 
spring.datasource.username=${RDS_USERNAME}
spring.datasource.password=${RDS_PASSWORD}
spring.jpa.hibernate.ddl-auto=update

现在,当我想从右键单击project>runas>maven install创建一个jar文件时,它会抛出如下错误:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
java.lang.IllegalStateException: Failed to load ApplicationContext

我还在pom.xml中添加了以下依赖项

<configuration>
<finalName> digitalProfile</finalName>
</configuration>
smtd7mpg

smtd7mpg1#

把这个加到你的脸上 application.properties 它应该能解决你的问题。

spring.datasource.driver-class-name=com.mysql.jdbc.Driver
x7yiwoj4

x7yiwoj42#

未能确定合适的驱动程序类别
你需要检查依赖关系。找不到驱动程序意味着,缺少将用于连接到数据库的驱动程序jar。mysql驱动程序应该存在于pom文件中,或者任何构建文件中。

相关问题