2013-06-28 136 views
12

我想创建一个使用apache maven的包。当我运行mvn clean install命令它给下面的错误:dependencies.dependency.version'缺少错误

dependencies.dependency.version' is missing for javax.servlet:servlet-api.jar

我已经把那servlet的api.jar文件'我的项目的资源文件夹内

可以在任何人告诉我应该在哪里地方, jar文件?

UPDATE: 这里是我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 

<parent> 
    <artifactId>felix-parent</artifactId> 
    <groupId>org.apache.felix</groupId> 
    <version>2.1</version> 
    <relativePath>../pom/pom.xml</relativePath> 
</parent> 

<modelVersion>4.0.0</modelVersion> 

<artifactId>maven-bundle-plugin</artifactId> 
<version>2.4.1-SNAPSHOT</version> 
<packaging>maven-plugin</packaging> 

<name>Maven Bundle Plugin</name> 
<description> 
    Provides a maven plugin that supports creating an OSGi bundle 
    from the contents of the compilation classpath along with its 
    resources and dependencies. Plus a zillion other features. 
    The plugin uses the Bnd tool (http://www.aqute.biz/Code/Bnd) 
</description> 

<scm> 
    <connection>scm:svn:http://svn.apache.org/repos/asf/felix/trunk/bundleplugin</connection> 
    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/trunk/bundleplugin</developerConnection> 
    <url>http://svn.apache.org/repos/asf/felix/trunk/bundleplugin</url> 
</scm> 

<build> 
    <plugins> 
    <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <configuration> 
    <source>1.5</source> 
    <target>1.5</target> 
    </configuration> 
    </plugin> 
    </plugins> 
</build> 

<dependencies> 
     <!-- Provided APIs --> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
     </dependency> 

    </dependencies> 

<reporting> 
    <plugins> 
    <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-plugin-plugin</artifactId> 
    <version>3.2</version> 
    </plugin> 
    <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-changes-plugin</artifactId> 
    <version>2.9</version> 
    <configuration> 
    <component>12311143</component> 
    <versionPrefix>maven-bundle-plugin-</versionPrefix> 
    <statusIds>Resolved,Closed</statusIds> 
    <maxEntries>1000</maxEntries> 
    <issueManagementSystems> 
     <issueManagementSystem>JIRA</issueManagementSystem> 
    </issueManagementSystems> 
    <useJql>true</useJql> 
    </configuration> 
    </plugin> 
    </plugins> 
</reporting> 

</project> 

感谢 安德森

+1

请向我们展示您的pom.xml。你显然错过了'''servlet-api'的''。 – LaurentG

+0

请找到我的pom.xml – user2532663

回答

13

您还没有在dependency中添加version标记。

<dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>servlet-api</artifactId> 
     <version>1.0.0</version> //Add the version. 
</dependency> 
1

的信息是很清楚的:你的POM的dependencies元素中,你有制造品javax.servlet:servlet-api.jar一个dependency元素。并且在这个dependency元素中,必须有一个版本元素,但是您没有提供它。

<dependencies> 
    <!-- Provided APIs --> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>servlet-api</artifactId> 

     <!-- missing version here: --> 
     <version>3.0</version> 
    </dependency> 
</dependencies> 

请注意,3.0只是一个例子。提供正确的版本。

+0

谢谢..实际上,我在我的POM中有超过20个依赖关系。我知道groupid,artifactId但我完全不知道版本。有什么办法可以加入? – user2532663

+1

任何方式来包括什么?你真的应该知道你想使用哪个版本的servlet API。没人可以为你猜。 –

+0

我发现所有的版本但有两个版本,一个是 com.day.cq CQ-公共 \t \t \t 5.5.0 我知道上面的版本是正确的。但是maven找不到它。但它提供了另一种方式将它导入为 mvn deploy:deploy-file -DgroupId = com.day.cq -DartifactId = cq-commons -Dversion = 5.5.0 -Dpackaging = jar -Dfile =/path/to/file - Durl = [url] -DrepositoryId = [id] 它是什么url,/ path/to/file,id? 请指导我 – user2532663

2

我有一个稍微不同的原因相同的错误。

我的项目使用依赖管理(由于某些原因,有2个<dependencyManagement>节),并且有许多模块和子模块。

顶级 POM有:

<dependencyManagement> 
     <dependency> 
      <groupId>org.apache.spark</groupId> 
      <artifactId>spark-core_2.10</artifactId> 
      <version>${spark.version}</version> 
     </dependency> 
    </dependencyManagement> 

子平 POM有

<dependencyManagement> 
     <dependency> 
      <groupId>org.apache.spark</groupId> 
      <artifactId>spark-core_2.10</artifactId> 
      <scope>provided</scope> 
     </dependency> 
    </dependencyManagement> 

叶POM

<dependency> 
     <groupId>org.apache.spark</groupId> 
     <artifactId>spark-core_2.10</artifactId> 
    </dependency> 

到FI X是我删除从中间级POM的<dependencyManagement>部分,改变了叶POM

<dependency> 
     <groupId>org.apache.spark</groupId> 
     <artifactId>spark-core_2.10</artifactId> 
     <scope>provided</scope> 
    </dependency> 
0

在我来说,我有一个单一的POM,并面临着同样的问题。从Harry的回答中得知,我添加了我的依赖管理部分,问题解决了。

+0

这不提供一个问题的答案,应该是一个评论。请参阅[我应该何时评论?](https://stackoverflow.com/help/privileges/comment)。 一旦你有足够的[声望](https://stackoverflow.com/help/whats-reputation),你将可以在任何帖子上[评论](https://stackoverflow.com/help/privileges/comment);相反,[提供不需要提问者澄清的答案](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-c​​an- I-DO-代替)。 – Dwhitz