1

我有弹簧MVC Web应用程序。我已经在其中使用了弹簧启动器,通过添加下面的依赖关系。如何注册弹簧MVC应用程序以启动弹出管理器

<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服务器。

任何人都可以帮助我吗?

+0

[文档](http://codecentric.github.io/spring-boot-admin/1.4.1/#getting-started)是什么意思? –

+0

我做了这部分,遵循文档并将其应用于应用程序中,但未显示任何错误并未注册到管理服务器。 – Harshil

回答

1

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

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

如果你不想使用client-lib,你也可以通过简单的http post请求注册到管理服务器的​​端点。

$ 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 
+0

谢谢..... – Harshil

+0

它在春季mvc项目中适合你吗?你能证明你是怎么做到的?@哈尔希尔 – Xiaokun

相关问题