无法生成jar文件

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

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

  1. # spring.jpa.hibernate.ddl-auto=update
  2. # spring.datasource.url=jdbc:mysql://localhost:3306/db_digitalprofile?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
  3. # spring.datasource.username=root
  4. # spring.datasource.password=
  5. # server.port=9090
  6. # spring.jpa.show-sql = true
  7. # spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

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

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

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

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

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

  1. <configuration>
  2. <finalName> digitalProfile</finalName>
  3. </configuration>
smtd7mpg

smtd7mpg1#

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

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

x7yiwoj42#

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

相关问题