2017-06-18 13 views
0

私はスプリングブートを使用してアプリケーションを構築しようとしています。私はjersyを設定しようとしています。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[email protected]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[email protected]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) 
+0

Jersey 1.xをSpring Bootで使用しようとしているのはなぜですか? –

+0

@peeskillet私はジャージの注釈に慣れています。より良い方法があれば教えてください –

+0

私の主張は、あなたが2.xを使用しているときにジャージー_version_ 1.xを使用していることです。これはSpringブートとの統合が良好です –

答えて

1

は、Configurationクラス

@Configuration 
public class JerseyConfig extends ResourceConfig { 
    public JerseyConfig() { 
      register(JerseyController.class); 
     } 
    } 
を作成

このJerseyControllerクラスは、すべての残りの部分を持っています1はこれが(ノート役立ちます

@Component 
@Path("/jersey") 
public class JerseyController { 

    @GET 
    @Produces("application/json") 
    public String health() { 
     System.out.println("Here"); 
     return "Jersey: Up and Running!"; 
    } 
} 

希望終了です。DONOTはジャージを追加することを忘れを

+0

応答に感謝します。各コントローラクラスを登録する必要があります。もし私が10のコントローラクラスを持っていれば、それらのすべてを登録する必要があると言えますか?またはすべてのクラスを取得できるワイルドカードを使用できますか? –

+0

あなたはそれを行うか、別々のクラスのthatsはあなたがあなたのJerseyConfigにListableBeanFactoryを注入した後、すなわち '' 'パブリックJerseyConfig(ListableBeanFactoryパスの注釈を持つすべてのBeanを追加することができ、これらのクラスに結合し、その後、 –

+0

上記と同じ操作を行うことができますbeanFactory){ beanFactory.getBeansWithAnnotation(Path.class).values()。forEach(this :: register); '' ' –

関連する問題