在控制台中找不到Spring Boot,/executor return Resource



下面提到的是我的pom.xmlapplication.yml和日志。所有CCD_ 3&/actuator/*端点返回到登录页面。请在这里找到登录页面截图

有一个不同的应用程序用于跟踪管理员。因此,管理依赖关系仅用于此。

Pom.xml:

<project>
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>com.application.application-name</groupId>
<artifactId>application-name</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>application-name</name>
<description> service for handling the events</description>
<packaging>jar</packaging>
<properties>
<java.version>1.8</java.version>
<spring-boot-admin.version>2.4.0</spring-boot-admin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<version>2.5.6.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.4.0</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-dependencies</artifactId>
<version>${spring-boot-admin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

Application-dev.yml:

security.basic.enabled: false
server:
port: ${PORT:8087}
spring:
application:
name: XYZ
boot:
#   https://codecentric.github.io/spring-boot-admin/current/#spring-boot-admin-client
admin:
api-path: /instances
client:
auto-registration: true
auto-deregistration: true
register-once: true
url: "http://localhost:9090"
instance:
name: XYZ
username: superadmin
password: admin
security:
filter:
dispatcher-types: async,forward,request,error
user:
name: superadmin
password: admin
logging:
level:
#    root: ${ROOT_LOGGING_LEVEL:DEBUG}
org:
apache:
kafka: ERROR
#      de:
#        codecentric:
#          boot:
#            admin:
#              client:
#                registration: DEBUG
management:
endpoints:
web:
exposure:
include: "*"
exclude: heapdump
endpoint:
health:
show-details: always
metrics:
enabled: true
security:
enabled: true
shutdown:
enabled: true
health:
mail:
enabled: false
server:
port: 8087

日志:

2022-04-12 17:21:52.701  INFO 568530 --- [nio-8087-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-04-12 17:21:52.701  INFO 568530 --- [nio-8087-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2022-04-12 17:21:52.701 DEBUG 568530 --- [nio-8087-exec-1] o.s.web.servlet.DispatcherServlet        : Detected StandardServletMultipartResolver
2022-04-12 17:21:52.701 DEBUG 568530 --- [nio-8087-exec-1] o.s.web.servlet.DispatcherServlet        : Detected AcceptHeaderLocaleResolver
2022-04-12 17:21:52.701 DEBUG 568530 --- [nio-8087-exec-1] o.s.web.servlet.DispatcherServlet        : Detected FixedThemeResolver
2022-04-12 17:21:52.702 DEBUG 568530 --- [nio-8087-exec-1] o.s.web.servlet.DispatcherServlet        : Detected org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator@139c2be3
2022-04-12 17:21:52.702 DEBUG 568530 --- [nio-8087-exec-1] o.s.web.servlet.DispatcherServlet        : Detected org.springframework.web.servlet.support.SessionFlashMapManager@37badac
2022-04-12 17:21:52.702 DEBUG 568530 --- [nio-8087-exec-1] o.s.web.servlet.DispatcherServlet        : enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data
2022-04-12 17:21:52.702  INFO 568530 --- [nio-8087-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2022-04-12 17:21:52.716 DEBUG 568530 --- [nio-8087-exec-1] o.s.web.servlet.DispatcherServlet        : GET "/actuator", parameters={}
2022-04-12 17:21:52.725 DEBUG 568530 --- [nio-8087-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped to ResourceHttpRequestHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/", "/"]
2022-04-12 17:21:52.726 DEBUG 568530 --- [nio-8087-exec-1] o.s.w.s.r.ResourceHttpRequestHandler     : Resource not found
2022-04-12 17:21:52.727 DEBUG 568530 --- [nio-8087-exec-1] o.s.web.servlet.DispatcherServlet        : Completed 404 NOT_FOUND
2022-04-12 17:25:01.621 DEBUG 568530 --- [nio-8087-exec-8] o.s.web.servlet.DispatcherServlet        : GET "/actuator/health", parameters={}
2022-04-12 17:25:01.623 DEBUG 568530 --- [nio-8087-exec-8] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped to ResourceHttpRequestHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/", "/"]
2022-04-12 17:25:01.625 DEBUG 568530 --- [nio-8087-exec-8] o.s.w.s.r.ResourceHttpRequestHandler     : Resource not found
2022-04-12 17:25:01.625 DEBUG 568530 --- [nio-8087-exec-8] o.s.web.servlet.DispatcherServlet        : Completed 404 NOT_FOUND

此外,这是我对应用程序的安全配置:


import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@EnableWebSecurity
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {

@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/actuator/**");
}

}

我是忘了要添加的内容还是做错了什么?请帮我解决这个问题,因为这对我来说真的很重要。

默认情况下,所有执行器端点都是安全的。在application-dev.yml文件中,您需要禁用执行器端点的安全性。

management:
security:
enabled: false

如果问题仍然存在,请尝试手动公开您需要的端点:

management:
endpoints:
web:
exposure:
include: [health,actuator,info]

使用yml文件的一个色调缺陷是:缩进。请尝试使用application.properties文件。可读性更强,无需麻烦。

最新更新