本文共 472 字,大约阅读时间需要 1 分钟。
@RunWith(SpringJUnit4ClassRunner.class)//在Junit环境下提供Spring TestContext Framework的功能@ContextConfiguration(classes = {TestConfig.class})//用来加载ApplicationContext,齐总classes属性用来加载配置类@ActiveProfiles("prod")//用来声明活动的profilepublic class java { @Autowired private TestBean testBean; @Test public void prodBeanShouldInject(){ String expected="from production profile"; String actual=testBean.getContent(); Assert.assertEquals(expected,actual); }}
转载地址:http://wljqi.baihongyu.com/