1, 下载maven 官方网站:http://maven.apache.org
2,5分钟速成:
英文版: http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
中文版:http://yjhexy.iteye.com/admin/blogs/443453
3,详细信息:http://maven.apache.org/guides/getting-started/index.html
4, 查找依赖:http://mvnrepository.com/
maven eclipse:eclipse的时候可以加上参数:-DdownloadSources=true
来下载包括可运行JAR包,源代码和JAVA文档。
如果是eclipse的wtp插件开发的话:mvn -Dwtpversion=2.0 eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
有的时候发现搜索出来的内容如下图:
发现会有JDK13,和JDK15的区别,这个时候如果不指定JDK版本的话将导致引用依赖失败:
所以POM文件会类似以下定义
4.0.0 com.yajun jsonDemo jar 1.0-SNAPSHOT jsonDemo http://maven.apache.org junit junit 3.8.1 test net.sf.json-lib json-lib 2.1 compile jdk15
5,mvn install的时候需要一起打包sources,需要添加:
运行:
Run "mvn -DperformRelease=true clean install"
后面如果再导入 eclipse 之前需要把eclipse生成的target 先删掉才可以。
5,最后我常用的命令:
用maven自动生成构建: mvn archetype:generate
用我指定的构建:mvn archetype:create -DgroupId=com.yajun.babyStore -DartifactId=babyStore.web -DarchetypeArtifactId=maven-archetype-webapp
打包我的应用:mvn package -DskipTests=true
6,编译的时候需要制定JDK1.5 来编译,则需要在build中加上如下plugin
mvn install:install-file -DgroupId=org.bamboo.springx -DartifactId=springx -Dversion=1.2.2 -Dpackaging=jar -Dclassifier=sources -Dfile=/path/to/file