java - 行家: (use -source 5 or higher to enable static import declarations)

标签 java maven-2

如何使用源 5? 我试过了

mvn -source 5 test

但它没有工作:-)

当我通过 javac 编译文件时,一切正常。

最佳答案

您需要配置maven-compiler-plugin :

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

编辑:更改示例以使用最新版本的插件。

关于java - 行家: (use -source 5 or higher to enable static import declarations),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2451268/

相关文章:

Java - 读取进程输出时出现问题

maven-2 - Maven - 添加自定义阶段以使用其他配置执行插件

java - 随机,与最后 10 个不同。(Java)

java - Hibernate 空间索引注释

java - 不生成OSGI-INF文件夹

jakarta-ee - 是否可以限制 Maven 构建的输出?

java - 将 mojo 添加到另一个 Maven 插件定义的自定义生命周期

java - 通过 shell 添加对现有 pom.xml 的依赖

java - 是否可以在 Eclipse 中显示图像直方图

java - 如何调用groovy类中接口(interface)的默认方法