ConfigurationProperties 사용

894 단어 springbootspring
application.yml
my:
  name: 170
  port: 12000
  username: root
  servers:
    - localhost
    - www.kq.com
  map:
      "[/key1]": value1
      "[/key2]": value2
      /key3: value3
      name: king

MyConfiguration

/**
 * MyConfiguration
 *  application.yml   my  
 * @author kq
 */
@Data
@Component
@ConfigurationProperties("my")
public class MyConfiguration {

    private String name;
    private String username;
    private Integer port;

    private List servers;

    private Map map;

}

 
쓰다
@Autowired
MyConfiguration myConfiguration;

 인쇄 하 다.
MyConfiguration(name=170, username=root, port=12000, servers=[localhost, www.kq.com], map={/key1=value1, /key2=value2, key3=value3, name=king})

 
 

좋은 웹페이지 즐겨찾기