您的位置:首页 > 其它

Maven3 项目创建设置

2015-12-27 23:21 239 查看


New Project

For this example I will be using Eclipse for my IDE.

Download Eclipse IDE for Java EE Developers from http://www.eclipse.org/downloads/

Unzip the contents in your root Eclipse folder. In my case I unzipped it in c:/java/eclipse

Run the ‘eclipse.exe’ in [eclipse root]/eclipse

Select a workspace location for Eclipse to store your projects. In my case I used the default location



Click on the ‘Workbench’ icon



Select Help -> Install New Software



Click the ‘Add…’ button

Name: m2eclipse

Location: http://m2eclipse.sonatype.org/sites/m2e

Click ‘OK’



Check the ‘Maven Integration for Eclipse’ option

Click ‘Next’



Click ‘Next >’



Select ‘I accept the terms of the license agreements’

Click ‘Finish’



Click ‘Restart Now’





Select Window -> Preferences



Add the Maven 3 location the you installed earlier



Create a new Maven project by selecting File -> New -> Other…



Select Maven -> Maven Project



Check ‘Create a simple project (skip archetype selection)’

Click ‘Next >’



Enter Project Information

Enter Group Id. This is the domain where the project is hosted. For example if the ‘Awesome’ project was hosted at GitHub then the Group Id would be ‘com.github.awesome’.

Enter Artifact Id. This is the name of the resulting artifact. For example if Artifact Id is ‘awesome’ and the packaging is JAR the artifact will be named ‘awesome.jar’.

The version can remain 0.0.1-SNAPSHOT

Select the packaging that you desire

Enter a Name. This name will show up in the console when you run Maven. This will also show up in the documentation that Maven generates

Enter a Description. This is used in the documentation

Click ‘Next >’



Add a dependency on JUnit. One of the best features of m2eclipse plugin is the ability to search for available dependencies. (This feature does not work if you configure ‘M3_HOME’ instead of ‘M2_HOME’)



Click ‘Finish’

src – source and resource files

target – compiled files, reports and generated artifacts

main – application/library files

test – test files

java – java files

resources – non java files like XML



Maven’s default package structure:



Open the pom.xml file.

Add the compiler plugin so you can configure your JDK version. Search for the maven-compiler-plugin.



For this example set the JDK version to 1.6



<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>

Run ‘Maven install’ to verify that the project and environment is setup correctly



The build was successful



maven需要的jar下载
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: