Skip to content

Why is injecting @Bean from different modules allowed? #1214

Answered by odrotbohm
alfonsoristorato asked this question in Q&A
Discussion options

You must be logged in to vote

Spring Modulith's dependency verification operates on a type level, not on bean instances. Bean instance references into other modules is not something wrong per se, as it's natural for one module to invoke another module directly. Also, we can't constrain references to other beans, as we're not even operating on a BeanFactory but sole type references.

I guess we can explore the idea of constraining the injection of foreign module instances, but currently that's out of scope.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by odrotbohm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants