- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 Spring Boot 构建一个应用程序。我正在尝试配置 Jersey 。
public class DemoApplication{
private static class Configuration extends AbstractApplicationConfiguration { }
public static void main(String[] args) {
ConfigurableApplicationContext ctx = SpringApplication.run(Configuration.class, args);
}
}
@Configuration
@Import({ WebXmlConfiguration.class})
@ImportResource({ "classpath*:META-INF/spring/appContext.xml" })
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class,
HibernateJpaAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class,
FlywayAutoConfiguration.class,
SecurityAutoConfiguration.class })
public class AbstractApplicationConfiguration {
}
@Configuration
public class WebXmlConfiguration {
@Bean
public Filter springSecurityFilterChain() {
return new DelegatingFilterProxy();
}
@Bean
public ServletRegistrationBean jersey() {
System.out.println("initalized jersey");
Servlet jerseyServlet = new SpringServlet();
try{
System.out.println(jerseyServlet.getServletConfig().getServletName());
}catch (Exception e) {
e.printStackTrace();
}
ServletRegistrationBean jerseyServletRegistration = new
ServletRegistrationBean();
jerseyServletRegistration.setServlet(jerseyServlet);
jerseyServletRegistration.addUrlMappings("/*");
jerseyServletRegistration.setName("jersey-servlet");
jerseyServletRegistration.setLoadOnStartup(1);
jerseyServletRegistration
.addInitParameter("com.sun.jersey.api.json.POJOMappingFeature", "true");
jerseyServletRegistration.addInitParameter("com.sun.jersey.spi.container.ContainerResponseFilters",
ResponseCorsFilter.class.getName());
jerseyServletRegistration.addInitParameter("com.sun.jersey.config.feature.DisableWADL", "true");
System.out.println("end of spring config");
// debugging for development:
// jerseyServletRegistration.addInitParameter("com.sun.jersey.spi.container.ContainerRequestFilters",
// LoggingFilter.class.getName());
return jerseyServletRegistration;
}
}
当我运行此代码时,我收到一条错误消息“ResourceConfig 实例不包含任何根资源类”。该日志与下面共享。每当我点击 api 时,都会出现相同的错误“ResourceConfig 实例不包含任何根资源类。”
2017-06-18 21:10:17.738 INFO 15676 --- [ main] com.praveen.praveen.PraveenApplication : Starting PraveenApplication on praveen-PC with PID 15676 (started by praveen in C:\Users\praveen\Desktop\New folder\praveen\praveen)
2017-06-18 21:10:17.754 INFO 15676 --- [ main] com.praveen.praveen.PraveenApplication : No active profile set, falling back to default profiles: default
2017-06-18 21:10:17.953 INFO 15676 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@105fece7: startup date [Sun Jun 18 21:10:17 IST 2017]; root of context hierarchy
2017-06-18 21:10:23.041 INFO 15676 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-06-18 21:10:23.081 INFO 15676 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2017-06-18 21:10:23.084 INFO 15676 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.15
2017-06-18 21:10:23.359 INFO 15676 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-06-18 21:10:23.360 INFO 15676 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 5418 ms
initalized jersey
end of spring config
2017-06-18 21:10:23.783 INFO 15676 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-06-18 21:10:23.784 INFO 15676 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-06-18 21:10:23.784 INFO 15676 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-06-18 21:10:23.784 INFO 15676 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-06-18 21:10:23.786 INFO 15676 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2017-06-18 21:10:23.786 INFO 15676 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'jersey-servlet' to [/*]
2017-06-18 21:10:23.788 INFO 15676 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-06-18 21:10:24.389 INFO 15676 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@105fece7: startup date [Sun Jun 18 21:10:17 IST 2017]; root of context hierarchy
2017-06-18 21:10:24.537 INFO 15676 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-06-18 21:10:24.541 INFO 15676 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-06-18 21:10:24.640 INFO 15676 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-06-18 21:10:24.642 INFO 15676 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-06-18 21:10:24.750 INFO 15676 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-06-18 21:10:25.055 INFO 15676 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-06-18 21:10:25.216 INFO 15676 --- [ main] c.s.j.s.s.c.servlet.SpringServlet : Using default applicationContext
2017-06-18 21:10:25.220 INFO 15676 --- [ main] c.s.j.s.i.a.WebApplicationImpl : Initiating Jersey application, version 'Jersey: 1.17 01/17/2013 03:31 PM'
2017-06-18 21:10:25.612 ERROR 15676 --- [ main] c.s.j.s.i.a.RootResourceUriRules : The ResourceConfig instance does not contain any root resource classes.
2017-06-18 21:10:25.620 ERROR 15676 --- [ main] c.s.j.s.s.c.servlet.SpringServlet : Exception occurred when intialization
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:99) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1331) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:168) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:774) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:770) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193) ~[jersey-core-1.17.jar:1.17]
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:770) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.spi.spring.container.servlet.SpringServlet.initiate(SpringServlet.java:117) ~[jersey-spring-1.17.jar:1.17]
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:319) [jersey-servlet-1.17.jar:1.17]
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605) [jersey-servlet-1.17.jar:1.17]
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210) [jersey-servlet-1.17.jar:1.17]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374) [jersey-servlet-1.17.jar:1.17]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557) [jersey-servlet-1.17.jar:1.17]
at javax.servlet.GenericServlet.init(GenericServlet.java:158) [tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1183) [tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992) [tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4931) [tomcat-embed-core-8.5.15.jar:8.5.15]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedContext.deferredLoadOnStartup(TomcatEmbeddedContext.java:78) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.startConnector(TomcatEmbeddedServletContainer.java:273) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:196) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:297) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:145) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) [spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at com.praveen.praveen.PraveenApplication.main(PraveenApplication.java:15) [bin/:na]
2017-06-18 21:10:25.621 ERROR 15676 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : StandardWrapper.Throwable
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:99) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1331) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:168) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:774) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:770) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193) ~[jersey-core-1.17.jar:1.17]
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:770) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.spi.spring.container.servlet.SpringServlet.initiate(SpringServlet.java:117) ~[jersey-spring-1.17.jar:1.17]
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:319) ~[jersey-servlet-1.17.jar:1.17]
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605) ~[jersey-servlet-1.17.jar:1.17]
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210) ~[jersey-servlet-1.17.jar:1.17]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374) ~[jersey-servlet-1.17.jar:1.17]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557) ~[jersey-servlet-1.17.jar:1.17]
at javax.servlet.GenericServlet.init(GenericServlet.java:158) ~[tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1183) [tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992) [tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4931) [tomcat-embed-core-8.5.15.jar:8.5.15]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedContext.deferredLoadOnStartup(TomcatEmbeddedContext.java:78) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.startConnector(TomcatEmbeddedServletContainer.java:273) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:196) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:297) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:145) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) [spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at com.praveen.praveen.PraveenApplication.main(PraveenApplication.java:15) [bin/:na]
2017-06-18 21:10:25.622 ERROR 15676 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Servlet [jersey-servlet] in web application [] threw load() exception
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:99) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1331) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:168) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:774) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:770) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193) ~[jersey-core-1.17.jar:1.17]
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:770) ~[jersey-server-1.17.jar:1.17]
at com.sun.jersey.spi.spring.container.servlet.SpringServlet.initiate(SpringServlet.java:117) ~[jersey-spring-1.17.jar:1.17]
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:319) ~[jersey-servlet-1.17.jar:1.17]
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605) ~[jersey-servlet-1.17.jar:1.17]
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210) ~[jersey-servlet-1.17.jar:1.17]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374) ~[jersey-servlet-1.17.jar:1.17]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557) ~[jersey-servlet-1.17.jar:1.17]
at javax.servlet.GenericServlet.init(GenericServlet.java:158) ~[tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1183) ~[tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992) ~[tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4931) ~[tomcat-embed-core-8.5.15.jar:8.5.15]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedContext.deferredLoadOnStartup(TomcatEmbeddedContext.java:78) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.startConnector(TomcatEmbeddedServletContainer.java:273) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:196) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:297) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:145) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) [spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
at com.praveen.praveen.PraveenApplication.main(PraveenApplication.java:15) [bin/:na]
2017-06-18 21:10:25.637 INFO 15676 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-06-18 21:10:25.645 INFO 15676 --- [ main] com.praveen.praveen.PraveenApplication : Started PraveenApplication in 9.426 seconds (JVM running for 11.567)
最佳答案
创建配置类
@Configuration
public class JerseyConfig extends ResourceConfig {
public JerseyConfig() {
register(JerseyController.class);
}
}
这个 JerseyController 类将拥有所有其余的结束
@Component
@Path("/jersey")
public class JerseyController {
@GET
@Produces("application/json")
public String health() {
System.out.println("Here");
return "Jersey: Up and Running!";
}
}
希望这会有所帮助(注意:不要忘记为 Spring boot 添加 jersey 依赖项)
关于java - 设置 Jersey 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44616721/
我已阅读 Jersey documentation ,并表示 Jersey 在读取实体后自动关闭连接(例如 response.readEntity(SomeObject.class)) 但是当抛出异常
Jersey vs Jersey (Standalone) vs Jersey with Grizzly vs Jersey with Tomcat - for REST services 有什么区别
如何通过 guice 使用非 Jersey 资源和 Jersey 资源? 我希望“/”由普通 servlet 处理。但我希望 Jersey 处理“/users”。 假设我有一个带@Path("/use
我正在尝试使用 Maven、Apache Tomcat 7.0、Eclipse IDE 创建一个基本的 RESTful 应用程序。我在 google 提供的一些示例代码中遇到了 jersey-serv
我已经从 Jersey 1.7 升级到 2.16,但 Jersey 似乎无法找到我的资源(请参阅下面的堆栈)。任何想法发生了什么?我尝试在扩展 ResourceConfig 的自定义应用程序类中初始化
我正在使用 com.yammer.dropwizard.config.Environment addProvider 方法在 Jersey 中注册提供程序。我也有一个自定义提供程序,它执行类似于 Dr
在 Jersey 1.x 中,您可以使用 ContainerRequest.getFormParameters()对表单数据进行请求过滤,但我在 Jersey 2.x 中看不到明显的等价物。我已经实现
我正在使用Jersey的集成Jackson处理将传入的JSON转换为POJO,例如: @POST @Consumes(MediaType.APPLICATION_JSON) public Respon
我正在尝试以编程方式创建 Jersey 资源(没有注释)。我有一个将 Name 和 id 作为输入参数的方法 raiseAlarm。我想从 JSON 输入中获取名称,并且我希望 id 来自路径参数。代
Dropwizard official documentation Jersey 客户端不可测试,有人有 dropwizard Jersey 客户端样本吗? 最佳答案 我发现在 Dropwizard
我一直在寻找解决这个问题的方法,但没有成功。我发现的最新帖子可以追溯到 2010 年。我正在使用带有嵌入式 grizzly 2.2.1 的 Jersey 1.12。 如果我理解正确,除非我将 Jers
我想开发一个 Web API,它将生成和使用 JSON 和 XML 数据。 我已经使用JAXB来支持XML,并且工作正常。现在我想添加 JSON 类型。我研究了不同的教程,所有教程都使用不同的依赖项,
如此处所述:http://wikis.sun.com/display/Jersey/WADL 我在 Tomcat 6 中使用 Jersey 1.4。 我已经尝试了所有可能的带有“/applicatio
我是jax-rs的新手,并且已经用jersey和glassfish构建了Web服务。 我需要的是一种方法,服务启动后即被称为。在这种方法中,我想加载自定义配置文件,设置一些属性,编写日志等等。 我尝试
当客户端请求 Not Acceptable MIME 类型时,如何防止 Jersey 在客户端发送 HTML 页面?我想使用 ExceptionMapper,但我不确定要捕获什么异常,或者这是否是处理
我试图在它的 JSON 被解码后拦截一个资源调用。通过阅读一些论坛和帖子,我发现我可以通过实现 来做到这一点。 org.glassfish.jersey.server.spi.internal.Res
我的 webapp 包含一个库,其中包含一个用 @javax.ws.rs.ext.Provider 注释的类。 .如果存在此类,我的 web 应用程序(在 EAR 中部署为 WAR)将无法启动并显示以
我想自定义404响应,即服务器(不是我)在找不到请求的资源时抛出(或自己抛出一个自定义的WebApplicationException,如果可以测试一个应用程序中是否存在请求的资源)?资源列表存储在某
我有一个受 Shibboleth(SSO 实现)保护的 Jersey API。 Shibboleth 将登录用户的 ID 放入请求属性中。在后端,我使用 Shiro 进行授权。 Shiro 希望了解登
我目前正在使用 Jersey 返回 JSON。我该如何返回 JSONP?例如我当前的RESTful方法是: @GET @Produces(MediaType.APPLICATION_JSON) pub
我是一名优秀的程序员,十分优秀!