目的
一个业务项目需要用到另一个项目(主要是平时自己积累的工具类)中的module。
一、材料准备
1、创建一个自己的工具项目
可参考如下文章建立一个多module的project:https://www.jianshu.com/p/b5932f2fd4e8

service 模块中的服务

2、创建一个业务项目
用idea随意创建一个springboot项目,用于测试。


二、操作
1、安装工具项目到本地maven仓库(关键)
需要安装整个工具项目,不要只安装module



2、调用
在业务项目的pom.xml文件中引入service
安装了工具项目,我们就可以在业务项目中调用本地仓库中安装的service模块

在代码中调用


运行业务项目,打印了hello

3、业务项目打jar包
在业务项目上,任然执行maven的install,得到业务项目的jar包

4、在cmd中执行业务项目的jar包

访问结果:打印了hello

在业务项目的jar包中,我们可以找到service的jar包

网友评论