maven使用本地的jar包

Posted by hcy on May 31, 2019

maven使用本地的jar包


起因

1
2
	为了写这个网站后台,我把项目考在移动硬盘中拿回家继续写,结果maven引用的一个jar在公司maven私服里面,我自己电脑里没有。
项目跑不起来。

解决方法

1
	机智的我,想起来连接公司服务器,从其他使用到这个jar的项目中获得到了jar包,可是怎么把这个jar安装到本地的maven中,并让我能够在idea中使用呢??

配置mavne,下面拿mysql 连接驱动做讲解

1
2
3
4
5
6
7
8
   		<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
			<version>version</version>
			<scope>system</scope>
			<systemPath>d:/mysql-connector.jar</systemPath>
        </dependency>

1
也就是配置一个systemPath标签,值填本地jar包地址,就可以在idea中运行了

以上配置打包成war包是不会将本地jar 打包进去的,如果需要打包

1
2
3
4
5
6
7
<plugin>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-maven-plugin</artifactId>
	<configuration>
		<includeSystemScope>true</includeSystemScope>
	</configuration>
</plugin>

转载请注明出处:https://www.huangchaoyu.com/2019/05/31/maven使用本地的jar包/