Maven创建快速入门模板 [英] Maven creating quickstart template

查看:72
本文介绍了Maven创建快速入门模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习行家.我刚刚安装了Maven.

I am learning maven. I just installed maven.

mvn -version

Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T23:07:52+05:30)
Maven home: C:\Users\gopir\Documents\MyJabberFiles\mohanasw@netapp.com\apache-maven-3.2.1-bin\apache-maven-3.2.1\bin\..
Java version: 1.7.0_71, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_71\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

我试图在的帮助下创建一个项目

I tried to create a project with the help of

 mvn -e archetype:generate -DgroupId=x:y -DartifactId=testMaven -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

我遇到以下错误

 Failed to execute goal org.apache.maven.plugins:maven-archetype-\     
 plugin:2.3:generate (default-cli) on project standalone-pom: Error merging 
 velocity templates -> [Help 1]
 he.maven.lifecycle.LifecycleExecutionException: Failed to execute goal 
 org.apache.maven.plugins:maven-archetype-plugin:2.3:generate (default-cli) 
 on project standalone-pom: Error merging velocity templa...

它是默认值吗?我应该怎么做才能获取pom.xml和其他目录?

Is it default one? What should i change to get my pom.xml and other directories?

谢谢

推荐答案

我将在此处列出我定期使用的步骤(截至今天). 您可以比较您的步骤,并查看需要更改的地方.显示了Mac/OSX的相对路径.从概念上讲,这与Windows没有什么不同.

I will list here the steps that I use on a regular basis(as of today). You can compare your steps and see where you need change. The relative paths are shown for Mac / OSX. Which isn't different, conceptually, than windows.

以下所有命令都将在终端上运行.

All of the commands in the following are to be run on terminal.

  1. cd进入工作空间,或mkdir进入项目文件夹 /Users/ProjectFolder

  1. cd into workspace or mkdir for project folder /Users/ProjectFolder

运行以下命令mvn archetype:generate -DgroupId=com.folder.name.you.like -DartifactId=NameOfProject -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

cd进入名为artifactID的文件夹,然后运行mvn eclipse:eclipse

cd into the folder named as artifactID and run mvn eclipse:eclipse

文件->导入->在Eclipse中将现有项目选择到现有项目中作为现有项目进入工作区,并提供artifactId的路径 从上面.导入成功后,请检查以确保在eclipse项目中具有pom.xml.

File->import->Select Existing Project Into Workspace the project in eclipse as existing project and give the path to the artifactId from above. Check to make sure you have the pom.xml in the eclipse project once the import succeeds.

在pom.xml中为maven编译器添加以下插件(这是针对 Java 1.8)

Add the following plugin for maven compiler in pom.xml (this is for java 1.8)

     <build>
        <plugins>
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

  1. 在eclipse中将源文件添加到项目中 从相同的当前目录运行以下命令(如#3中所示) 以上)mvn package
  1. Add source files to the project in eclipse run the following command from the same present directory (as in #3 above) mvn package

这篇关于Maven创建快速入门模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆