In a simple example of CommandLineRunner from within the main method of a Spring Boot Application class.
Trying to understand the effect/meaning of return args-> lambda function in the run method. The method should return the instance of the CommandLineRunner.
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}
@Bean
public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
// what happens here? What is the equivalent Java 7 return statement?
return args -> {
System.out.println("run is working");
};
}
Look into "functional interface", added in Java 8. CommandLineRunner is one. That code is equivalent to returning an anonymous class.