【发布时间】:2016-10-25 14:37:07
【问题描述】:
我正在尝试为 servlet 创建一个简单的 UnitTest。显然,maven 存在一些问题(我认为)会影响构建过程。
我做了一些研究,显然这是一个已知问题。根据我的不足,需要做的是更改 pom.xml 中 javaee-web-api 依赖项的位置
不幸的是,这个解决方案对我不起作用。这非常令人沮丧,因为我花了很多时间在配置而不是编码上。
知道如何解决这个问题或其他一些测试解决方案吗?
我正在使用 Maven 和 NetBeans。
谢谢
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
【问题讨论】:
-
provided 的意思是“已经在类路径上”,也许你想用 test 代替?
-
你能发布错误吗?您的项目 Dynamic Web Module 版本是多少?
-
6.0
javax/javaee-*人工制品因这个问题而臭名昭著。它们可以编译,但它们已被剥夺了允许它们在运行时使用所需的内容。
标签: java maven unit-testing netbeans-8