1. @Conditional使用流程
编写条件类
1 | /** 实现Condition接口 */ |
配置类1
2
3
4
5
6
7
8
public class BeanConfig {
({MyCondition.class}) // 满足条件才注册
public Person person() {
return new Person("jack", 10);
}
}
测试方法
1 |
|
编写条件类
1 | /** 实现Condition接口 */ |
配置类1
2
3
4
5
6
7
8@Configuration
public class BeanConfig {
@Bean
@Conditional({MyCondition.class}) // 满足条件才注册
public Person person() {
return new Person("jack", 10);
}
}
测试方法
1 | @Test |
微信支付
支付宝