I'm trying to run an application on spring boot, but to do that I need to add some resources to tomcat, eg. data source configuration and others.
Normally i would add something ike
<Resources name="..." ....>
but how can i achieve that in spring boot?
I think the following would work for you (I have successfully used a similar approach to customize some other aspect of embedded tomcat):
@Configuration
public class TomcatConfig implements EmbeddedServletContainerCustomizer {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if(container instanceof TomcatEmbeddedServletContainerFactory) {
TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory = (TomcatEmbeddedServletContainerFactory) container;
tomcatEmbeddedServletContainerFactory.addContextCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
connector.setNamingResources(.......);
}
});
}
}
}
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.