java.io.FileNotFoundException: class path resource [templates/] spring-cloud-netflix-eureka-server
来源:互联网 发布:webuploader php demo 编辑:程序博客网 时间:2024/06/04 20:05
用main方法启动spring cloud eureka server工程的时候,报如下错误:
java.io.FileNotFoundException: class path resource [templates/] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/cloud/spring-cloud-netflix-eureka-server/1.3.5.RELEASE/spring-cloud-netflix-eureka-server-1.3.5.RELEASE.jar!/templates/ at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:215) ~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:53) ~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.ui.freemarker.FreeMarkerConfigurationFactory.getTemplateLoaderForPath(FreeMarkerConfigurationFactory.java:338) [spring-context-support-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.ui.freemarker.FreeMarkerConfigurationFactory.createConfiguration(FreeMarkerConfigurationFactory.java:290) [spring-context-support-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer.afterPropertiesSet(FreeMarkerConfigurer.java:116) [spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) [spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) [spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) [spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) [spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) [spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) [spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) [spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE] at com.xxx.SpringCloudEurekaServerApplication.main(SpringCloudEurekaServerApplication.java:19) [classes/:na]
如何解决?
后来发现调查发现spring-context-support这个jar包里的这个类:FreeMarkerConfigurationFactory.java下面有这样一段代码:
protected TemplateLoader getTemplateLoaderForPath(String templateLoaderPath) { if(this.isPreferFileSystemAccess()) { try { Resource ex = this.getResourceLoader().getResource(templateLoaderPath); File file = ex.getFile(); if(this.logger.isDebugEnabled()) { this.logger.debug("Template loader path [" + ex + "] resolved to file path [" + file.getAbsolutePath() + "]"); } return new FileTemplateLoader(file); } catch (Exception var4) { if(this.logger.isDebugEnabled()) { this.logger.debug("Cannot resolve template loader path [" + templateLoaderPath + "] to [java.io.File]: using SpringTemplateLoader as fallback", var4); } return new SpringTemplateLoader(this.getResourceLoader(), templateLoaderPath); } } else { this.logger.debug("File system access not preferred: using SpringTemplateLoader"); return new SpringTemplateLoader(this.getResourceLoader(), templateLoaderPath); } }
通过这段代码知道,也就是在debug模式下,会打印这个exception,于是把application.properties中的debug注释掉:
#debug=true#logging.level.org.springframework.web=DEBUG#logging.level.com.picahealth.cloud=DEBUG
把debug模式注释掉,上面的错误就不会打印出来了!
阅读全文
0 0
- java.io.FileNotFoundException: class path resource [templates/] spring-cloud-netflix-eureka-server
- nested exception is java.io.FileNotFoundException: class path resource [spring/spring-datasource-mog
- Spring Cloud Netflix Eureka
- java.io.FileNotFoundException: class path resource [spring.xml] cannot be opened because it does not
- [SSM/Junit]java.io.FileNotFoundException: class path resource [spring-mybatis.xml] cannot be opened
- 异常解决 java.io.FileNotFoundException: class path resource [spring/springmvc.xml]
- 异常解决 java.io.FileNotFoundException: class path resource [spring/applicationContext_*.xml]
- java.io.FileNotFoundException: class path resource [spring/ApplicationCont.xml] cannot be opened be
- 异常解决 java.io.FileNotFoundException: class path resource [spring/applicationContext_*.xml]
- 【Bug解决】Spring配置错误:java.io.FileNotFoundException: class path resource [cxd/entity/User.hbm.xml] canno
- java cxf nested exception is java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-ex
- class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: cla
- nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cann
- java.io.FileNotFoundException: class path resource [META-INF/xfire/services.xml] cannot be opened b
- java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not
- java.io.FileNotFoundException: class path resource [XXXXX.xml] cannot be opened
- java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not
- Caused by: java.io.FileNotFoundException: class path resource [com/ncs/bean/News.hbm.xml] cannot be
- FPN解读
- 以洗衣程序为例讲解自顶向下,逐步求精的结构化程序设计方法
- 网络 TCP/IP和HTTP
- 再提递归
- FZU 2027
- java.io.FileNotFoundException: class path resource [templates/] spring-cloud-netflix-eureka-server
- 一个简单的DGA(Domain Generate Algorithm)
- STL(二)vector 动态数组
- shell脚本批量操作用户
- fastjson中JSON语句与map转换(结合List与JSONObject)
- FZU 2028
- 【Codevs1078】最小生成树 Prim算法(5/1000)
- Druid集成Kerberos
- 如何在Android系统锁屏后使程序继续运行