问答详情
源自:6-1 SpringBoot 整合freemarker

freemarker页面启动无法访问

2018-12-09 15:01:40.575  WARN 9784 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'viewResolver' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration$FreeMarkerWebConfiguration': Unsatisfied dependency expressed through field 'properties': Error creating bean with name 'spring.freemarker-org.springframework.boot.autoconfigure.freemarker.FreeMarkerProperties': Could not bind properties to FreeMarkerProperties (prefix=spring.freemarker, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is org.springframework.validation.BindException: org.springframework.boot.bind.RelaxedDataBinder$RelaxedBeanPropertyBindingResult: 1 errors

Field error in object 'spring.freemarker' on field 'charset': rejected value [UTF-8 ]; codes [typeMismatch.spring.freemarker.charset,typeMismatch.charset,typeMismatch.java.nio.charset.Charset,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.freemarker.charset,charset]; arguments []; default message [charset]]; default message [Failed to convert property value of type [java.lang.String] to required type [java.nio.charset.Charset] for property 'charset'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.nio.charset.Charset]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.freemarker-org.springframework.boot.autoconfigure.freemarker.FreeMarkerProperties': Could not bind properties to FreeMarkerProperties (prefix=spring.freemarker, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is org.springframework.validation.BindException: org.springframework.boot.bind.RelaxedDataBinder$RelaxedBeanPropertyBindingResult: 1 errors

Field error in object 'spring.freemarker' on field 'charset': rejected value [UTF-8 ]; codes [typeMismatch.spring.freemarker.charset,typeMismatch.charset,typeMismatch.java.nio.charset.Charset,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.freemarker.charset,charset]; arguments []; default message [charset]]; default message [Failed to convert property value of type [java.lang.String] to required type [java.nio.charset.Charset] for property 'charset'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.nio.charset.Charset]]

2018-12-09 15:01:40.585  INFO 9784 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service Tomcat

2018-12-09 15:01:40.608  INFO 9784 --- [  restartedMain] utoConfigurationReportLoggingInitializer : 


Error starting ApplicationContext. To display the auto-configuration report enable debug logging (start with --debug)



2018-12-09 15:01:40.625 ERROR 9784 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 


***************************

APPLICATION FAILED TO START

***************************


提问者:慕无忌2832284 2018-12-09 15:02

个回答

  • 殷浩
    2019-03-03 00:09:27

    报错信息里面已经说了,是在配置spring.freemarker的charset属性出错了,无法将UTF-8进行转换,但是属性和值应该都没问题,你检查一下你的UTF-8后面是不是有个空格,多了这个空格,就会导致无法识别编码,properties文件的=后面的值,前面可以加空格,但是后面千万不能乱加空格

  • 慕村5257649
    2018-12-10 17:25:33

    是不是在application.properties里面的配置有误