使用maven构建和打包项目、使用私有仓库Nexus中遇到的问题和解决方案

官方文档:

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就可以了

 

原文地址:https://www.cnblogs.com/feng-gamer/p/13048679.html