Skip to content

Instantly share code, notes, and snippets.

@kjunine
Created September 9, 2013 09:23
Show Gist options
  • Save kjunine/6493386 to your computer and use it in GitHub Desktop.
Save kjunine/6493386 to your computer and use it in GitHub Desktop.
Spring @componentscan Execlude Filter Example
@Configuration
@ImportResource("classpath:/net/kjunine/test.xml")
@PropertySource("classpath:/net/kjunine/test.properties")
@ComponentScan(basePackages = "net.kjunine", excludeFilters = { @Filter(type = FilterType.CUSTOM, value = { SamplePackageFilter.class }) })
public class TestConfig {
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
static class SamplePackageFilter extends RegexPatternTypeFilter {
public SamplePackageFilter() {
super(Pattern.compile("net\\.kjunine\\.sample\\..*"));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment