나는 그런 봄 부팅 테스트가 있습니다SpringApplicationConfiguration에서 설정 클래스를 선언하는 순서. 봄 부팅
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {
PropertyConfig.class,
ServiceConfigA.class,
ServiceConfigB.class}
)
public class SpringTest {
@Test
public void test() {
...
}
}
때 PropertyConfig
내부 콩을 무시하고 서비스 CONFIGS에서 콩 일부 필드를 autowire하기 수 없기 때문에 나는 컨텍스트 초기화 오류 클래스의 목록에 첫 번째 선언 PropertyConfig
클래스입니다. 내가 PropertyConfig
일부 serivce 구성 후 이동 후 PropertyConfig
안의 콩을 초기화했습니다.
PropertyConfig
에는 PropertiesFactoryBean
및 PropertySourcesPlaceholderConfigurer
두 개의 빈이 포함되어 있습니다. 원인이 PropertySourcesPlaceholderConfigurer
에 존재하지 않습니다. 서비스 구성의 bean이 @Value
주석이있는 자동 추가 필드를 사용할 수 없습니다 (자동으로 String에서 Integer로 변환 할 수 없음).
내 질문에 왜 PropertyConfig
콩은 첫 번째 경우 초기화되지 않습니다? 스프링 부트 테스트에서 설정로드의 일부 기능이 있습니까?
'PropertySourcesPlaceholderConfigurer' 빈을'static'으로 만들 수 있도록 조언 해 주시겠습니까? –