首页>代码>spring boot通过@ConfigurationProperties注解实现加载application.properties配置,支持多层嵌套语法>/springboot-nested-properties-file/src/main/java/com/hellokoding/util/Application.java
package com.hellokoding.util; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @Slf4j @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Bean public CommandLineRunner runner(SimpleProperties simpleProperties, NestedProperties nestedProperties, ZuidaimaProperties zuidaimaProperties) { return r -> { log.info(simpleProperties.getA()); log.info(nestedProperties.getA().getB()); log.info("site.domain:{},site.name:{},site.author:{}", zuidaimaProperties.getSite().getDomain(), zuidaimaProperties.getSite().getName(), zuidaimaProperties.getSite().getAuthor()); }; } }