0
votes

I have removed the embedded tomcat and generating the war and deploying it in Tomcat. While generating the war I can add maven dependency as mentioned here or use maven war plugin to add jars and then deploy it to Tomcat. My requirement is to add jars after the war is generated. I can add bean definitions xml using @ImportResource from external path and while deploying the boot app I can see it loads the bean definitions. But I need to add jars from external location after the war was generated. I knew if I use embedded Tomcat I can use loader.path property and load jars dynamically from a location. The same should be achieved in war deployment I guess. Please guide me here.

Note in previous Spring app , we used a context.xml to load external plugin jars which customises our app.

<Context>
<Resources>
    <PostResources className="org.apache.catalina.webresources.DirResourceSet" base="/path/to/thirdpartylibs/" webAppMount="/WEB-INF/lib" />
    <PostResources className="org.apache.catalina.webresources.DirResourceSet" base="/path/to/plugins/" webAppMount="/WEB-INF/lib" />
    <PostResources className="org.apache.catalina.webresources.DirResourceSet" base="/path/to/additional/beandefinitions" webAppMount="/WEB-INF" />
</Resources>

The same kind of functionality using spring boot we require. Is it possible ?

1
It should work in my opinion as long as resources are loaded before Spring Boot app. - LMC
Make sure context.xml is inside conf/Catalina/localhost with the proper context root name for your app. - LMC

1 Answers

0
votes

i don't know if it's possible or not but why would you want to do this when u can just use the embedded tomcat from the spring boot, the purpose of spring boot was not to get confused with the configuration, so i recommend to use spring boot embedded tomcat and the single jar file for deployment