In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the Spring Cloud integration Spring Boot Admin method". In the daily operation, I believe that many people have doubts about what the Spring Cloud integration Spring Boot Admin method is. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "what is the Spring Cloud integration Spring Boot Admin method?" Next, please follow the editor to study!
1. What is Spring Boot Admin?
Spring Boot Admin is an open source project developed by codecentric. You can use Spring Boot Admin to manage and monitor your Spring Boot project.
It is divided into two parts: the client and the server. The client adds the HTTP interface to your Spring Boot application to add disclosure-related information, and then registers to the Spring Boot Admin server. This step can be registered directly with the server, or through Eureka or Consul.
On the other hand, Spring Boot Admin Server visually presents the monitoring information of Vue.js program. And supports a variety of event notification operations.
2. Spring Boot Admin server
The Spring Boot Admin server is based on the Spring Boot project, not to mention how to create a Spring Boot project here, you can refer to the previous article or get a Spring Boot project directly from https://start.spring.io/.
2.1. Add dependency (server side)
You only need to add web and Spring-boot-admin-starter-server dependencies.
De.codecentric spring-boot-admin-starter-server 2.2.2 org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-actuator org.springframework.boot spring-boot-starter-security 2.2. Configure application.ymlserver: port: 8000 # Service Monitoring server spring: application: name: wireless-admin-server cloud: nacos: discovery: server-addr: localhost:8848 security: user: name: admin password: admin2.3 Startup Class: AdminServerMainpackage com.gpdi.wireless;import de.codecentric.boot.admin.server.config.EnableAdminServer;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication Import org.springframework.cloud.client.discovery.EnableDiscoveryClient; / * * @ Author Lxq * @ Date, 2020-5-7 17:45 * @ Version 1.0 * / @ EnableAdminServer@SpringBootApplication@EnableDiscoveryClientpublic class AdminServerMain {public static void main (String [] args) {SpringApplication.run (AdminServerMain.class, args);} 2.4 configuration class: SecuritySecureConfig (direct cp official documentation) package com.gpdi.wireless.config; import de.codecentric.boot.admin.server.config.AdminServerProperties Import org.springframework.context.annotation.Configuration;import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;import org.springframework.security.config.annotation.web.builders.HttpSecurity;import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;import org.springframework.security.web.csrf.CookieCsrfTokenRepository / * @ Author Lxq * @ Date 22:15 on 2020-5-7 * @ Version 1.0 * * / @ Configurationpublic class SecuritySecureConfig extends WebSecurityConfigurerAdapter {private final String adminContextPath; public SecuritySecureConfig (AdminServerProperties adminServerProperties) {this.adminContextPath = adminServerProperties.getContextPath ();} @ Override protected void configure (HttpSecurity http) throws Exception {/ / @ formatter:off SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler (); successHandler.setTargetUrlParameter ("redirectTo") SuccessHandler.setDefaultTargetUrl (adminContextPath + "/") Http.authorizeRequests () / grants public access to all static assets and login pages. AntMatrices (adminContextPath + "/ assets/**"). PermitAll () .antMatrices (adminContextPath + "/ login"). PermitAll () / / must authenticate every other request .anyRequest () .authenticated () .and () / configure login and logout .formLogin () .formLogin (adminContextPath + "/ login") .formHandler (successHandler) .logout () .logout () .logoutUrl (adminContextPath + "/ logout") .and () / enable HTTP-Basic support. This is required for Spring Boot Admin Client registration. HttpBasic (). And () .csrf () .csrfTokenRepository (CookieCsrfTokenRepository.withHttpOnlyFalse ()) .encrypingAntMatrices (/ / disable CRSF to protect the endpoints that the Spring boot management client uses to register. AdminContextPath + "/ instances", / / disable CRSF protection for actuator endpoints adminContextPath + "/ actuator/**");}}
3. Spring Boot Admin client
The creation of a Spring Boot project is still not mentioned, only the dependencies needed by the Spring Boot Admin client need to be added, and the relevant API interface for obtaining information will be added when the project starts. Then configure the Spring Boot Admin server in the Spring Boot configuration file for monitoring.
3.1 client dependency
< !--服务监控客户端-->De.codecentric spring-boot-admin-starter-client 2.2.2 com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discovery 3.2 client configuration
Client configuration is mainly to enable the client to successfully register with the server, so it is necessary to configure the relevant information of the application where the client is located and the url of the Spring Boot Admin Server server.
Server: port: 8761 spring: application: name: wireless-code-generatr cloud: nacos: discovery: server-addr: localhost:8848 # expose the endpoint management: endpoints: web: exposure: include:'* 'endpoint: health: show-details: always logging: file: name: boot.log pattern:#### log highlight file:'% clr (% d {yyyy-MM-dd HH:mm:ss.SSS}) {faint}% clr (% 5p)% clr (${PID}) {magenta}% clr (- -) {faint}% clr ([.15t]) {faint}% clr (%-40.40logger {39}) {cyan}% clr (:) {faint}% m% n% wEx'
The include in the configuration: "*" exposes all ports. For production environments, you should confidently choose which interfaces to expose.
3.3. Client running
Starting the client will expose the relevant running status interface and automatically send registration information to the configured server.
4. Spring Boot Admin function
Click the online application instance on the monitoring page to jump to the detailed monitoring and management page of the application instance, that is, the web display implemented by Vue.js.
Spring Boot Admin Server can monitor many functions, so it is not difficult to use.
Some of the things that can be monitored are described below:
Application running status, such as time, number of garbage collection, number of threads, memory usage trend.
Apply performance monitoring to view the current value by selecting the JVM or Tomcat parameters.
Apply environmental monitoring, view system environment variables, apply configuration parameters, and configure parameters automatically.
Apply bean management, check the Spring Bean, and you can see if it is a singleton.
Apply scheduled tasks and view the list of scheduled tasks for the application.
Apply log management, dynamically change the log level, and view the log.
Apply JVM management to view the current thread running and dump memory stack information.
Apply mapping management to view the application interface call method, return type, processing class and other information.
The log management mentioned above allows you to dynamically change the log level and view the log. By default, you can only change the log level dynamically, and you need to configure the log path manually if you want to view the log online.
The log path and log highlighting can be configured on the client as follows.
# configuration file: application.ymllogging: file: name: boot.log pattern:# log highlights file:'% clr (% d {yyyy-MM-dd HH:mm:ss.SSS}) {faint}% clr (% 5p)% clr (${PID}) {magenta}% clr (- -) {faint}% clr ([.15t]) {faint}% clr (%-40.40logger {39}) {cyan}% Clr (:) {faint}% m% n% wEx'
The following is the client application log viewed on the Spring Boot Admin monitoring page.
At this point, the study on "what is the Spring Cloud integration Spring Boot Admin method" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.