2
자바 애노테이션 기반 스프링 웹 애플리케이션을 사용하면서 속성 소스 처리를 사용자 정의하고 싶습니다.자바 애노테이션 기반 구성의 @PropertyResource 처리 동작 사용자 정의
@Configuration
@PropertySource("ldap.properties")
@Repository
public class LdapDao {
...
@Autowired
public void setEnv(Environment env) throws NamingException {
this.url = env.getProperty("url").trim();
this.user = env.getProperty("user").trim();
this.password = env.getProperty("password).trim();
this.initializeLdapContext();
}
...
}
이 경우 스프링은 classpath에서 속성 소스를 찾습니다.
@PropertySource("file:/${conf.dir}/ldap.properties")
ldap.properties 시스템 속성 "conf.dir"에 의해 지정된 디렉토리에서 검색됩니다 : 같은 속성 소스가 선언됩니다.
시스템 자원 "conf.dir"에 지정된 디렉토리에서 등록 정보 자원을 먼저 검색하는 동작이 필요합니다. 거기에 없다면, 그 위치는 기본적으로 classpath가됩니다.
이 동작을 수행하는 방법에 대한 제안 사항이 있으십니까?