为什么80%的码农都做不了架构师?>>>   

1、找到模板项目

删掉.idea文件夹

2、在项目目录下执行

mvn archetype:create-from-project

3、找到生成出的模板

cd到target/generated-sources/archetype

4、修改文件

(1)修改你这个archetype的target/generated-sources/archetype/pom.xml

配置

<groupId>com.scipio</groupId><artifactId>app-scaffold-archetype</artifactId><version>1.0-SNAPSHOT</version><packaging>maven-archetype</packaging><name>app-scaffold-archetype</name>

(2)修改archetype-metadata

在目录target/generated-sources/archetype/src/main/resources/META-INF/maven/atchetype-metadata.xml

<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="app-scaffold"xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><requiredProperties> <requiredProperty key="groupId"> <defaultValue>com.scipio</defaultValue> </requiredProperty> <requiredProperty key="artifactId"> <defaultValue>myapp</defaultValue> </requiredProperty> <requiredProperty key="package"> <defaultValue>com.scipio.myapp</defaultValue> </requiredProperty> </requiredProperties><fileSets><fileSet encoding="UTF-8"><directory></directory><includes><include>.gitignore</include></includes></fileSet></fileSets><modules><module id="${artifactId}-web" dir="app-web" name="app-web"><fileSets><fileSet filtered="true" packaged="true" encoding="UTF-8"><directory>src/main/java</directory><includes><include>**/*.java</include></includes></fileSet><fileSet filtered="true" encoding="UTF-8"><directory>src/main/webapp</directory><includes><include>**/*.xml</include><include>**/*.properties</include></includes></fileSet><fileSet filtered="true" encoding="UTF-8"><directory>src/main/resources</directory><includes><include>**/*.xml</include></includes></fileSet><fileSet encoding="UTF-8"><directory>src/main/webapp</directory><includes><include>**/*.inc</include><include>**/*.js</include><include>**/*.ftl</include><include>**/*.css</include></includes></fileSet><fileSet encoding="UTF-8"><directory>src/main/resources</directory><includes><include>**/*.sql</include><include>**/*.ftl</include></includes></fileSet><fileSet filtered="true" packaged="true" encoding="UTF-8"><directory>src/test/java</directory><includes><include>**/*.java</include></includes></fileSet><fileSet encoding="UTF-8"><directory></directory><includes><include>.gitignore</include></includes></fileSet></fileSets></module><module id="${artifactId}-remote-service" dir="app-remote-service" name="app-remote-service"><fileSets><fileSet filtered="true" packaged="true" encoding="UTF-8"><directory>src/main/java</directory><includes><include>**/*.java</include></includes></fileSet><fileSet filtered="true" packaged="true" encoding="UTF-8"><directory>src/test/java</directory><includes><include>**/*.java</include></includes></fileSet></fileSets></module></modules>
</archetype-descriptor>

(3)修改两个模块的名称,与配置文件的dir对应

比如app-web,app-remote-service

(4)修改母project的pom.xml

在archetype/src/main/resources/archetype-resources/pom.xml

修改名称

    <groupId>${groupId}</groupId><artifactId>${artifactId}</artifactId><version>${version}</version><packaging>pom</packaging><name>${artifactId}</name><url>http://maven.apache.org</url>

配上相应的子模块

<modules><module>${artifactId}-remote-service</module><module>${artifactId}-web</module>
</modules>

(5)修改子模块的pom.xml

app-remote-service

<parent><artifactId>${rootArtifactId}</artifactId><groupId>${groupId}</groupId><version>${version}</version></parent><modelVersion>4.0.0</modelVersion><artifactId>${rootArtifactId}-remote-service</artifactId><packaging>jar</packaging><name>${rootArtifactId}-remote-service</name><version>${version}</version>

app-web

   <parent><artifactId>${rootArtifactId}</artifactId><groupId>${groupId}</groupId><version>${version}</version><relativePath>..</relativePath></parent><artifactId>${rootArtifactId}-web</artifactId><version>${version}</version><packaging>war</packaging><name>${rootArtifactId}-web</name><url>http://maven.apache.org</url>

5、安装

mvn clean package install (本地安装)

mvn clean package deploy (远程安装)

6、本地使用

切换到其他目录(该目录不能有pom.xml文件)

mvn archetype:generate -DarchetypeCatalog=local

选择本地的那个app-scaffold

然后按提示输入变量,artifactId默认是myapp,自己在confirm时按N,然后自己修改

最后就生成出来了

7、部署你的archetype

在arget/generated-sources/archetype目录下

修改pom.xml

在project节点下增加maven服务器

<distributionManagement><repository><id>scipio-nexus-releases</id><name>Scipio Nexus Repository</name><url>http://nexus.scipio.com:8081/nexus/content/repositories/releases/</url></repository><snapshotRepository><id>scipio-nexus-snapshots</id><name>Scipio Nexus Repository</name><url>http://nexus.scipio.com:8081/nexus/content/repositories/snapshots/</url></snapshotRepository></distributionManagement>

mvn clean package deploy

8、使用该archetype

mvn archetype:generate -DgroupId=com.scipio -DartifactId=myapp -Dpackage=com.scipio.myapp -DarchetypeGroupId=com.scipio -DarchetypeArtifactId=mtapp-scaffold-archetype

参考:

http://numberformat.wordpress.com/2009/11/15/creating-a-new-maven-archetype-and-publishing-it-to-nexus/

http://www.shenyanchao.cn/blog/2013/05/21/use-maven-archetype-to-generate-project-architecture/

http://maven.apache.org/archetype/maven-archetype-plugin/advanced-usage.html

转载于:https://my.oschina.net/scipio/blog/288104

Maven创建自己的工程相关推荐

  1. Maven 创建、测试工程

    创建工程 Maven 使用原型(archetype)插件创建工程. cd d: cd eclipse-workspace mvn archetype:generate -DgroupId=com.wj ...

  2. vaadin ---用maven创建vaadin 的工程

    为什么80%的码农都做不了架构师?>>>    使用maven 命令创建vaadin 工程: mvn archetype:generate -DarchetypeGroupId=co ...

  3. eclipse maven 创建总POM 工程

    首先进入到eclipse的workspace,我这里的workspace目录是D:\workspace 1.创建总的POM D:\workspace>mvn archetype:create - ...

  4. 使用Maven创建多模块父子Spring Boot工程

    使用Maven创建Spring Boot工程_紫月下枫叶的博客-CSDN博客目录1.开发环境2.创建普通maven工程3.添加Spring Boot父工程4.添加Web场景依赖5.添加主程序6.添加C ...

  5. 在eclipse上使用Maven创建动态web项目

    在eclipse上使用Maven创建web工程和使用Maven创建普通Java工程一样,不过在Packaging一栏选择"war",这个过程具体就不多说了,详情见我上一篇文章. 我 ...

  6. eclipse 创建maven 项目 动态web工程完整示例

    需求表均同springmvc案例 此处只是使用maven 注意,以下所有需要建立在你的eclipse等已经集成配置好了maven了,说白了就是新建项目的时候已经可以找到maven了 没有的话需要安装m ...

  7. maven 主工程 java_Maven创建Java Application工程(既jar包)

    Maven在创建工程时使用的是archetype(原型)插件,而如果要创建具体的工程,比如Application这些,那么可以使用maven-archetype-quickstart(相当于一个子类型 ...

  8. DEA中创建父子工程与maven打包Springboot聚合工程报错程序包不存在

    DEA中创建父子工程与maven打包Springboot聚合工程报错程序包不存在 问题描述 springboot 项目打包(package)或安装到仓库(install)的时候报错:程序包com.fu ...

  9. Maven创建父子工程详解

    前言: 在微服务盛行的当下,我们创建的工程基本都是父子工程,我们通过父工程来引入jar,定义统一的版本号等,这样我们在子工程中就可以直接引用后使用了,而不需要去重复的声明版本号等,这样会更方便对整个项 ...

最新文章

  1. 工作经验:Java 系统记录调用日志,并且记录错误堆栈
  2. 如何营造专属你的企业技术影响力氛围感?我不允许你还不知道
  3. linux C 学习
  4. 转:数学之美番外篇:平凡而又神奇的贝叶斯方法 收藏
  5. 用python倒序输出一个字符串_Python 反转字符串(reverse)的方法小结
  6. java 倒序分页_翻动100万级的数据(自定义的MSSQL分页查询过程)
  7. Apache和Nginx防盗链
  8. 杂:(4)NE555
  9. XML文件解析--Python
  10. 最爱的城市(dfs)
  11. Java 集合系列-第七篇-List总结
  12. [洛谷P2463][SDOI2008]Sandy的卡片
  13. Linux界面介绍及基础知识
  14. 【python文字游戏】飞花令
  15. 申宝投资-昨日三大指数缩量探底回升
  16. 【Python爬虫案例学习4】Python 爬取meizitu
  17. 医院影像服务器系统,锐潮医学影像管理系统(PACS)
  18. 项目运行时报错出现:因为在此系统上禁止运行脚本有关详细信息,请参阅 https。该如何解决
  19. 【学习笔记】AGC009/AGC019/AGC029/AGC035
  20. 热门编程语言那么多,该选择哪个

热门文章

  1. 基于Docker的云部署
  2. 关于window.close()不能关闭的问题解决
  3. GLM国产大模型训练加速:性能最高提升3倍,显存节省1/3,低成本上手
  4. 电脑调分辨率黑屏了怎么办_分辨率调不了怎么办 电脑屏幕分辨率调不了的原因及解决方法...
  5. zabbix监控主机是否存活
  6. 不同网段设备相互访问
  7. CF555E Case of Computer Network
  8. 使用微软Monaco Editor 编写在线调试工具
  9. python爬虫实战二:爬取网站表情包
  10. 戴锦华讲电影:电影与现实 2020-6-15