스프링의 속성 대체 메커니즘에서 약간의 손실이 있습니다. 나는이 자바 구성이스프링 자바 환경 설정에서 주석의 자리 표시 자 사용하기
@Configuration
@ComponentScan(basePackageClasses = Application.class)
@PropertySources({
@PropertySource("classpath:/config/default.properties")
})
public class ApplicationConfig {
@Bean
public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
return pspc;
}
가 지금은 @EnableMongoRepositories("${my.custom.repobasepackage}")
을 다음과 같이 정의 자리를 사용하여 봄 - 데이터 주석 @EnableMongoRepositories
를 추가하고 검색에 대한 사용자 정의 basepackage을 정의 할 수 있다고 가정 할 수 있습니다. 자리 표시자는 내 default.properties에 정의되어 있습니다.
그러나이 속성은 여기서 해결할 수 없습니다. Spring의 속성 교체에 대해 자세히 살펴보면 속성을 분석하려고 시도하는 것을 볼 수 있으므로 그렇게 할 수 있습니다.
그러나 자리 표시자를 바꾸는 데 사용되는 기본 Environment
클래스는 내 PropertyPlaceholderConfigurer에 대해 알지 못하지만 내 SystemProperties 및 내 VM-Props에 대해서만 알고 있습니다. :-(
내 "PropertyPlaceholder은"그 때문에, 장소에 이미 org.springframework.context.annotation.ClassPathBeanDefinitionScanner # getOrCreateEnvironment.java 번호 339 (내가 사용 봄 4.0.1)에있는 것을 볼 수 있습니다 초기화에서 순서를 묻는 질문이 아니지만 사용 된 BeanDefinitionRegistry가 인터페이스 EnvironmentCapable
을 구현하지 않기 때문에 여기 Spring App-Context Bootstrapping에 대한 이해가 끝나고 있습니다
아무도 나를 도와 줄 수 없습니까? 거기에 내 재산 자리 표시자를 사용하는 Environment
인스턴스를 제공 할 수있는 BeanDefinitionRegistry가 있습니까?
도움이 매우 감사합니다 !! 너를 위해 쿠키가있어! :-))
이 건배, 스테판