I'm trying to pass in a value to be autowired from a custom configuration file in Spring boot. Below are code snippets:
Spring class
@Configuration
public class MyConfig {
@Value("${BOOTSTRAP_SERVERS}")
private String bootstrapServers;
myfile.yaml
BOOTSTRAP_SERVERS:
10.0.0.12:9092
Execution command
java -jar app.jar --spring.config.location=/file/path/myfile.yaml
However when I type the above command I'm getting this error:
java.lang.IllegalArgumentException: Could not resolve placeholder 'BOOTSTRAP_SERVERS' in value "${BOOTSTRAP_SERVERS}"
What am I missing here in order to get this to work? I intend to mount the app in kubernetes so I need to be able to externalize my configuration. Thanks in advance.