使用命令行快速创建Maven多模块项目
1.创建父模块
mvn archetype:generate -DgroupId=name.isgodonto -DartifactId=auth-all -Dversion=1.0.0-SNAPSHOT -Dpackage=name.isgodonto -DarchetypeArtifactId=maven-archetype-site-simple -DarchetypeGroupId=org.apache.maven.archetypes -DinteractiveMode=false
2.创建子模块
cd auth-all mvn archetype:generate -DgroupId=name.isgodonto -DartifactId=auth-dal -Dversion=1.0.0-SNAPSHOT -Dpackage=name.isgodonto -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeGroupId=org.apache.maven.archetypes -DinteractiveMode=false mvn archetype:generate -DgroupId=name.isgodonto -DartifactId=auth-biz -Dversion=1.0.0-SNAPSHOT -Dpackage=name.isgodonto -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeGroupId=org.apache.maven.archetypes -DinteractiveMode=false mvn archetype:generate -DgroupId=name.isgodonto -DartifactId=auth-web -Dversion=1.0.0-SNAPSHOT -Dpackage=name.isgodonto -DarchetypeArtifactId=maven-archetype-webapp -DarchetypeGroupId=org.apache.maven.archetypes -DinteractiveMode=false
3.目录结构:
auth-all:父(聚合)模块
auth-dal:数据访问模块
auth-biz:业务模块,依赖于auth-dal
auth-web:web模块,依赖于auth-biz
4.pom文件调整如下:
1)auth-all的pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>name.isgodonto</groupId> <artifactId>auth-all</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>pom</packaging> <properties> <auth.version>1.0.0-SNAPSHOT</auth.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <jetty.version>8.1.13.v20130916</jetty.version> </properties> <modules> <module>auth-dal</module> <module>auth-biz</module> <module>auth-web</module> </modules> <dependencyManagement> <dependencies> <!-- ================================================= --> <!-- 模块间依赖 --> <!-- ================================================= --> <dependency> <groupId>name.isgodonto</groupId> <artifactId>auth-dal</artifactId> <version>${auth.version}</version> </dependency> <dependency> <groupId>name.isgodonto</groupId> <artifactId>auth-biz</artifactId> <version>${auth.version}</version> </dependency> <dependency> <groupId>name.isgodonto</groupId> <artifactId>auth-web</artifactId> <version>${auth.version}</version> </dependency> </dependencies> </dependencyManagement> <build> <pluginManagement> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>${jetty.version}</version> </plugin> </plugins> </pluginManagement> </build> </project>
2)all-dal的pom.xml:
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>name.isgodonto</groupId> <artifactId>auth-all</artifactId> <version>1.0.0-SNAPSHOT</version> </parent> <artifactId>auth-dal</artifactId> <name>auth-dal</name> </project>
3)admin-biz的pom.xml:
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>name.isgodonto</groupId> <artifactId>auth-all</artifactId> <version>1.0.0-SNAPSHOT</version> </parent> <artifactId>auth-biz</artifactId> <name>auth-biz</name> <dependencies> <dependency> <groupId>name.isgodonto</groupId> <artifactId>auth-dal</artifactId> </dependency> </dependencies> </project>
4)auth-web的pom.xml:
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>name.isgodonto</groupId> <artifactId>auth-all</artifactId> <version>1.0.0-SNAPSHOT</version> </parent> <artifactId>auth-web</artifactId> <packaging>war</packaging> <dependencies> <dependency> <groupId>name.isgodonto</groupId> <artifactId>auth-biz</artifactId> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <configuration> <webApp> <contextPath>/</contextPath> </webApp> <scanIntervalSeconds>5</scanIntervalSeconds> <stopKey>myapp</stopKey> <stopKey>9999</stopKey> <connectors> <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector"> <port>80</port> <maxIdleTime>60000</maxIdleTime> </connector> </connectors> <requestLog implementation="org.eclipse.jetty.server.NCSARequestLog"> <filename>target/access.log</filename> <retainDays>90</retainDays> <append>false</append> <extended>false</extended> <logTimeZone>GMT+8:00</logTimeZone> </requestLog> </configuration> </plugin> </plugins> <finalName>auth-web</finalName> </build> </project>
5.运行项目:
在auth-all下执行以下命令安装包到本地仓库:
mvn clean install -pl auth-web -am
在auth-web下执行以下命令启动jetty容器:
mvn jetty:run
在浏览器输入http://localhost,看到"Hello World!"就成功了!
相关推荐
使用Maven构建多模块项目
所有用Maven管理的真实的项目都应该是分模块的,每个模块都对应着一个pom.xml。它们之间通过继承和聚合(也称作多模块,multi-module)相互关联。 提供了一个简单的Maven多模块实例
maven多模块项目使用jetty,详细看http://blog.csdn.net/xiejx618/article/details/49936541
maven多模块项目,使用eclipse开发工具创建,有意可下载,没有解压密码
springboott创建maven多模块项目1
Maven多模块项目编译速度慢,下面我们来学习下优化的方法。 mvn clean package -T 4C -Dmaven.test.skip=true -Dmaven.compile.fork=true -T 4C 代表本机4个CPU内核都参与编译工程, -Dmaven.test.skip=true 代表...
maven多模块项目,采用阿里巴巴连接池,springmvc,spring,slf4j与log4j日志,数据库为mysql,页面为jsp
详细介绍IDEA从远程仓库SVN拉去MAVEN项目.多模块的项目
NULL 博文链接:https://yansxjl.iteye.com/blog/2333900
maven构建Web工程相关的命令行命令的总结
1.2.maven多模块项目配置1
NULL 博文链接:https://zlrzlm7454.iteye.com/blog/2321724
使用spring+springMvc+Mybatis+maven搭建多模块化的web项目
maven是一款java包管理软件,有点像ruby的gem,本教程使用maven创建多模块项目!
node-maven node-maven is a CLI tool for helping you escape from search-copy-paste, when you wanna compile a maven central library. Based on Maven Central API Quick Look Usage First of all, you are ...
maven 模块化项目demo,使用maven 开发模块化程序demo源码
前提eclipse已安装maven插件,maven插件可以在线安装但会有很多问题,也可以在网上找离线安装包安装。
maven构建多模块项目,参考:http://blog.csdn.net/xiejx618/article/details/19849035
eclipse + maven多模块项目框架 + jetty热部署的实例源码 让你掌握maven中那些令人迷惑的一堆配置,基于此框架快速搭建maven多模块项目完美环境。
详细介绍idea通过svn检出maven多模块项目,每一步都有截图以及操作顺序,很完整。