错误详情:
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文件中添加 … 配置, 使用后并不生效.
排查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);
}