简体   繁体   English

对于@Transactional方法,禁用警告“Access可以是包私有”

[英]Disable warning “Access can be package-private” for @Transactional methods

I have several public methods annotated with @Transactional and IntelliJ shows the warning that they can be package-private or private. 我有几个用@Transactional注释的公共方法,IntelliJ显示它们可以是包私有或私有的警告。

@Transactional
public void doSomething() {
  ///body
}

Since methods annotated with @Transactional should be public, how can I disable in IntelliJ this inspection/warning only for those methods ? 由于使用@Transactional注释的方法应该是公共的,如何在IntelliJ中仅对这些方法禁用此检查/警告?

Sadly, it isn't possible to make all methods annotated with @Transactional clear the warning, although it is possible to add @SuppressWarnings("WeakerAccess") to make the warning go away. 遗憾的是,尽管可以添加@SuppressWarnings("WeakerAccess")以使警告消失,但不可能使用@Transactional注释所有方法清除警告。
Alternatively, you can disable this inspection altogether in IntelliJ IDEA by going to FileSettingsEditorInspections . 或者,您可以通过转到FileSettingsEditorInspections在IntelliJ IDEA中完全禁用此检查。 In the list show in this view you will want to navigate through the subcategories: JavaDeclaration redundancy and uncheck the checkbox called "Declaration access can be weaker" that will be available then. 在此视图的列表中,您将需要浏览子类别: JavaDeclaration redundancy并取消选中“声明访问可能较弱”的复选框。 If you wish to disable this for future projects, choose the profile "Default" from the dropdown menu labelled "Profile", otherwise, just do this for "Project Default". 如果您希望在将来的项目中禁用此功能,请从标有“配置文件”的下拉菜单中选择配置文件“默认”,否则,只需对“项目默认值”执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM