- springboot项目和springboot admin项目不建议放在一起,因为目的是为了监控,如果放在一起的话,一旦springboot挂了,springboot admin也就一起挂了,监控就失去意义.
- 搭建监控项目:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.4.1</version>
</dependency>
注意版本号要springboot版本号一致.
@SpringBootApplication
@EnableAdminServer
public class MindsaApplication {
public static void main(String[] args) {
SpringApplication.run(MindsaApplication.class, args);
}
}
启动类上加注解EnableAdminServer
server:
port: 8000
配置端口8000
- 配置要监控的服务
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.4.1</version>
</dependency>
版本号要一致
spring:
application:
name: jingxihua-inner # 服务名称
boot:
admin:
client:
url: http://localhost:8000 #监控中心地址
instance:
prefer-ip: true #以IP的形式展示服务列表
# 如果配置了server.servlet.context-path,则改地址也要加上
service-url: http://localhost:8088 #监控服务地址(当前服务的地址)
server:
port: 8088
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
logging:
file:
name: jingxihua-inner.log
标签:SpringBoot,Admin,spring,boot,单体,版本号,admin,监控,springboot From: https://blog.51cto.com/u_14121041/6415440