2012-06-26 3 views
3

Я хочу, чтобы зависимости lib lib в каталоге maven в lib при установке проекта. Я использовал это в моем файле pom.Ошибка «копирование-зависимости» в maven

<project> 
    <dependencies> 
     ... 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <version>2.4</version> 
       <executions> 
        <execution> 
         <id>copy-dependencies</id> 
         <phase>package</phase> 
         <goals> 
          <goal>copy-dependencies</goal> 
         </goals> 
         <configuration> 
          <outputDirectory>${project.build.directory}/dependencies</outputDirectory> 
         </configuration>  
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

Но это ошибка следующая:

Description Resource Path Location Type 
maven-dependency-plugin (goals "copy-dependencies", "unpack") is not supported by m2e. pom.xml /jasperreports-test line 60 Maven Project Build Lifecycle Mapping Problem 

Я попытался это исправить. Это файл pom в моем проекте.

<project> 

    <groupId>com.vccorp.adtech</groupId> 
    <artifactId>UserAgentService</artifactId> 
    <version>14.06.201</version> 

    <name>UserAgentService</name> 
    <url>http://maven.apache.org</url> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
     <dependency>    
     </dependency> 
    </dependencies> 
    <build> 
     <pluginManagement> 
      <plugins> 
       <plugin> 
        <groupId>org.eclipse.m2e</groupId> 
        <artifactId>lifecycle-mapping</artifactId> 
        <version>1.0.0</version> 
        <configuration> 
         <lifecycleMappingMetadata> 
          <pluginExecutions> 
           <pluginExecution> 
            <pluginExecutionFilter> 
             <groupId>org.apache.maven.plugins</groupId> 
             <artifactId>maven-dependency-plugin</artifactId> 
             <versionRange>[1.0.0,)</versionRange> 
             <goals> 
              <goal>copy-dependencies</goal> 
             </goals> 
            </pluginExecutionFilter> 
            <action> 
             <ignore /> 
            </action> 
           </pluginExecution> 
          </pluginExecutions> 
         </lifecycleMappingMetadata> 
        </configuration> 
       </plugin> 
      </plugins> 
     </pluginManagement> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <version>1.0</version> 
       <executions> 
        <execution> 
         <id>copy</id> 
         <phase>install</phase> 
         <goals> 
          <goal>copy-dependencies</goal> 
         </goals> 
         <configuration> 
          <outputDirectory> 
           ${project.build.directory}/lib 
          </outputDirectory> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

Но когда установить его ошибки следующие:

> [INFO] Building UserAgentService 14.06.201 [INFO] 
> ------------------------------------------------------------------------ SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
> SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: 
> See http://www.slf4j.org/codes.html#StaticLoggerBinder for further 
> details. Downloading: 
> http://222.255.27.149:8081/nexus-maven/content/groups/public/org/apache/maven/plugins/maven-dependency-plugin/1.0/maven-dependency-plugin-1.0.pom 
> [INFO] 
> ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] 
> ------------------------------------------------------------------------ [INFO] Total time: 4.716s [INFO] Finished at: Tue Jun 26 11:55:06 ICT 
> 2012 [INFO] Final Memory: 5M/15M [INFO] 
> ------------------------------------------------------------------------ [ERROR] Plugin org.apache.maven.plugins:maven-dependency-plugin:1.0 or 
> one of its dependencies could not be resolved: Failed to read artifact 
> descriptor for 
> org.apache.maven.plugins:maven-dependency-plugin:jar:1.0: Could not 
> transfer artifact 
> org.apache.maven.plugins:maven-dependency-plugin:pom:1.0 from/to nexus 
> (http://222.255.27.149:8081/nexus-maven/content/groups/public/): 
> Connection refused: no further information to 
> http://222.255.27.149:8081/nexus-maven/content/groups/public/org/apache/maven/plugins/maven-dependency-plugin/1.0/maven-dependency-plugin-1.0.pom 
> -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using 
> the -X switch to enable full debug logging. [ERROR] [ERROR] For more 
> information about the errors and possible solutions, please read the 
> following articles: [ERROR] [Help 1] 
> http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException 

Это мой файл setting.xml.

<settings> 
    <servers> 
     <server> 
      <id>mjx-snapshot</id> 
      <username>deployment</username> 
      <password>deployment123</password> 
     </server> 
     <server> 
      <id>vccorp-repository</id> 
      <username>editor</username> 
      <password>edxmaven</password> 
     </server> 
    </servers> 
    <mirrors> 
     <mirror> 
      <id>nexus</id> 
      <mirrorOf>*</mirrorOf> 
      <url>http://192.168.5.149:8081/nexus-maven/content/groups/public/</url> 
     </mirror>  
     <mirror> 
      <id>public_nuxus</id> 
      <mirrorOf>*</mirrorOf> 
      <url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url> 
     </mirror> 
    </mirrors> 
    <profiles> 
     <profile> 
      <id>development</id> 
      <repositories> 
       <repository> 
        <id>central</id> 
        <url>http://central</url> 
        <releases> 
         <enabled>true</enabled> 
        </releases> 
        <snapshots> 
         <enabled>true</enabled> 
        </snapshots> 
       </repository> 
      </repositories> 
      <pluginRepositories> 
       <pluginRepository> 
        <id>central</id> 
        <url>http://central</url> 
        <releases> 
         <enabled>true</enabled> 
        </releases> 
        <snapshots> 
         <enabled>true</enabled> 
        </snapshots> 
       </pluginRepository> 
      </pluginRepositories> 
     </profile> 
     <profile> 
      <!--this profile will allow snapshots to be searched when activated --> 
      <id>public-snapshots</id> 
      <repositories> 
       <repository> 
        <id>public-snapshots</id> 
        <url>http://public-snapshots</url> 
        <releases> 
         <enabled>false</enabled> 
        </releases> 
        <snapshots> 
         <enabled>true</enabled> 
        </snapshots> 
       </repository> 
      </repositories> 
      <pluginRepositories> 
       <pluginRepository> 
        <id>public-snapshots</id> 
        <url>http://public-snapshots</url> 
        <releases> 
         <enabled>false</enabled> 
        </releases> 
        <snapshots> 
         <enabled>true</enabled> 
        </snapshots> 
       </pluginRepository> 
      </pluginRepositories> 
     </profile> 
    </profiles> 
    <!-- <activeProfiles> <activeProfile>central</activeProfile> </activeProfiles> --> 
</settings> 

Пожалуйста, помогите!

+0

Почему вы пытаетесь скопировать зависимости? Если вы просто хотите создать исполняемый банку, посмотрите на плагин maven-assembly. –

+0

Спасибо, Жан-Реми. Я использовал плагин maven-assembly, но иногда я хочу использовать зависимости от копирования по некоторым причинам. – tienthanhakay

+0

Я сам использовал это для этой цели. Nevermind, в данный момент у меня нет никакой подсказки (не изучая ее глубже), чтобы решить вашу проблему. –

ответ

1

Я решил эту ошибку. Репозиторий, который я использую, недоступен, поэтому Maven не может загрузить плагины.

2

Для меня это похоже на попытку найти версию 1.0 от maven-dependency-plugin, которая isn't available in Maven Central. Используйте версию 2.4, как и в первом фрагменте POM, который вы вставили, и все должно быть в порядке.