简体   繁体   中英

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
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 ?

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.
Alternatively, you can disable this inspection altogether in IntelliJ IDEA by going to FileSettingsEditorInspections . 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. 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".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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