這是我在pom.xml
:爲什麼servlet-api.jar將其狀態從測試轉換爲編譯?
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
這是我mvn --debug war:war
後看到:
[...]
[DEBUG] com.sun.jersey.jersey-test-framework:jersey-test-framework-grizzly:jar:1.4:test
[DEBUG] com.sun.jersey.jersey-test-framework:jersey-test-framework-core:jar:1.4:test
[DEBUG] org.glassfish:javax.servlet:jar:3.0-b66:test
[DEBUG] com.sun.grizzly:grizzly-servlet-webserver:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-http:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-framework:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-rcm:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-portunif:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-http-servlet:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-utils:jar:1.9.18-i:test
[DEBUG] javax.servlet:servlet-api:jar:2.5:compile
[...]
,請注意最後一行。爲什麼它不是"test"
,而是"compile"
?
PS。確實很奇怪。這是我的完整pom.xml
(對不起,這不是短期):
[...]
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version> <!-- 10 Sep 2010 -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>1.2.5</version> <!-- 13 Oct 2010 -->
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version> <!-- 9 Oct 2010 -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version> <!-- 9 Oct 2010 -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6.2</version> <!-- 12 Oct 2010 -->
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version> <!-- 2 Nov 2010 -->
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<!-- version see below in dependencyManagement section -->
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<!-- version see below in dependencyManagement section -->
</dependency>
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly</artifactId>
<!-- version see below in dependencyManagement section -->
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<!-- version see below in dependencyManagement section -->
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-ejbd</artifactId>
<!-- version see below in dependencyManagement section -->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<!-- version see below in dependencyManagement section -->
</dependency>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<!-- version see below in dependencyManagement section -->
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version> <!-- 9 Oct 2010 -->
<scope>provided</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-ejbd</artifactId>
<version>3.1.3</version> <!-- 26 October 2010 -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.4.2</version> <!-- 29 oct 2010 -->
</dependency>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.10</version> <!-- 12 October 2010 -->
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
[...]
這是怎麼maven-war-plugin
配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
<configuration>
<archive>
<manifestEntries>
<SCM-Revision>${buildNumber}</SCM-Revision>
</manifestEntries>
</archive>
</configuration>
</plugin>
你有沒有的javax.servlet:servlet的API中:jar:2.5作爲其一部分的? –
Buhb
2010-11-04 15:26:17
@Buhb請參閱我的問題的更新版本 – yegor256 2010-11-04 16:14:55
您是否配置了帶有servlet-api相關性的maven-war-plugin? – 2010-11-04 16:16:25