简体   繁体   English

无法实例化UriInfo指定的类是接口

[英]Failed to instantiate UriInfo Specified class is an interface

I want to use annotation @Context to retrieve the URI 我想使用注释@Context检索URI

@GetMapping(value = "/profile/{username}", produces = MediaType.APPLICATION_JSON_VALUE)
public Response getProfile(
        @PathVariable String username,
        @Context UriInfo uriInfo
) {
    return Optional
            .ofNullable(userService.findOneByUsername(username))
            .map(user -> Response
                          .created(uriInfo.getAbsolutePathBuilder().path(username).build())
                          .status(Response.Status.OK)
                          .entity(user).build())
            .orElseGet(() -> {
                throw new ProfileNotFoundException();
            });
}

However, while displaying the page throws an exception 但是,在显示页面时会引发异常

org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.ws.rs.core.UriInfo]: Specified class is an interface

I can not find information on how to fix. 我找不到有关如何修复的信息。

UriInfo isn't a part Spring MVC. UriInfo不是Spring MVC的一部分。 You can use @RequestParam in Spring MVC for this 您可以在Spring MVC中使用@RequestParam

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Boot WebFluxTest 测试,无法实例化存储库,指定类为接口 - Spring Boot WebFluxTest test, failed to instantiate repository, specified class is an interface 带有SpringBoot的GraphQLTester无法实例化xxx指定的class是一个接口 - GraphQLTester with SpringBoot Failed to instantiate xxx specified class is an interface 无法实例化[org.springframework.data.domain.Pageable]:指定的类是接口 - Failed to instantiate [org.springframework.data.domain.Pageable]: Specified class is an interface spring boot - 如何在HTTP控制器处理程序中避免“无法实例化[java.util.List]:指定的类是一个接口”? - spring boot - how to avoid “Failed to instantiate [java.util.List]: Specified class is an interface” in HTTP controller handler? Spring插入错误无法实例化[java.util.Map]:指定的类是一个接口 - Spring insert error Failed to instantiate [java.util.Map]: Specified class is an interface 无法实例化[java.util.List]:指定的类是GET请求中的接口 - Failed to instantiate [java.util.List]: Specified class is an interface in GET request org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.ui.Model]:指定的类是接口 - org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ui.Model]: Specified class is an interface HK2服务修复失败javax.ws.rs.core.UriInfo的日志警告中出现以下异常:在UriInfo类中找不到合适的构造函数 - HK2 service reification failed Warning in logs for javax.ws.rs.core.UriInfo with exception: Could not find a suitable constructor in UriInfo class Spring Mongodb-无法实例化 bean class [java.util.List]:指定 class 是一个接口 - Spring Mongodb- Could not instantiate bean class [java.util.List]: Specified class is an interface spring MVC3错误无法实例化bean类[java.util.List]:指定的类是偶尔的接口 - spring MVC3 errors Could not instantiate bean class [java.util.List]: Specified class is an interface Occasional
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM