无法在项目 fhirql 上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile):致命

Posted

技术标签:

【中文标题】无法在项目 fhirql 上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile):致命错误编译【英文标题】:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project fhirql: Fatal error compiling 【发布时间】:2020-07-29 07:00:49 【问题描述】:

我运行命令 mvn clean package 我得到上面的错误我的 pom 是:

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<parent>
    <groupId>ca.uhn.hapi.fhir</groupId>
    <artifactId>hapi-fhir</artifactId>
    <version>3.2.0</version>
</parent>

<groupId>com.canehealth</groupId>
<artifactId>fhirql</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<properties>
    <maven.compiler.target>1.11</maven.compiler.target>
    <maven.compiler.source>1.11</maven.compiler.source>
    <maven.build.timestamp.format>EEE, MMM dd yyyy, HH:mm Z</maven.build.timestamp.format>
</properties>

<dependencies>
    <!-- Compile -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jersey</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-spring-boot-starter</artifactId>
        <version>$project.parent.version</version>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-jpaserver-base</artifactId>
        <version>$project.parent.version</version>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-jaxrsserver-base</artifactId>
        <version>$project.parent.version</version>
    </dependency>

    <!--<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>-->

    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt</artifactId>
        <version>0.9.1</version>
    </dependency>

    <!-- Added -->
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-client</artifactId>
        <version>$project.parent.version</version>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-structures-dstu3</artifactId>
        <version>$project.parent.version</version>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-testpage-overlay</artifactId>
        <version>$project.parent.version</version>
        <type>war</type>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-testpage-overlay</artifactId>
        <version>$project.parent.version</version>
        <classifier>classes</classifier>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>
    <!-- Optional -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
    <!-- Test -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-spring-boot-autoconfigure</artifactId>
        <version>$project.parent.version</version>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-base</artifactId>
        <version>$project.parent.version</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.2.6.RELEASE</version>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <overlays>
                    <overlay>
                        <groupId>ca.uhn.hapi.fhir</groupId>
                        <artifactId>hapi-fhir-testpage-overlay</artifactId>
                    </overlay>
                </overlays>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.11</source>
                <target>1.11</target>
            </configuration>
        </plugin>
    </plugins>
</build>

【问题讨论】:

移除编译器插件。并使用 11 作为 java 版本。 另外去掉 maven-war-plugin 没有意义在 jar 包装类型内创建战争... 【参考方案1】:

由于您没有粘贴完整的错误,我相信您可能遇到了以下错误

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project demo: Fatal error compiling: error: invalid target release: 1.11 -

对于 maven 编译器,正确的 JDK 版本是 1.81.91.101112 ..

你也可以简单地将上面的&lt;properties&gt;标签替换为下面

    <properties>
    <java.version>11</java.version>
   </properties>

我从 Spring Initializr 的一个示例项目中获取了上述一个。 您也可以从 maven 编译器插件中删除配置。

【讨论】:

我试过但同样的错误..你能试一试吗? filebin.net/w1qz6i8jsnqrtv41【参考方案2】:

我遇到了同样的问题,将版本 11 更改为 1.8 后它对我有用,

替换

<properties>
   <java.version>11</java.version>
  </properties>

<properties>
   <java.version>1.8</java.version>
  </properties>

【讨论】:

【参考方案3】:

您可以将maven.compiler.target 版本从1.11 更改为11

<properties>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <maven.compiler.release>11</maven.compiler.release>
</properties>

【讨论】:

以上是关于无法在项目 fhirql 上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile):致命的主要内容,如果未能解决你的问题,请参考以下文章

无法执行目标org.apache.maven.plugins:maven-deploy-plugin:2.7:在项目上部署default-deploy

无法在项目 mavenproject2 上执行目标 org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (默认):

无法在项目上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-testCompile)

Maven 构建编译错误:无法在项目 Maven 上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-c

无法在项目上执行目标 org.apache.maven.plugins:maven-compiler-plugin (default-compile):致命错误编译:未找到 tools.jar

无法在项目 jraft 上执行目标 org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli):没有治