源代码1.3不支持Netbeans Maven注释,请使用源代码5

源代码1.3不支持Netbeans Maven注释,请使用源代码5,maven,netbeans,compiler-construction,maven-plugin,Maven,Netbeans,Compiler Construction,Maven Plugin,使用Netbeans 6.7中的Maven构建项目时,我会收到以下错误消息: Error annotations are not supported in -source 1.3 (use -source 5 or higher to enable annotations) 我已经看到,我需要在POM.xml中添加一个maven编译器插件配置,但我不想对每个项目都这样做。我可以在一个影响所有maven项目的中心位置设置它吗?在settings.xml中 我已经将Netbeans配置为使

使用Netbeans 6.7中的Maven构建项目时,我会收到以下错误消息:

Error   annotations are not supported in -source 1.3   (use -source 5 or higher to enable annotations)
我已经看到,我需要在POM.xml中添加一个maven编译器插件配置,但我不想对每个项目都这样做。我可以在一个影响所有maven项目的中心位置设置它吗?在settings.xml中


我已经将Netbeans配置为使用Maven 3.0.3,并且我的JAVA_主页指向JDK 1.5。

即使在每个项目中使用Netbeans配置它非常简单:

  • 右键单击您的项目
  • 选择«属性»
  • 在项目属性窗口中选择«来源»
  • 选择1.3中的«源/二进制/格式»
  • 单击“确定”将正确更新pom
更好的方法是使用()

在父pom.xml中配置插件:

        <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>com.mycompany</groupId>
      <artifactId>parent-pom</artifactId>
      <version>1.0-SNAPSHOT</version>
      <packaging>pom</packaging>
      <name>parent-pom</name>
      <build>
          <plugins>
              <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>1.3</source>
                        <target>1.3</target>
                    </configuration>
                </plugin>
          </plugins>
      </build>
    </project>

4.0.0
com.mycompany
母体聚甲醛
1.0-快照
聚甲醛
母体聚甲醛
org.apache.maven.plugins
maven编译器插件
2.3.2
1.3
1.3
之后,您的模块可以通过以下方式继承此行为:

<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>com.mycompany</groupId>
    <artifactId>parent-pom</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>
<artifactId>mavenproject1</artifactId>
<packaging>jar</packaging>
<name>mavenproject1</name>

4.0.0
com.mycompany
母体聚甲醛
1.0-快照
mavenproject1
罐子
mavenproject1

再次感谢你,约阿希姆。