2013-06-28 11 views
12

Próbuję utworzyć pakiet za pomocą apache maven. Kiedy uruchamiam mvn clean install polecenie to daje poniższy błąd:dependencies.dependency.version "brakuje błędu

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

umieściłem że „servlet-api.jar” wewnątrz folderu zasobów mojego projektu

Czy jakiekolwiek ktoś proszę powiedzieć, gdzie należy umieścić że plik jar?

UPDATE: Oto moja 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> 

Dzięki Anderson

+1

Pokaż nam swój plik pom.xml. Najwyraźniej przegapiłeś '' '' servlet-api' '. – LaurentG

+0

Proszę znaleźć mój pom.xml – user2532663

Odpowiedz

13

Nie dodano znacznika version w dependency.

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

Przesłanie jest jasne: wewnątrz elementu dependencies swojej pom, masz dependency element z artefaktem javax.servlet:servlet-api.jar . I wewnątrz tego elementu dependency musi być element wersji, ale go nie dostarczyłeś.

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

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

Należy pamiętać, że 3.0 jest tylko przykładem. Podaj odpowiednią wersję.

+0

Dzięki ... W moim POM jest więcej niż 20 zależności. znałem groupid, artefactId, ale nie znam dokładnie tej wersji. Czy jest jakiś sposób na uwzględnienie? – user2532663

+1

w jaki sposób? Naprawdę powinieneś wiedzieć, której wersji API serwletu chcesz użyć. Nikt nie może odgadnąć dla ciebie. –

+0

znalazłem całą wersję z wyjątkiem dwóch wersjach jedno jest com.day.cq CQ-commons \t \t \t 5.5.0 Wiedziałem wyżej wersja jest poprawna. Ale maven nie może go znaleźć. Ale dało alternatywny sposób importowania go jako mvn deploy: deploy-file -DgroupId = com.day.cq -DartifactId = cq-commons -Direct = 5.5.0 -Dopakowanie = jar -Dfile =/ścieżka/do/plik - Durl = [url] -DrepositoryId = [id] jaki jest adres URL,/path/to/file, id? Proszę mnie poprowadzić – user2532663

2

Miałem ten sam błąd z nieco innego powodu.

Mój projekt wykorzystuje zarządzanie zależnościami (z jakichś powodów ma 2 <dependencyManagement>) i zawiera wiele modułów i podmodułów.

Najwyższy poziom pom miał:

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

Sub-level pom miał

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

Liść pom miał

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

FI x go usunąłem sekcję <dependencyManagement> z pom średniego szczebla i zmienił pom liść mieć

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

w moim przypadku mam jeden pom i stał w obliczu tego samego problemu. Biorąc podpowiedź z powyższej odpowiedzi Harry'ego, dodałem moją sekcję dependancymanagement i problem został rozwiązany.

+0

To nie daje odpowiedzi na pytanie, powinno być komentarzem. Zobacz [Kiedy powinienem komentować?] (Https://stackoverflow.com/help/privileges/comment). Po uzyskaniu wystarczającego [reputation] (https://stackoverflow.com/help/whats-reputation) będzie można [comment] (https://stackoverflow.com/help/privileges/comment) w dowolnym poście; zamiast tego [dostarczaj odpowiedzi, które nie wymagają wyjaśnień od pytającego] (https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can- i-do-zamiast). – Dwhitz