I am trying to use SPeL to extract some data from the application context using
@Value
Precisely, I want this code as a value
@Autowired
private ApplicationContext context;
Map<String, CrudRepository> repos =
context.getBeansOfType(CrudRepository.class);
@Value("#{...})
private Map<String, CrudRepository> repos;
is there a magic variable like "systemProperties" that I can invoke? There has to be!
Something like this:
@Value("#{beanFactory.getBeansOfType(T(org.springframework.data.repository.CrudRepository))}")
private Map<String, MessageChannel> repos;
The SpEL here is based on the BeanExpressionContext
, so its getBeanFactory()
does the trick for us!
From other side you don't need @Value
for the Map<String, CrudRepository>
. The normal @Autowired
works the same way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With