首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >dependencies.dependency.version‘缺少错误

dependencies.dependency.version‘缺少错误
EN

Stack Overflow用户
提问于 2013-06-28 16:46:23
回答 3查看 102.1K关注 0票数 27

我正在尝试使用apache创建一个包。当我运行mvn clean install命令时,它会给出以下错误:

javax.servlet:servlet-api.jar缺少dependencies.dependency.version‘

我已将‘servlet-api.jar’放置在项目的资源文件夹中。

有人能告诉我把那个jar文件放在哪里吗?

更新:这是我的pom.xml

代码语言:javascript
复制
    <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>

谢谢安德森

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-06-28 17:02:06

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

代码语言:javascript
复制
<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>1.0.0</version>   //Add the version.
</dependency>
票数 24
EN

Stack Overflow用户

发布于 2016-09-21 09:05:31

我犯了同样的错误,原因略有不同。

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

最高层pom有:

代码语言:javascript
复制
    <dependencyManagement>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.10</artifactId>
            <version>${spark.version}</version>
        </dependency>
    </dependencyManagement>

分层次pom

代码语言:javascript
复制
    <dependencyManagement>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.10</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencyManagement>

叶荚

代码语言:javascript
复制
    <dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-core_2.10</artifactId>
    </dependency>

为了解决这个问题,我从中间级别的pom中删除了<dependencyManagement>部分,并将叶pom更改为

代码语言:javascript
复制
    <dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-core_2.10</artifactId>
        <scope>provided</scope>
    </dependency>
票数 9
EN

Stack Overflow用户

发布于 2013-06-28 17:00:47

消息非常清楚:在pom的dependencies元素中,有一个带有javax.servlet:servlet-api.jardependency元素。在这个dependency元素中,必须有一个version元素,但是您没有提供它。

代码语言:javascript
复制
<dependencies>
    <!-- Provided APIs -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>

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

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

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17369743

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档