我是Springboot的新手,我无法用Mysql制作Springboot的jar文件来部署在.I中使用Eclipse IDE。
我创建了一个在本地主机上运行良好的应用程序,当我想要将它部署到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现在,当我想要创建jar文件时,右键单击project>,运行As>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>发布于 2020-12-06 04:12:49
无法确定合适的驱动程序类
您需要检查依赖关系。找不到驱动程序意味着缺少将用于连接到数据库的驱动程序jar。mysql驱动程序应该存在于pom文件或任何构建文件中。
发布于 2020-12-06 08:33:43
把这个添加到你的application.properties上,它应该会解决你的问题。
spring.datasource.driver-class-name=com.mysql.jdbc.Driverhttps://stackoverflow.com/questions/65155246
复制相似问题