<context:property-placeholder location="classpath*:/prop/*.properties"/> <!-- property --> <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg ref="mongo"/> <constructor-arg name="databaseName" value="${mongo.db}"/> <!-- property --> </bean>
<context:property-placeholder location="classpath*:/prop/*.properties"/> <import resource="classpath*:my-${proj.env}.xml"/> <!-- property -->
<beans profile="test"> <!-- "test" --> <import resource="classpath*:/my-test.xml"/> </beans> <beans profile="prod,dev"> <!-- HE "test" --> <import resource="classpath*:/my-prod.xml"/> </beans>
ClassPathXmlApplicationContext ontext = new ClassPathXmlApplicationContext(new String[]{"classpath*:bean.xml"}, false); ontext.getEnvironment().setActiveProfiles("test"); ontext.refresh();
@ContextConfiguration(locations = {"classpath*:bean.xml"}) @ActiveProfiles(profiles = {"test"}) @RunWith(SpringJUnit4ClassRunner.class) public class SuperTest { ...
Source: https://habr.com/ru/post/156731/
All Articles