Maven-如何从原型创建项目

时间:2020-03-05 08:19:57

标签: java maven mvn-repo

我是Maven的新手,我必须从原型archetype-2jse-simple-1.1.1创建项目,我将其保存在本地目录中。您能帮我在终端中使用哪些控制台命令。我只知道我必须使用mvn archetype:generate。我尝试了几次,但我不知道我的本地原型是否运行。

1 个答案:

答案 0 :(得分:2)

在Maven中,使用archetype:generate时,您可以指定用于生成Maven主题的原型。

mvn archetype:generate -DarchetypeGroupId=<archetype group id> -DarchetypeArtifactId=<archetype artifactid> -DarchetypeVersion=<archetype version>

例如,如果原型的groupId为cz.swigroup,原型artifactId为archetype-2jse-simple,版本为1.1.1,则命令为。

mvn archetype:generate -DarchetypeGroupId=cz.swigroup -DarchetypeArtifactId=archetype-2jse-simple -DarchetypeVersion=1.1.1

更新

由于工件不是来自中央存储库,而是来自https://artifactory.cs.vsb.cz/libs-release-local/,因此您必须在~/.m2/settings.xml中添加存储库

<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">

    <profiles>
        <profile>
            <id>maven-repositories</id>
            <repositories>
                <repository>
                    <id>artifactory.cs.vsb.cz</id>
                    <name>artifactory.cs.vsb.cz</name>
                    <url>https://artifactory.cs.vsb.cz/libs-release-local/</url>
                </repository>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>maven-repositories</activeProfile>
    </activeProfiles>
</settings>
相关问题