maven自定义catalog创建archetype
来源:互联网 发布:反恐数据库外泄 编辑:程序博客网 时间:2024/06/06 20:19
1.创建一个maven项目作为模板,官方说创建archetype类型的,我个人没有试验成功,如有可行案例请指点一下。
要说自定义catalog这个坑我个人可是踩得狠了,整整痛苦了我三天时间,也许这是小白必须经历的过程吧!在这里我要感谢一篇文章的博主。正是通过这篇文章我得到了解决问题的思路。如有需要可以参考下列链接:
http://blog.csdn.net/wanxu12345678910/article/details/55099461
1.我个人创建的catalog项目骨架如下图所示:
这是一个模拟的项目(一般自定义的项目应该是ssh,ssm框架整合项目,这样就省去很多重复的配置,有人所我直接拷贝以前配置好的项目不也挺快的吗。好吧个人有个人的喜好。我懒不喜欢复制粘贴),当然如果你知道了原理那么你就可根据你需要定制生成。
2.有了这么一个项目,那么就可接着下面的步骤了。
两种方式进入到项目的根目录下。
1). window+r =>cmd
2).cd 到项目的根目录下
另一种快速的方式是打开该项目所在的根路径,选中该项目按住shift+鼠标右键选择“在此处打开命令行(w)” 同样可以进入到改项目
在命令行中输入 mvn archetype:create-from-project
构建成功后会在该项目的target目录下生成一个generated-sources文件夹,这个文件夹的下有一个archetype文件夹,这个就是我们所需要的自定义的项目内容了。
使用上面的两种方式的一种进入到这个archetype目录,
打开改文件夹archetype\src\main\resources\META-INF\maven下的archetype-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="webapp" xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <fileSets> <fileSet filtered="true" encoding="UTF-8"> <directory>src/main/resources</directory> <includes> <include>**/*.xml</include> </includes> </fileSet> <fileSet filtered="true" encoding="UTF-8"> <directory>src/main/webapp</directory> <includes> <include>**/*.jsp</include> <include>**/*.xml</include> </includes> </fileSet> <fileSet encoding="UTF-8"> <directory>src/main/webapp</directory> <includes> <include>**/*.MF</include> </includes> </fileSet> <fileSet filtered="true" encoding="UTF-8"> <directory>.settings</directory> <includes> <include>**/*.xml</include> </includes> </fileSet> <fileSet encoding="UTF-8"> <directory>.settings</directory> <includes> <include>**/*.container</include> <include>**/*.component</include> <include>**/*.name</include> <include>**/*.jsdtscope</include> <include>**/*.prefs</include> </includes> </fileSet> <fileSet filtered="true" encoding="UTF-8"> <directory></directory> <includes> <include>.classpath</include> <include>.project</include> </includes> </fileSet> </fileSets></archetype-descriptor>
这里我们重点要修改一下我们需要把下列代码根据需要修改成自己的。
<fileSet filtered="true" encoding="UTF-8"> <directory>src/main/resources</directory> <includes> <include>**/*.xml</include> </includes></fileSet>
我需要的是所有resources文件下的内容所有我修改为
<fileSet filtered="true" encoding="UTF-8"> <directory>src/main/resources</directory> <includes> <include>**</include> </includes></fileSet>
最后完整的archetype-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="webapp" xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <fileSets> <fileSet filtered="true" encoding="UTF-8"> <directory>src/main/webapp</directory> <includes> <include>**</include> </includes> </fileSet> <fileSet encoding="UTF-8"> <directory>src/main/resources</directory> <includes> <include>**</include> </includes> </fileSet> <fileSet encoding="UTF-8"> <directory>src/main/java</directory> <includes> <include>**</include> </includes> </fileSet> <fileSet filtered="true" encoding="UTF-8"> <directory>.settings</directory> <includes> <include>**/*.xml</include> </includes> </fileSet> <fileSet encoding="UTF-8"> <directory>.settings</directory> <includes> <include>**/*.prefs</include> <include>**/*.component</include> <include>**/*.container</include> <include>**/*.name</include> <include>**/*.jsdtscope</include> </includes> </fileSet> <fileSet filtered="true" encoding="UTF-8"> <directory></directory> <includes> <include>.classpath</include> <include>.project</include> </includes> </fileSet> </fileSets></archetype-descriptor>
另外由于生成的archetype 文件夹下是没有一些文件夹的,这个时候我们要自己添加好。具体要在archetype-resources 下src/main/resources下添加需要的文件夹当然src/main/java 和src/test/java也可以根据需要添加,不过别忘了在target下的archetype-resources下添加同样的文件夹,具体为什么我也不是太清楚,感觉和官方提供的archetype方式创建的archetype有点像但是由于个人整了两天没整出官方方式的archetype。总是由于各种原因生成的项目不对,最后感觉时间就是生命选择了已经可行的方案,过程复杂点,能用就够,希望有会的高手指点一下。
具体完整的archetype目录结构我作为一个新工程打开截图如下:
进入到archetype输入mvn install 运行
在本地的repository中有一个archetype-catalog.xml文件,使用eclipse打开它可以看到它比之前添加了
<archetype> <groupId>com.greenapple.webapp</groupId> <artifactId>webapp-archetype</artifactId> <version>0.1</version> <description>webapp-archetype</description></archetype>
这就是我们新添加的catalog这时候我们只要在window=>Preferences中引入改catalog文件即可
最后说一下要删除该archetype只需要把该catalog文件中添加的上面的内容delete掉就可以了,想要更加彻底的删除可以把对应的repository下的对应的groupId和artifactId 文件夹delete掉就可以。
- maven自定义catalog创建archetype
- maven 创建自定义archetype
- 使用Maven创建自定义Archetype
- 使用maven创建自定义的archetype
- archetype-catalog
- 自定义maven archetype插件
- 自定义maven-archetype
- maven 自定义archetype
- 自定义maven archetype
- 自定义maven-archetype
- 自定义maven archetype
- 手把手创建自定义的分层的maven-archetype
- Maven学习笔记(十一)-创建自定义的archetype(项目模板)
- MAVEN 创建自己maven archetype
- 如何自定义 maven中的archetype
- 创建简单的maven archetype
- maven 创建自己的archetype
- 创建简单的maven archetype
- CentOS 6.6挂载iSCSI存储
- Js函数
- [算法与数据结构]
- 远程过程调用(RPC)详解
- HTTP常见状态码
- maven自定义catalog创建archetype
- mongoexport和mongoimport
- hdu12823(两凸包之间最短距离)
- HDU 4185 Oil Skimming 二分匹配
- Hdu 6060 RXD and dividing【思维】
- 冒泡排序和插入排序
- 【转】快速搭建react的webpack初始环境
- Javascript整理
- 挑战程序竞赛系列(31):4.5剪枝