将-source设置为1.5,显然设置为1.3 [英] setting -source to 1.5, it is set to 1.3 apparently

查看:127
本文介绍了将-source设置为1.5,显然设置为1.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用eclipse,使用maven2插件。
我试图设置一个简单的基于弹簧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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆