关于springboot:springcloud子模块项目启动无法配置数据源Failed-to-configure-a-DataSource

谬误详情:

07:31:04.082 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter - [report,40] - 

***************************
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).

07:31:04.083 [Thread-1] WARN  c.a.n.c.h.HttpClientBeanHolder - [shutdown,108] - [HttpClientBeanHolder] Start destroying common HttpClient
07:31:04.083 [Thread-1] WARN  c.a.n.c.h.HttpClientBeanHolder - [shutdown,114] - [HttpClientBeanHolder] Destruction of the end
Disconnected from the target VM, address: '127.0.0.1:63119', transport: 'socket'

Process finished with exit code 1

我的项目环境:

springcloud+Nacos+mybatisPlus

解决形式:

搜寻解决形式,有网友说是: 在多模块的maven我的项目中 springboot没有读到配置文件造成的,所以只用在此模块的最外层pom文件中增加<build> … </build>配置, 应用后并不失效.
排查N久后发现, 在nacos中,导入其余我的项目的残缺配置文件后 我的项目是能够失常启动的,证实是配置文件的问题!!!!!! 删除与以后模块无关的配置文件后,发现, 以后子模块的配置的nacos分组是本人设置的个性化分组,而不是默认的”DEFAULT_GROUP”,
在以后我的项目的 .yml 文件中并没有指定以后应用的分组是个性化分组:

nacos配置:

批改yml文件:

重启,失效!!!!!

也能够通过注解形式实现:
在启动类上减少注解:

 @SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)

须要留神 : 应用注解还要把allow-bean-definition-overriding的值设为true

spring.main.allow-bean-definition-overriding=true

如果不失效,能够试试手写的:

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(TestApplication.class);
        app.setAllowBeanDefinitionOverriding(true);
        app.run(args);
    }

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理