为什么要实施从Java接口的方法时,Eclipse不包括注释吗? [英] Why Eclipse does not include annotations when implementing methods from a Java interface?

查看:201
本文介绍了为什么要实施从Java接口的方法时,Eclipse不包括注释吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下接口:

import javax.xml.ws.Action;

public interface AnnotationsTestInterface {
    @Action
    public void annotatedMethod();
}

和实现类:

public class Impl implements AnnotationsTestInterface {}

此时Eclipse询问我添加未实现的方法(我选择这个),或使课堂抽象。

At this point Eclipse asks me to add unimplemented methods (I choose this) or make the class abstract.

添加后的类看起来是这样的:

After the addition the class looks like this:

import javax.xml.ws.Action;

public class Impl implements AnnotationsTestInterface {

    @Override
    @Action
    public void annotatedMethod() {
        // TODO Auto-generated method stub
    }
}

它正确地写入动作注释。

It correctly writes the Action annotation.

在另一个Eclipse实例(相同的版本,不同的用户)添加未实现的方法这个动作的结果(无 @Action 注释):

On another Eclipse instance (same version, different user) the "Add unimplemented methods" action results in this (no @Action annotation):

public class Impl implements AnnotationsTestInterface {

    @Override
    public void annotatedMethod() {
        // TODO Auto-generated method stub
    }
}

有一个选项的地方,这个交易?

Is there an option somewhere that deals with this?

请注意,该执行环境设置在Java SE 6,具有JDK 6。

Note that the execution environment is set on Java SE 6, with a JDK 6.

推荐答案

在Eclipse中,转到窗口 - > preferences->爪哇 - > code风格 - >清理,并在那里东张西望。如果不存在,环顾四周在code风格。你应该找到它!如果我猜,如果@Action没有显示出来的TODO自动生成的东西smutzle并没有什么,你有一个旧版本的Eclipse,或者没有配置做到这一点。希望这有助于<:)

On eclipse, go to Window->Preferences->Java->Code Style->Clean Up and look around in there. If not there, look around in Code Style. You ought to find it! If I had to guess, if @Action isn't showing up in the TODO auto-generated stuff smutzle and what not, you have an old version of eclipse, or it wasn't configured to do that. Hope this helps <:)

这篇关于为什么要实施从Java接口的方法时,Eclipse不包括注释吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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