简体   繁体   English

专家依赖战争问题

[英]maven dependency war issue

I wanted to exclude the following dependency from final war build(using mvn package/install). 我想从最终的战争构建中排除以下依赖性(使用mvn软件包/安装)。

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 . 您有2个选项, providedtest provided will exclude the jar from the classpath in your tests, too. provided也会在测试中将jar排除在类路径之外。 If you want to test code that depends on that dependency, you should use test instead. 如果要测试依赖于该依赖关系的代码,则应改用test

If you still see this dependency in your war file after installing we'll need more information to debug. 如果在安装后仍在war文件中看到此依赖关系,我们将需要更多信息进行调试。 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. 也可能是另一个依赖关系可传递地包括此jar,因此您必须使用exclude标签将其删除。

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. 如果要在安装了JSF库的应用程序服务器(例如GlassfishJboss等)上进行部署,则首选提供的 scope 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. 另外,如果要在上下文服务器(例如tomcatjetty等)上进行部署,请删除作用域目标以跨库复制该库以避免依赖关系问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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