Search code examples
springjbossear

Removing a JAR from deployment


I am working on a Spring Project on a JBoss server. I am facing a situation where I think removing a jar from the deployment may solve all the issues. But I want to keep the JAR in compile time so that I can use it in the classes.

I want to know how I can remove a jar from deployment only but keep it during the run time.

Probably, this is not the question to be asked on SO, as a matter of fact, SO is all about Coders and its main intention is to help us in solving a problem.

So, anyone ? How I can do this ?


Solution

  • If you are using Maven, the you need to mark the dependency as provided.

    For example

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
        <scope>provided</scope>
    </dependency>
    

    If you are using Gradle the corresponding element would be providedCompile. The code would look like:

    providedCompile 'log4j:log4j:1.2.17'
    

    For an Eclipse based build, check out this SO post