【发布时间】:2019-01-08 06:23:57
【问题描述】:
我有一个使用 Spring Boot 2.0.x.RELEASE 的非常简单的演示应用程序
在我的 POM 中有:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
<exclusions>
<exclusion>
<!-- We're using undertow as our embedded web container instead of tomcat -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Embedded web container- serves Jersey resources -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<!-- Support for Spring Actuator & Health Check Endpoints -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
我的主应用程序看起来像:
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Bean
ResourceConfig getJerseyConfig() {
final HashMap<String, Object> jerseyProperties = new HashMap<>();
jerseyProperties.put(ServerProperties.MEDIA_TYPE_MAPPINGS, "json : application/json");
ResourceConfig resourceConfig = new ResourceConfig()
.register(TestEndpoints.class);
resourceConfig = resourceConfig.setProperties(jerseyProperties);
return resourceConfig;
}
}
当我尝试点击执行器端点(例如/actuator)时,我收到 404,但我可以毫无问题地点击TestEndpoints.java 中的端点。我使用 Spring Boot 1.5.x 进行了此操作,但现在看来 Jersey 不允许执行器端点通过。如果我完全删除 ResourceConfig bean,那么我可以点击执行器端点。我必须添加一些配置以允许执行器端点通过球衣吗?
【问题讨论】:
-
/actuator/info? -
我可以正常工作,请查看stackoverflow.com/a/56325410/320087
标签: java spring-boot jersey-2.0 spring-boot-actuator