IT_Programming/Dev Libs & Framework
[펌] spring profile 을 사용하여 환경에 맞게 deploy 하기
JJun ™
2016. 2. 11. 04:31
* 출처
: https://www.lesstif.com/pages/viewpage.action?pageId=18220309
Spring profile 을 사용하여 환경에 맞게 deploy 하기
개요
spring 3.1 부터 포함된 기능으로 환경에 맞게 적합한 profile 을 사용할 수 있게 하는 기능. maven profile 과 비슷한 역할을 한다고 보면 됨.
사용
application Context 의 beans 설정에 다음과 같이 profile 을 지정
profile 설정시 여러개의 profile 을 지정할수 있다
활성화
jvm property 로 전달
spring.profiles.active property 에 활성화할 프로파일명을 설정 (, 로 여러 개 설정 가능)
web.xml 에 설정
web.xml 에 활성화할 프로파일 설정.
ApplicationContext 의 Environment 에 설정
@ActiveProfiles annotation 사용
jUnit 등으로 test case 를 돌릴 경우에 유용
Ref
- http://spring.io/blog/2011/02/14/spring-3-1-m1-introducing-profile
- http://spring.io/blog/2011/06/21/spring-3-1-m2-testing-with-configuration-classes-and-profiles
- http://docs.spring.io/spring/docs/3.2.8.RELEASE/javadoc-api//org/springframework/context/annotation/Profile.html