Optimize startup speed

This commit is contained in:
JiaJu Zhuang
2023-07-30 11:20:55 +08:00
parent 4782c6745d
commit 25d789ba73

View File

@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.MessageSource;
import org.springframework.context.NoSuchMessageException;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
@ -18,8 +19,9 @@ import org.springframework.stereotype.Component;
*/
@Slf4j
@Component
@Lazy(value = false)
public class I18nUtils implements InitializingBean {
public static final String DEFAULT_message_Code="common.systemError";
public static final String DEFAULT_MESSAGE_CODE="common.systemError";
@Resource
private MessageSource messageSource;
private static MessageSource messageSourceStatic;
@ -34,7 +36,7 @@ public class I18nUtils implements InitializingBean {
} catch (NoSuchMessageException e) {
log.error("no message.", e);
}
return messageSourceStatic.getMessage(DEFAULT_message_Code, args, LocaleContextHolder.getLocale());
return messageSourceStatic.getMessage(DEFAULT_MESSAGE_CODE, args, LocaleContextHolder.getLocale());
}
/**