NutzCN Logo
问答 如果加载jar里面的ftl文件
发布于 1996天前 作者 qq_db201893 1852 次浏览 复制 上一个帖子 下一个帖子
标签:

我将ftl及一些基础类打成了一个java,用maven的方式依赖,结果调用的时候调用不了jar中的ftl文件,找的还是调用方的地址去找ftl文件

2019-07-05 12:10:00,086 [FailProcessor] [WARN] Error@/manage/login :
java.lang.RuntimeException: freemarker.template.TemplateNotFoundException: Template not found for name "/view/template/manage/login/login.ftl".
The name was interpreted by this TemplateLoader: FileTemplateLoader(baseDir="F:\daoboinfo\daobo\源代码\trunk\daobo\db-ebs\target\db-ebs-1.0.0-SNAPSHOT\WEB-INF", canonicalBasePath="F:\daoboinfo\daobo\源代码\trunk\daobo\db-ebs\target\db-ebs-1.0.0-SNAPSHOT\WEB-INF\").
	at org.nutz.lang.Lang.wrapThrow(Lang.java:191) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.plugins.view.freemarker.FreemarkerView.render(FreemarkerView.java:80) ~[nutz-plugins-views-1.r.68-SNAPSHOT.jar:?]
	at org.nutz.mvc.impl.processor.ViewProcessor.process(ViewProcessor.java:66) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at com.ydl.core.mvc.ProcessTimeProcessor.process(ProcessTimeProcessor.java:25) ~[db-base-1.0.0-SNAPSHOT.jar:?]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:33) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:38) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.integration.shiro.NutShiroProcessor.process(NutShiroProcessor.java:126) ~[nutz-integration-shiro-1.r.68-SNAPSHOT.jar:?]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.integration.shiro.NutShiroProcessor.process(NutShiroProcessor.java:126) ~[nutz-integration-shiro-1.r.68-SNAPSHOT.jar:?]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:8.5.40]
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:112) ~[shiro-web-1.4.1.jar:1.4.1]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:8.5.40]
	at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:64) ~[log4j-web-2.11.2.jar:2.11.2]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:470) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:395) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:316) ~[catalina.jar:8.5.40]
	at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:742) ~[jasper.jar:8.5.40]
	at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:712) ~[jasper.jar:8.5.40]
	at org.apache.jsp.index_jsp._jspService(index_jsp.java:114) ~[?:?]
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) ~[jasper.jar:8.5.40]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[servlet-api.jar:?]
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476) ~[jasper.jar:8.5.40]
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386) ~[jasper.jar:8.5.40]
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) ~[jasper.jar:8.5.40]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[servlet-api.jar:?]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:8.5.40]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-websocket.jar:8.5.40]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:8.5.40]
	at org.nutz.mvc.NutFilter.nextChain(NutFilter.java:230) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:205) ~[nutz-1.r.68-SNAPSHOT.jar:1.r.68-SNAPSHOT]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:8.5.40]
	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:124) ~[druid-1.1.16.jar:1.1.16]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:8.5.40]
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) ~[shiro-web-1.4.1.jar:1.4.1]
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) ~[shiro-web-1.4.1.jar:1.4.1]
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) ~[shiro-core-1.4.1.jar:1.4.1]
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) ~[shiro-core-1.4.1.jar:1.4.1]
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387) ~[shiro-core-1.4.1.jar:1.4.1]
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) ~[shiro-web-1.4.1.jar:1.4.1]
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) ~[shiro-web-1.4.1.jar:1.4.1]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:8.5.40]
	at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71) ~[log4j-web-2.11.2.jar:2.11.2]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) ~[catalina.jar:8.5.40]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) ~[catalina.jar:8.5.40]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) ~[catalina.jar:8.5.40]
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660) ~[catalina.jar:8.5.40]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) ~[catalina.jar:8.5.40]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ~[catalina.jar:8.5.40]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798) ~[tomcat-coyote.jar:8.5.40]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) ~[tomcat-coyote.jar:8.5.40]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808) ~[tomcat-coyote.jar:8.5.40]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) ~[tomcat-coyote.jar:8.5.40]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-coyote.jar:8.5.40]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_171]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_171]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-util.jar:8.5.40]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171]
7 回复

这个ftl文件存在在一个jar里面,路径也是对的,就是程序只会在当前module里面找,不会找jar里面的文件

打包成完整的jar(nutzboot:shade)才执行从jar加载模板文件,开发期默认是从文件夹加载(方便修改),如果你这个需求很必要,报个issue吧

我没用nutzboot,只是简单的nutz的maven工程

用freemarker的插件?好像是不能自适应的

就是我把一些ftl文件及一些工具类放到一个jar中,然后把这个jar放到一个maven工程下面依赖,在maven工程里面想直接调用这个jar的ftl文件,但是找不到这个jar的文件

走servlet3标准,在resources(classpath资源目录)下创建META-INF/resources/WEB-INF/pages目录

pages名字谁便起,是你指定的freemarker模板视图目录与pages同级的是web-fragment.xml

我试试,现在是直接放到这个目录下是不可以的

添加回复
请先登陆
回到顶部