Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.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
Spring security 为什么弹簧启动执行器返回404而不是401?_Spring Security_Spring Boot_Spring Boot Actuator - Fatal编程技术网

Spring security 为什么弹簧启动执行器返回404而不是401?

Spring security 为什么弹簧启动执行器返回404而不是401?,spring-security,spring-boot,spring-boot-actuator,Spring Security,Spring Boot,Spring Boot Actuator,这是一个非常愚蠢的问题,但我不明白为什么当我尝试访问安全端点时,执行器会给我404而不是401 我添加了依赖项 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> 现在,我可以访问该应用程序,并且(一个残废版本)

这是一个非常愚蠢的问题,但我不明白为什么当我尝试访问安全端点时,执行器会给我404而不是401

我添加了依赖项

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>
现在,我可以访问该应用程序,并且(一个残废版本)
/health
,但当我转到
/metrics
,它会给我一个
WWW-Authenticate
标题,很好,但带有404,因此我的浏览器不会提示我输入用户和密码

$ curl -v http://localhost:8081/metrics
* STATE: INIT => CONNECT handle 0x6000572d0; line 1090 (connection #-5000)
* Added connection 0. The cache now contains 1 members
*   Trying ::1...
* STATE: CONNECT => WAITCONNECT handle 0x6000572d0; line 1143 (connection #0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8081 (#0)
* STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x6000572d0; line 1240 (connection #0)
* STATE: SENDPROTOCONNECT => DO handle 0x6000572d0; line 1258 (connection #0)
> GET /metrics HTTP/1.1
> Host: localhost:8081
> User-Agent: curl/7.45.0
> Accept: */*
>
* STATE: DO => DO_DONE handle 0x6000572d0; line 1337 (connection #0)
* STATE: DO_DONE => WAITPERFORM handle 0x6000572d0; line 1464 (connection #0)
* STATE: WAITPERFORM => PERFORM handle 0x6000572d0; line 1474 (connection #0)
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 404 Not Found
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< Strict-Transport-Security: max-age=31536000 ; includeSubDomains
< WWW-Authenticate: Basic realm="Spring"
< Content-Length: 0
< Date: Thu, 21 Jan 2016 15:55:12 GMT
<
* STATE: PERFORM => DONE handle 0x6000572d0; line 1632 (connection #0)
* Curl_done
* Connection #0 to host localhost left intact

为什么会这样?我可以更改它吗?

您已经设置了
管理。上下文路径=/exactor
,因此所有的exactor端点都将以此作为前缀。您的URL应该是
localhost:8080/activator/metrics

您已经设置了
管理。上下文路径=/activator
,因此所有的执行器端点都将以此为前缀。您的URL应该是
localhost:8080/exactor/metrics

确保您添加了spring boot starter web:

  <dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-web</artifactId>
  </dependency>

org.springframework.boot
SpringBootStarterWeb

确保已添加spring boot starter web:

  <dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-web</artifactId>
  </dependency>

org.springframework.boot
SpringBootStarterWeb
1。在application.properties中,endpoints.health.enabled=false
这引起了我这边的问题。我从application.properties中删除了此属性
2.在pom.xml中,它应该在标记中编译。
org.springframework.boot
弹簧靴起动器执行器
编译
1。在application.properties中,endpoints.health.enabled=false
这引起了我这边的问题。我从application.properties中删除了此属性
2.在pom.xml中,它应该在标记中编译。
org.springframework.boot
弹簧靴起动器执行器
编译

是否可以发布整个配置文件?您应该为所有端点(即使是组成的端点)获得401,除了那些明确不敏感的端点,如
/health
@adamr我添加了我拥有的属性,如果您的意思是这样的话。假设您的应用程序运行在不同的端口上,您是否可以尝试在与应用程序相同的端口上运行执行器,然后查看指标是否有效?您是否可以发布整个配置文件?您应该为所有端点(即使是组成的端点)获得401,除了那些明确不敏感的端点,如
/health
@adamr我添加了我拥有的属性,如果您的意思是这样的话。假设您的应用程序运行在不同的端口上,您能否尝试在与应用程序相同的端口上运行执行器,然后查看指标是否有效?抱歉,在第一次编辑中,我发布了一个更新版本的属性,带有
management.context path=/exactor
。那不应该在那里,我删除了它。对不起,在第一次编辑中,我发布了一个更新版本的属性,带有
management.context path=/exactor
。这不应该存在,我删除了它。编译是默认范围。因此,如果没有范围标记,则为compile。compile是默认范围。因此,如果没有scope标记,它就是编译的。
  <dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-web</artifactId>
  </dependency>
1. endpoints.health.enabled=false , in application.properties
This was causing issue at my end. I removed this property from application.properties

2.In pom.xml it should be compile in <scope> tag.
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
        <scope>compile</scope>
</dependency>