首页  

springboot2 FileEncodingApplicationListener简介     所属分类 springboot 浏览量 942
spring-boot-2.0.0.RELEASE.jar
/META-INF/spring.factories



# Application Listeners
org.springframework.context.ApplicationListener=\
org.springframework.boot.ClearCachesApplicationListener,\
org.springframework.boot.builder.ParentContextCloserApplicationListener,\
org.springframework.boot.context.FileEncodingApplicationListener,\
org.springframework.boot.context.config.AnsiOutputApplicationListener,\
org.springframework.boot.context.config.ConfigFileApplicationListener,\
org.springframework.boot.context.config.DelegatingApplicationListener,\
org.springframework.boot.context.logging.ClasspathLoggingApplicationListener,\
org.springframework.boot.context.logging.LoggingApplicationListener,\
org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener

检查 file-encoding 是否匹配
spring.mandatory-file-encoding
mandatory 强制的
spring.mandatory-file-encoding=xxx


@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
		ConfigurableEnvironment environment = event.getEnvironment();
		// 没有配置则返回
		if (!environment.containsProperty("spring.mandatory-file-encoding")) {
			return;
		}
		String encoding = System.getProperty("file.encoding");
		String desired = environment.getProperty("spring.mandatory-file-encoding");
		
		if (encoding != null && !desired.equalsIgnoreCase(encoding)) {
			logger.error("System property 'file.encoding' is currently '" + encoding
					+ "'. It should be '" + desired
					+ "' (as defined in 'spring.mandatoryFileEncoding').");
			logger.error("Environment variable LANG is '" + System.getenv("LANG")
					+ "'. You could use a locale setting that matches encoding='"
					+ desired + "'.");
			logger.error("Environment variable LC_ALL is '" + System.getenv("LC_ALL")
					+ "'. You could use a locale setting that matches encoding='"
					+ desired + "'.");
			throw new IllegalStateException(
					"The Java Virtual Machine has not been configured to use the "
							+ "desired default character encoding (" + desired + ").");
		}
}
	
	

Thread [main] (Suspended (breakpoint at line 60 in FileEncodingApplicationListener)) FileEncodingApplicationListener.onApplicationEvent(ApplicationEnvironmentPreparedEvent) line: 60 FileEncodingApplicationListener.onApplicationEvent(ApplicationEvent) line: 47 SimpleApplicationEventMulticaster.doInvokeListener(ApplicationListener, ApplicationEvent) line: 172 SimpleApplicationEventMulticaster.invokeListener(ApplicationListener, ApplicationEvent) line: 165 SimpleApplicationEventMulticaster.multicastEvent(ApplicationEvent, ResolvableType) line: 139 SimpleApplicationEventMulticaster.multicastEvent(ApplicationEvent) line: 127 EventPublishingRunListener.environmentPrepared(ConfigurableEnvironment) line: 74 SpringApplicationRunListeners.environmentPrepared(ConfigurableEnvironment) line: 54 SpringApplication.prepareEnvironment(SpringApplicationRunListeners, ApplicationArguments) line: 351 SpringApplication.run(String...) line: 317 DemoApp.main(String[]) line: 98

上一篇     下一篇
java死锁实例

SpringBoot启动过程简介

Springboot2 Tomcat自定义配置

maven jar包冲突处理

aerospike 某客户 stop-write 实例

aerospike 最大 TTL 限制