Srping Boot Admin的配置(RP,sr,srping boot admin,编程语言)

时间:2024-05-09 18:03:49 作者 : 石家庄SEO 分类 : 编程语言
  • TAG :

前言
Spring Boot Admin是一个Web应用,用于管理和监视Spring Boot应用程序的运行状态。每个Spring Boot应用程序都被视为客户端并注册到管理服务器。背后的数据采集是由Spring Boot Actuator端点提供。

集成
注意一定要版本对应,否则会出现意想不到的问题,建议使用Srping Boot Admin 2.0+以上版本,可以多语言切换。

父项目
pom.xml引入:

<modules> <module>admin-server</module> <module>admin-client</module></modules><parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.2.RELEASE</version> <relativePath/></parent><dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jetty</artifactId> </dependency></dependencies>

监控服务端
pom.xml引入:

<artifactId>admin-server</artifactId><dependencies> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-server</artifactId> <version>2.2.1</version> </dependency> <!--登录认证--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <!--掉线发送邮件通知--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency></dependencies>

application.properties配置文件:

https://blog.52itstyle.vipserver.port=9000spring.application.name=SpringBootAdminspring.security.user.name=adminspring.security.user.password=adminspring.boot.admin.monitor.status-interval = 10000spring.boot.admin.monitor.info-interval = 10000spring.mail.host = smtp.163.comspring.mail.username = 13188888888@163.comspring.mail.password = 2020spring.boot.admin.notify.mail.from = 13188888888@163.comspring.boot.admin.notify.mail.to = 88888888@qq.com

启动类:

/** * 系统监控 * 爪哇笔记:https://blog.52itstyle.vip */@Configuration@EnableAutoConfiguration@EnableAdminServerpublic class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Configuration public static class SecuritySecureConfig extends WebSecurityConfigurerAdapter { private final AdminServerProperties adminServer; public SecuritySecureConfig(AdminServerProperties adminServer) { this.adminServer = adminServer; } @Override protected void configure(HttpSecurity http) throws Exception { SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler(); successHandler.setTargetUrlParameter("redirectTo"); successHandler.setDefaultTargetUrl(this.adminServer.path("/")); http.authorizeRequests() .antMatchers(this.adminServer.path("/assets/**")).permitAll() .antMatchers(this.adminServer.path("/login")).permitAll() .anyRequest().authenticated() .and() .formLogin().loginPage(this.adminServer.path("/login")).successHandler(successHandler).and() .logout().logoutUrl(this.adminServer.path("/logout")).and() .httpBasic().and() .csrf() .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) .ignoringRequestMatchers( new AntPathRequestMatcher(this.adminServer.path("/instances"), HttpMethod.POST.toString()), new AntPathRequestMatcher(this.adminServer.path("/instances/*"), HttpMethod.DELETE.toString()), new AntPathRequestMatcher(this.adminServer.path("/actuator/**")) ) .and() .rememberMe().key(UUID.randomUUID().toString()).tokenValiditySeconds(1209600); } }}

监控客户端
pom.xml引入:

<artifactId>admin-client</artifactId><dependencies> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-client</artifactId> <version>2.2.1</version> </dependency></dependencies>

application.properties配置文件:

https://blog.52itstyle.vipspring.boot.admin.client.instance.name = 007spring.boot.admin.client.url= http://localhost:9000management.endpoints.web.exposure.include=*spring.boot.admin.client.username = adminspring.boot.admin.client.password = adminspring.boot.admin.client.period = 10000spring.boot.admin.client.connect-timeout = 5000spring.boot.admin.client.read-timeout = 5000spring.boot.admin.client.instance.service-url = http://localhost:8080

监控界面
Srping Boot Admin的配置

Srping Boot Admin的配置

Srping Boot Admin的配置

Srping Boot Admin的配置

Srping Boot Admin的配置

不得不说,2.X 版本还是很美观大气上档次的,并且监控告警功能齐全,

 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:Srping Boot Admin的配置的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:飞机游戏在C语言程序的基本语句能完成功能的体会下一篇:

75 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18