gpt4 book ai didi

java - SSL-REST-server with grizzly,ResourceConfig 实例不包含任何根资源类

转载 作者:太空宇宙 更新时间:2023-11-04 07:43:07 26 4
gpt4 key购买 nike

我正在尝试使用 SSL 与 grizzly 完成一个安全的 REST 服务器。我在中配置我的资源

package SPSServer.controller.Grizzly;
@Path("/")
public class MessageRessource {

@GET
@Path("serverinfo")
@Produces({MediaType.APPLICATION_JSON,MediaType.TEXT_XML})
public ServerInfo serverinfo() {
ServerInfo info = new ServerInfo();
info.server = System.getProperty("os.name") + " " + System.getProperty("os.version");
return info;
}



@GET
@Produces({MediaType.APPLICATION_JSON,MediaType.TEXT_XML})
//@Produces( MediaType.TEXT_PLAIN )
public String message() {
return "Yea! ";
}
}

现在我开始灰熊

    webServer = new GrizzlyWebServer(1337, ".", true);
SSLConfig sslConfig = new SSLConfig(true);
webServer.setSSLConfig(sslConfig);
ServletAdapter adapter = new ServletAdapter();
final Map<String, String> initParams = new HashMap<String, String>();
adapter.addInitParameter(PackagesResourceConfig.PROPERTY_PACKAGES, "SPSServer.controller.Grizzly.MessageRessource");
adapter.addInitParameter(ClasspathResourceConfig.PROPERTY_CLASSPATH, ".");

adapter.setContextPath("/");
adapter.setServletInstance(new ServletContainer());

webServer.addGrizzlyAdapter(adapter, new String[]{"/"});
webserver.start();

`

开头为

Mar 31, 2013 4:55:14 PM com.sun.grizzly.Controller logVersion INFO: GRIZZLY0001: Starting Grizzly Framework 1.9.56 - 3/31/13 4:55 PM Hit return to stop...

但是当我尝试访问资源时/'(https://locahost:1337/)' 它向我抛出此错误:

Mar 31, 2013 4:56:12 PM com.sun.jersey.api.core.PackagesResourceConfig init INFO: Scanning for root resource and provider classes in the packages: SPSServer.controller.Grizzly.MessageRessource Mar 31, 2013 4:56:12 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate INFO: Initiating Jersey application, version 'Jersey: 1.17.1 02/28/2013 03:28 PM' Mar 31, 2013 4:56:13 PM com.sun.jersey.server.impl.application.RootResourceUriRules SEVERE: The ResourceConfig instance does not contain any root resource classes. Mar 31, 2013 4:56:13 PM com.sun.grizzly.http.servlet.ServletAdapter doService SEVERE: service exception: com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.

我尝试过让 grizzly 工作(通过 jersey HttpServerFactory,我得到了一个没有 ssl 的工作休息服务器,并且我设法让 httpsServer 工作,但两者结合在一起让我头痛了好几天),所以现在我真的依赖你的帮助。提前致谢(如果有人纠正我的语法,我不会冒犯,我仍然需要学习)

最佳答案

关于java - SSL-REST-server with grizzly,ResourceConfig 实例不包含任何根资源类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15730786/

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