目录 |
目的 |
${basedir} |
存放 pom.xml和所有的子目录 |
${basedir}/src/main/java |
项目的 java源代码 |
${basedir}/src/main/resources |
项目的资源,比如说 property文件 |
${basedir}/src/test/java |
项目的测试类,比如说 JUnit代码 |
${basedir}/src/test/resources |
测试使用的资源 |
1
2
3
4
5
6
7
8
9
10
11
12
13
|
mvn archetype:create 创建Maven项目
mvn compile 编译源代码
mvn deploy 发布项目
mvntest-compile 编译测试源代码
mvntest运行应用程序中的单元测试
mvn site 生成项目相关信息的网站
mvn clean 清除项目目录中的生成结果
mvn package 根据项目生成的jar
mvninstall在本地Repository中安装jar
mvn eclipse:eclipse 生成eclipse项目文件
mvnjetty:run 启动jetty服务
mvntomcat:run 启动tomcat服务
mvn clean package -Dmaven.
test
.skip=
true
:清除以前的包后重新打包,跳过测试类
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
~
pwd
/Users/lion/
~ brew cask search java
==> Removing legacy Tap
==> Adding caskroom Tap
Cloning into
'/usr/local/Library/Taps/caskroom/homebrew-cask'
...
remote: Counting objects: 51450,
done
.
remote: Compressing objects: 100% (64
/64
),
done
.
remote: Total 51450 (delta 37), reused 5 (delta 2)
Receiving objects: 100% (51450
/51450
), 16.61 MiB | 26.00 KiB
/s
,
done
.
Resolving deltas: 100% (31783
/31783
),
done
.
Checking connectivity...
done
.
Tapped 1 formula
==> We need tomakeCaskroomforthe firsttimeat
/opt/homebrew-cask/Caskroom
==> We
'll set permissions properly so we won'
t needsudointhe future
Password:
==> Exact match
java
==> Partial matches
eclipse-java javafx-scene-builder
~ brew cask info java
java: 1.8.0_20
http:
//www
.oracle.com
/technetwork/java/javase/downloads/jdk8-downloads-2133151
.html
/opt/homebrew-cask/Caskroom/java/1
.8.0_20 (2 files, 210M)
https:
//github
.com
/caskroom/homebrew-cask/blob/master/Casks/eclipse-java
.rb
==> Contents
JDK 8 Update 20.pkg (
install
)
==> Caveats
This Cask makes minor modifications to the JRE to prevent issues with
packaged applications, as discussed here:
https:
//bugs
.eclipse.org
/bugs/show_bug
.cgi?
id
=411361
If your Java application still asksforJRE installation, you might need
to reboot orlogout
/login
.
Installing this Cask means you have AGREED to the Oracle Binary Code
License AgreementforJava SE at
http:
//www
.oracle.com
/technetwork/java/javase/terms/license/index
.html
~ brew caskinstalljava
==> Caveats
This Cask makes minor modifications to the JRE to prevent issues with
packaged applications, as discussed here:
https:
//bugs
.eclipse.org
/bugs/show_bug
.cgi?
id
=411361
If your Java application still asksforJRE installation, you might need
to reboot orlogout
/login
.
Installing this Cask means you have AGREED to the Oracle Binary Code
License AgreementforJava SE at
http:
//www
.oracle.com
/technetwork/java/javase/terms/license/index
.html
==> Downloading http:
//download
.oracle.com
/otn-pub/java/jdk/8u20-b26/jdk-8u20-ma
######################################################################## 100.0%
==> Running installerforjava; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
Password:
==> installer: Package name is JDK 8 Update 20
==> installer: Installing at base path /
==> installer: Theinstallwas successful.
java installed to
'/opt/homebrew-cask/Caskroom/java/1.8.0_20'
(2 files, 210M)
~ java -version
java version
"1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
~ brew info maven
maven: stable 3.2.3
http:
//maven
.apache.org/
Not installed
From: https:
//github
.com
/Homebrew/homebrew/blob/master/Library/Formula/maven
.rb
~ brewinstallmaven
==> Downloading http:
//www
.apache.org
/dyn/closer
.cgi?path=maven
/maven-3/3
.2.3
/bi
==> Best Mirror http:
//mirrors
.cnnic.cn
/apache/maven/maven-3/3
.2.3
/binaries/apac
######################################################################## 100.0%
/usr/local/Cellar/maven/3
.2.3: 76 files, 8.0M, builtin4 seconds
~ whichmvn && mvn --version
/usr/local/bin/mvn
Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-12T04:58:10+08:00)
Maven home:
/usr/local/Cellar/maven/3
.2.3
/libexec
Java version: 1.8.0_20, vendor: Oracle Corporation
Java home:
/Library/Java/JavaVirtualMachines/jdk1
.8.0_20.jdk
/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name:
"mac os x"
, version:
"10.9"
, arch:
"x86_64"
, family:
"mac"
|
1
2
|
~
mkdir
/Users/lion/Documents/_my_soft/mavenrepo
~
vi
/usr/local/Cellar/maven/3
.2.3
/libexec/conf/settings
.xml
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<?xmlversion=
"1.0"
encoding=
"UTF-8"
?>
<settingsxmlns=
"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"
>
<!-- 设置Maven仓库的存放位置 -->
<localRepository>
/Users/lion/Documents/_my_soft/mavenrepo
<
/localRepository
>
<pluginGroups>
<
/pluginGroups
>
<proxies>
<
/proxies
>
<servers>
<
/servers
>
<mirrors>
<
/mirrors
>
<profiles>
<
/profiles
>
<
/settings
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
~ brew cask search eclipse
==> Partial matches
eclipse-ide eclipse-jee nodeclipse
eclipse-java eclipse-platform
~ brew cask info eclipse-ide
eclipse-ide: 4.4.0
http:
//eclipse
.org/
Not installed
https:
//github
.com
/caskroom/homebrew-cask/blob/master/Casks/eclipse-ide
.rb
==> Contents
eclipse
/Eclipse
.app (link)
~ brew caskinstalleclipse-ide
==> Downloading http:
//download
.eclipse.org
/technology/epp/downloads/release/lun
######################################################################## 100.0%
##可以看到Eclipse被安装到了目录/Users/lion/Applications/下面
==> Symlinking App
'Eclipse.app'
to
'/Users/lion/Applications/Eclipse.app'
eclipse-ide installed to
'/opt/homebrew-cask/Caskroom/eclipse-ide/4.4.0'
(1461 files, 227M)
|
#在浏览器打开:http://www.eclipse.org/m2e/download/,然后同时将install的图标拖动到Eclipse Marketplace中,会弹出一个窗口,点击Confirm,后面就继续下一步,就完成了在线安装的过程。如下图:
#安装完后,会提示让你重启Eclipse,重启后进入初始页面会发现如下变化,同时点击左上角菜单栏的Eclipse->Preferences,也可以看到我们现在有了Maven配置项,如下图:
4.7、修改Eclipse4.4的Maven配置
#配置Eclipse使用我们刚刚安装的Maven,在菜单栏点击Window->Preferences,打开参数配置窗口,点击Mavek->Installations,然后点击右侧的Add,添加我们刚才安装的Maven路径,如下图:
#让Eclipse的Maven插件使用我们自定义的setting.xml文件,在菜单栏点击Window->Preferences,打开参数配置窗口,点击Mavek->User Settings,然后在Global Settings和User Settings中输入:/usr/local/Cellar/maven/3.2.3/libexec/conf/settings.xml,如下图:
4.6、用Maven创建一个Hello World
参考文章《maven3.2.3+eclipse4.4+JDK1.8+win8.1_64bit环境搭建》,demo可以复用。
4.7、用Maven创建项目的pom.xml简单介绍
参考文章《maven3.2.3+eclipse4.4+JDK1.8+win8.1_64bit环境搭建》,demo可以复用。
4.8、使用Eclipse打开Maven创建的项目,在控制台输出Hello World
参考文章《maven3.2.3+eclipse4.4+JDK1.8+win8.1_64bit环境搭建》,demo可以复用。
5、扩展阅读
Maven3常用POM属性及Settings属性介绍:http://blog.csdn.net/lgm277531070/article/details/6922645
Maven Settings:http://maven.apache.org/ref/3.2.3/maven-settings/settings.html
Maven pom.xml 配置详解:http://blog.csdn.net/ithomer/article/details/9332071
POM Reference:http://maven.apache.org/pom.html