gpt4 book ai didi

java - 接口(interface)上可以使用@ApplicationPath 注解吗?

转载 作者:行者123 更新时间:2023-11-29 04:07:43 25 4
gpt4 key购买 nike

根据JAXRS规范,@ApplicationPath可以用在接口(interface)上吗?

import javax.ws.rs.ApplicationPath;

@ApplicationPath("/")
public interface TestRes {

}

编译器对此没有问题。但这是好方法吗?

最佳答案

ApplicationPath文档清楚地说它只适用于 javax.ws.rs.core.Applicationsubclass 所以如果你在接口(interface)上应用它不会工作,所以当你部署你最终可能会出现此错误消息 The ResourceConfig instance does not contain any root resource classes."

Identifies the application path that serves as the base URI for all resource URIs provided by Path.May only be applied to a subclass of Application.

jaxrs

The @ApplicationPath annotation is used to define the URL mapping for the application. The path specified by @ApplicationPath is the base URI for all resource URIs specified by @Path annotations in the resource class. You may only apply @ApplicationPath to a subclass of javax.ws.rs.core.Application.

关于java - 接口(interface)上可以使用@ApplicationPath 注解吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57307788/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com