[Spring] properties 파일 읽기.
ITWeb/개발일반 2013. 8. 13. 18:35해당 프로젝트에 conf 디렉토리 하나 만드시고 거기에 profile 별 디렉토리도 만드시고..
아래 같이 해주면 됩니다. (뭐 나만 알아 볼라고 대충 등록함.)
[pom.xml]
<resource>
<directory>${basedir}/conf/${env}</directory>
<targetPath>${project.build.directory}/conf</targetPath>
<filtering>false</filtering>
</resource>
[class]
resource = new ClassPathResource(propsFile);
props = PropertiesLoaderUtils.loadProperties(resource);
clusterName = props.getProperty("cluster.name");
[properties]
cluster.name=es-cluster
cluster.node.list=192.168.56.104:9300,192.168.56.104:9301