官方文檔:
http://maven.apache.org/index.html
http://maven.apache.org/plugins/index.html
每次重新導入項目,java1.8語法報錯,Project的Java Compiler默認為java1.5
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties>
前提是一定已經安裝了jdk1.8,並且已經在eclipse的installed jres中配置
install或deploy時報錯:Failed to execute xxx plugins : Compilation failure : No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
解決方法:maven打包需要jdk環境,而不是jre, 所以修改eclipse的java環境,將默認選項改為jdk
maven項目打包時生成dependency-reduced-pom.xml
原因是打包時使用了maven-shade-plugin插件,添加以下配置將取消生成此文件:
<configuration> <createDependencyReducedPom>false</createDependencyReducedPom> </configuration>
開發環境運行報錯:找不到或無法加載主類
執行完maven clean, 運行程序主函數會報錯提示:找不到或無法加載主類。 重新執行下maven update就可以了