maven加载外部依赖包

并不是所有的jar包都能在maven仓库下载,另外有些场景也不好使用私有仓库,那么这种情况下,如何把这些外部的jar也通过maven管理起来呢。

##使用maven-install-plugin

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-install-plugin</artifactId>
				<version>2.5.2</version>
			</plugin>

实例

在maven工程根目录新建lib文件夹,里头有个demo.jar纳入管理

<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-install-plugin</artifactId>
				<version>2.5.2</version>
				<executions>
					<execution>
						<id>install-demo-jar</id>
						<phase>clean</phase>
						<configuration>
							<repositoryLayout>default</repositoryLayout>
							<groupId>com.example</groupId>
							<artifactId>demojar</artifactId>
							<version>1.0.0</version>
							<file>${project.basedir}/lib/demo.jar</file>
							<packaging>jar</packaging>
							<generatePom>true</generatePom>
						</configuration>
						<goals>
							<goal>install-file</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

安装

mvn clean install

添加依赖

		<dependency>
			<groupId>com.example</groupId>
			<artifactId>demojar</artifactId>
			<version>1.0.0</version>
		</dependency>

这样就大功告成了,可以打成fat jar

doc

转载于:https://my.oschina.net/go4it/blog/1476085

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值