2017-07-27 56 views
0

我已经准备了3个项目。其中两个建成罐子,其中一个建成战争。无法从本地存储库下载定制jar

我有maven在eclipse中构建了2个jar项目。我发现他们已经放入本地存储库。

但是,当我直接构建战争项目时,我已经在pom中设置了依赖关系,它应该从存储库下载。但是,它不能下载。当我在build war文件中检查web_inf/lib时。只有两个空文件夹找到。

如果我直接构建pom.work.app。构建的war文件将包含所有需要的定制jar项目。

我有搜索互联网上的相关问题,但没有建议的解决方案可以帮助。

我在构建战争项目中缺少的东西。

这是.m2目录设置文件

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> 



<localRepository>C:\Users\Vincent\.m2\repository\</localRepository>  


<profiles> 
    <profile> 
     <id>jboss-public</id> 
     <repositories> 
     <repository> 
      <id>jboss-public-repository</id> 
      <name>JBoss Public Maven Repository Group</name> 
      <url>http://repository.jboss.org/nexus/content/groups/public/</url> 
     </repository> 

     <repository> 
      <id>jboss-local-repository</id> 
      <name>JBoss local Maven Repository Group</name> 
      <url> file://C:\Users\Vincent\.m2\repository\</url> 
     </repository> 
     </repositories> 
    </profile> 

     <profile> 
      <id>wildfly-remote</id> 
      <properties> 
       <wildfly-hostname>127.0.0.1</wildfly-hostname> 
       <wildfly-port>9991</wildfly-port> 
       <wildfly-username>vincent</wildfly-username> 
       <wildfly-password>x12345</wildfly-password> 
      </properties> 
     </profile> 

     <profile> 
      <id>wildfly-local</id> 
      <properties> 
       <wildfly-home>G:\Program Files (x86)\wildfly-10.1.0.Final</wildfly-home> 
       <wildfly-hostname>localhost</wildfly-hostname> 
       <wildfly-port>9991</wildfly-port> 
       <wildfly-username>vincent</wildfly-username> 
       <wildfly-password>x12345</wildfly-password> 
      </properties> 
     </profile> 


    </profiles> 

这是pom.work.app文件

<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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>example.work</groupId> 
    <artifactId>pom.work.app</artifactId> 
    <version>0.0.1</version> 

    <packaging>pom</packaging> 
    <name>pom.work.app</name> 
    <url>http://maven.apache.org</url> 

     <modules> 
     <module>../jar.work.framework.service</module>  
     <module>../jar.work.service</module> 
     <module>../work.ui</module> 
     </modules> 


<properties> 
....... 
....... 
<properties> 


<repositories> 
     <repository> 
      <id>maven repo</id> 
      <url>http://repo1.maven.org/maven2</url> 
     </repository> 

     <repository> 
      <id>eaio.com</id> 
      <url>http://eaio.com/maven2</url> 
     </repository> 

     <repository> 
      <id>maven-restlet</id> 
      <name>Public online Restlet repository</name> 
      <url>http://maven.restlet.com</url> 
     </repository> 



     <repository> 
      <id>JBoss Repository</id> 
      <name>JBoss Repository</name> 
      <url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url> 
     </repository> 
</repositories> 

<dependencyManagement> 
     <dependencies> 

      <dependency> 
       <groupId>example.work</groupId> 
       <artifactId>jar.work.framework.service</artifactId> 
       <version>${example.work}</version> 
      </dependency> 

      <dependency> 
       <groupId>example.work</groupId> 
       <artifactId>jar.work.service</artifactId> 
       <version>${example.work}</version> 
      </dependency> 

         ....... 
         ....... 

     </dependencies> 
</dependencyManagement> 

<build> 
     <pluginManagement> 
      <plugins> 

      <plugin> 
       <groupId>org.wildfly.plugins</groupId> 
       <artifactId>wildfly-maven-plugin</artifactId> 
       <version>1.2.0.Alpha6</version> 
       <executions> 
        <execution> 
         <phase>install</phase> 
         <goals> 
          <goal>deploy</goal> 
         </goals> 

        <configuration>       
        <hostname>127.0.0.1</hostname> 
        <port>9990</port> 
        <username>vincent</username> 
        <password>x12345</password> 
        </configuration> 

        </execution> 
       </executions> 
      </plugin> 

       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <version>2.3.2</version> 
        <configuration> 
         <source>${jdk.version}</source> 
         <target>${jdk.version}</target> 
         <debug>true</debug> 
         <debuglevel>lines,source</debuglevel> 
        </configuration> 
       </plugin> 

       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-war-plugin</artifactId> 
        <version>3.1.0</version> 
       </plugin> 

       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-surefire-plugin</artifactId> 
        <version>2.17</version> 
       </plugin> 

       <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-antrun-plugin</artifactId> 
       <version>1.7</version> 
       <executions> 
        <execution> 
        <id>copy</id> 
        <phase>install</phase> 
        <goals> 
         <goal>run</goal> 
        </goals> 
        <configuration> 
         <target> 
          <copy file="${basedir}/../work/target/work.ui.war" 
          tofile="G:\Program Files (x86)\wildfly-10.1.0.Final\standalone\deployments\tmp_work.war" />  
         </target> 
        </configuration> 
        </execution> 
       </executions> 
       </plugin> 



      </plugins> 
     </pluginManagement> 
    </build> 

</project> 

这是work.ui POM文件

<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"> 
    <modelVersion>4.0.0</modelVersion> 

    <parent> 
     <groupId>excample.work</groupId> 
     <artifactId>pom.work.app</artifactId> 
     <version>0.0.1</version> 
     <relativePath>../pom.work.app/pom.xml</relativePath> 
    </parent> 

    <artifactId>work.ui</artifactId> 
    <packaging>war</packaging> 
    <name>work Maven Webapp</name> 



    <repositories> 
     <repository> 
      <id>maven repo</id> 
      <url>http://repo1.maven.org/maven2</url> 
     </repository> 



     <repository> 
     <id>spring-snapshots</id> 
     <name>Spring Snapshots</name> 
     <url>https://repo.spring.io/libs-snapshot</url> 
     <snapshots> 
      <enabled>true</enabled> 
     </snapshots> 
     </repository> 

    <repository> 
     <id>prime-repo</id> 
     <name>PrimeFaces Maven Repository</name> 
     <url>http://repository.primefaces.org</url> 
     <layout>default</layout> 
    </repository> 

</repositories> 

<dependencies> 
    <dependency> 
     <groupId>excample.work</groupId> 
     <artifactId>jar.work.service</artifactId> 
     <version>${xcample.work}</version> 
    </dependency> 

     <dependency> 
     <groupId>excample.work</groupId> 
     <artifactId>jar.work.framework.service</artifactId> 
     <version>${xcample.work}</version> 
    </dependency> 



    </dependencies> 


<build> 


    <defaultGoal>install</defaultGoal> 
     <directory>${basedir}/target</directory> 
     <finalName>${project.artifactId}</finalName> 

     <sourceDirectory>src/main/java</sourceDirectory> 

    <pluginManagement> 
    <plugins> 

        <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-war-plugin</artifactId> 

        <configuration> 
         <warName>${project.artifactId}</warName> 
         <webXml>src/main/webapp/WEB-INF/web.xml</webXml> 

         <webResources> 
          <resource> 
           <directory>src/main/webapp</directory> 
           <includes> 
            <include>**/*</include> 
           </includes> 
          </resource> 
         </webResources> 

        </configuration> 
       </plugin> 



    </plugins> 
    </pluginManagement> 
    </build> 
</project> 

这是罐子。 work.service文件

<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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <parent> 
     <groupId>example.work</groupId> 
     <artifactId>pom.work.app</artifactId> 
     <version>0.0.1</version> 
     <relativePath>../pom.work.app/pom.xml</relativePath> 
    </parent> 

    <artifactId>jar.work.service</artifactId> 
    <packaging>jar</packaging> 

    <name>jar.work.service</name> 


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

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

    <build> 

    <defaultGoal>install</defaultGoal> 
     <directory>${basedir}/target</directory> 
     <finalName>${project.artifactId}</finalName> 

     <sourceDirectory>src/main/java</sourceDirectory> 

     <resources> 
      <resource> 
       <directory> 
        src/main/resources 
       </directory> 
      </resource> 
     </resources> 

     <pluginManagement> 
      <plugins> 



       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-antrun-plugin</artifactId> 
        <executions> 
         <execution> 
          <id>default-cli</id> 
          <phase>generate-resources</phase> 
          <goals> 
           <goal>run</goal> 
          </goals> 

         </execution> 
        </executions> 
       </plugin> 
      </plugins> 
     </pluginManagement> 
    </build> 



</project> 

这是jar.work.framework.service文件

<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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <parent> 
     <groupId>example.work</groupId> 
     <artifactId>pom.work.app</artifactId> 
     <version>0.0.1</version> 
     <relativePath>../pom.work.app/pom.xml</relativePath> 
    </parent> 




    <artifactId>jar.work.framework.service</artifactId> 
    <name>jar.work.framework.service</name> 
    <description>service</description> 


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

<build> 

     <defaultGoal>install</defaultGoal> 
     <directory>${basedir}/target</directory> 
     <finalName>${project.artifactId}</finalName> 

     <sourceDirectory>src/main/java</sourceDirectory> 

     <resources> 
      <resource> 
       <directory> 
        src/main/resources 
       </directory> 
      </resource> 
     </resources> 

     <pluginManagement> 
      <plugins> 

       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-antrun-plugin</artifactId> 
        <executions> 
         <execution> 
          <id>default-cli</id> 
          <phase>generate-resources</phase> 
          <goals> 
           <goal>run</goal> 
          </goals> 

         </execution> 
        </executions> 
       </plugin> 




      </plugins> 


     </pluginManagement> 
    </build> 







</project> 

后,我建立独立,他们的jar文件在本地存储库中创建两个jar项目。

enter image description here

构建work.ui后,只有空的文件夹中创建。

enter image description here

+0

我在eclipse中输入目标“clean install -U”作为命令 – vincent

+0

删除了不适合XML的片段。内嵌图片 –

+0

哪些代码段?例如? – vincent

回答

0

我找到解决方案。 project> maven> run configurations>取消选中'Resolve workspace artifacts'

相关问题