@ComponentScan 过滤以com.zyxk.sl开头的包,以ForTest结构的类
@ComponentScan(basePackages = {"com.zyxk.sl.forumservice","com.zyxk.sl.ctcomponent"},
excludeFilters={
@ComponentScan.Filter(type=FilterType.REGEX,pattern={"com.zyxk.sl..*ForTest"})
} )
@Conditional
public class MySqlDriverPresentsCondition implements Condition {
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
try {
Class.forName("com.mysql.jdbc.Driver");
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
}
@Configuration 配置
@ContextConfiguration(classes=AConfig.class)