Currently I have a legacy project that uses spring MVC. Now there is need to implement Spring boot actuator. So my questions are
It would be great if someone can describe step by step implementation of it. I am using Eclipse, Gradle, Tomcat
To answer your first question:
yes You can use actuator in your spring mvc project. Add this to pom.xml
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-actuator</artifactId> <version>Compatible version with mvc</version> </dependency>
Add configuration below
@Configuration @EnableWebMvc @Import({EndpointAutoConfiguration.class , PublicMetricsAutoConfiguration.class , HealthIndicatorAutoConfiguration.class }) public class MyActuatorConfig { @Bean @Autowired public EndpointHandlerMapping endpointHandlerMapping(Collection<? extends MvcEndpoint> endpoints) { return new EndpointHandlerMapping(endpoints); } @Bean @Autowired public EndpointMvcAdapter metricsEndPoint(MetricsEndpoint delegate) { return new EndpointMvcAdapter(delegate); } }
2. Answer your second questions
Of course you can use Spring boot
and spring MVC
, just simple have below as parent to manage all dependencies version etc..
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
and spring-boot-starter-web
as dependency.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.