EasonJim

假设自己开发了一个公共类库想要用到其它项目中,为了方便管理所有项目都引入Maven,如果在项目上要用这个公共类库,可以有如下思路解决:

1、采用本地手动机制拷贝项目到lib文件夹中,但是缺点就是更新这些操作都必须是手动。

2、搭建私有仓库nexus,把公共库提交上去。

3、上次到默认中央仓库,参考:http://www.cnblogs.com/EasonJim/p/6671419.html

4、安装到本地仓库,既local中。

很明显,第4种方式是最方便且最快的,每次类库更新后再更新到本地仓库中,其它项目通过Maven自动更新即可。

以下为操作命令:

mvn install:install-file -Dfile=C:\JSoftCommon-0.0.1.jar -DgroupId=com.jsoft.tools -DartifactId=JSoftCommon -Dversion=0.0.1 -Dpackaging=jar

提示:首先指定具体的jar文件路径,其次分别指定Maven版本的xml节点groupId、artifactId、version。

install插件更详细的解释,参考:http://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html

通过上述方法安装好之后,就可以在项目上的pom.xml定为到这个依赖包,如:

<dependency>
      <groupId>com.jsoft.tools</groupId>
      <artifactId>JSoftCommon</artifactId>
      <version>0.0.1</version>
</dependency>

配置好后,即可跟普通项目通过Maven构建。

 

以上参考:http://www.yiibai.com/maven/include-library-manully-into-maven-local-repository.html

分类:

技术点:

相关文章:

  • 2022-01-17
  • 2022-01-01
  • 2021-12-06
  • 2021-08-06
  • 2021-04-11
  • 2021-11-17
猜你喜欢
  • 2021-07-08
  • 2021-06-14
  • 2021-05-23
  • 2021-06-16
  • 2021-11-20
相关资源
相似解决方案