1

我有 Spring MVC Web 应用程序。我通过添加如下依赖项在其中使用了弹簧启动执行器。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-actuator</artifactId>
    <version>1.4.0.RELEASE</version>
</dependency>

在我的配置文件中,我导入了如下类。

@Configuration
@ComponentScan({"com.test.*"})
@Import({EndpointWebMvcAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class, EndpointAutoConfiguration.class,
HealthIndicatorAutoConfiguration.class,PublicMetricsAutoConfiguration.class})
@EnableWebMvc
@PropertySource("classpath:appconfig.properties")
public class SpringWebConfig extends WebMvcConfigurerAdapter {
}

现在,当我点击网址“ http://localhost:8080/health ”时,我得到了响应

{"status":"UP","diskSpace":{"status":"UP","total":493767094272,"free":417100754944,"threshold":10485760}}

所以,这很完美。现在我的问题是如何将此 Spring MVC Web 应用程序注册到 spring-boot-admin 服务器。

谁能帮我 ?

4

1 回答 1

3

如果您不想使用 Spring Boots 自动配置 ( @EnableAutoConfiguration),请查看SpringBootAdminClientAutoConfigurationspring-boot-admin-starter-client 库的表单,其中配置了用于在管理服务器上注册的所有组件。

主要是ApplicationRegistrator一些 taskScheduler 用于发出频繁的注册。

如果您根本不想使用 client-lib,您也可以通过一个简单的 http post 请求注册到管理服务器的/api/applications端点。

$ curl -H"Content-Type: application/json" --data '{ "serviecUrl":"http://localhost:8080/", "healthUrl":"http://localhost:8080/health", "managementUrl":"http://localhost:8080/","name":"my-app"}' http://<adminserver-host>:<port>/api/applications
于 2016-09-16T17:03:34.507 回答