Maven常用配置或命令
程序员文章站
2022-07-12 21:48:58
...
Maven插件列表
https://maven.apache.org/plugins/index.html
只是更新或解析项目的依赖, only update dependencies
mvn dependency:resolve
If you just want to re-load/update dependencies (I assume, with constantly changing you mean either SNAPSHOTS or local dependencies you update yourself), you can use mvn dependency:resolve
命令行下指定User Level的settings.xml文件
mvn -s d:\path\settings.xml jetty:run
查看maven使用的global and User settings.xml位置
http://*.com/questions/9988814/how-do-i-find-out-which-settings-xml-file-maven-is-using
不过好像只有maven 3.0开始才有用,Maven version 2.2.1好像就不行
Start maven with -X option (debug) and examine the beginning of the output. There should be something like this:
...
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from c:\....\apache-maven-3.0.3\conf\settings.xml
[DEBUG] Reading user settings from c:\....\.m2\settings.xml
[DEBUG] Using local repository at C:\....\repository
...
maven系统属性和环境变量属性
mvn help:system
命令可以显示所有系统属性和环境变量属性
指定当前project的maven编译时用的java编译器版本和字符集编码
http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> <source>1.7</source> <target>1.7</target> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build>
为什么project的maven依赖不正确,指向过时的依赖?
原因很有可能是你根本没有mvn install过,或者说没有使用maven构建过项目,而只是创建了一个maven项目,修改了pom.xml里的依赖,然后update project,这样其实maven是不能保证指向正确的依赖包的,必须编译一次