我创建了一个像这样的 JpaRepository:
package com.app.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;
import com.app.entity.SampleEntity;
@Repository
@RepositoryRestResource(collectionResourceRel = "exposed-uri",
path = "exposed-uri")
public interface SampleEntityRepository
extends JpaRepository<SampleEntityRepository, Integer> {
}
我的实体是这样的:
@Entity
@Table(name = "SAMPLETABLE")
public class SampleEntity {
@Id
@Column(name = "ID")
private Integer id;
@Column(name = "OTHER")
private String otherField;
@Column(name = "DESCRIPTION")
private String description;
//Some non-relevant boilerplate
}
我的问题是,我不明白可能的原因,...有时资源对客户端应用程序不可用,收到 404 错误状态,就像暴露的存储库 REST 资源没有运行一样。在应用程序的 @RestController 类中声明的其他类仍然可以访问并正常工作。
在这种情况下,我的解决方法是重新启动 SpringBoot 应用程序,但显然这对我们的客户来说是不可接受的。
是否有人在无需重构您的 REST 服务以停止使用从 JpaRepositories 公开的服务的情况下遇到此问题?有什么想法吗?谢谢!