WARN o.a.c.l.WebappClassLoaderBase - [log,173] - The web application [ROOT] appears to have started a thread named [Thread-5] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base@17.0.9/sun.net.dns.ResolverConfigurationImpl.notifyAddrChange0(Native Method)
java.base@17.0.9/sun.net.dns.ResolverConfigurationImpl$AddressChangeListener.run(ResolverConfigurationImpl.java:176)
12:18:07.660 [restartedMain] 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 suitable jdbc url
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 (the profiles dev are currently active).
Disconnected from the target VM, address: '127.0.0.1:61616', transport: 'socket'
Process finished with exit code 1
这个错误表明 Spring Boot 应用程序无法自动配置数据源,一般是因为没有在配置中指定url
属性,并且也没有找到嵌入式数据库
解决方案
1. 检查数据库配置文件
这个错误信息表明Spring Boot应用程序在尝试配置数据源时失败了,具体原因是因为没有指定url属性,并且没有找到可以自动配置的嵌入式数据源
1、可以去application-dev.yml文件里面核查配置项,如指定数据源URL:在application.properties或application.yml文件中的数据库连接URL的准确性。
2、添加嵌入式数据库依赖:如果你希望使用嵌入式数据库(如H2、HSQL或Derby),请确保在项目的依赖管理文件(如pom.xml或build.gradle)中包含了相应的依赖。
例如,对于H2数据库,添加:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
3、检查配置文件路径:确保application.properties或application.yml文件位于正确的路径下,通常是src/main/resources目录。
4、检查配置文件名称:确保配置文件的名称正确无误,Spring Boot会自动加载这些文件来配置应用程序。