peekay
peekay

Reputation: 1271

spring boot application container guidance

I am curious to get some input from people on how to manage tomcat dependencies in spring boot applications. In a nutshell spring boot applications typically embed the container to make the application independent of any other applications on the server. However, I need to make an application available for deployment to an external container as well. This brought me to the question how to do a single build that would work inside and outside a provided container. I know I can simply build a war file (using maven) and then execute it using "java -jar my.war" as well as just dropping it in the provided container and running it. however if I drop it in the container as is I have container libraries in the application. this seems bad to me and I was wondering if anyone else had an opinion on this that they would like to share.

Upvotes: 0

Views: 65

Answers (1)

Andy Wilkinson
Andy Wilkinson

Reputation: 116111

If you're building a war file that you want to be executable (run with java -jar) and that you want to deploy to a container, then you should mark the Tomcat dependencies as provided. This will package them in the war file's WEB-INF/lib-provided directory. Spring Boot's executable war support will load them from there, but your container will ignore them – it will only load classes from jars in WEB-INF/lib.

Upvotes: 2

Related Questions