Which have more priority: Spring annotation or xml configuration
annotations, spring, xml
Solution
In your example the default name for the bean created by @Component would be "demo", matching your XML, so only a single bean will be created - the instance created by the XML.
If the XML specified a different name (or the `@Component` annotation gave a different name), two instances would be created.
Problem
If i have a `spring bean` defined using both `xml` configuration and `annotation`. Then while initialization, which have more priority, `xml` or `annotations`. Like my bean is... ``` package com.abc; @Component Class Demo{ ... } ``` And my `xml` configuration is... ``` ... <context:annotation-config /> <context:component-scan base-package="com.abc" /> <bean id="demo" class="com.abc.Demo"/> ... ``` Now the `demo` bean is defined using both `xml` and `annotations`. While initialization, who is initializing `bean`: `annotation` or `xml`.