'Enable http actuator with disable default web server

I need create spring boot application as daemon with disabled default web server and with active server actuator by http.

I need actuator only by http no jmx.

Actuator should work by 7001 port and should expose only actuator endpoints without bissnes @RestController endpoints.

My configuration:

management.server.port: 7001

Maven dapendecy: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.1.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> <version>2.1.1.RELEASE</version> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency>

With above configuration spring boot run with two TomcatWebServer 8080 (default) and 7001 actuator:

2019-11-22 20:49:50.246 INFO 4824 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 7001 (http) with context path '' 2019-11-22 20:49:50.256 INFO 4824 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''

But i want only actuator 7001.

I can add to properties file spring.main.web-application-type=none but it disable all web servers.

How can i achieve it ?



Solution 1:[1]

you can also set server port to 7001 and TomcatWebServer will start once

application.properties:

server.port=7001
management.server.port=7001

log output:

Tomcat initialized with port(s): 7001 (http)
Tomcat started on port(s): 7001 (http) with context path ''

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1