1.调试工程的时候,有时候要追踪源码文件
使用maven命令:mvn dependency:sources下载依赖包的源代码。
或者
mvn dependency:sources -DdownloadSources=true -DdownloadJavadocs=true
或者
eclipse窗口->首选项->maven->勾选download artifact sources
还有一种应该也行:
org.apache.maven.plugins
maven-eclipse-plugin
2.9
true
true
网站原文
Artifacts with sources deployed can be attached to Eclipse libraries using downloadSources. Javadocs may be attached using downloadJavadocs The sources and javadocs of the librariesmust exist in the repository so that the plugin can download it and attach it.
2.编译打jar包时要把源码也打包增加如下配置
maven-source-plugin
2.1
true
compile
jar
3.列出jar包依赖关系
mvn dependency:tree > dep.log
4.解决资源文件编码问题
org.apache.maven.plugins
maven-resources-plugin
2.3
UTF-8
5.拷贝依赖的jar到lib目录下
org.apache.maven.plugins
maven-jar-plugin
true
lib/
com.test.MonitorMain
org.apache.maven.plugins
maven-dependency-plugin
copy
package
copy-dependencies
${project.build.directory}/lib
6.根据不同环境采用不同设置,通过实现,配置在外
develop
true
jdbc:oracle:thin:@127.0.0.1:1521:ORCL
product
jdbc:oracle:thin:@228.7.75.102:1521:ORCL
同时配置
org.apache.maven.plugins
maven-resources-plugin
2.3
UTF-8
src/main/resources
true
同时配置src/main/resources/db.properties
jdbc.url=${jdbc.url}
编译时制定参数:
测试环境直接 mvn clean package -Dmaven.test.skip=true 因为中设置默认采用测试环境配置
正式环境 mvn clean package -Dmaven.test.skip=true -Pproduct
7.mavn 制定编译器版本和字符编码
UTF-8
1.6
1.6
或者
src/main/java org.apache.maven.plugins maven-compiler-plugin lib 1.6 1.6 UTF-8