java服务器错误怎么解决_如何解决java.lang.IllegalStateException:服务器处于错误状态异常...
我正在嘗試在核心
java項目(swing應用程序)中部署restful web-service.我正在使用jersy.
我已經搜索到谷歌的許多網站,但我無法找到為什么這附加.
public class Main {
public static void main(String[] args) throws Exception{
ResourceConfig resourceConfig = new ResourceConfig(MyResource.class);
URI baseUri = UriBuilder.fromUri("http://localhost/").port(10049).build();
HttpServer server = JdkHttpServerFactory.createHttpServer(baseUri,resourceConfig);
server.start();
System.out.println("Press Enter to stop the server. ");
System.in.read();
server.stop(0);
}
}
@Path("/hello")
public class MyResource {
// This method is called if TEXT_PLAIN is request
@GET
@Produces(MediaType.TEXT_PLAIN)
public String sayPlainTextHello() {
return "Hello Jersey";
}
// This method is called if XML is request
@GET
@Produces(MediaType.TEXT_XML)
public String sayXMLHello() {
return "sdasd";
}
// This method is called if HTML is request
@GET
@Produces(MediaType.TEXT_HTML)
public String sayHtmlHello() {
return "dsdfd";
}
}
例外:
Exception in thread "main" java.lang.IllegalStateException: server in wrong state
at sun.net.httpserver.ServerImpl.start(ServerImpl.java:139)
at sun.net.httpserver.HttpServerImpl.start(HttpServerImpl.java:58)
at org.glassfish.jersey.jdkhttp.JdkHttpServerFactory$2.start(JdkHttpServerFactory.java:363)
Maven的:
org.glassfish.jersey.containers
jersey-container-jdk-http
2.22.1
如何解決上述異常.
總結
以上是生活随笔為你收集整理的java服务器错误怎么解决_如何解决java.lang.IllegalStateException:服务器处于错误状态异常...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: bootstrap 彈窗默認打開_Boo
- 下一篇: 500万现金支票怎么取钱