Skip to content

Instantly share code, notes, and snippets.

@Qkyrie
Created December 5, 2013 10:12
Show Gist options
  • Save Qkyrie/7803019 to your computer and use it in GitHub Desktop.
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>.
<?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>
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