我有一个解决这个问题的方法,但我想发布这个以防其他人遇到这个问题。
我们有一个 Spring Boot Web 应用程序,它被打包为一个 war 文件并部署到 Tomcat。它有几个用@RepositoryRestResource 注释的PagingAndSortingRepository 类来处理rest 请求,还有一些用@RestController 注释的其他类。RestController 类确实对存储库类进行了一些调用。
通过 spring-boot 的 2.2.5.RELEASE 版本,一切正常。升级到 2.2.6.RELEASE 后我们遇到了问题。一切都很好(意味着可以访问两种类型的休息资源)但是在运行大约 10-15 分钟后,通过 RepositoryRestResource 访问的所有内容都开始返回 404 错误。任何日志中都没有错误消息,他们在之前工作正常时才开始返回 404 错误。RestControllers 一直工作正常。恢复到 2.2.5.RELEASE 后,我们没有更多问题。
由于我们使用了dependencyManagement,我认为这不是版本不匹配的问题。pom.xml 文件中的所有 spring 工件都没有版本。这是pom中的内容:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.5.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)