Error OK,KO

1 篇文章 0 订阅

maven编译时始终出现以下提示:

error: generics are not supported in -source 1.3
-source 1.3 中不支持泛型(请使用 -source 5 或更高版本以启用泛型)

error: annotation are not supported in -source 1.3
-source 1.3 中不支持注解(请使用 -source 5 或更高版本以启用注释)

而用mvn -v查看结果:

Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_60, vendor: Oracle Corporation
Java home: /usr/lib/jvm/jdk1.7.0_60/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-45-generic", arch: "amd64", family: "unix"

显然与所配置的JDK无关。最终解决办法:

在项目的pom.xml中,添加:

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

问题解决了,可是紧接着编译,发现又产生新的错误提示:

error: multi-catch statement is not supported in -source 1.5
-source 1.5 中不支持多catch语句块

于是,我狠了狠心,将maven的编译插件直接提高到1.7,修改pom.xml:

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

OK,KO!

参考链接:Compiler插件配置

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值