0

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 ?

nav3916872
  • 978
  • 13
  • 20
  • It should work in my opinion as long as resources are loaded before Spring Boot app. – LMC Sep 08 '18 at 22:59
  • Make sure context.xml is inside `conf/Catalina/localhost` with the proper context root name for your app. – LMC Sep 08 '18 at 23:06

1 Answers1

0

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

Amin Chokan
  • 15
  • 1
  • 6
  • I do understand that Springboot is opinionated and architecture of microservices etc etc.. We are actually in the process of migrating from Spring to boot. But because of certain tight deadlines and other issues, we want go with the above approach atleast for some more time. I guess you do understand . – nav3916872 Sep 08 '18 at 09:41
  • its not as hard as you think,i myself had to migrate from good old spring to spring boot, the hardest part of migrating was changing the column names and things related to Database in order for the spring boot to resume the previous project,it might take couple of days to learn how to migrate after resolving the bugs, but i strongly suggest you migrate as soon as possible – Amin Chokan Sep 08 '18 at 10:19