AdminUI
启动AdminUI界面,需要单独定义AdminUI-Server服务,独立于功能服务之外。所有功能服务作为AdminUI-Client服务连接到Server服务,Server服务检测到连接后对进行监控处理。
Server
pom
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
</dependency>
application.properties
TIPS:注意端口不要和客户端冲突
server.port=8081
启动类
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
/**
* 启动类的配置与标准的spring boot启动类配置不同
*
* 访问地址:http://localhost:8081
* @author lenovo
*
*/
@Configuration
@EnableAutoConfiguration
@EnableAdminServer
public class AdminUiServerApplication {
public static void main(String[] args) {
SpringApplication.run(AdminUiServerApplication.class, args);
}
}
Client
pom
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
application.properties
# acturtor http 开启的endpoint
management.endpoints.web.exposure.include=*
# admin-ui server
spring.boot.admin.client.url=http://127.0.0.1:8081
# 不使用域名注册,以IP形式注册
spring.boot.admin.client.instance.prefer-ip=true