Git Product home page Git Product logo

Comments (6)

zhaohaoyun avatar zhaohaoyun commented on July 3, 2024 2

问题的原因是加载模板目录方法错误,setDirectoryForTemplateLoading在IDE运行没问题,但是打包发布以后没办法从jar包直接加载文件路径
正确解决方法:
cfg.setDirectoryForTemplateLoading(new File("src/main/resources/templates"));
修改为
cfg.setClassForTemplateLoading(this.getClass(),"templates");

项目中只要修改两个地方
com.yupi.sqlfather.config.FreeMarkerConfigurationConfig
com.yupi.sqlfather.FreeMarkerTest

from sql-father-backend-public.

KweilinFang avatar KweilinFang commented on July 3, 2024

w我也是遇见这样的问题,是哪个路径的问题,具体我也不知道怎么解决

from sql-father-backend-public.

KweilinFang avatar KweilinFang commented on July 3, 2024

from sql-father-backend-public.

Bemege avatar Bemege commented on July 3, 2024

按照你的方式修改完之后似乎还是不太行 报错内容: Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2022-11-02 15:25:24.203 ERROR 19852 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   :  *************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class Action: Consider the following: If you want an embedded database (H2, HSQL or Derby), please put it on the classpath. If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

------------------ 原始邮件 ------------------ 发件人: "liyupi/sql-father-backend-public" @.>; 发送时间: 2022年11月2日(星期三) 中午1:56 @.>; @.@.>; 主题: Re: [liyupi/sql-father-backend-public] 请教下各位大佬 (Issue #8) pom.xml添加build静态文件的处理 src/main/resources /.xml /.properties /.ftl — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

我发现了 就算这样改在运行过程中还是会有问题,我现在更换一种读取模板的新方式 目前看来可行 我正在验证

from sql-father-backend-public.

Bemege avatar Bemege commented on July 3, 2024

更换模板读取方式可行,已测试 :

https://sqlfather.xgeek.top/

  1. 删除 com.yupi.sqlfather.config.FreeMarkerConfigurationConfig 文件,不再手动去resources目录下去读取模板

  2. 在 application.yml 中添加配置 freemarker.template-loader-path=classpath:/templates/

  3. 全局搜索 private static Configuration configuration; 修改为 private static FreeMarkerConfigurer freeMarkerConfigurer;

  4. 上一步的静态对象注入的set方法中的对象也要修改
    image

  5. 全局搜索 configuration.getTemplate 替换为 freeMarkerConfigurer.getConfiguration().getTemplate

from sql-father-backend-public.

Bemege avatar Bemege commented on July 3, 2024

按照你的方式修改完之后似乎还是不太行 报错内容: Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2022-11-02 15:25:24.203 ERROR 19852 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   :  *************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class Action: Consider the following: If you want an embedded database (H2, HSQL or Derby), please put it on the classpath. If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

------------------ 原始邮件 ------------------ 发件人: "liyupi/sql-father-backend-public" @.>; 发送时间: 2022年11月2日(星期三) 中午1:56 @.>; @.@.>; 主题: Re: [liyupi/sql-father-backend-public] 请教下各位大佬 (Issue #8) pom.xml添加build静态文件的处理 src/main/resources /.xml /.properties /.ftl — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

我更新了最新方法 可以参考一下

from sql-father-backend-public.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.