我正在使用JRE 1.5。仍然当我尝试编译我的代码时,它失败了说使用JRE 1.5而不是1.3
C:\ temp \ SpringExample> mvn -e clean install +错误堆栈跟踪已打开。 [INFO]扫描项目...... [INFO] ----------------------------------------------- ------------------------- [INFO]构建SpringExample [INFO]任务段:[清理,安装] [INFO] ----------------------------------------------- ------------------------- [INFO] [clean:clean {execution:default-clean}] [INFO]删除目录C:\ temp \ SpringExample \ target [INFO] [资源:资源{执行:默认资源}] [警告]使用平台编码(实际上是Cp1252)来复制过滤后的资源,即构建依赖于平台! [INFO]复制6个资源 [INFO] [编译器:compile {execution:default-compile}] [INFO]将6个源文件编译为C:\ temp \ SpringExample \ target \ classes [INFO] ----------------------------------------------- ------------------------- [ERROR]构建失败 [INFO] ----------------------------------------------- ------------------------- [INFO]编译失败 C:\ temp \ SpringExample \ src \ main \ java \ com \ mkyong \ stock \ model \ Stock.java:-source 1.3中不支持[45,9]注释 (尝试使用-source 1.5启用注释) @override
[INFO] -------------------------------------------- ---------------------------- [信息]追踪 org.apache.maven.BuildFailureException:编译失败 C:\ temp \ SpringExample \ src \ main \ java \ com \ mkyong \ stock \ model \ Stock.java:-source 1.3中不支持[45,9]注释 (尝试使用-source 1.5启用注释) @override
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:715)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
引起:org.apache.maven.plugin.CompilationFailureException:编译失败 C:\ temp \ SpringExample \ src \ main \ java \ com \ mkyong \ stock \ model \ Stock.java:-source 1.3中不支持[45,9]注释 (尝试使用-source 1.5启用注释) @override
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
[INFO] -------------------------------------------- ---------------------------- [INFO]总时间:2秒 [INFO]完成时间:12月22日星期三10:04:53 IST 2010 [INFO]最终记忆:9M / 16M [INFO] ----------------------------------------------- ------------------------- C:\ temp \ SpringExample> javac -version javac 1.5.0_08 javac:没有源文件
答案 0 :(得分:7)
你有类似下面的内容来指定maven编译器插件使用的java版本吗?
<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>
答案 1 :(得分:5)
较短的版本
<project>
<properties>
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
</properties>
....