【问题标题】:Using different Java source version when running Maven2 build运行 Maven2 构建时使用不同的 Java 源版本
【发布时间】:2014-07-28 18:11:33
【问题描述】:

我正在尝试使用通常的方式运行我的 Maven 构建:

mvn clean install

我收到一系列错误,内容如下:

annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)

执行构建时如何使用 -source 5。我的 JAVA_HOME 指向 JDK 1.6。

【问题讨论】:

    标签: java maven-2


    【解决方案1】:

    将此添加到您的 pom.xml:

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

    它也记录在Maven FAQ

    如需了解更多信息,请查看Compiler Plugin documentation

    【讨论】:

      【解决方案2】:

      它在 pom.xml 中。你应该把&lt;source&gt;1.3&lt;/source&gt;改成

      <source>1.6</source> 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-11-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-30
        • 2011-06-07
        相关资源
        最近更新 更多