我在Spring中使用freemarker。無法解析模板加載器路徑Freemarker
這是我配置我的freemarker方式:
<bean id="freemarkerConfiguration" class="org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean">
<property name="templateLoaderPath" value="classpath:/META-INF/templates"/>
</bean>
這種結構實際上是工作的罰款,我能夠使用模板來生成我的報告等
但是在WebLogic中,我總是得到這個例外:
15 Sep 2012 01:03:02,060 DEBUG DefaultListableBeanFactory.doCreateBean:504 - Eagerly caching bean 'freemarkerConfiguration' to allow for resolving potential circular references
15 Sep 2012 01:03:02,074 DEBUG DefaultListableBeanFactory.invokeInitMethods:1498 - Invoking afterPropertiesSet() on bean with name 'freemarkerConfiguration'
15 Sep 2012 01:03:02,228 DEBUG FreeMarkerConfigurationFactoryBean.getTemplateLoaderForPath:360 - Cannot resolve template loader path [classpath:/META-INF/templates] to [java.io.File]: using SpringTemplateLoader as fallback
java.io.FileNotFoundException: class path resource [META-INF/templates] cannot be resolved to absolute file path because it does not reside in the file system: zip:C:/Oracle/Middleware/user_projects/domains/gppuser/servers/GPPFilesBCSIS/tmp/_WL_user/GPPFilesBCSIS/phxni8/war/WEB-INF/lib/_wl_cls_gen.jar!/META-INF/templates
at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:204)
at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:52)
at org.springframework.ui.freemarker.FreeMarkerConfigurationFactory.getTemplateLoaderForPath(FreeMarkerConfigurationFactory.java:351)
at org.springframework.ui.freemarker.FreeMarkerConfigurationFactory.createConfiguration(FreeMarkerConfigurationFactory.java:304)
at org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean.afterPropertiesSet(FreeMarkerConfigurationFactoryBean.java:60)
這個錯誤實際上是在加載過程中發生的。任何人都知道如何解決和刪除這個異常?該文件實際上仍然使用提供的模板生成,所以我不確定這個錯誤是什麼。
對於您的信息:我沒有使用爆炸部署。
但模板目錄在我的war文件中(並且也直接在war文件中訪問) – Rudy
是的。這就是爲什麼Spring的'Resource'機制被用來代替'File',正如我上面所解釋的那樣。再次,這是正常的。它只是一個調試消息,而不是錯誤消息。 (除非確實在調試,否則不應該存儲調試級別的消息。)或者這有什麼問題? – ddekany