一
@Component public class ServletContextInit implements ServletContextAware { @Override public void setServletContext(ServletContext servletContext) { TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai"); TimeZone.setDefault(tz); //初始化 try { } catch (Exception e) { e.printStackTrace(); } } }
二
@Slf4j @Component public class InitApplicationRunner implements ApplicationRunner { @Override public void run(ApplicationArguments applicationArguments) { log.info("-------------->" + "初始化开始,now=" + new Date()); TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai"); TimeZone.setDefault(tz); initCache(); log.info("-------------->" + "初始化结束,now=" + new Date()); } private void initCache() { try { //初始化缓存、内存 } catch (Exception e) { log.error("初始化失败!", e); } } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)