Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured解决办法

vps-under-title.png anjingling.png 1.png 科学上网教程 | 机场推荐 | 本站商务合作

新建springboot项目启动出错:Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.

出现错误的原因是我在官网[https://start.spring.io/]生成框架代码的时候,加入的Mybatis依赖。因此,autoconfig会去读取数据源配置,而新建的项目还没有配置数据源,所以会导致异常出现。

解决办法:

1.去掉maven数据库依赖;
2.在启动类的@EnableAutoConfiguration或@SpringBootApplication中添加exclude = {DataSourceAutoConfiguration.class},排除此类的autoconfig。启动以后就可以正常运行。

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)  
public class BdservoApplication {  

    public static void main(String[] args) {  
        SpringApplication.run(BdservoApplication.class, args);  
    }  
}
赞(0)
未经允许禁止转载:优米格 » Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured解决办法

评论 抢沙发

合作&反馈&投稿

商务合作、问题反馈、投稿,欢迎联系

广告合作侵权联系

登录

找回密码

注册

Ads Blocker Image Powered by Code Help Pro

检测到广告已被屏蔽

您好,系统检测到您使用了广告屏蔽组件。

本网站并不包含任何侵入性广告,我们提供免费的内容,但是需要广告收入来维持运营,还请将本站加入拦截白名单!