02-eclipse下集成maven项目

1:eclipse下maven环境配置

打开eclipse(eclipse 4以上已经集成maven插件) => Window =>Preferences => maven
1)maven安装路径配置 Installations :
2)配置 User Settings :打开settings.xml(E:\apache-maven-3.3.3\conf)配置文件
   
  1. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  4. <!-- localRepository //本地仓库
  5. |The path to the local repository maven will use to store artifacts.
  6. |
  7. |Default: ${user.home}/.m2/repository //默认配置位置
  8. <localRepository>/path/to/local/repo</localRepository>
  9. -->
  10. <localRepository>E:/mavenRepository</localRepository> //配置本地仓库,增加这一行
在eclipse下指定settings.xml文件.
 
说明:maven的目录结构
maven.PNG

2.eclipse下导入和创建maven项目
导入maven项目:
导入01-Maven课程创建的maven-01或者maven-02项目:
File => Import => Maven => Existing Maven Projects  => 选择maven项目
配置eclipse下项目的环境变量:
右击导入的项目 => Properties => Java Complier =>JDK Compliance 去掉打勾选择1.7 => 点击Java Build Path => Remove掉J2SE-1.5 =>
点击Add Library => 选择JRE System Library =>Finish => Yes
 
创建maven项目:
File => New => Other => Maven => Maven Project => 选择项目保存的位置 => 选择使用哪种方式创建maven项目 (这里选择quickstart) =>
填写组织名称,项目名称,版本号,包路径
 
3.eclipse下maven命令的使用
右击导入的项目 => Run As => 选择需要执行的maven命令
选择Maven build ...
maven.PNG
 
此时可以在控制台看到结果:
  1. [INFO]Scanningfor projects...
  2. [INFO]
  3. [INFO]------------------------------------------------------------------------
  4. [INFO]Building maven-011.0-SNAPSHOT
  5. [INFO]------------------------------------------------------------------------
  6. [INFO]Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
  7. [INFO]Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom (4 KB at 2.1 KB/sec)
  8. [INFO]Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/22/maven-plugins-22.pom
  9. [INFO]Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/22/maven-plugins-22.pom(13 KB at 14.9 KB/sec)
  10. [INFO]
  11. [INFO]--- maven-clean-plugin:2.5:clean (default-clean)@ maven-01---
  12. [INFO]Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.pom
  13. [INFO]Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.pom (4 KB at 6.9 KB/sec)
  14. [INFO]Downloading: https://repo.maven.apache.org/maven2/org/sonatype/spice/spice-parent/16/spice-parent-16.pom
  15. [INFO]Downloaded: https://repo.maven.apache.org/maven2/org/sonatype/spice/spice-parent/16/spice-parent-16.pom(9 KB at 14.3 KB/sec)
  16. [INFO]Downloading: https://repo.maven.apache.org/maven2/org/sonatype/forge/forge-parent/5/forge-parent-5.pom
  17. [INFO]Downloaded: https://repo.maven.apache.org/maven2/org/sonatype/forge/forge-parent/5/forge-parent-5.pom(9 KB at 14.2 KB/sec)
  18. [INFO]Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.jar
  19. [INFO]Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.jar (221 KB at 95.9 KB/sec)
  20. [INFO]Deleting F:\mavenDemo\train\maven-01\target
  21. [INFO]
  22. [INFO]--- maven-resources-plugin:2.6:resources (default-resources)@ maven-01---
  23. [INFO]Using'UTF-8' encoding to copy filtered resources.
  24. [INFO] skip non existing resourceDirectory F:\mavenDemo\train\maven-01\src\main\resources
  25. [INFO]
  26. [INFO]--- maven-compiler-plugin:3.1:compile (default-compile)@ maven-01---
  27. [INFO]Changes detected - recompiling the module!
  28. [INFO]Compiling1 source file to F:\mavenDemo\train\maven-01\target\classes
  29. [INFO]------------------------------------------------------------------------
  30. [INFO] BUILD SUCCESS
  31. [INFO]------------------------------------------------------------------------
  32. [INFO]Total time:8.688 s
  33. [INFO]Finished at:2016-05-13T15:10:48+08:00
  34. [INFO]FinalMemory:13M/159M
  35. [INFO]------------------------------------------------------------------------
 





posted @ 2016-05-20 11:27  iMinority  阅读(208)  评论(0)    收藏  举报