Spring custom annotation is not recognized as @Autowired analogue

Hello,

Could someone describe me how to configure Idea to recognize custom Spring annotations?

I'm using Spring and java-configs, Spring facet is added to my modules, so each bean annotated by @Autowire and declared in @Configuration class is shown correctly. But we have custom annotation like

 
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Bean
@Scope
(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public @interface CustomController {

}


and beans that are annotated by it are not recognized by Idea:

  • methods in @Configuration file is marked as never used
  • injection in another class is marked as invalid  with message "Could not autowire. No beans of '...' type found."

@Configuration
public class MasterdataRequestConfiguration {

    @CustomController
    MasterdataRequestController masterdataRequestController() {
        return new MasterdataRequestController();
    }

    @Bean
    TerminalAttributesService terminalAttributesService() {
        return new TerminalAttributesService();

}

terminalAttributesService is injected without warnings but masterdataRequestController is not found by Idea with such configuration's file.




Is there any way to point that this annotation is a @Bean too?
Please note that I don't want to disable this check - it can be very useful.
3 comments
Comment actions Permalink

What version of IntelliJ IDEA do you use?


0
Comment actions Permalink

I'm using version 15.0.2.
Do you mean that such annotations are recognized somewhere? :)

0
Comment actions Permalink

Sorry, indeed meta-annotations for "@Bean" are not supported currently. Please watch https://youtrack.jetbrains.com/issue/IDEA-149463 for progress. Thanks for reporting!

0

Please sign in to leave a comment.