Java Maven-Spring Web Project - Separating Dependencies into Jar o War

I'm brand new in Maven. I'm working with Spring-Maven project, it generates a WAR file with 95Mb of dependencies (JARs) and 5Mb of my code. There is anyway to separate code and libs? packaging my code into WAR and all dependencies into other WAR/Jar?.

Im deploying my app in tomcat server.

Thank you in advance!

Upvotes: 0

Views: 123

Answers (1)

Amila
Amila

Reputation: 5213

You can exclude selected dependencies in the WAR by specifying scope as provided in your pom.

For example:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <scope>provided</scope>
</dependency>

Just make sure your dependencies are available in the classpath. You can put them in shared lib directory in server.

For example, in tomcat it's /lib directory.

Upvotes: 2

Related Questions