Maven3 项目创建设置

New Project

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

  1. Download Eclipse IDE for Java EE Developers from http://www.eclipse.org/downloads/
  2. Unzip the contents in your root Eclipse folder.  In my case I unzipped it in c:/java/eclipse
  3. Run the ‘eclipse.exe’ in [eclipse root]/eclipse
  4. Select a workspace location for Eclipse to store your projects.  In my case I used the default location

    Maven3 项目创建设置_第1张图片

  5. Click on the ‘Workbench’ icon

    Maven3 项目创建设置_第2张图片

  6. Select Help -> Install New Software

    Maven3 项目创建设置_第3张图片

  7. Click the ‘Add…’ button
  8. Name: m2eclipse
  9. Location: http://m2eclipse.sonatype.org/sites/m2e
  10. Click ‘OK’

    Maven3 项目创建设置_第4张图片

  11. Check the ‘Maven Integration for Eclipse’ option
  12. Click ‘Next’

    Maven3 项目创建设置_第5张图片

  13. Click ‘Next >’

    Maven3 项目创建设置_第6张图片

  14. Select ‘I accept the terms of the license agreements’
  15. Click ‘Finish’

  16. Click ‘Restart Now’


    Maven3 项目创建设置_第7张图片

  17. Select Window -> Preferences

    Maven3 项目创建设置_第8张图片

  18. Add the Maven 3 location the you installed earlier

    Maven3 项目创建设置_第9张图片

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

  20. Select Maven -> Maven Project

    Maven3 项目创建设置_第10张图片

  21. Check ‘Create a simple project (skip archetype selection)’
  22. Click ‘Next >’

    Maven3 项目创建设置_第11张图片

  23. Enter Project Information
    1. 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’.
    2. 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’.
    3. The version can remain 0.0.1-SNAPSHOT
    4. Select the packaging that you desire
    5. 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
    6. Enter a Description. This is used in the documentation
    7. Click ‘Next >’

  24. 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’)

    Maven3 项目创建设置_第12张图片

  25. 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

    Maven3 项目创建设置_第13张图片
    Maven’s default package structure:
    Maven3 项目创建设置_第14张图片

  26. Open the pom.xml file.
  27. Add the compiler plugin so you can configure your JDK version. Search for the maven-compiler-plugin.

  28. For this example set the JDK version to 1.6

    Maven3 项目创建设置_第15张图片

    <configuration> 
    	<source>1.6</source> 
    	<target>1.6</target> 
    </configuration>
  29. Run ‘Maven install’ to verify that the project and environment is setup correctly

  30. The build was successful

    Maven3 项目创建设置_第16张图片


























maven需要的jar下载

你可能感兴趣的:(Maven3 项目创建设置)