freemarker mysql 生成bean_spring boot使用freemarker生成静态html—基于springmvc+tomcat切到springboot实战三...

以运行jar的方式启动spring boot,如果要使用freemarker生成静态html(例如书生的首页),怎么访问呢?

首先,生成静态页面的路径获取方式:

@Override

public String getContextPath() {

String contextPath = ClassUtils.getDefaultClassLoader().getResource("").getPath();

return contextPath;

}

@Override

public String getPageBasePath() {

return getContextPath() + File.separator + "templates";

}

其次,application.yml配置template-loader-path

template-loader-path:

- file:./templates/

- classpath:/templates/

最后,打包的时候把application.yml打包到启动jar所在目录

maven-resources-plugin

2.4.1

copy-cms-config

process-resources

copy-resources

${project.build.directory}

src/main/resources

application.yml

true

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值