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)配置文件
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"><!-- localRepository //本地仓库|The path to the local repository maven will use to store artifacts.||Default: ${user.home}/.m2/repository //默认配置位置<localRepository>/path/to/local/repo</localRepository>--><localRepository>E:/mavenRepository</localRepository> //配置本地仓库,增加这一行
在eclipse下指定settings.xml文件.
说明:maven的目录结构
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 ...
此时可以在控制台看到结果:
[INFO]Scanningfor projects...[INFO][INFO]------------------------------------------------------------------------[INFO]Building maven-011.0-SNAPSHOT[INFO]------------------------------------------------------------------------[INFO]Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom[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)[INFO]Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/22/maven-plugins-22.pom[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)[INFO][INFO]--- maven-clean-plugin:2.5:clean (default-clean)@ maven-01---[INFO]Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.pom[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)[INFO]Downloading: https://repo.maven.apache.org/maven2/org/sonatype/spice/spice-parent/16/spice-parent-16.pom[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)[INFO]Downloading: https://repo.maven.apache.org/maven2/org/sonatype/forge/forge-parent/5/forge-parent-5.pom[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)[INFO]Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.jar[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)[INFO]Deleting F:\mavenDemo\train\maven-01\target[INFO][INFO]--- maven-resources-plugin:2.6:resources (default-resources)@ maven-01---[INFO]Using'UTF-8' encoding to copy filtered resources.[INFO] skip non existing resourceDirectory F:\mavenDemo\train\maven-01\src\main\resources[INFO][INFO]--- maven-compiler-plugin:3.1:compile (default-compile)@ maven-01---[INFO]Changes detected - recompiling the module![INFO]Compiling1 source file to F:\mavenDemo\train\maven-01\target\classes[INFO]------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO]------------------------------------------------------------------------[INFO]Total time:8.688 s[INFO]Finished at:2016-05-13T15:10:48+08:00[INFO]FinalMemory:13M/159M[INFO]------------------------------------------------------------------------



浙公网安备 33010602011771号