服务端:
pom.xml 引入包,注册到nacos
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
注入
@SpringBootApplication
@EnableFeignClients
@EnableAdminServer
@EnableDiscoveryClient
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
配置文件
#开启端点
management.endpoints.web.exposure.include=*
management.security.enabled=false
management.security.endpoint.health.show-details= ALWAYS
nacos配置,写在bootstrap.properties配置文件里(当前nacos要求),自己的nacos的服务端ip端口
spring.application.name=springBootAdmin
spring.cloud.nacos.discovery.server-addr=192.168.1.31:8848
spring.cloud.nacos.config.server-addr=192.168.1.31:8848
启动服务,在nacos发现服务
浏览器输入地址加端口,打开springbootadmin后台,此时,没有项目,(图为完成后截图)
客户端配置 springbootadmin 配置
springcloud nacos 相关配置入上
参数配置:
写在非bootstrap.properties 配置文件中 :management.endpoints.web.exposure.include=*
nacos写在bootstrap.properties 配置文件中(同上ip)
spring.application.name=client
spring.cloud.nacos.discovery.server-addr=192.168.1.31:8848
spring.cloud.nacos.config.server-addr=192.168.1.31:8848
加入nacos注解即可,无需springbootadmin相关注解
@EnableDiscoveryClient
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
启动服务,在nacos后台发现项目,
再次打开springbootadmin后台,
代码下载站地址:https://download.csdn.net/download/jialiuyang/11069675
————————————————
版权声明:本文为CSDN博主「jly_灵宝娃」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/jialiuyang/article/details/88871225