将-source设置为1.5,显然设置为1.3 [英] setting -source to 1.5, it is set to 1.3 apparently
问题描述
我试图设置一个简单的基于弹簧3 mvc web应用程序的注释。
所以我去了RunAs,点击'maven build',我设置目标为编译。
编译时,我收到错误消息:
code> E:\dev\eclipse\springmvc2\src\main\java\web\HomeController.java:-source 1.3中不支持[5,1]注释
(使用-source 5或更高版本启用注释)
@Controller
到目前为止修改了eclipse.ini来使用jdk。我也确定在偏好下,它是在java 1.6。
不知道在哪里更改java版本?
(我假定source 1.3意味着java 1.3,我需要它至少与1.5兼容)
您还应该在 pom.xml
中设置正确的源代码(因为maven可以在没有Eclipse的情况下进行构建,使用Eclipse首选项):
< project ...>
...
< 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>
...
< / project>
I am using eclipse, with maven2 plugin. I am trying to setup a simple annotations based spring 3 mvc web application.
So I went to RunAs and clicked on 'maven build', I set the goal as 'compile'.
When it compiles, I get the error message:
E:\dev\eclipse\springmvc2\src\main\java\web\HomeController.java:[5,1] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Controller
so far I modified the eclipse.ini to use the jdk. I also made sure under preferences, it is at java 1.6.
Not sure where else to change the java version?
(I am assuming source 1.3 means java 1.3 and that I need it to be at least version 1.5 compatible)
You should also set a proper source version in pom.xml
(because maven can make builds without Eclipse, so it can't use Eclipse preferences):
<project ...>
...
<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>
...
</project>
这篇关于将-source设置为1.5,显然设置为1.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!