springboot跳转错误页面

问题遇到的现象和发生背景

在学习springboot的时,官网说可以在templates下配置错误页面,当发生错误时会默认跳转,配置如下

img

当我去访问一个并不存在的访问路径时,报的是404错误,springboot并没有为我跳到配置的错误页面

img

img

这是为啥呢?

没有使用模板引擎情况下,异常页面放在static目录下。
放入templates下则引入依赖

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