Autowiring a collection via the constructor with Spring

后端 未结 4 1276
栀梦
栀梦 2021-02-07 01:31

I have what seems to be a simple problem, as stated in the title. Here is the kind of class I have :

public class Foo {
    @Autowired
    public Foo(@Qualifier(         


        
4条回答
  •  面向向阳花
    2021-02-07 02:03

    As others stated it is impossible to use @Autowired for Strings and collections of String. You can use @Value with spring EL here assuming you have spring in version 3:

    public class Foo {
        @Autowired
        public Foo(@Value("#{bar}") Set bar) {
            // ...
        }
    }
    

提交回复
热议问题