简体   繁体   中英

maven dependency war issue

I wanted to exclude the following dependency from final war build(using mvn package/install).

Which scope is preferable?

<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.2.2</version>
    <scope>provided</scope>
</dependency>

You have 2 options, provided or test . provided will exclude the jar from the classpath in your tests, too. If you want to test code that depends on that dependency, you should use test instead.

If you still see this dependency in your war file after installing we'll need more information to debug. It could be that you included this dependency more than once without realizing it. It could also be that another dependency is transitively including this jar and you'll have to use the exclude tag to remove it.

Depending on your target deploy server. If you're deploying on application server such as Glassfish , Jboss etc. with JSF libraries installed then scope provided is preferred. Or alternatively use exclusion to remove the dependency from your target war.

Alternatively, if you are deploying on a context server such as tomcat , jetty etc. remove scope target to copy the library across to avoid dependency issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM