본문 바로가기
Spring Boot/error

java.lang.IllegalStateException: Failed to load ApplicationContext

by 상국이 2022. 2. 5.
728x90

java.lang.IllegalStateException: Failed to load ApplicationContext

...

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springRunner': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'my.age' in value "${my.age}"

java.lang.IllegalStateException: Failed to load ApplicationContext

	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
	at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
	//중략
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springRunner': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'my.age' in value "${my.age}"
	//중략

 원인

 : (test/resources/application.properties를 따로 정의하는 경우) src/main/resources/application.properties에 해당 키값을 정의해두고, test/resources/application.properties에는 정의하지 않는경우 해당 오류 발생

 

해결방법

 : 두 application.properties에 동일하게 정의 혹은 test/resources/application.properties 삭제

728x90

댓글