022-06-28 12:00:40.819 ERROR [-,,,] 18920 --- [ restartedMain] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthIndicatorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicatorRegistry]: Factory method 'healthIndicatorRegistry' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbHealthIndicator' defined in class path resource [org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthIndicatorAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicator]: Factory method 'dbHealthIndicator' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2022-06-28 12:00:40.838 INFO [-,,,] 18920 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2022-06-28 12:00:40.848 WARN [-,,,] 18920 --- [ restartedMain] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [AsyncReporter{RabbitMQSender{addresses=[localhost:5672], queue=zipkin}}] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
[email protected]/jdk.internal.misc.Unsafe.park(Native Method)
[email protected]/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:234)
[email protected]/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2123)
app//zipkin2.reporter.ByteBoundedQueue.drainTo(ByteBoundedQueue.java:81)
app//zipkin2.reporter.AsyncReporter$BoundedAsyncReporter.flush(AsyncReporter.java:257)
app//zipkin2.reporter.AsyncReporter$Builder$1.run(AsyncReporter.java:190)
2022-06-28 12:00:40.849 WARN [-,,,] 18920 --- [ restartedMain] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [spring.cloud.inetutils] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
[email protected]/jdk.internal.misc.Unsafe.park(Native Method)
[email protected]/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
[email protected]/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2081)
[email protected]/java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:433)
[email protected]/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
[email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
[email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[email protected]/java.lang.Thread.run(Thread.java:834)
2022-06-28 12:00:40.851 WARN [-,,,] 18920 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2022-06-28 12:00:41.853 WARN [-,,,] 18920 --- [ restartedMain] z.r.AsyncReporter$BoundedAsyncReporter : Timed out waiting for in-flight spans to send
2022-06-28 12:00:45.842 INFO [-,,,] 18920 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-06-28 12:00:45.848 ERROR [-,,,] 18920 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
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).
当时我已经配置了Nacos的依赖,编写了配置文件,然后在 Linux 服务器上启动了 Nacos服务,当启动 SpringBoot 项目的时候,发生了报错
<dependency>
<groupId>com.alibaba.cloudgroupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discoveryartifactId>
dependency>
<dependency>
<groupId>com.alibaba.cloudgroupId>
<artifactId>spring-cloud-starter-alibaba-nacos-configartifactId>
dependency>
<dependency>
<groupId>com.alibaba.nacosgroupId>
<artifactId>nacos-clientartifactId>
dependency>
spring:
cloud:
nacos:
discovery:
server-addr: 192.168.159.133:8848
config:
server-addr: 192.168.159.133:8848
namespace: 4558f032-32ff-4e7b-b090-8dbfe9fc6a39
group: PAGE_GROUP
type: yaml
ext-config[0]:
data-id: ProductPageDemo-dev.yaml
refresh: true # 启用自动更新
ext-config[1]:
data-id: ProductPageDemo-1.yaml
refresh: true # 启用自动更新
ext-config[2]:
data-id: ProductPageDemo-2.yaml
refresh: true # 启用自动更新
/**
* @author 云梦归遥
* @date 2022/6/25 11:57
* @description
*/
@RequestMapping("/pageTest")
@RestController
@RefreshScope // 手动刷新 Config 远程配置文件到本地缓存
public class PageTestController {
// 测试 Nacos 配置中心
@Value("${dev1.dataId:no}")
private String dev1_dataId;
@Value("${dev2.dataId:no}")
private String dev2_dataId;
@Value("${dev3.dataId:no}")
private String dev3_dataId;
@RequestMapping("/dev1")
public String getDev1(){
return "/dev1 对应配置文件:" + dev1_dataId;
}
@RequestMapping("/dev2")
public String getDev2(){
return "/dev2 对应配置文件:" + dev2_dataId;
}
@RequestMapping("/dev3")
public String getDev3(){
return "/dev3 对应配置文件:" + dev3_dataId;
}
}
<dependency>
<groupId>com.alibaba.cloudgroupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discoveryartifactId>
dependency>
<dependency>
<groupId>com.alibaba.cloudgroupId>
<artifactId>spring-cloud-starter-alibaba-nacos-configartifactId>
dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-dependenciesartifactId>
<version>Greenwich.RELEASEversion>
<type>pomtype>
<scope>importscope>
dependency>
<dependency>
<groupId>com.alibaba.cloudgroupId>
<artifactId>spring-cloud-alibaba-dependenciesartifactId>
<version>2.1.0.RELEASEversion>
<type>pomtype>
<scope>importscope>
dependency>
dependencies>
dependencyManagement>
spring:
cloud:
nacos:
discovery:
server-addr: 192.168.159.133:8848
config:
server-addr: 192.168.159.133:8848
namespace: 4558f032-32ff-4e7b-b090-8dbfe9fc6a39
ext-config[0]:
group: PAGE_GROUP
type: yaml
data-id: ProductPageDemo-dev.yaml
refresh: true # 启用自动更新
ext-config[1]:
type: yaml
group: PAGE_GROUP
data-id: ProductPageDemo-1.yaml
refresh: true # 启用自动更新
ext-config[2]:
type: yaml
group: PAGE_GROUP
data-id: ProductPageDemo-2.yaml
refresh: true # 启用自动更新