Springboot Error: Failed to configure a DataSource: ‘url’ attribute is not specified and no embedd

Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.

Cannot configure datasource: the ‘URL’ property is not specified, and the embedded datasource cannot be configured.

Obviously, you don’t configure some attributes of datasource in your application, such as address value, database driver, user name, password,

As we all know, the biggest advantage of springboot is automatic configuration: so we just need to give it the value of the configuration file, and it will be automatically configured. Configure in application.properties In the file

Then I will give you some of the most basic configuration information of springboot

#Accessing the root path

#app name
spring.application.name=springboot-demo

#port
server.port=8080

#encode
server.tomcat.uri-encoding=utf-8

#database
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/sql_test
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.max-idle=10
spring.datasource.max-wait=10000
spring.datasource.min-idle=5
spring.datasource.initial-size=5

#session
server.servlet.session.timeout=30m

Of course, you can not configure it, but you need to declare it

Just start the class header declaration:

@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})

Similar Posts: