SpringBoot报错: Error creating bean with name freeMarkerConfigurer defined in class path resource
程序员文章站
2022-05-19 10:01:23
...
今天写代码没有看黄历,加了点代码,项目运行不起来,项目报错如下所示:
2020-05-25 10:00:03.913 - [ERROR] - [org.springframework.boot.SpringApplication:reportFailure:858] - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'freeMarkerConfigurer' defined in class path resource [org/springframework/boot/autoconfigure/freemarker/FreeMarkerServletWebConfiguration.class]: Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at com.yueniu.yngp.YngpServer.main(YngpServer.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ExceptionInInitializerError: null
at org.springframework.ui.freemarker.FreeMarkerConfigurationFactory.newConfiguration(FreeMarkerConfigurationFactory.java:327)
at org.springframework.ui.freemarker.FreeMarkerConfigurationFactory.createConfiguration(FreeMarkerConfigurationFactory.java:257)
度娘发现都是说jar包版本过低,需要升级freemaker的版本。可是我已经是比较高的版本。看来问题不是出在这里。然后使用谷歌搜索,发现:
解决方案有两个:
1:在配置文件中,设置:spring.freemarker.check-template-location=false
可是我并不是使用freemaker做页面处理的。所以这种解决方案pass掉。
2:在自动注解中过滤到freemakerConfiguration这个类就可以。
具体解决:在你的spring boot启动类中添加:
@EnableAutoConfiguration(exclude = { FreeMarkerAutoConfiguration.class })
即可。这样就过滤掉了。
重启启动项目,正常访问了。
总结:
这个问题主要是因为spring boot的@EnableAutoConfiguration注解引起的。
这是我得微信公众号:程序猿微刊 更多文章请关注微信公众号
上一篇: 审计练习14——[网鼎杯 2018]Comment
下一篇: 【SSH】Error creating bean with name 'sessionFactory' defined in class path resource [applicationConte
推荐阅读
-
Error creating bean with name 'entityManagerFactory' defined in class path resource解决方案
-
Spring Boot 报错:Error creating bean with name 'entityManagerFactory' defined in class path resource
-
Error creating bean with name 'entityManagerFactory' defined in class path resource解决方案
-
Error creating bean with name 'sqlSessionFactory' defined in class path resource [config/spring/applicationContext.xml]: Invocation of init me
-
Spring Cloud中遇到的Error creating bean with name 'hystrixCommandAspect' defined in class path resource
-
【SpringBoot】----- Error creating bean with name 'entityManagerFactory' defined in class path resourc
-
error creating bean with name sqlSessionFactory defined in class path resource spring/spring-mvc
-
Error creating bean with name 'entityManagerFactory' defined in class path resource解决方案
-
遇到Error creating bean with name 'flywayInitializer' defined in class path resource解决办法
-
【J】BeanCreationException: Error creating bean with name 'shiroFilter' defined in class path resource