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

1. Problem description

The company wants to migrate the existing code to the Yundao platform. The dependency package in the previous pure javaWeb project needs to be changed to a maven warehouse. In terms of code modification, except for the addition of the pom.xml file, there is not much change, but the war is built. In the file, a lot of errors of missing dependent packages were prompted. After adding one by one, the error was finally reported
Insert picture description here

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project httpjsoncuvdb: Compilation failure: Compilation failure:
[ERROR] /data/jenkins-new/workspace/httpjsoncuvdb_0.0.1_build-Mamy7_4863/src/main/java/com/tydic/odsb/httpjson/ResourceServiceImpl.java:[102,48] cannot access javax.xml.rpc.Service
[ERROR] class file for javax.xml.rpc.Service not found
[ERROR] /data/jenkins-new/workspace/httpjsoncuvdb_0.0.1_build-Mamy7_4863/src/main/java/com/tydic/odsb/httpjson/ResourceServiceImpl.java:[103,29] cannot access javax.xml.rpc.Call
[ERROR] class file for javax.xml.rpc.Call not found
[ERROR] -> [Help 1]
[ERROR]

I checked it on the Internet, and many posts said it was caused by the inconsistency between the jdk set by maven and the jdk version required by the project. You need to match the two versions.

<!-- 这种设置方式 -->
	<properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
<!-- 或者这种方式 -->
<build>
       <plugins>
           <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
                    <!-- <version>3.7.0</version> -->  
                    <configuration>
                  <source>1.8</source>
                  <target>1.8</target>
                  <encoding>utf-8</encoding>
              </configuration>
           </plugin>
       </plugins>
    </build>
<!-- 再或者直接设置maven的settings.xml文件 -->
<!-- 配置方式请自行百度 设置maven的jdk版本 -->

After I set it up, the same error was reported. Later, I carefully checked the log and found that there were two more errors before reporting this error.
Insert picture description here
I began to think it was the error of maven-compiler-plugin that caused the cannot access javax.xml.rpc. Service
class file for javax.xml.rpc.Service not found

Later, I thought it might be the source of the error, so I checked it and
said that the jaxrpc.jar in the Axis package was missing
and the dependency was added and executed again. The problem was solved.
Insert picture description here

		<dependency>
            <groupId>org.apache.axis</groupId>
            <artifactId>axis-jaxrpc</artifactId>
            <version>1.4</version>
        </dependency>

Two, my pom file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>httpjsoncuvdb</artifactId>
    <version>1.0-SNAPSHOT</version>
    
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.2.14.jre7</version>
        </dependency>

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.62</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
            <version>2.3.35</version>
        </dependency>

        <dependency>
            <groupId>org.apache.struts.xwork</groupId>
            <artifactId>xwork-core</artifactId>
            <version>2.3.35</version>
        </dependency>
        
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>2.5.1</version>
        </dependency>
        
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>2.5.1</version>
        </dependency>
        
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>2.5.1</version>
        </dependency>
        
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>2.5.1</version>
        </dependency>
        
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.5.8</version>
        </dependency>

        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.2.2</version>
            <classifier>jdk15</classifier>
        </dependency>

        
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.3.2</version>
        </dependency>
        
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
            <version>4.0</version>
        </dependency>
        
    
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.5</version>
            <scope>compile</scope>
        </dependency>
        
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.orm</artifactId>
            <version>2.5.6</version>
        </dependency>
        
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
        </dependency>
        
        <dependency>
            <groupId>axis</groupId>
            <artifactId>axis</artifactId>
            <version>1.2</version>
        </dependency>
        
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
        </dependency>
        
    
        <dependency>
            <groupId>org.apache.axis</groupId>
            <artifactId>axis-jaxrpc</artifactId>
            <version>1.4</version>
        </dependency>


    </dependencies>
    
    
<build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>

        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-war-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
</build>
    
</project>

Three, talk to yourself

When encountering similar problems, if the code is okay (it ran through locally before the migration), it is necessary to focus on the problem of dependent packages. Inconsistent versions or lack of dependent packages are common reasons for errors.

Guess you like

Origin blog.csdn.net/zhuyin6553/article/details/109109481