- github Address: github.com/codecentric...
- Documents Address: codecentric.github.io/spring-boot...
Use SpringBootAdmin divided into two parts in the project: the server and the client. The client provides health from birth to the server via http way
- version:
<spring.boot.admin.version>2.1.6</spring.boot.admin.version>
1. Build the server project
- Server dependent
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>${spring.boot.admin.version}</version>
</dependency>
复制代码
- Mark notes on startup class
@EnableAdminServer
- Set Port
server:
port: 8080
复制代码
- You can start
If there is an error:
2019-11-02 09:50:14.924 ERROR 55391 --- [nio-8080-exec-2] o.a.catalina.connector.CoyoteAdapter : Exception while processing an asynchronous request
java.lang.IllegalStateException: Calling [asyncError()] is not valid for a request with Async state [MUST_DISPATCH]
at org.apache.coyote.AsyncStateMachine.asyncError(AsyncStateMachine.java:440) ~[tomcat-embed-core-9.0.16.jar:9.0.16]
at org.apache.coyote.AbstractProcessor.action(AbstractProcessor.java:512) [tomcat-embed-core-9.0.16.jar:9.0.16]
at org.apache.coyote.Request.action(Request.java:430) ~[tomcat-embed-core-9.0.16.jar:9.0.16]
at org.apache.catalina.core.AsyncContextImpl.setErrorState(AsyncContextImpl.java:396) ~[tomcat-embed-core-9.0.16.jar:9.0.16]
at org.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:239) ~[tomcat-embed-core-9.0.16.jar:9.0.16]
at org.apache.coyote.AbstractProcessor.dispatch(AbstractProcessor.java:241) [tomcat-embed-core-9.0.16.jar:9.0.16]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:53) [tomcat-embed-core-9.0.16.jar:9.0.16]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834) [tomcat-embed-core-9.0.16.jar:9.0.16]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415) [tomcat-embed-core-9.0.16.jar:9.0.16]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.16.jar:9.0.16]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_191]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_191]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.16.jar:9.0.16]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_191]
复制代码
- Tomcat will replace jetty
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
</dependency>
<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>
复制代码
Complete project source code github.com/FutaoSmile/...
2. The client - service needs to be monitored
- Adding clients rely
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
<!-- https://codecentric.github.io/spring-boot-admin/2.1.6/#getting-started-->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.1.6</version>
</dependency>
复制代码
- Configure the server's address SpringBootAdmin
spring:
boot:
admin:
client:
url: http://localhost:8080
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
复制代码
- Start SpringBoot client project
- Access server configuration address:
http://localhost:8080
- If there is no data, like this This is because your SpringBoot project encapsulates data monitoring endpoint returned, returned from the Info data structure can be seen.
- The solution is not to let the data SpringBoot package monitors endpoints returned
- If you are using
@RestControllerAdvice
the constraint about the package path@RestControllerAdvice("com.west.lake.blog.controller")
-
Request log and time-consuming monitoring request
-
Cache Manager