无法使用自定义创建的 Maven 原型(prototype)。
Maven 告诉我:您的过滤器不匹配任何原型(prototype)。 我的系统:
- window 7
- Java 7
- maven 3.2
我采取的步骤是:
- 创建我的项目
- 在命令提示符下导航到我的项目并运行命令:
mvn archetype:create-from-project
- Navigate to target\generated-sources\archetype and run this command:
mvn install archetype:update-local-catalog
cd back to my Projects folder and run the command
mvn archetype:generate -DarchetypeCatalog=local
Once I run that command I see:
[INFO] Scanning for projects... [INFO] [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleTreadedBuilder with a thread count of 1 [INFO] [INFO] ----------------------------------------------------- [INFO] Building restTemplate-archetype 1.0-SNAPSHOT [INFO] ----------------------------------------------------- [INFO] [INFO] >>> maven-archetype-plugin:2.3:generate (default-cli) @restTemplate-archetype >>> [INFO] <<< maven-archetype-plugin:2.3:generate (default-cli) @restTemplate-archetype <<< [INFO] [INFO] --- maven-archetype-plugin:2.3:generate (default-cli) @restTemplate-archetype --- [INFO] Generating project in Interactive mode [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0) Choose archetype: Your filter doesn't match any archetype (hint: enter to return to initial list) choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): :
However If I navigate in Eclipse to New->Project->Maven Project I go to select an archetype, navigate to my archetype-catalog.xml (located in my ~/.m2/ directory) I see my archetype ready to be used... yet if I use my "default local" it's not there?
My settings.xml folder has my local repository set to
<localRepository>~/Projects_3.7.1/.m2/repository</localRepository>
如果我尝试使用我的 archetype-catalog.xml,Eclipse 将允许我使用我的原型(prototype)……它会破坏任何 XML,但那是另一篇文章的内容。我相信如果我让 Maven 从我的自定义原型(prototype)生成我的项目,我会很好。
有什么建议吗?
最佳答案
运行额外的 mvn archetype:crawl
。
我不确定为什么需要这样做。在我的 Mac 系统上,mvn install
执行所有必需的步骤,其中还包括 update-local-catalog
作业。从 Windows 运行它似乎会导致您观察到的相同问题。这里对存储库进行额外的抓取似乎可以解决问题。根据您的 Maven 版本,寻找可能的 problems与抓取。
关于java - Maven 找不到我的自定义 Maven 原型(prototype),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30672206/