If I have a private static inner class annotated with @Service
, will it be autowired?
Will Spring's component search find it?
Yes; Spring's component scanner will also find inner classes and treat them as beans.
Remember to use the $-notation when referring to the class from an XML-file; e.g.
<bean id="myBean" class="com.mybeans.OuterClass$InnerClass"/>
.
UPDATE: Yes; Spring can instantiate private inner classes.
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