定义一个特殊的接口
public interface ServiceWebSecurityConfigurer { void configure(HttpSecurity http) throws Exception;}然后只有一个ConfigurerAdapter:
public class MyConfigurerAdapter extends WebSecurityConfigurerAdapter { @Autowired(required = false) ServiceWebSecurityConfigurer serviceSecConfig; public void configure(HttpSecurity http) throws Exception { http.authorizeRequests(). // whatever if (serviceSecConfig != null) serviceSecConfig.configure(http); http.authorizeRequests(). // whatever }}然后在需要时在其他地方实现ServiceWebSecurityConfigurer。也可以有多种实现,只需将它们自动连接为列表,然后迭代并在主配置中使用它们即可。



