我已经安装了最新版本的球衣(捆绑版本:2.13.0)以及该版本的示例。然后我尝试了(用于测试 Restful 服务 - \examples\helloworld-pure-jax-rs\src\main\java\org\glassfish\jersey\examples)Eclipse 中的 Hello World 示例。结果是这样的:
"Hello World" Jersey Example Application
Exception in thread "main" java.lang.IllegalArgumentException: No container provider supports the type interface com.sun.net.httpserver.HttpHandler
at org.glassfish.jersey.server.ContainerFactory.createContainer(ContainerFactory.java:87)
at org.glassfish.jersey.server.internal.RuntimeDelegateImpl.createEndpoint(RuntimeDelegateImpl.java:71)
at org.glassfish.jersey.examples.helloworld.jaxrs.App.startServer(App.java:72)
at org.glassfish.jersey.examples.helloworld.jaxrs.App.main(App.java:88)
我认为该示例应该开箱即用,因为它不使用任何特定的 http 服务器。仅有的
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
我的Java版本是:
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) Client VM (build 25.25-b02, mixed mode, sharing)
知道可能出了什么问题或者我错过了什么吗?
最好的
克莱门斯
就我而言,我正在遵循一个例子。最后我只需要添加这个依赖org.glassfish.jersey.containers
jersey-container-jdk-http
(记住异常的消息“否容器提供程序支持类型接口 com.sun.net.httpserver.HttpHandler”):
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jdk-http</artifactId>
<version>2.18</version>
</dependency>
您可以根据您的环境更改版本。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)