Created
December 5, 2013 10:12
-
-
Save Qkyrie/7803019 to your computer and use it in GitHub Desktop.
Spring Component Scanning Tip
The use of <context:component-scan> implicitly enables the functionality of
<context:annotation-config>. There is usually no need to include the
<context:annotation-config> element when using <context:component-scan>.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:context="http://www.springframework.org/schema/context" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans | |
http://www.springframework.org/schema/beans/spring-beans.xsd | |
http://www.springframework.org/schema/context | |
http://www.springframework.org/schema/context/spring-context.xsd"> | |
<context:component-scan base-package="org.example"/> | |
</beans> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Configuration | |
@ComponentScan("com.company") // search the com.company package for @Component classes | |
@ImportXml("classpath:com/company/data-access-config.xml") // XML with DataSource bean | |
public class Config { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment