-source 1.3 不支持泛型 [英] generics are not supported in -source 1.3

查看:25
本文介绍了-source 1.3 不支持泛型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 maven 打包时遇到问题.在这段代码中:

I have a problem while maven packaging. In this code:

public class LoginDialog extends Dialog {

    private final TextField<String> customer;
                          ^here
    private final TextField<String> login1;
    private final TextField<String> password1;
    private final MainController controller= new MainController();
    private String customerId;
    private String login;
    private String password;

我有一个类似的错误:

[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
...src/main/java/com/messagedna/web/client/widget/LoginDialog.java:[19,27] error: generics are not supported in -source 1.3

这可能是什么原因?

推荐答案

泛型是在 java 1.5 中添加的.您的 Maven 正在为 Java 1.3 编译.

Generics were added in java 1.5. Your maven is compiling for java 1.3.

这可以通过以下两种方式之一解决.

This can be fixed in one of two ways.

删除泛型,以便您可以编译 <1.5

Remove generics so that you can compile for < 1.5

更改 maven 配置以针对较新版本的 java 进行编译.你应该能够在你的 pom 中编辑你的编译器插件:

Change the maven configuration to compile for a newer version of java. You should be able to edit your compiler plugin in your pom:

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

这告诉 maven 为 1.5 编译

This tells maven to compile for 1.5

这篇关于-source 1.3 不支持泛型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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