限定符注释方法未将 bean 查找为配置 class

Qualifier annotation method not finding beans as a Configuration class

下面的工作正常,问题是我需要在另一个将使用此处创建的一些资源的 bean 之前 运行。当我将 @Component 更改为 @Configuration 时,出现错误 Cannot find bean with qualifier localSNS

@Component
public class ResourceCreation {

    String queueUrl;

    @Qualifier("localSNS")
    @Autowired
    AmazonSNS amazonSNS;

您可以用 @DependsOn

注释 class

FileProcessor specifies its dependencies with @DependsOn. We can also annotate a Component with @DependsOn:

@Component
@DependsOn({"filereader", "fileWriter"})