java - @RepositoryRestResource 不起作用 Spring boot 2.2.1.RELEASE。运行时发生错误 RegionRepository 必须只包含单个路径段
问题描述
@RepositoryRestResource(path = "/region", collectionResourceRel = "list", excerptProjection = CustomRegion.class)
public interface RegionRepository extends JpaRepository<Region, Integer> {
}
数据休息类
@SpringBootApplication
public class ProfUzApplication {
public static void main(String[] args) {
SpringApplication.run(ProfUzApplication.class, args);
}
}
主跑班
发生的错误
org.springframework.beans.factory.UnsatisfiedDependencyException:在 URL [jar:file:/C:/Users/saidk/.m2/repository/org/springframework/data/spring-data-rest 中定义名称为“repositorySearchController”的 bean 创建错误-webmvc/3.2.1.RELEASE/spring-data-rest-webmvc-3.2.1.RELEASE.jar!/org/springframework/data/rest/webmvc/RepositorySearchController.class]:通过构造函数参数1表示的不满足的依赖关系;嵌套异常是 org.springframework.beans.factory.BeanCreationException:在类路径资源 [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class] 中定义名称为“entityLinks”的 bean 创建时出错:通过工厂方法进行 Bean 实例化失败; 嵌套异常是 org.springframework.beans.BeanInstantiationException: 无法实例化 [org.springframework.data.rest.webmvc. support.RepositoryEntityLinks]:工厂方法“entityLinks”抛出异常;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建类路径资源 [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class] 中定义的名称为“resourceMappings”的 bean 时出错:通过工厂方法进行 Bean 实例化失败; 嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.data.rest.core.mapping.RepositoryResourceMappings]:工厂方法“resourceMappings”抛出异常;嵌套异常是 java.lang.IllegalStateException:为 uz.pdp.prof.repository.RegionRepository 配置的路径/区域必须只包含一个路径段!嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建类路径资源 [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class] 中定义的名称为“resourceMappings”的 bean 时出错:通过工厂方法进行 Bean 实例化失败; 嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.data.rest.core.mapping.RepositoryResourceMappings]:工厂方法“resourceMappings”抛出异常;嵌套异常是 java.lang.IllegalStateException:为 uz.pdp.prof.repository.RegionRepository 配置的路径/区域必须只包含一个路径段!嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建类路径资源 [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class] 中定义的名称为“resourceMappings”的 bean 时出错:通过工厂方法进行 Bean 实例化失败; 嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.data.rest.core.mapping.RepositoryResourceMappings]:工厂方法“resourceMappings”抛出异常;嵌套异常是 java.lang.IllegalStateException:为 uz.pdp.prof.repository.RegionRepository 配置的路径/区域必须只包含一个路径段!在类路径资源 [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class] 中定义:通过工厂方法进行 Bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.data.rest.core.mapping.RepositoryResourceMappings]:工厂方法“resourceMappings”抛出异常;嵌套异常是 java.lang.IllegalStateException:为 uz.pdp.prof.repository.RegionRepository 配置的路径/区域必须只包含一个路径段!在类路径资源 [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class] 中定义:通过工厂方法进行 Bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.data.rest.core.mapping.RepositoryResourceMappings]:工厂方法“resourceMappings”抛出异常;嵌套异常是 java.lang.IllegalStateException:为 uz.pdp.prof.repository.RegionRepository 配置的路径/区域必须只包含一个路径段!resourceMappings 抛出异常;嵌套异常是 java.lang.IllegalStateException:为 uz.pdp.prof.repository.RegionRepository 配置的路径/区域必须只包含一个路径段!resourceMappings 抛出异常;嵌套异常是 java.lang.IllegalStateException:为 uz.pdp.prof.repository.RegionRepository 配置的路径/区域必须只包含一个路径段!
解决方案
您必须在 @RepositoryRestResource 中提及 path='endpoint name' 而不使用 '/'。您必须使用 @RepositoryRestResource(path = "region" ),它是直接 spring MVC 在/region创建 RESTful 端点
推荐阅读
- java - HashMap 对象不会复制到另一个 HashMap 对象中
- sql - 如果 json_agg 什么也没找到,posgres 返回空行
- batch-file - 从用户给定的字符串中添加引号
- c++ - 在有向图中打印所有循环
- electron - electron-forge make 导致错误:找不到为“win32”平台配置的任何 make 目标
- julia - Julia Symbolics 中常量表示的 Sqrt
- python - 为什么scrapy-proxys显示我的IP而不是代理?
- python - 是否可以在混淆矩阵中添加额外的列?
- javascript - 如何在单个页面上播放不同的音频文件
- swift - 在 Swift 中的 textview 中显示 REST API 结果不起作用