Spring 引导应用程序使用 spring-boot-starter-actuator 给出 "unable to start tomcat" 异常
Spring boot application gives "unable to start tomcat" exception with spring-boot-starter-actuator
我有我的 spring-boot 应用程序,带有 spring-boot-starter-web,然后我将 spring-boot-starter-actuator 添加到 gradle文件。没有编译错误。但是当我尝试 运行 服务器时,它给出了以下异常。
我的build.gradle内容(只收录主要内容)
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
} ...........
compile "org.springframework.boot:spring-boot-starter-actuator"
compile group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.1.3' .........
我的application.properties内容
server.port = 2128
spring.couchbase.env.timeouts.connect=10000
spring.couchbase.env.timeouts.query=180000
spring.couchbase.env.timeouts.view=20000
spring.couchbase.bootstrap-hosts=localhost
spring.couchbase.bucket.name=localdb
spring.couchbase.bucket.password=*****
spring.data.couchbase.repositories.type=自动
spring.data.couchbase.auto-index=true
server.compression.enabled=真
server.compression.mime-类型=application/json,text/plain
spring.servlet.multipart.enabled=真
spring.servlet.multipart.maxFileSize=50MB
spring.servlet.multipart.maxRequestSize=50MB
我的Application.java
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
启动服务器时出现以下异常。
org.springframework.context.ApplicationContextException: 无法启动网络服务器;
嵌套异常是 org.springframework.boot.web.server.WebServerException:无法启动嵌入 Tomcat
原因:org.springframework.beans.factory.BeanCreationException:创建名称为 'servletEndpointRegistrar' 的 bean 在 class 路径资源中定义时出错
WebMvcServletEndpointManagementContextConfiguration.class]: 通过工厂方法实例化 Bean 失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:
无法实例化 [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]:工厂方法 'servletEndpointRegistrar' 抛出异常;
嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为 'healthEndpoint' 的 bean 在 class 路径资源中定义时出错
org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]:通过方法'healthEndpoint'参数1表示的未满足的依赖;
嵌套异常是 org.springframework.beans.factory.BeanCreationException:在 class 路径资源 [org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.class] 中定义名称 'healthIndicatorRegistry' 创建 bean 时出错:通过工厂方法实例化 Bean 失败
有什么有用的提示吗?
通过 application.properties 文件
中的以下条目关闭默认运行状况检查后,我终于能够启动应用程序
management.health.defaults.enabled=false
我有我的 spring-boot 应用程序,带有 spring-boot-starter-web,然后我将 spring-boot-starter-actuator 添加到 gradle文件。没有编译错误。但是当我尝试 运行 服务器时,它给出了以下异常。
我的build.gradle内容(只收录主要内容)
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
} ...........
compile "org.springframework.boot:spring-boot-starter-actuator"
compile group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.1.3' .........
我的application.properties内容
server.port = 2128
spring.couchbase.env.timeouts.connect=10000
spring.couchbase.env.timeouts.query=180000
spring.couchbase.env.timeouts.view=20000
spring.couchbase.bootstrap-hosts=localhost
spring.couchbase.bucket.name=localdb
spring.couchbase.bucket.password=*****
spring.data.couchbase.repositories.type=自动
spring.data.couchbase.auto-index=true
server.compression.enabled=真
server.compression.mime-类型=application/json,text/plain
spring.servlet.multipart.enabled=真
spring.servlet.multipart.maxFileSize=50MB
spring.servlet.multipart.maxRequestSize=50MB
我的Application.java
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
启动服务器时出现以下异常。
org.springframework.context.ApplicationContextException: 无法启动网络服务器; 嵌套异常是 org.springframework.boot.web.server.WebServerException:无法启动嵌入 Tomcat 原因:org.springframework.beans.factory.BeanCreationException:创建名称为 'servletEndpointRegistrar' 的 bean 在 class 路径资源中定义时出错 WebMvcServletEndpointManagementContextConfiguration.class]: 通过工厂方法实例化 Bean 失败;嵌套异常是 org.springframework.beans.BeanInstantiationException: 无法实例化 [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]:工厂方法 'servletEndpointRegistrar' 抛出异常; 嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为 'healthEndpoint' 的 bean 在 class 路径资源中定义时出错 org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]:通过方法'healthEndpoint'参数1表示的未满足的依赖; 嵌套异常是 org.springframework.beans.factory.BeanCreationException:在 class 路径资源 [org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.class] 中定义名称 'healthIndicatorRegistry' 创建 bean 时出错:通过工厂方法实例化 Bean 失败
有什么有用的提示吗?
通过 application.properties 文件
中的以下条目关闭默认运行状况检查后,我终于能够启动应用程序management.health.defaults.enabled=false