无法使用Java高于1.8的maven编译器插件进行编译
我有一个基于NetBeans maven的项目,我想从Java1.8切换到12,但我无法编译它 经过多次尝试,我决定从头开始,创建一个非常简单的项目,以了解如何进行此更改 嗯,我已经试过了,但我也不能编译这个简单的项目 有人能解释一下我做错了什么吗 序言 NetBeans:10.0 JAVA\u HOME:C:\Program Files\JAVA\jdk-12(我也试过9、10、11) 马文: 项目创建无法使用Java高于1.8的maven编译器插件进行编译,java,maven,java-8,maven-plugin,maven-compiler-plugin,Java,Maven,Java 8,Maven Plugin,Maven Compiler Plugin,我有一个基于NetBeans maven的项目,我想从Java1.8切换到12,但我无法编译它 经过多次尝试,我决定从头开始,创建一个非常简单的项目,以了解如何进行此更改 嗯,我已经试过了,但我也不能编译这个简单的项目 有人能解释一下我做错了什么吗 序言 NetBeans:10.0 JAVA\u HOME:C:\Program Files\JAVA\jdk-12(我也试过9、10、11) 马文: 项目创建 使用窗口创建项目(第一个TopComponent) 我将JDK版本从11(NetBea
<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>
<parent>
<groupId>it.prj</groupId>
<artifactId>Project-parent</artifactId>
<version>2.9</version>
</parent>
<artifactId>Project-source</artifactId>
<packaging>nbm</packaging>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<useOSGiDependencies>true</useOSGiDependencies>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<useDefaultManifestFile>true</useDefaultManifestFile>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-api-annotations-common</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-windows</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util-ui</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util-lookup</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-awt</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-modules-settings</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
<type>jar</type>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
建筑项目资料来源2.9
---maven clean插件:2.5:clean(默认清洁)@Project source------ maven-resources-plugin:3.1.0:resources (default-resources) @ Project-source ---
Using 'UTF-8' encoding to copy filtered resources.
Copying 1 resource
--- maven-compiler-plugin:3.8.0:compile (default-compile) @ Project-source ---
Changes detected - recompiling the module!
Compiling 1 source file to D:\Project\Project-source\target\classes
--- nbm-maven-plugin:4.1:manifest (default-manifest) @ Project-source ---
NBM Plugin generates manifest
Adding OSGi bundle dependency - javax.annotation:javax.annotation-api
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:nbm-maven-plugin:4.1:manifest (default-manifest) on project Project-source:
Execution default-manifest of goal org.codehaus.mojo:nbm-maven-plugin:4.1:manifest failed.: IllegalArgumentException
编辑
在您的示例中,nbm maven插件失败,但编译过程正常
暂时从您的构建中删除
nbm-maven插件
,看看maven是否可以在没有它的情况下构建。也许您可以完全跳过此插件,因为它似乎只针对NetBeans IDE。请使用如下4.2版本:
<groupId>org.apache.netbeans.utilities</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<version>4.2</version>
org.apache.netbeans.utilities
nbm maven插件
4.2
替换对以下内容的任何引用:
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
org.codehaus.mojo
nbm maven插件
jdk>8生成的jar文件无法被旧版本的插件解析。
nbm maven插件
失败,编译失败。暂时从您的构建中删除nbm maven plugin
,看看它是否有效。是的,删除构建中的插件;新的问题是,行“nbm”不再被识别,如果删除它,project将无法工作nbm maven plugin
似乎不再维护,根据,它可能无法与最新的Java版本一起工作,除非有人在维护它。
--- maven-resources-plugin:3.1.0:resources (default-resources) @ Project-source ---
Using 'UTF-8' encoding to copy filtered resources.
Copying 1 resource
--- maven-compiler-plugin:3.8.0:compile (default-compile) @ Project-source ---
Changes detected - recompiling the module!
Compiling 1 source file to D:\Project\Project-source\target\classes
--- nbm-maven-plugin:4.1:manifest (default-manifest) @ Project-source ---
NBM Plugin generates manifest
Adding OSGi bundle dependency - javax.annotation:javax.annotation-api
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:nbm-maven-plugin:4.1:manifest (default-manifest) on project Project-source:
Execution default-manifest of goal org.codehaus.mojo:nbm-maven-plugin:4.1:manifest failed.: IllegalArgumentException
<groupId>org.apache.netbeans.utilities</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<version>4.2</version>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>