java - dependencies.dependency.version' 缺少错误

标签 java maven-2 osgi-bundle

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

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

我已将“servlet-api.jar”放在我项目的资源文件夹中

谁能告诉我应该把那个jar文件放在哪里?

更新: 这是我的 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>

谢谢 安德森

最佳答案

你没有在dependency中添加version标签。

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

关于java - dependencies.dependency.version' 缺少错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17369743/

相关文章:

java - Android:聚焦 EditText 时不调用 onBackPressed

java - 在 weblogic 12c 上运行的 REST 项目 (netbeans) 上,EntityManager 始终为 null

java - 没有参数时如何获取泛型类?

spring - 如何找出maven的pom.xml中依赖的jar包?

git - maven-release-plugin 是否将标签推送到远程 Git 存储库?

java - 在 CXF 中使用 rpc/encoded 样式的方法

java - 如何指定自定义自由特征的依赖特征

java - 通过DER算法解码Java中的证书

java - 为什么运行 Java 测试时 BundleContext 为 null?

eclipse - 如果我想转换 eclipse 项目以开始使用 maven2,我需要做什么?