无法从本地存储库下载自定义jar

时间:2017-07-27 07:26:23

标签: eclipse maven

我准备了3个项目。其中两个是作为罐子建造的,其中一个是作为战争建造的。

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

然而,当我直接构建war项目时,我已经在pom中设置了它应该从存储库下载的依赖项。但是,它无法下载。当我在构建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>

这是jar.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

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。 项目&gt; maven&gt;运行配置&gt;取消选中“Resolve workspace artifacts”

相关问题