Spring 2.6.3:无法配置数据源:'url'属性



我创建了一个新的Spring Starter项目,并在application.properties中指定了数据库设置:

spring.jpa.hibernate.ddl-auto=update
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.datasource.url=jdbc:mysql://localhost:3306/mydb?&useLegacyDatetimeCode=false&serverTimezone=UTC&useUnicode=yes&character_set_server=utf8mb4
spring.datasource.username=.....
spring.datasource.password=.....

pom.xml中,我有mysql依赖项:

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>

我也做过maven -> Update。。。。

启动项目时,控制台显示:

***************************
APPLICATION FAILED TO START
***************************
Description:
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

我不明白。。我只是提供了他需要的。。。数据源url…

当我更改spring version to 2.3.0.RELEASE。。。它是有效的。但为什么不使用newer one 2.6.3呢?

据我所知,Spring.properties文件的键值使用kebab大小写。

你有

spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver

什么时候应该是

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

最新更新