maven引入本地的jar包

常规方法是执行命令,安装到maven仓库

mvn install:install-file -Dfile=jar包地址 -DgroupId=组织id -DartifactId=工件id -Dversion=1.0 -Dpackaging=jar

本次不使用这种方法,不安装的方式直接引入本地的jar包。

以引入gsjdbc4.jar为例,pom.xml如下

<dependencies>
<dependency>
		    <groupId>org.postgresql</groupId>
		    <artifactId>postgresql</artifactId>
		    <scope>system</scope>
		    <systemPath>${project.basedir}/lib/gsjdbc4.jar</systemPath>
		</dependency>
	</dependencies>
<plugins>
			
			<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <!-- <version>0.0.1</version> -->
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                    <compilerArguments>
                        <extdirs>${project.basedir}/lib</extdirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
		</plugins>

注意点:groupId和artifactId如何写,可以展开jar包

如果以上方法没生效 maven clean试试。还不行我就没办法了

参考:https://segmentfault.com/a/1190000037770505?sort=newest

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值