[英]Spring Boot Freemarker fails from 2.2.0 upgrade
将 spring-boot-parent 升级到2.2.0.RELEASE
,我基于 freemarker 的 Spring Boot Web 应用程序无法正确处理请求。
我有一个@Controller
服务/hello
与src/main/resources/templates/hello.ftl
。
@Controller
class HelloController() {
@RequestMapping(value = ["/hello"])
fun hello(): String {
return "hello"
}
}
根据要求,它只出现在错误页面上,显示There was an unexpected error (type=Not Found, status=404).
.
错误堆栈跟踪并没有说太多。 它只是说org.springframework.web.servlet.resource.ResourceHttpRequestHandler: Resource not found
。
我的pom.xml
基本如下:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.RELEASE</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
</dependencies>
在升级到 Spring Boot 2.2.0.RELEASE 之前,它工作得非常好。
这里有什么问题?
我也花了一天时间试图弄清楚这一点。 想知道为什么在遵循代码示例时代码不起作用。
它在我降级到 Spring Boot 2.1.9 后才起作用,并且仅在搜索与 2.2.0 相关的问题时才找到此答案。
如果 Spring 至少检查并在发生这样的重大变化时抛出有意义的异常或警告,那就太好了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.