Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile...

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.springcloud:eureka:jar:1.0.0
[WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ line 42, column 21
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.springcloud:service-a:jar:1.0.0
[WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ line 65, column 21
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.springcloud:service-b:jar:1.0.0
[WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ line 65, column 21
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] my-spring-cloud                                                    [pom]
[INFO] common                                                             [jar]
[INFO] eureka                                                             [jar]
[INFO] service-a                                                          [jar]
[INFO] service-b                                                          [jar]
[INFO] 
[INFO] ------------------< com.springcloud:my-spring-cloud >-------------------
[INFO] Building my-spring-cloud 1.0.0                                     [1/5]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ my-spring-cloud ---
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ my-spring-cloud ---
[INFO] Installing /var/jenkins_home/workspace/spring-cloud@2/pom.xml to /root/.m2/repository/com/springcloud/my-spring-cloud/1.0.0/my-spring-cloud-1.0.0.pom
[INFO] 
[INFO] -----------------------< com.springcloud:common >-----------------------
[INFO] Building common 1.0.0                                              [2/5]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ common ---
[INFO] Deleting /var/jenkins_home/workspace/spring-cloud@2/common/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ common ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/jenkins_home/workspace/spring-cloud@2/common/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ common ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 10 source files to /var/jenkins_home/workspace/spring-cloud@2/common/target/classes
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by lombok.javac.apt.LombokProcessor to field com.sun.tools.javac.processing.JavacProcessingEnvironment.processorClassLoader
WARNING: Please consider reporting this to the maintainers of lombok.javac.apt.LombokProcessor
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for my-spring-cloud 1.0.0:
[INFO] 
[INFO] my-spring-cloud .................................... SUCCESS [  0.700 s]
[INFO] common ............................................. FAILURE [  5.555 s]
[INFO] eureka ............................................. SKIPPED
[INFO] service-a .......................................... SKIPPED
[INFO] service-b .......................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.286 s
[INFO] Finished at: 2019-07-27T14:17:05Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project common: Fatal error compiling: java.lang.ExceptionInInitializerError: com.sun.tools.javac.code.TypeTags -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :common

问题描述:
spring-cloud 项目,本地运行打包都很正常没有问题,然后换 Jenkins 持续集成时,maven 打包报错

产生原因:
主要原因就是 maven 的环境与你配置的环境不吻合,下面是 pom 中的配置

<build>
    <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.8</source>
             <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>


可以看到 pom 中配的是本地 3.5.1,而服务器的则是 3.6.0 所以报错了

解决方法:
把 pom 中配置的环境改为与服务器中的环境一致,所以本地,测试,生产环境尽可能保持一致能少不少问题

<build>
    <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.0</version>
            <configuration>
                <source>1.8</source>
             <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

 

 

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页