java - How to Configure JAXRS and Spring With Annotations -


i working on little spring web service project. here example route:

package com.example.api;  import javax.ws.rs.get; import javax.ws.rs.path; import javax.ws.rs.produces; import javax.ws.rs.pathparam; import javax.ws.rs.ext.provider; import javax.ws.rs.core.mediatype;  @provider public class webserviceroutes {      @get     @path("/hello")     public string health() {         return "hello";     }  } 

then in spring configuration class:

package com.example.api;  import org.springframework.context.annotation.bean; import org.springframework.context.annotation.configuration;  @configuration public class springcontextconfiguration {      @bean( destroymethod = "shutdown" )     public springbus cxf() {         return new springbus();     }      @bean     public webserviceroutes webserviceroutes() {         return new webserviceroutes();     } } 

and in web.xml:

<?xml version="1.0" encoding="utf-8"?> <web-app version="3.0">     <display-name>api</display-name>     <context-param>         <param-name>contextclass</param-name>         <param-value>org.springframework.web.context.support.annotationconfigwebapplicationcontext</param-value>     </context-param>     <context-param>         <param-name>contextconfiglocation</param-name>         <param-value>com.example.api.springcontextconfiguration</param-value>     </context-param>     <listener>         <listener-class>org.springframework.web.context.contextloaderlistener</listener-class>     </listener>     <listener>         <listener-class>org.springframework.web.context.request.requestcontextlistener</listener-class>     </listener>     <servlet>         <servlet-name>cxfservlet</servlet-name>         <servlet-class>org.apache.cxf.transport.servlet.cxfservlet</servlet-class>         <load-on-startup>1</load-on-startup>     </servlet>     <servlet-mapping>         <servlet-name>cxfservlet</servlet-name>         <url-pattern>/*</url-pattern>     </servlet-mapping> </web-app> 

however, when deploy war file in jetty, , attempt request /api/hello receive message: "no service found." status 404. doing wrong?


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -