简体   繁体   English

当我安装了Oracle JDK 1.7时,为什么mvn 3.0.4在Ubuntu 13.04上使用-source 1.3?

[英]Why does mvn 3.0.4 use -source 1.3 on Ubuntu 13.04 when I have Oracle JDK 1.7 installed?

I have mvn 3.0.4 and Oracle JDK 1.7 installed on Ubuntu 13.04. 我在Ubuntu 13.04上安装了mvn 3.0.4和Oracle JDK 1.7。 When I build an existing project I get 当我建立一个现有项目时,我得到

error: generics are not supported in -source 1.3

This same project works on Windows 7 with JDK 1.7 and mvn 3.0.4 without modifying the pom.xml to tell it which version of Java to use. 该项目在Windows 7以及JDK 1.7和mvn 3.0.4上运行,而无需修改pom.xml来告诉它要使用的Java版本。

Ubuntu has openjdk 1.7 installed, but I have Oracle JDK 1.7 in the path before openjdk. Ubuntu已安装了openjdk 1.7,但在openjdk之前的路径中有Oracle JDK 1.7。

What's wrong with maven on Ubuntu 13.04? Ubuntu 13.04上的maven有什么问题?

Thanks. 谢谢。

You need to tell Maven to use JDK 1.5(???) to compile your source code explicitly. 您需要告诉Maven使用JDK 1.5(???)显式编译源代码。 Declare Maven compiler plugin (maven-compiler-plugin) in your pom.xml file, like this : 在pom.xml文件中声明Maven编译器插件(maven-compiler-plugin),如下所示:

File : pom.xml 档案:pom.xml

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

I removed mvn 3.0.4 (Ubuntu packaged version) and installed 3.1.0 (from Apache web site) and it now works. 我删除了mvn 3.0.4(Ubuntu打包版本)并安装了3.1.0(来自Apache网站),现在可以使用了。 There must be a problem with the packaged version of mvn 3.0.4 for Ubuntu. 适用于Ubuntu的mvn 3.0.4的打包版本一定存在问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么 maven 会忽略我安装的 JDK? - Why does maven ignores the JDK i installed? 未找到 Maven 3.0.4 安装到 Ubuntu mvn - Maven 3.0.4 installation to Ubuntu mvn not found 安装了 Maven,但 mvn -version 无法识别。 当我使用 %M2_HOME%\bin\mvn -version 时工作 - Installed Maven, but mvn -version is not recognized. Works when I use %M2_HOME%\bin\mvn -version 即使安装了Java 1.7,Maven也会给出Java版本错误(询问Java 1.5) - Maven gives a java version error (ask for java 1.5) even when I have java 1.7 installed Maven无法识别在Ubuntu Shell上安装的$ JAVA_HOME jdk - Maven does not recognize the $JAVA_HOME jdk installed on Ubuntu shell 当我使用`mvn hpi:run`时有一个ArrayIndexOutOfBoundsException - There is a ArrayIndexOutOfBoundsException when I use `mvn hpi:run` 当我在由mvn:assembly构建的批处理中使用args4j时,为什么会发生java.lang.NoClassDefFoundError - Why occurs a java.lang.NoClassDefFoundError when I use args4j in a batch built by mvn:assembly 当我使用“ mvn -v”时,为什么我的电脑中有两个java路径 - Why there are two java path in my PC when i use the “mvn -v” Maven构建在Ubuntu 12.04,JDK1.7上失败 - Maven build fails on Ubuntu 12.04, JDK1.7 为什么我在运行mvn clean install时有errorRebind结果&#39;javax.validation.ValidatorFactory&#39;必须是一个类? - Why I have errorRebind result 'javax.validation.ValidatorFactory' must be a class when i run mvn clean install?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM