将servlet-api从测试范围Maven中排除 [英] Exclude servlet-api from test scope Maven

查看:428
本文介绍了将servlet-api从测试范围Maven中排除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在pom.xml中具有以下依赖关系,以便我的IDE(IntelliJ)具有在编译期间可用的servlet-api类,但在构建中未提供.

I have the following dependency in my pom.xml so that my IDE (IntelliJ) has the servlet-api classes available during compilation, but not provided in the build.

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>3.0-alpha-1</version>
    <scope>provided</scope>
 </dependency>

但是当在测试范围内运行时,提供的范围会将此依赖项中的类添加到类路径中,这对于Jetty来说是个问题,我以编程方式开始.因为它已经在它的库中了,所以我得到了

But provided scope adds the classes in this dependency to the classpath when running in test scope, that's a problem for Jetty which I start programmatically. Since it already has it in its library I get a

 java.lang.SecurityException: class "javax.servlet.FilterRegistration"'s signer information does not match signer information of other classes in the same package

如果删除此依赖项,Jetty服务器将在测试范围内正确启动,但是我需要IntelliJ的此依赖关系来编译我的代码.解决此问题的最佳方法是什么,有什么办法可以排除测试范围的这种依赖关系?

If I remove this dependency the Jetty server starts correctly in test scope, but I need this dependency for IntelliJ to compile my code. Whats the best way to solve this, is there a way I can exclude this dependency for the test scope ?

推荐答案

尝试将其设置为编译范围

try to set it to compile scope

这篇关于将servlet-api从测试范围Maven中排除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆