Reputation: 1411
I am trying to build a test setup containing two Sprin Boot Applications. Both of the Apps have a seperate class.
Both Apps look something like this: (but are different, seperated classes)
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.*;
@RestController
@EnableAutoConfiguration
public class MySpringBootApplet {
@RequestMapping("/")
public String home() {
System.out.println("home() called ..");
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.println("waited ..");
return "<!DOCTYPE html><html><body><h1>Test</h1><p>Hello world!</p></body></html>";
}
Both are started with
SpringApplication app = new SpringApplication(MySpringBootApplet.class);
app.run();
When the second app is started, I get the error:
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.springframework.boot.actuate.endpoint.jmx.DataEndpointMBean@6a48a7f3] with key 'requestMappingEndpoint'; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Endpoint,name=requestMappingEndpoint
I can imagine that this is because both applications try to register with the same interface. But how do I separate this?
Thanks for your help
Upvotes: 2
Views: 3257
Reputation: 11
spring.jmx.enabled = false
Use this setting in application.properties will be ok.
Upvotes: 1