SpringBoot启动报错url' attribute is not specified and no embedded datasource could be configured.

在新建springBoot项目的时候,我就只选择了一个web、MySQL、mybatis,当启动时就报 错,错误信息如下

SpringBoot启动报错url' attribute is not specified and no embedded datasource could be configured.

经过半天的查找终于发现了问题,启动的时候需要在启动类的@EnableAutoConfiguration或@SpringBootApplication中添加exclude= {DataSourceAutoConfiguration.class},排除此类的autoconfig。启动以后就可以正常运行。

即:@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})