Spring 2.6.3: Failed to configure a DataSource: 'url' attribute
I have created a new Spring Starter Project and I specified in application.properties
the db settings:
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=.....
in pom.xml
I have the mysql dependency:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
I have also done maven -> Update
....
When starting the project the console says:
***************************
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
I don´t understand..i just provided what he needs...the datasource.url...
When I change the spring version to 2.3.0.RELEASE
...it works. But why not with the newer one 2.6.3
?
As far as I know, Spring .properties file uses kebab-case for its key values.
You have
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
when it should be
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver