项目一启动方法就运行
Spring容器加载bean,postConstruct就运行了
类加@Commoent 方法加@PostConstruct
@Commoent
public class Constant {
@PostConstruct
public void test(){
System.out.println("项目启动就运行了呃呃呃呃呃呃呃呃呃呃呃呃呃呃呃呃呃,因为spring容器注册bean");
}
}
一使用对象就有map
代码块
public class Constant {
public static String EvaluationInfo = "EvaluationInfo";
public static String WholeDepartment = "WholeDepartment";
public static Map<Integer, String> REVIEW_MAP;
static {
System.out.println("Constant运行了啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊");
REVIEW_MAP = new HashMap<Integer, String>();
REVIEW_MAP.put(0, EvaluationInfo);
REVIEW_MAP.put(5, WholeDepartment);
}
}