I have a working properties file for a Spring Boot application, but whenever I convert this into Yaml, I get an error, saying that the database url has not been specified.
I am using the following dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
and the config is as follows for the properties file (which works fine):
spring.datasource.url=jdbc:mysql://localhost:3306/db_name?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=username
spring.datasource.password=password
spring.jpa.hibernate.ddl-auto=update
spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
In Yaml I have:
spring:
datasource:
url: "jdbc:mysql://localhost:3306/db_name?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC"
driver-class-name: com.mysql.cj.jdbc.Driver
username: "username"
password: "password"
jpa:
hibernate:
ddl-auto: update
generate-ddl: true
show-sql: true
I have tried with and without quotation marks, I have tried driverClassName instead of driver-class-name, but each time I get the following message when the server tries to start up:
***************************
APPLICATION FAILED TO START
***************************
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
...