I'm doing a research project to determine to what extent we can configure embedded Tomcat with Spring boot. One of the items I was asked to look into was with regard to whether we can still use the app manager. I don't have a specific use case for why we'd want to use an app manager with an embedded tomcat, so maybe that makes this question unanswerable:
Does the embedded tomcat 7 used by Spring Boot contain a tomcat manager app, and if not, what does it take to add/enable it?
Does the embedded tomcat 7 used by Spring Boot contain a tomcat manager app
No, it doesn't and I'm not really sure that it makes sense to try to add it.
A primary function of the manager app is to allow you to start and stop individual applications without stopping the container and to deploy and undeploy individual applications. When you're using Spring Boot with embedded Tomcat you should consider your application and container as a single entity so starting or stopping your application and starting and stopping the container are one and the same thing.
A secondary function of the manager app is to provide access to OS and JVM properties, something that Spring Boot's actuator already does for you.
What does it take to add/enable it?
If you choose not to heed the above, it's easy to add the manager app (although I can't promise that it all works as expected – I leave that as an exercise for the (foolhardy) reader):
@Bean
public EmbeddedServletContainerFactory servletContainer() {
return new TomcatEmbeddedServletContainerFactory() {
@Override
protected TomcatEmbeddedServletContainer getTomcatEmbeddedServletContainer(
Tomcat tomcat) {
tomcat.addUser("admin", "secret");
tomcat.addRole("admin", "manager-gui");
try {
tomcat.addWebapp("/manager", "/path/to/manager/app");
}
catch (ServletException ex) {
throw new IllegalStateException("Failed to add manager app", ex);
}
return super.getTomcatEmbeddedServletContainer(tomcat);
}
};
}
You'll also need a dependency on Jasper as the manager app uses JSPs. Assuming you're using Maven:
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With