@Component
public class Configure {
// appid
private static String appId = "wxbexxxxxxx";//
// @Value("${wx.app.id}")
@Value("#{configProperties['wx.app.id']}")
public void setAppId(String appId) {
Configure.appId = appId;
}
}
对于static变量
只能在setAppId方法上加注解,另外class需要加 @Component等注解,这样spring才能扫描到
<context:component-scan base-package="com.coffee.app" />
还需要注意的一点是 包扫描要加载spring-mvc.xml中而不是applicationContext.xml