합쭈기 programming

소스상에서 properties 사용하기 본문

Java/Spring

소스상에서 properties 사용하기

innocent_k 2015. 5. 7. 10:05
@Component
@PropertySource("classpath:/props/global.properties")
public class PropsManager {

	@Autowired
	Environment env;


	public String getLocalPath()
	{
		return env.getProperty(PropsParam.LOCAL_PATH); 
	}
	
	public String getImagePath()
	{
		return env.getProperty(PropsParam.LOCAL_PATH) + env.getProperty(PropsParam.IMAGE_PATH); 
	}
	
	public String getBoardPath()
	{
		return env.getProperty(PropsParam.BOARD_PATH); 
	}
	
	
	static class PropsParam{
		
		static final String LOCAL_PATH = "localPath";
		static final String IMAGE_PATH = "imgPath";
		static final String BOARD_PATH = "boardPath";
	}
	
}