Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.


APPLICATION FAILED TO START


Description:
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).

在学习java的过程中,发现如上问题,
解决:Mybatis没有找到合适的加载类,可以根据上述日志发现spring-datasourse-url没有加载成功。
在@@SpringBootApplication注解上加上exclude,解除自动加载DataSourceAutoConfiguration.class

`import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;

@SpringBootApplication(exclude=DataSourceAutoConfiguration.class)
public class StoreApplication {
DataSourceProperties sdp;
public static void main(String[] args) {
SpringApplication.run(StoreApplication.class, args);
}
}`

posted @   爱笑的爱豆  阅读(80)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示