If I create a bean as follows:
@Repository("myRepository")
public class MyRepository {
...
}
In XML should I be able to wire it in as follows:
<bean id="xmlBean" class="uk.co.foo.myBean">
<constructor-arg ref="myRepository"/>
</bean>
Or is mixing like this not allowed?
The reason is for some things, generally business logic, it make sense for me to configure and wire various beans in XML as I may have multiple instances of the same interfaces, be likely to swap stuff round and it lets me to see my project configuration clearly from XML. However for repositorys it’s very unlikely I am going to need to do or see any of those things and it’s much more convenient just to use annotations.
It should work fine dont forget to enable context scanning in your xml configuration for Spring to find the bean it needs to
AutoWire. You enable scanning by