乐趣区

关于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);
    }
退出移动版