spring boot 在jdk 1.7下使用 commandLineRunner

在spring boot 中有一段代码,使用的是java 1.8的语法:

    @Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
return args -> { System.out.println("Let's inspect the beans provided by Spring Boot:"); String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
System.out.println(beanName);
} };
}

在java 1.7下要如何使用呢?

    @Bean
public CommandLineRunner commandLineRunner(final ApplicationContext ctx) {
return new CommandLineRunner() {
public void run(String[] args) {
System.out.println("Let's inspect the beans provided by Spring Boot:");
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
System.out.println(beanName);
}
}
};
}
上一篇:spring实现一对多表单的保存


下一篇:DirectX11 With Windows SDK--00 目录