Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 升级到Boot 1.2后无法访问Spring Boot执行器健康端点_Java_Spring Boot Actuator - Fatal编程技术网

Java 升级到Boot 1.2后无法访问Spring Boot执行器健康端点

Java 升级到Boot 1.2后无法访问Spring Boot执行器健康端点,java,spring-boot-actuator,Java,Spring Boot Actuator,我在将Spring Boot从1.1.12升级到1.2.5时遇到问题,但在所有版本的1.2.x中都存在相同的问题。执行器提供的/health端点现在正在返回到一个用于工作的集成测试。升级依赖项时未更改任何代码 以下是测试用例: @Test public void testNoUserForStatusEndpoint() throws Exception { HttpEntity<String> entity = new HttpEntity<>(null, he

我在将Spring Boot从1.1.12升级到1.2.5时遇到问题,但在所有版本的1.2.x中都存在相同的问题。执行器提供的
/health
端点现在正在返回到一个用于工作的集成测试。升级依赖项时未更改任何代码

以下是测试用例:

@Test
public void testNoUserForStatusEndpoint() throws Exception {
    HttpEntity<String> entity = new HttpEntity<>(null, headers);
    ResponseEntity<String> response = template
            .exchange(base + "/health", HttpMethod.GET, entity, String.class);
    assertEquals(HttpStatus.OK, response.getStatusCode());
    assertEquals("{\"status\":\"UP\"}", response.getBody());
}
我怎样才能通过考试

更新:

最初,在
application.properties
中定义的唯一相关设置是
endpoints.health.enabled=true

management.health.status.order=UP、DOWN、OUT\u SERVICE、UNKNOWN
添加到
application.properties
中没有区别

使用所有三个属性会导致401(不起作用):

主类只是一个精简的Spring Boot应用程序启动器:

@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
我已经尝试添加
http.authorizeRequests().antMatchers(“/health**”).permitAll()
到上面详述的安全配置方法的第一行。这没什么区别


根据Spring Boot,当使用自定义安全性时,
endpoints.health.sensitive
属性被忽略。我在文档中没有发现这一点。

请在application.properties或application.yml上尝试这一点:-

management.health.status.order=UP,DOWN,OUT_OF_SERVICE,UNKNOWN

我找到了解决办法

@Order(securityproperty.ACCESS\u OVERRIDE\u Order)
添加到我的自定义身份验证筛选器(在问题中称为
CustomAuthenticationFilter
)会更改定义安全筛选器bean的语义

在没有注释的情况下,Spring Boot假设我要覆盖所有过滤器,而只单独使用自定义过滤器

通过注释,Spring Boot将my filter添加到预定义筛选器列表中。这允许
/health
端点再次工作


有关详细信息,请参见GitHub上的。

或添加
管理.security.enabled=false

到application.properties

我在/health url中遇到404错误。但是,它使用/exactor/health url而不是/health。

与类似,但安全细节不同。谢谢。这没有什么区别。请尝试这些:-endpoints.health.enabled=true&endpoints.health.sensitive=false我已经做过了。我的测试用例中仍有401响应。你能分享应用程序使用的应用程序属性以及主要类的详细信息吗?Sry我错过了要点。它的问题在于webseurity配置。您能否尝试将此作为配置方法中的第一行:-http.authorizeRequests().antMatchers(“/health**”).permitAll();“自定义身份验证筛选器”是什么意思。哪个物体?我也有同样的问题。请参见hier:@emoleumasi,它表示用于身份验证的
javax.servlet.Filter
实例。我正在为此使用自定义类。你能为我的问题提供一些建议吗?-(.谢谢你的帮助
@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
management.health.status.order=UP,DOWN,OUT_OF_SERVICE,UNKNOWN