idea maven 项目引入本地第三方jar


由于第三方jar不在远程maven库上,又要实现远程服务器自动打包发布功能,当然远程服务器本地仓库也是没有要引入的第三方的jar,所以需要把本地引入的jar使用本地引入的方式,生成war时,直接打到war里。

pom【<dependencies>】节点添加本地jar

<dependency>
            <groupId>com.xxx.xxx</groupId>
            <artifactId>xx-xx-api</artifactId>
            <version>1.0-SNAPSHOT</version>
            <scope>system</scope>
            <systemPath>${basedir}/lib/xx-xx-api-1.0-SNAPSHOT.jar</systemPath>
</dependency>

 

pom【<build><plugins><build/><plugins/>】添加以下

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
                            <includeScope>system</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
scope说明:
总结来说:
compile:默认的scope,运行期有效,需要打入包中。
provided:编译期有效,运行期不需要提供,不会打入包中。
runtime:编译不需要,在运行期有效,需要导入包中。(接口与实现分离)
test:测试需要,不会打入包中。
system:非本地仓库引入、存在系统的某个路径下的jar。(一般不使用)

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM