eclipse中maven工程添加本地庫至Maven Dependencies


1.WEB-INF文件夾下添加lib文件夾,文件夾下添加demo-client-0.1-SNAPSHOT.jar

2.pom.xml中配置如下代碼:

1 <dependency>
2 <groupId>com.ali.demo.sso</groupId>
3 <artifactId>demo-common-resource</artifactId>
4 <version>0.1-resource-SNAPSHOT</version>
5 <scope>system</scope> 
6 <systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/demo-client-0.1-SNAPSHOT.jar</systemPath>
7 </dependency>

 system scope引入的包,在使用jar-with-dependencies打包時將不會被包含,可以使用resources將本地包打進jar-with-dependencies

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
              </descriptorRefs>
              <finalName>xxx-jar-with-dependencies</finalName>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
     <resources>
      <resource>
        <targetPath>lib/</targetPath>
        <directory>lib/</directory>
        <includes>
          <include>**/demo-client-0.1-SNAPSHOT.jar</include>
        </includes>
      </resource>
    </resources>
  </build>

生成的xxx-jar-with-dependencies.jar中,將會包含lib目錄以及demo-client-0.1-SNAPSHOT.jar,並且能夠被在執行的時候被找到。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM