내가 원래 레이아웃의 다음과 같은 종류의 XML 파일을 한 이유는 확실하지 :콩 -
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="FirstBean">...</bean>
<bean id="SecondBean">...</bean>
<bean id="ThirdBean">...</bean>
</beans>
우리를 위해 잘 작동. 그러나 오늘날 우리는 특정 환경 (프로덕션 및 테스트)에서 콩의 일부를 인스턴스화하기를 원한다는 사실을 깨달았습니다. 그리고이를 실현하기 위해서는 프로파일이 필요했습니다. - 응용 프로그램의 초기 시작시 - 내가 수행 다음
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- Beans to run commonly amongst both profiles -->
<beans>
<bean id="FirstBean">...</bean>
</beans>
<!-- Beans to run in prod -->
<beans profile="production">
<bean id="SecondBean">...</bean>
</beans>
<!-- Beans to run in test -->
<beans profile="test">
<bean id="ThirdBean">...</bean>
</beans>
</beans>
그리고 ... 올바른 콩을로드 콩을 얻기 위해서는 다음과 같이 우리는 몇 가지 요소를 중첩 및 프로필을 추가하여 이런 짓을 나는 또한 시도
System.setProperty("spring.profiles.active", "test");
:
System.setProperty("spring.profiles.active", "production");
을하지만 지금은 세 가지 콩 "그런 빈 정의"를 받고 없습니다 계속 (현재 테스트 용으로 하드 코딩).
여기서 충분한 정보를 제공해 주셨으면합니다. 나는 정말로 이것에 붙어 있습니다 - 다양한 온라인 자원을 따라 왔습니다.
너무 적은 정보를, 단편과 개요가 없습니다. 어떤 bean에서 시작할 때 그렇게하려고 할 때, 당신은 그 속성들을 언제/어디서 설정하고 있는가? 당신은 너무 늦었다. –