在 IntelliJ 和 Eclipse 开发人员都在工作的项目中使用 @NotNull [英] Using @NotNull in a project where both IntelliJ and Eclipse developers are working

查看:25
本文介绍了在 IntelliJ 和 Eclipse 开发人员都在工作的项目中使用 @NotNull的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IntelliJ IDEA 的一位同事(正在从事另一个项目)向我展示了令人惊叹的 @NotNull 注释.我在这里阅读了关于如何开始在任何地方添加 @NotNull 节省大量时间和麻烦的消息(当 IntelliJ 10 检测到 null 会造成严重破坏时,它甚至可以自动将 @NotNull 添加到旧代码中)).

A co-worker on IntelliJ IDEA (working on another project) showed me the amazing @NotNull annotation. I've read messages here on SO about how starting to add @NotNull everywhere saved lots of time and headaches (and IntelliJ 10 can even add automatically @NotNull to old code when it detects that null would wreak havoc).

自从我阅读了我的第一条可能的@NotNull 违规" 消息(实时,在 IDE 中,甚至是在部分 .java 文件中编译)我的下巴掉下来,我被迷住了.

Since I read my first "Probable @NotNull violation" message (in real-time, in the IDE, even on a partial .java file that doesn't compile yet) my jaw dropped and I got hooked.

所以我想知道:如果我们想在开发人员同时使用 Eclipse 和 IntelliJ 的项目中开始使用 @NotNull,有什么需要知道的吗?

So I was wondering: is there anything that needs to be known if we want to start using @NotNull in a project where developers are using both Eclipse and IntelliJ?

我知道 IntelliJ 带有 annotations.jar.这与 Eclipse 兼容吗?

I know IntelliJ ships with the annotations.jar. Is this compatible with Eclipse?

推荐答案

还可以将注释存储在源之外.设置 > 代码样式 > 代码生成 > 使用外部注释.然后将注释存储在 annotations.xml 文件中而不是源中.这样 Eclipse 用户就永远不必看到注释.可以配置 annotations.xml 的位置,最好将文件与项目一起存储在版本控制中.

There is also the possibility to store the annotations outside of the source. Settings > Code Style > Code generation > Use external annotations. The annotations are then stored in an annotations.xml file instead of in the source. That way Eclipse users never have to see the annotations. The location of the annotations.xml can be configured and it is probably best to store the file with the project in version control.

http://www.jetbrains.com/idea/webhelp/using-external-annotations.htmlhttp://blogs.jetbrains.com/idea/2008/02/external-注释/

这篇关于在 IntelliJ 和 Eclipse 开发人员都在工作的项目中使用 @NotNull的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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