我最近将一个项目从Spring Boot1.5.1升级到2.0.0,但是我们的自定义执行器endpoint没有注册。我尝试了以下endpoint迁移指南(docs.spring.io、github和spring.io),以使用新方法迁移我们的自定义endpoint,但它不起作用。
下面是我正在尝试注册的简化endpoint:
@Component
@Endpoint(id = "time")
public class TimeEndpoint {
@ReadOperation
public Map<String, Object> getTimeInfo() {
return new HashMap<String, Object>() {{
put("time", DateTime.now(UTC));
}};
}
}
我甚至尝试从类中删除@component
并将其注册为主@configuration
类中的bean,如下所示:
@Bean
public TimeEndpoint timeEndpoint() {
return new TimeEndpoint();
}
当我构建项目并启动时,我看到它注册了/healt
、/info
和/acture
endpoint,但没有注册我的/time
endpoint。尝试转到/time
或/actuctor/time
将导致404。
WebMvcEndpointHandlerMapping - Mapped "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
WebMvcEndpointHandlerMapping - Mapped "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
WebMvcEndpointHandlerMapping - Mapped "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto protected java.util.Map<java.lang.String, java.util.Map<java.lang.String, org.springframework.boot.actuate.endpoint.web.Link>> org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.links(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
我甚至尝试升级到2.0.1,但那也没有帮助。
我错过了什么?
我相信,沙兰·德·席尔瓦的答案是不正确的。我只是在一个相同的问题上花了几个小时,因为属性名称不同。应该是:
management:
endpoints:
web:
exposure:
include: 'health,info,metrics,customendpoint'
下面是正式的引用:https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#production-ready-endpoints-exposing-endpoints
我是新来的Spring Boot。在我的控制器中,我使用s作为。缺省情况下,在传递无效的时,Spring返回。 当客户端传递一个无效的时,我想抛出一个自定义的,这样我就可以使用这个异常返回一个自定义的错误。 我试图注册一个定制的(实现)。 为了注册这个组件,我将这个转换器添加到springs。使用。 我还尝试使用而不是这里提到的:Spring没有使用mongo定制转换器 我尝试过的其他解决方案是:
我是新来的Laravel。我有两种不同的用户类型:老师和学生。教师在网站注册表格中注册账户,但学生注册由windows应用程序提供。所以我必须为这个应用程序提供一个API。默认Laravel认证是足够的教师注册,但我可以使用相同的AuthController API注册?我不需要视图或重定向到网站。
我已经为log4j2编写了一个自定义触发策略,该策略将被回滚。在每小时/天/你的工作时间间隔结束时,按照本SO帖子的建议记录文件。 虽然我遵循基于时间的触发策略约定(命名等),但我无法看到我的策略被实例化和使用。 解决方案由3个java文件和一个maven文件组成,可在github上获得 在这里,您可以从政策本身找到主要内容: log4j2。xml文件: 编辑: 在调试过程中,我了解到在log4j
在META-INF/Services中,添加了javax.annotation.processing.processor条目,指定自定义注释处理器类。
我正在我的项目中使用模块,该模块公开了要监视的RESTendpointURL 默认情况下,仅公开 和 终结点。 根据我的使用案例,我正在通过< code > application . properties 文件自定义endpoint。 我想了解,Spring启动究竟在哪里为和创建实际的endpoint,以及它如何通过HTTP公开它们?
春奴B:好的。我从一个STS Spring Starter项目/Maven/Java8/Spring Boot2.0开始,并选择Web和致动器依赖项。它构建和运行良好,并转发到http://localhost:8080/acturet/health。我在主应用程序类中添加了一个“endpoint”,使其看起来像这样。