Java 如何向spring boot admin注册spring MVC应用程序

Java 如何向spring boot admin注册spring MVC应用程序,java,spring-mvc,spring-boot,spring-boot-actuator,spring-boot-admin,Java,Spring Mvc,Spring Boot,Spring Boot Actuator,Spring Boot Admin,我有spring MVC web应用程序。我在它里面使用了弹簧启动执行器,添加了如下依赖项 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-actuator</artifactId> <version>1.4.0.RELEASE</version> </dependenc

我有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 {
}
现在,当我点击url“”时,我得到了响应

{"status":"UP","diskSpace":{"status":"UP","total":493767094272,"free":417100754944,"threshold":10485760}}
所以,这是完美的。现在我的问题是如何将这个SpringMVCWeb应用程序注册到SpringBootAdminServer


有人能帮我吗?

如果您不想使用Spring Boots自动配置(
@EnableAutoConfiguration
),请查看Spring boot管理员客户端库中的
SpringBootAdminClientAutoConfiguration
,其中配置了所有用于在管理服务器上注册的组件

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

如果您根本不想使用客户机库,还可以通过一个简单的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
$curl-H“内容类型:application/json”--数据“{”serviecUrl”:http://localhost:8080/,“healthUrl”:http://localhost:8080/health,“managementUrl”:http://localhost:8080/“,”名称“:“我的应用程序”}”http://:/api/applications

你说了什么?我做了那部分,遵循文档并在应用程序中应用了它,但它没有显示任何错误,也没有注册到管理服务器。它在spring mvc项目中对你有用吗?你能展示一下你是怎么做到的吗?@Harshil