mvn自定义archetype

1、新建一个maven项目,最好选择quickStart这种,干净,然后配置好自己想要的布局和文件;并且在pom.xml中加上
                <plugin>  
                    <groupId>org.apache.maven.plugins</groupId>  
                    <artifactId>maven-archetype-plugin</artifactId>  
                    <version>2.2</version>  
                </plugin> 


2、eclipse右键pom.xml执行archetype:create-from-project,或者在项目的根目录使用命令行执行;


3、只能用命令行:在\项目\target\generated-sources\archetype下执行mvn install;


4、新建maven项目,勾选snapshoot,即可看到自己的archetype;


出现的一些问题:
1、第二步执行时报找不到maven.home;
解决:
使用自己的maven替换eclipse中自带的maven,并且在eclipse中设置maven->installations和maven->user settings,之后新建一个新项目执行1-4;


2、如何删除自己的骨架?
解决:
(1)命令行cd到自己仓库,执行mvn archetype:crawl,自动遍历仓库,生成archetype-catalog.xml文件,这个文件记录了仓库中已有的archetype信息,然后设置eclipse->maven->archetype,选择刚才生成的archetype-catalog.xml文件,这样eclipse读取到的archetype就和你的仓库同步了;

为了删除archetype,你可先将对应的文件夹删除,然后你可以修改archetype-catalog.xml或再次执行archetype:crawl重新生成新的文件;


希望能给看到的人一些帮助,少走一些弯路

猜你喜欢

转载自blog.csdn.net/qq_36691683/article/details/77620621
今日推荐