SpringBoot找不到html资源的原因

SpringBoot在写完Controller之后直接启动访问,但是找不到相对应的页面资源,报404错误。

我的Controller编写没有错误,html文件也放在了templates文件夹下,但是为什么找不到资源呢?

我发现我导入的thymeleaf包不对,请不要导入Maven库下的thymeleaf包,在SpringBoot中是不会自动配置的。你要导入的是这个包。

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>    

导入这个包后,启动,访问正常。

posted @ 2019-10-15 18:26  雨溅残冰  阅读(3144)  评论(3编辑  收藏  举报