春季启动:对其进行配置以查找webapp文件夹 [英] Spring boot: configure it to find the webapp folder

查看:98
本文介绍了春季启动:对其进行配置以查找webapp文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,Spring Boot在我的src/main/webapp文件夹中查找我的html文件.如果我使用另一个文件夹放置html文件,在哪里可以更改Spring Boot的设置?

By default, Spring Boot looks in my src/main/webapp folder to find my html files. Where can I change the settings for Spring Boot if I use another folder to put the html files?

稍后,文件将被包装在jar中以进行部署.我还有其他需要担心的事情吗?

Later, the files will be wrapped in jars for deployment. Are there other things I need to worry about?

推荐答案

查看文档: /static/public/resources/META-INF/resources

如果将应用程序打包为JAR(部署.jar),则不建议使用src/main/webapp.

If you are packaging your application as a JAR (deploying a .jar), using src/main/webapp is not recommended.

您可以通过覆盖WebMvcConfigurerAdapter

    @Configuration
    public class MvcConfig extends WebMvcConfigurerAdapter {
        @Override
        public void addResourceHandlers(ResourceHandlerRegistry registry){
             registry.addResourceHandler("/**")
                .addResourceLocations("/")
                .setCachePeriod(0);
        }
    }

这篇关于春季启动:对其进行配置以查找webapp文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆