hi
application.properties has configured spring.datasource.url value in src/main/resources,Startup class configuration:
@SpringBootApplication
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
@ComponentScan
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Run, throw Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured
@PingGao89 Unfortunately, we don't have the time to diagnose a problem from a handful of lines of code. If you would like us to spend some time investigating, please spend some time to provide a complete example of the problem. You should also review your annotations. @SpringBootApplication is a combination of @EnableAutoConfiguration, @ComponentScan, and @Configuration so you have some duplication there.
hi
my code
springboot-test.zip
@PingGao89 welcome to the wonderful world of YAML. Your properties are missing a space so there are simply ignored. If I am adding a space between : and the value for all properties, the app attempts to connect to the configured database.
Your sample is very interesting as it shows a regression: you are using our infrastructure that might throw an exception and the failure analyzer wrongly assumes that the auto-configuration is at play so you get something like Failed to auto-configure a DataSource: while the exception is coming from your own code (you can see that by enabling the debug log).
We will use this issue to fix the message.
馃槩 Thank you for solving the problem
Most helpful comment
@PingGao89 welcome to the wonderful world of YAML. Your properties are missing a space so there are simply ignored. If I am adding a space between
:and the value for all properties, the app attempts to connect to the configured database.Your sample is very interesting as it shows a regression: you are using our infrastructure that might throw an exception and the failure analyzer wrongly assumes that the auto-configuration is at play so you get something like
Failed to auto-configure a DataSource:while the exception is coming from your own code (you can see that by enabling the debug log).We will use this issue to fix the message.