I use
@Inject Instance<Interface> xxx
which will implement a new instance of each class that implements the interface. This is very useful because I do not need to know how many or who these classes are to create them, and I can repeat them without knowing how many of them.
Now I do not know how to reproduce this behavior using Spring.
Can you help me?
Thanks,
The best solution I have found so far is to enter applicationContext and
@Inject ApplicationContext applicationContext; ... Map<String, Object> mapInstance = applicationContext.getBeansWithAnnotation(MyAnnotation.class);
Spring @Inject , @Autowired. , @Component, @Repository, @Service @Controller, Beans.xml.
: http://docs.spring.io/spring/docs/4.0.1.RELEASE/spring-framework-reference/htmlsingle/#beans-factory-collaborators
@Autowired private List<Interface> interfaces;
CDI bean List<Interface>, Spring beans Interface.
List<Interface>
Interface
,
@Autowired private Map<String, Interface> interfaces;
beans Interface bean.
( javax.inject.Inject , @Autowired @Inject.)
javax.inject.Inject
@Autowired
@Inject
Source: https://habr.com/ru/post/1525048/More articles:Is it advisable to remove Gemfile.lock? - ruby | fooobar.comиспользовать pandoc для вставки изображений в файл docx, которые находятся в HTML - pandoccreate a pull request for one fix made on a fork on github - githubjavax.naming.NameNotFoundException: The name [comp / env] is not related in this context - springC #: multiply array elements by each other - c #Unable to read property * 0 * null - javascriptmpi4py зависает при попытке отправки больших данных - hangFind the difference in an array using a loop - arraysHow to use SignalR with Xamarin - c #Unsafe JavaScript attempt to access frame with url in Android - javascriptAll Articles