报如下错误:也就是说数据源的url没有配置。要么把报错数据源配上,要么排除掉数据源的加载。这里当然是后者了,把数据源加载排除。
报错内容:
启动报错时的启动类:
@SpringBootApplication public class SpringBootTestApplication { public static void main(String[] args) { SpringApplication.run(SpringBootTestApplication.class, args); } }
依照以上报错使用了Druid的加载配置,将DruidDataSourceAutoConfigure排除。修改之后的启动类:
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class) public class SpringBootTestApplication { public static void main(String[] args) { SpringApplication.run(SpringBootTestApplication.class, args); } }
修改完成后再次启动,仍然出现报错↓↓↓
报错内容:虽然不默认加载Druid的数据源配置了,但是默认加载了springboot的默认数据源配置
依照此类错误,又把启动类进行调整,排除springboot的默认启动类DataSourceConfiguration
@SpringBootApplication(exclude = {DruidDataSourceAutoConfigure.class, DataSourceAutoConfiguration.class}) public class SpringBootTestApplication { public static void main(String[] args) { SpringApplication.run(SpringBootTestApplication.class, args); } }
再次启动,发现成功了!
https://blog.csdn.net/u012240455/article/details/82356075
https://blog.csdn.net/knqi007/article/details/83997634