java - Spring 致动器 '/auditevents'端点返回404

标签 java spring spring-security spring-boot-actuator

我在调用 /actuator/auditevents 端点时收到 404 错误。仔细观察后,我发现可用端点列表不包括 /auditevents 端点。

pom.xml 依赖项

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

application.properties

management.endpoints.web.exposure.include=*

http://localhost:8080/actuator 输出

{
    "_links": {
        "beans": {
            "href": "http://localhost:8080/actuator/beans",
            "templated": false
        },
        "caches": {
            "href": "http://localhost:8080/actuator/caches",
            "templated": false
        },
        "caches-cache": {
            "href": "http://localhost:8080/actuator/caches/{cache}",
            "templated": true
        },
        "conditions": {
            "href": "http://localhost:8080/actuator/conditions",
            "templated": false
        },
        "configprops": {
            "href": "http://localhost:8080/actuator/configprops",
            "templated": false
        },
        "env": {
            "href": "http://localhost:8080/actuator/env",
            "templated": false
        },
        "env-toMatch": {
            "href": "http://localhost:8080/actuator/env/{toMatch}",
            "templated": true
        },
        "health": {
            "href": "http://localhost:8080/actuator/health",
            "templated": false
        },
        "health-path": {
            "href": "http://localhost:8080/actuator/health/{*path}",
            "templated": true
        },
        "heapdump": {
            "href": "http://localhost:8080/actuator/heapdump",
            "templated": false
        },
        "info": {
            "href": "http://localhost:8080/actuator/info",
            "templated": false
        },
        "loggers": {
            "href": "http://localhost:8080/actuator/loggers",
            "templated": false
        },
        "loggers-name": {
            "href": "http://localhost:8080/actuator/loggers/{name}",
            "templated": true
        },
        "mappings": {
            "href": "http://localhost:8080/actuator/mappings",
            "templated": false
        },
        "metrics": {
            "href": "http://localhost:8080/actuator/metrics",
            "templated": false
        },
        "metrics-requiredMetricName": {
            "href": "http://localhost:8080/actuator/metrics/{requiredMetricName}",
            "templated": true
        },
        "scheduledtasks": {
            "href": "http://localhost:8080/actuator/scheduledtasks",
            "templated": false
        },
        "self": {
            "href": "http://localhost:8080/actuator",
            "templated": false
        },
        "threaddump": {
            "href": "http://localhost:8080/actuator/threaddump",
            "templated": false
        }
    }
}

Spring启动版本:2.2.6.RELEASE

不确定我是否缺少任何必需的配置。

最佳答案

可以通过在应用程序的配置中提供 AuditEventRepository 类型的 bean 来启用审核。

尝试将以下 bean 添加到您的应用程序中:

@Bean
public InMemoryAuditEventRepository repository(){
 return new InMemoryAuditEventRepository();
}

关于java - Spring 致动器 '/auditevents'端点返回404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61298875/

相关文章:

java - hudson 与特拉克

java - 如何在命令行 Java 中实现 Dropbox OAuth?

java - 如何在 Spring Boot 应用程序中将千分尺与 jmx 一起使用?

spring - Keycloak Spring Boot 适配器和匿名资源

spring - 在 yaml 中将 debug 设置为 true 而不是 @EnableWebSecurity(debug = true)

java - 任何其他类似于观察者模式的方式

java - 在 XSD 中进行与选择类似的序列会引发 "' 违反“唯一粒子属性”异常

java - 什么时候应该使用@Component 而不是@Service?

java - 运行具有属性文件关联的 Junit 时如何访问 XML 文件?

java - 如何在没有应用程序上下文的情况下使用 spring-security 过滤器?