내 응용 프로그램에서 SpringBoot 및 Spring 일괄 처리 (및 관리) 프레임 워크를 사용하고 있습니다. 또한 필요한 모든 속성을 저장하기 위해 application.yaml 파일을 사용하고 있습니다. Properties와 관련된 문제가 발생했습니다. ignoreUnresolvablePlaceholders
이 false
으로 설정된 SpringBatchAdmin에서 생성 된 PropertyPlaceholderConfigurer
bean이 있기 때문입니다. 여기서 상기 빈은 다음과 같습니다Spring PropertyPlaceholderConfigurer 속성 플래그가있는 IllegalArgumentException
<bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:/org/springframework/batch/admin/bootstrap/batch.properties</value>
<value>classpath:batch-default.properties</value>
<value>classpath:batch-${ENVIRONMENT:hsql}.properties</value>
</list>
</property>
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreResourceNotFound" value="true" />
<property name="ignoreUnresolvablePlaceholders" value="false" />
<property name="order" value="1" />
</bean>
내 문제는 현재 @Value
주석을 사용하여 페치의 모든 속성을 읽을이 3 개 파일 검색을 봄이다. 그래서 어떤 일이 발생합니까? 나는 SpringBatchAdmin에서 생성 된 PropertyPlaceholderConfigurer
bean에 선언 된 3 개의 파일 중 하나에 이러한 속성을 넣도록 Spring이 자신의 Properties 및 Spring을 선언 한 다른 종속성을 가지고 있습니다.
따라서, 예를 들어, 다음 클래스/빈 :
batch.properties
batch-default.properties
batch-sqlserver.properties
및 재산 find.me
이 이들 중 하나가 아닌 경우 :
@Component
public class Example{
@Value("${find.me}")
private String findMe;
...
}
는 다음과 같은 3 개 개의 파일에보고해야합니다 파일의 경우 다음 예외가 발생합니다.
java.lang.IllegalArgumentException: Could not resolve placeholder 'find.me' in string value "${find.me}"
문제는 yaml이나 Spring에서 "find.me"속성을 찾지 못했기 때문에, 이라는 SpringBatchAdmin을 사용하지 않으면 "find.me"속성이 실제로 내 application.yaml
파일에 있습니다.
또한 외부 소스 (광산이 아닌, SpringBatchAdmin)에서 가져온 질문이므로 PropertyPlaceholderConfigurer
을 수정할 수 없습니다.
어떻게 해결할 수 있습니까?