maven 构建多模块项目

一、构建 maven 主工程

1、使用 idea 新建 Project,选择 maven,选择 quickstart 类型。 

 

点击 Next,填写 GroupId、ArtifactId。

GroupID是项目组织唯一的标识符,实际对应JAVA的包的结构,是main目录里java的目录结构。

ArtifactID就是项目的唯一的标识符,实际对应项目的名称,就是项目根目录的名称。

 

 

点击 Next,选择 maven 相关版本,配置文件位置等。

 


 

点击 Next,选择项目存储目录,点击 Finish。

 


 

修改主工程 pom.xml 文件,把 packing 方式从 jar 改成 pom,如下图:

 

 

二、创建 maven module

建立 b2b2cweb、common、goods、goodsweb、customermgr 模块,其中 common、goods 是 quickstart 模块,b2b2cweb、goodsweb、customermgr 是 webapp 模块。

1、创建 b2b2cweb webapp 子模块

 

 填写模块名称,点击 next



 选择 org apache maven archetypes maven archetype webapp ,点击 next



 修改 package,点击 finish。

 

2、创建 common quickstart 子模块,选择 org apache maven archetypes maven archetype quickstart ,其他步骤与创建 b2b2cweb 相似。

 

3、创建 customermgr webapp 子模块,选择 org apache maven archetypes maven archetype webapp,其他步骤与创建 b2b2cweb 相似。

 

4、创建 goods quickstart 子模块,选择 org apache maven archetypes maven archetype quickstart ,其他步骤与创建 b2b2cweb 相似。

 

5、创建 goodsweb webapp 子模块,选择 org apache maven archetypes maven archetype webapp ,其他步骤与创建 b2b2cweb 相似。

 

三、配置模块间依赖关系

 

1、customermgr 模块 pom.xml 依赖关系



 2、 goods 模块 pom.xml  依赖关系

 

 3、goodsweb 模块 pom.xml 依赖关系



 

 4、b2b2cweb 模块 pom.xml 依赖关系



 

 5、在 b2b2cweb 模块中配置动态打包。



 

6、运行 Maven install,出现如下结果



 

 

四、使用 jetty 对工程进行测试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值