今天學習在本地搭建Maven工程時,執行了mvn archetype:generate 命令,報錯。
Unable to create project from archetype [org.apache.maven.archetypes:maven-archetype-quickstart:1.1]
Unable to add module to the current project as it is not of packaging type 'pom'
上網搜資料發現一個帖子,問題解決:
原文如下:
一開始以爲是IDE出錯了,很是着急,後來回想出錯之前的操作。就在這之前,我備份了一個pom文件,然後直接移到了workspace的根目錄下,心想是不是這個問題呢?帶着疑問,我把這個pom.xml刪掉了,然後再創建maven工程,果然不出所料,不再報錯了。
爲了確保是這個原因,後來google了一下,在國外一個論壇中碰到類似的問題,有個網友的回答摘抄如下:
Are you running the command from a directory that has an existing pom.xml file in it? I think that may be confusing Maven, as it thinks you're trying to add your new project as a sub-module of the project in the working directory.
原來是因爲我在Workspace下放了個POM文件,造成了M2eclipse插件的誤解,刪掉就OK了。