I want to run the servlet testing example available here using maven. Javaee web api should be declared as provided
:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>httpunit</groupId>
<artifactId>httpunit</artifactId>
<version>1.7</version>
<scope>test</scope>
</dependency>
However, one of the tests in the example throws ServletException
. NetBeans complains that java ee api is mis开发者_如何学Gosing on project classpath
. How does one solve this issue?
EDIT
It is not a NetBeans issue, it is a maven issue.
Now this is the most debilitating issue I have ever faced in my Java days. And it is followed by the most ridiculous workaround I have ever seen, ever:
<dependency>
<groupId>httpunit</groupId>
<artifactId>httpunit</artifactId>
<version>1.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
Yes, permute the declaration of dependencies in the pom.xml
(see here for "why") and make javaee-web-api
last.
It means that maven (or netbeans...I haven't used netbeans in 10 years), couldn't download or find that artifact in the local repository.
The scope provided means: I need the jar to compile my source code, but don't bundle the jar in the final package.
精彩评论