我可以建议这样做吗,这样定义测试:
@RunWith(SpringJUnit4ClassRunner.class)@TestExecutionListeners({ TestPreperationExecutionListener.class })@Transactional@ActiveProfiles(profiles = "localtest")@ContextConfigurationpublic class TestContext { @Test public void testContext(){ } @Configuration @PropertySource("classpath:/myprops.properties") @importResource({"classpath:context.xml" }) public static class MyContextConfiguration{ }}在myprops.properties文件中包含以下内容:
spring.profiles.active=localtest
有了这个,您的第二个属性文件应该得到解决:
meta-INF/spring/config_${spring.profiles.active}.properties


