• @ContextConfiguration : 加载配置文件
    • @ContextConfiguration(classes = {TestConfig.class})
    • @ContextConfiguration用来加载ApplicationContext 
    • classes属性用来加载配置类

比如:

  单个文件 @ContextConfiguration(Locations="../applicationContext.xml")

  @ContextConfiguration(classes = SimpleConfiguration.class)

  多个文件时,可用

  @ContextConfiguration(locations = { "classpath*:/spring1.xml", "classpath*:/spring2.xml" })

相关文章: