spring-boot Version: spring-boot-starter-parent 2.1.8.RELEASE & spring-boot-starter-parent 2.6.6 Java Version: 1.8.0_212 OS Version: macOS 11.6.7 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36
Step1: write a key-value pair in the application.yaml which the key contains the word "no"
neo:
test:
no:
value: true123
Step2: use @Value (import org.springframework.beans.factory.annotation.Value;)
@Value("${neo.test.no.value}")
String noValue;
Step3: print the value
@GetMapping("/test/no")
public String testNo() {
log.info("noValue: {}", noValue);
}
Step4: try to start the project then failed here is the error log:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'neo.test.no.value' in value "${neo.test.no.value}"
Finally, I wrote the same conf (neo.test.no.value = true123) into the application.properties, It can successfully start.
Comment From: philwebb
You're probably hitting the Norway problem. Try the following:
neo:
test:
"no":
value: true123
Comment From: philwebb
Please let us know if that fixes things.
Comment From: ilobos
Thx, it works.
"no" 'no' even \no , can successfully start the project.