Preface
I happened to have time recently, so I learned how to build a spring boot admin environment. There are many pitfalls encountered.
Most of the online monitoring is directly used in admin-url, and it doesn't feel flexible at all. This is not the result I want, so this article introduces the use of eureka service registration and discovery functions to flexibly monitor the program.
This article mainly records the construction process of spring boot admin, hoping it will be helpful. It's actually very simple, don't be misled by the conventional methods!
Environment introduction
Construction process
1. We do not need to make any changes to the previous eureka-client service, just keep it in its original state.
2. Build spring boot admin service (also an eureka service)
3. Test results
spring boot admin module
It is important to note here that so far (10:16 on October 31, 2017), we cannot use Edgware.BUILD-SNAPSHOT version of eureka for spring boot admin, and will report an error because the latest version of codecentric1.5.4 is incompatible.
So here I want to downgrade the spring cloud version that admin dependencies, I am using the Dalton.SR4 version. No problem!
pom file
<dependencies> <!--admin's service--> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-server</artifactId> <version>1.5.4</version> </dependency> <!--admin's ui dependencies--> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-server-ui</artifactId> <version>1.5.4</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> </dependency> </dependency> </dependency> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>Application
@Configuration@EnableAutoConfiguration@EnableDiscoveryClient@EnableAdminServerpublic class AdminServerApplication { public static void main(String[] args) { SpringApplication.run(AdminServerApplication.class, args); }} @EnableAdminServer Used to mark an admin application
Other annotations are consistent with ordinary eureka client applications
yml file
spring: application: name: admin-server boot: admin: routes: endpoints: env,metrics,trace,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,hystrix.streamureka: client: serviceUrl: defaultZone: http://localhost:8761/eureka/#test, no password management.security.enabled: falseserver: port: 8089
Results Display
At the end of this configuration, we start the application of eureka server, admin server, and eureka client``eureka client2 in turn.
1. First go to the eureka registration center http://localhost:8761/ to see if all applications have been registered
Our admin-server is also registered as a service, so that eureka's service discovery function can be used
2. Check the monitoring ui in admin server http://localhost:8089
At this point, our spring boot admin has been built!
Summarize
The above port service name will vary according to your own configuration. Please note
In addition, the version is also very noteworthy.
Also, the methods you use are different, so the configurations are also different. Everyone must pay attention to their implementation methods.
Source code is at https://github.com/eumji025/spring-cloud-repository/tree/edgware
The corresponding module is:
1.spring-cloud-discovery-eureka-client
2.spring-cloud-discovery-eureka-client2
3.spring-cloud-discovery-eureka-server
4.spring-boot-admin-server
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.