http://www.cnblogs.com/dragonfei/archive/2016/10/09/5906474.html

********************************************

1.简单示例:

SpringBoot中的的配置简单属性类支持ConfigurationProperties方式,看一个简单的示例。

Spring 配置解析之Properties
 1 @ConfigurationProperties(prefix = "org.dragonfei.demo")
 2 public class DemoProperties {
 3     private String name;
 4     private String password;
 5     private String test;
 6 
 7     public String getName() {
 8         return name;
 9     }
10 
11     public void setName(String name) {
12         this.name = name;
13     }
14 
15     public String getPassword() {
16         return password;
17     }
18 
19     public void setPassword(String password) {
20         this.password = password;
21     }
22 
23     public String getTest() {
24         return test;
25     }
26 
27     public void setTest(String test) {
28         this.test = test;
29     }
30 
31     @Override
32     public String toString() {
33         return "DemoProperties{" +
34                 "name='" + name + '\'' +
35                 ", password='" + password + '\'' +
36                 ", test='" + test + '\'' +
37                 '}';
38     }
39 }
Spring 配置解析之Properties
1 org.dragonfei.demo.name=dragonfei
2 org.dragonfei.demo.password=password
3 org.dragonfei.demo.test=test

相关文章:

  • 2021-05-25
  • 2021-05-23
  • 2022-02-09
  • 2022-01-26
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-13
  • 2022-01-07
相关资源
相似解决方案