maven 按业务拆分模块_java-maven-多模块拆分构建项目-阿里云开发者社区

便于后期的维护,我们一般会进行分层开发,基于Maven3开发。

system-parent

|—-pom.xml

|—-system-domain

|—-pom.xml

|—-system-dao

|—-pom.xml

|—-system-service

|—-pom.xml

|—-system-web

|—-pom.xml

网络问题可能会出现:

maven “Generating project in Batch mode”问题的解决

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

这句话的命令是创建一个默认的项目,但我在执行这个命令时,命令行会停在

[INFO] Generating project in Batch mode

增加一个-X参数,可以查看详细信息

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -X

可以看到,程序停在了下面这一行。

[DEBUG] Searching for remote catalog: http://repo1.maven.org/maven2/archetype-catalog.xml

去查询这个文件的时候网络比较差或者其他原因,导致挂在那里。

解决方法很简单。

1. 把上述地址复制到浏览器中,下载这个文件到本地。

2. 把文件archetype-catalog.xml复制到目录.m2\repository\org\apache\maven\archetype\archetype-catalog\2.2下面。

3. 在上述命令后增加参数-DarchetypeCatalog=local,变成读取本地文件即可。

mvn archetype:generate -DgroupId=me.gacl -DartifactId=system-parent -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -DarchetypeCatalog=local

将src文件夹删除,然后修改pom.xml文件,将jar修改为pom,pom表示它是一个被继承的模块

domain

mvn archetype:generate -DgroupId=me.gacl -DartifactId=system-domain -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -DarchetypeCatalog=local

service

mvn archetype:generate -DgroupId=me.gacl -DartifactId=system-service -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -DarchetypeCatalog=local

dao

mvn archetype:generate -DgroupId=me.gacl -DartifactId=system-dao -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -DarchetypeCatalog=local

web

mvn archetype:generate -DgroupId=me.gacl -DartifactId=system-web -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false -DarchetypeCatalog=local

然后就好了!

4.0.0

me.gacl

system-parent

pom

1.0-SNAPSHOT

system-parent

http://maven.apache.org

UTF-8

junit

junit

3.8.1

test

system-domain

system-dao

system-service

system-web

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

4.0.0

me.gacl

system-parent

1.0-SNAPSHOT

system-domain

jar

system-domain

http://maven.apache.org

UTF-8

junit

junit

3.8.1

test

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

4.0.0

me.gacl

system-parent

1.0-SNAPSHOT

system-dao

jar

system-dao

http://maven.apache.org

UTF-8

junit

junit

3.8.1

test

me.gacl

system-domain

${project.version}

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

4.0.0

me.gacl

system-parent

1.0-SNAPSHOT

me.gacl

system-service

1.0-SNAPSHOT

system-service

http://maven.apache.org

UTF-8

junit

junit

3.8.1

test

me.gacl

system-dao

${project.version}

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

4.0.0

me.gacl

system-parent

1.0-SNAPSHOT

me.gacl

system-web

1.0-SNAPSHOT

war

system-web Maven Webapp

http://maven.apache.org

junit

junit

3.8.1

test

me.gacl

system-service

${project.version}

system-web

org.mortbay.jetty

maven-jetty-plugin

最后编译

mvn clean install

在system-web目录下多出了target目录

启动项目

mvn jetty:run

最后导入IDE项目开发!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值