Spring 弹簧靴2执行器,不带弹簧靴和@enableauto配置
我正在尝试用现有的Gradle Spring MVC项目设置Spring执行器。我无法使用@EnableAutoConfiguration。 不幸的是,我无法到达执行器端点,我想我遗漏了一些东西 项目中的Spring依赖项包括:Spring 弹簧靴2执行器,不带弹簧靴和@enableauto配置,spring,spring-mvc,spring-boot-actuator,Spring,Spring Mvc,Spring Boot Actuator,我正在尝试用现有的Gradle Spring MVC项目设置Spring执行器。我无法使用@EnableAutoConfiguration。 不幸的是,我无法到达执行器端点,我想我遗漏了一些东西 项目中的Spring依赖项包括: // springVersion = 5.1.+ implementation( "org.springframework:spring-beans:$springVersion", "org.springframewor
// springVersion = 5.1.+
implementation(
"org.springframework:spring-beans:$springVersion",
"org.springframework:spring-webmvc:$springVersion",
"org.springframework:spring-jdbc:$springVersion")
implementation 'org.springframework.boot:spring-boot-starter-actuator'
我正在尝试使用以下内容配置project:
@Configuration
@Import({EndpointAutoConfiguration.class,
MetricsEndpointAutoConfiguration.class,
HealthEndpointAutoConfiguration.class,
MappingsEndpointAutoConfiguration.class,
InfoEndpointAutoConfiguration.class})
@EnableWebMvc
public class DI_App {
}
在属性文件中,我添加了:
management.endpoints.web.exposure.include=*
启用了非执行器端点,尝试访问它们时得到404。
我问了很多相关的问题,但没有一个解决方案对我有效
我可能需要定义自定义EndpointHandlerMapping
,但不确定如何执行,它似乎不可用。
(参考号:)
编辑:
当前,我的应用程序配置如下所示:
@Configuration
@EnableWebMvc
@ComponentScan("com.test.springtest")
@Import({
ConfigurationPropertiesReportEndpointAutoConfiguration.class,
EndpointAutoConfiguration.class,
WebEndpointAutoConfiguration.class,
HealthEndpointAutoConfiguration.class,
HealthIndicatorAutoConfiguration.class,
InfoEndpointAutoConfiguration.class,
InfoContributorAutoConfiguration.class,
LogFileWebEndpointAutoConfiguration.class,
LoggersEndpointAutoConfiguration.class,
WebMvcMetricsAutoConfiguration.class,
ManagementWebSecurityAutoConfiguration.class,
ManagementContextAutoConfiguration.class,
ServletManagementContextAutoConfiguration.class
})
public class DI_App {
private final ApplicationContext _applicationContext;
DI_App(ApplicationContext applicationContext) {
_applicationContext = applicationContext;
System.setProperty("management.endpoints.web.exposure.include", "*");
System.setProperty("management.endpoints.jmx.exposure.exclude", "*");
System.setProperty("management.endpoints.web.base-path", "/manage");
System.setProperty("management.server.port", "10100");
}
@Bean
public WebMvcEndpointHandlerMapping endpointHandlerMapping(Collection<ExposableWebEndpoint> endpoints) {
List<String> mediaTypes = List.of(MediaType.APPLICATION_JSON_VALUE, ActuatorMediaType.V2_JSON);
EndpointMediaTypes endpointMediaTypes = new EndpointMediaTypes(mediaTypes, mediaTypes);
WebEndpointDiscoverer discoverer = new WebEndpointDiscoverer(_applicationContext,
new ConversionServiceParameterValueMapper(),
endpointMediaTypes,
List.of(EndpointId::toString),
emptyList(),
emptyList());
return new WebMvcEndpointHandlerMapping(new EndpointMapping("/manage"),
endpoints,
endpointMediaTypes,
new CorsConfiguration(),
new EndpointLinksResolver(discoverer.getEndpoints()));
}
}
当前状态是,当转到/manage
端点时,我得到以下信息:
{"_links":{"self":{"href":"http://localhost:10100/dev/manage","templated":false},"info":{"href":"http://localhost:10100/dev/manage/info","templated":false}}}
但是
http://localhost:10100/dev/manage/info
返回404,没有其他端点可用。您可以通过检查spring.factories文件()来检查哪些配置执行自动配置过程。我没有检查缺少哪些,但是org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration
是一个公开web端点的配置,因此您肯定需要导入它。您是否尝试添加工件spring boot actuator autoconfigurate
?您必须编译(“org.springframework.boot:springbootstarteractor”)
在你的附件中。你检查过这个问题吗?直接添加弹簧启动执行器自动配置
没有任何区别,我的构建文件中确实有弹簧启动执行器
。我还检查了链接问题-它与执行器的v1.x有关,我需要版本2的帮助。你可以检查通过检查spring.factories文件()自动配置过程。我没有检查缺少哪些,但是org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration
是一个公开web端点的配置,因此您肯定需要导入它。您是否尝试添加工件spring boot actuator autoconfigurate
?您必须有编译(“org.springframework.boot:springbootstarter
在您的附件中。您检查过这个问题吗?直接添加弹簧启动执行器自动配置
没有任何区别,我的构建文件中确实有弹簧启动执行器
。我还检查了链接问题-它与执行器的v1.x有关,我需要有关版本2的帮助
{"_links":{"self":{"href":"http://localhost:10100/dev/manage","templated":false},"info":{"href":"http://localhost:10100/dev/manage/info","templated":false}}}