常量的使用方式

@Component
public class ServiceEnvConstants {

	/** 公钥-从详情页面获取 */
	public static String publicKey;
	@Value("${public_key}")
	public void setPublicKey(String publicKey) {
		ServiceEnvConstants.publicKey = publicKey;
	}

	/** 字符编码-传递给数据编码 */
	public static final String CHARSET = "UTF-8";

	
}

 Spring在初始化有几种方式,注意初始化先后顺序

posted @ 2018-12-14 17:57  一心行走  阅读(390)  评论(0编辑  收藏  举报