Failed to configure a DataSource: 'url' attribute is not specified spring boot3.0启动时候报错
spring boot的配置文件名由application.yml改为bootstrap.yml或者bootstrap.properties
报错:
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
然后在启动类加了后仍然报错
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
报错:
Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
我使用的是spring boot3.0,原因是需要在pom中添加如下,并且启动类去掉exclude = DataSourceAutoConfiguration.class
<!--如果配置文件是bootstrap.properties,必须的加这个-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>4.0.0</version>
</dependency>
@SpringBootApplication
@MapperScan("org.codelab.lab.propagation.mapper")
public class LabApplication {
public static void main(final String[] args) {
SpringApplication.run(LabApplication.class, args);
System.out.println("-----------------------------lab start success!!!---------------------------------------");
}
}