SpringBootApplication failed to load properties from application.yml file

Viewed 10761

Configuration class,

@Configuration
public class SpringContext {
@Bean
public BlockingQueue<String> queue(@Value("${queue.size}") int queueSize) {
    return new LinkedBlockingQueue<>();
   }
}

Main class,

@SpringBootApplication
public class SpringContextTest {

    public static void main(String[] args) {
        final SpringApplication springApplication = new SpringApplication(SpringContext.class);
        springApplication.setWebEnvironment(false);
        springApplication.run();
        System.out.println("queue.size" + System.getProperty("queue.size"));
    }

}

application.yml,

queue.size: 10

While starting the main class I'm getting the following error,

Caused by: java.lang.NumberFormatException: For input string: "${queue.size}"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[na:1.8.0_144]

I'm I missing some annotations ?, In my understanding I've used the minimal annotations required for a spring boot application. I have seen some similar posts but didn't helped. Also tried with --spring.config.location.

My Spring starter version: 1.3.6.RELEASE

3 Answers
Related