How to make Intellij detect Spring beans defined in generic parent class

Hi,

I have a lot of code looking like this

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ConfigurationBase<T>
{
public @Bean(name="S1") T getS1() { return null; }
public @Bean(name="S2") T getS2() { return null; }
}

And a derived class looking like this:

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;

public class ConfigurationDerived extends ConfigurationBase<String>
{
@Override
public String getS1() { return "S1+++"; }

public @Bean(name="S3") String getS3() { return "S3"; }

public @Bean(name="ID") String getCompositeName(
@Qualifier("S1") String s1,
@Qualifier("S2") String s2,
@Qualifier("S3") String s3)
{
return "hello!";
}
}

When the base class is not generic, IntelliJ is able to find all the Spring dependencies.

But when as in this example, the base class is generic, it can't find the beans defined in the base class

For example here, it won't find the beans "S1" and "S2"

Is there a work around?

 

0

请先登录再写评论。