# init加載使用
一般建議創建init類,使用@Init注解可在程序運行時直接先運行init類。再在方法名添加@Init注解;如類名未添加@Init注解則方法添加@init注解也不起作用;
@Value注解是從配置文件讀取值的用法
也可使用 App.getAppProperties("a")封裝的方法調用
application.yml配置文件添加。注意添加時格式
```
app:
a: 1
b: 2
```
<a name="123" id="shili"/>`示例`</a>
```java
@Init
public class Runsinit {
@Value("${app.a}")
String token;
@Init
public void sms(){
String a = App.getAppProperties("a");
System.out.println("展示sms配置啦");
System.out.println("展示sms配置"+a);
System.out.println("token"+token);
}
}
```
運行結果:
```java
展示sms配置啦
展示sms配置1
token1
```