- Arawn's Dev Blog
- Outsider's Dev Story
- Toby's Epril
- Benelog
- NHN 개발자 블로그
- SK 플래닛 기술 블로그
- OLC CENTER
- 소프트웨어 경영/공학 블로그
- 모바일 컨버전스
- KOSR - Korea Operating System …
- 넥스트리 블로그
- 리버스코어 ReverseCore
- SLiPP
- 개발자를 위하여... (Nextree 임병인 수석)
- "트위터 부트스트랩: 디자이너도 놀라워할 매끈하고 직관…
- Learning English - The English…
- real-english.com
- 'DataScience/Deep Learning' 카테…
- Deep Learning Summer School, M…
- Deep Learning Courses
민서네집
properties 파일 안에서 다른 key 를 참조할 수 있는가? how to reference already defined property in the properties file 본문
properties 파일 안에서 다른 key 를 참조할 수 있는가? how to reference already defined property in the properties file
브라이언7 2013. 8. 21. 14:25how to reference already defined property as the value for another key in the properties file.
http://www.coderanch.com/t/469713/java/java/reference-defined-property-key-properties
내가 하고 싶은 것이 위 블로그에 나와 있는 대로 다른 key 값을 참조해서 key 값을 얻고 싶었다.
예를 들면
server.ip=http://bryan7.tistory.com
java_url={server.ip}/category/Java
내가 원하는 것은 java_url=http://bryan7.tistory.com/category/Java
이렇게 값을 원하는 것이다.
그런데, 이런 것이 java.util.Properties 클래스나 Spring 의 properties 설정 만으로 자동으로 되는 것이 아니었다.
<!-- **************************************************************** -->
<!-- Configration -->
<!-- **************************************************************** -->
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:config/config.properties</value>
</list>
</property>
</bean>
<util:properties id="config" location="classpath:config/config.properties"/>
위와 같이 PropertyPlaceholder 로 자기 자신을 등록해 보아도 되지 않았다.
Spring 의 PropertyPlaceholder 의 역할은 Spring 설정 파일 안에서 값을 치환하고자 하는 목적이지 위에서처럼 Properties 파일 안에서 서로 값을 참조할 수 있도록 하는 역할은 아니었다.
이런 것을 하려면 java.util.Properties 클래스를 상속 받아서 코드를 추가해야 한다고 한다.
http://stackoverflow.com/questions/872272/how-to-reference-another-property-in-java-util-properties
http://www2.sys-con.com/ITSG/virtualcd/Java/archives/0612/mair/index.html
위 URL 에서 XProperties 클래스의 사용법과 소스 파일이 나와 있다. 나는 이것을 이용했다.
Properties 파일을 초기화 하는 방법은
http://www.mkyong.com/java/java-properties-file-examples/
여기를 참조했다.
그밖에 Properties 파일에 대한 블로그는 다음과 같다.
< java.util.Properties 클래스를 이용한 어플리케이션의 프로퍼티 설정 >
< Java Properties 사용방법 >
http://umzzil.egloos.com/2175356
< Spring Properties >
http://devnote.benelog.net/java/spring/spring-properties
< 시대착오적인 설정 파일 *.properties 를 버리자 >
http://kwon37xi.egloos.com/4665590
'Java' 카테고리의 다른 글
[OpenID4Java] Local signature verification failed 에러 (0) | 2013.08.24 |
---|---|
Java Timer 클래스를 이용한 작업 스케쥴링 (0) | 2013.08.22 |
[eclipse] 특정 파일을 JavaScript Validation 에서 제외시키기 (0) | 2013.08.17 |
[eclipse] 특정 폴더 이하를 validation에서 제외시키기 (How to exclude specific folders or files from validation in Eclipse?) (0) | 2013.08.17 |
[maven] pom.xml profile 설정 (0) | 2013.08.15 |