yy.properties内容
yy.open.appid=yy123
yy.open.secret=yymm1111
YyCons.java内容
import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
@Component
@PropertySource(“classpath:yy.properties”)
@ConfigurationProperties(prefix = “yy.open”)
@Data
public class YyCons implements InitializingBean {
private String appid;
private String secret;
public static String yy_appid;
public static String yy_secret;
@Override
public void afterPropertiesSet() throws Exception {
yy_appid=appid;
yy_secret=secret;
System.out.println("appid:==="+appid);
}
}
调用
System.out.println(“=====appid:”+ YyCons.yy_appid);