SpringBoot will show error if there is no datasource configuration in application.yml/application.properties
221229 11:14:44906 main W bServerApplicationContext#591 Exception encountered during context initialization ... nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
...
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
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Because on start up SpringBoot will attempt to auto initialise a datasource, to run a spring boot application without datasource. You must disable the auto configuration for the datasource and may be for JPA also by adding exclude = {...}
to the main entry.
Method #1
@SpringBootApplication
@EnableAutoConfiguration(exclude = {
DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class,
HibernateJpaAutoConfiguration.class})
public class Application {
public static void main(String[] args) {
SpringApplication.run(PayPalApplication.class, args);
}
}
Method #2
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
public class AppBoot {
public static void main(String[] args) {
SpringApplication.run(AppBoot.class, args);
}
}
标签:SpringBoot,args,public,报错,datasource,main,class,Datasource
From: https://www.cnblogs.com/milton/p/17017268.html