[Spring] Meta annotations and @Autowired.

I have several  meta annotations like the following:

@ContextConfiguration(locations = {"classpath:/META-INF/spring/application.xml"})
public @interface JpaRepositoryTest {}

used in tests like this:

public class FooRepositoryTest {
    @Autowired FooRepository repository;

    public void test
() { ... }

Now, the test runs fine, however IntellIJ marks @Autowired dependency as "Autowired members must be defined in a valid spring bean" (it disappears if I move @ContextConfiguration to FooRepositoryTest).
Is there some sort of configuration to make IntelliJ see the spring context from composite annotation or this feature is simply not supported?

Comment actions Permalink

It should work in IntelliJ IDEA 15.x

Comment actions Permalink

Well, it does not... I guess it's a bug then.

Comment actions Permalink

Any updates about this problem? I'm facing a similar issue. 


I have the following meta annotation:


public @interface AppWebIntegrationTest {
String[] value() default {};
The class I use the annotation:
public class DraftResourceIntegrationTest {

private ObjectMapper jacksonObjectMapper;

private DraftRepository draftRepository;


The tests runs fine but the IDE doesn't recognize the @Autowired objects and I get the following message:

"Could not autowire. No beans of 'DraftRepository' type found. less... (⌘F1)
Checks autowiring problems in a bean class."


Comment actions Permalink

Is there any work in progress for this subject ? I'm still having the same problem in 2017.3 : tests run fine but intellij doesn't recognize the auto-wired beans.

Comment actions Permalink

Please create an issue on YouTrack attaching sample project example: http://youtrack.jetbrains.com/issues/IDEA .


Please sign in to leave a comment.