I use the depends-on
attribute in our production system to control the shutdown order of the beans. Thus, Bean1
doesn't have a compile-time dependency on Bean2
, but it should be shutdown first to ensure correct operation. I'd like to test Bean1
in isolation by injecting it into my unit tests. Because Bean2
isn't part of the test, I don't want it to be loaded by Spring when I run the test. Is it possible to express this dependency outside of the definition of Bean1
and Bean2
?
The hacky solution I've come up with is to simply define a dummy Bean2
in my test context, which will be loaded to satisfy the dependency, but I'd like a more elegant solution.