在启动类上加 @Import(UserConfig.class) 注解引入其他需要的配置类(@Configuration注解过的类)
@ImportResource引入xml配置文件,代码如下:
package com.jiaobuchong.config; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.ImportResource; @Configuration @Import(CDPlayerConfig.class) @ImportResource("classpath:cons-injec.xml") //导入xml配置项 public class SoundSystemConfig { }
参考资料: