【发布时间】:2013-09-28 03:22:39
【问题描述】:
rest-server.xml:
<jaxrs:server id="baseApi" address="http://localhost:8080/myfashions/catalog">
<jaxrs:serviceBeans>
<bean class="com.myfashions.api.service.rest.implementation.CatalogServiceImpl"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="customRequestHandler"/>
<ref bean="customResponseHandler"/>
<ref bean="restExceptionMapper"/>
<bean class="org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider"/>
</jaxrs:providers>
</jaxrs:server>
界面:
public interface CatalogService {
@Path("/categories")
@GET
@Produces({MediaType.APPLICATION_JSON})
SelectCategoryBeanList getMyfashionCategories();
}
类:
@Service
@Path("/myfashions/catalog")
public class CatalogServiceImpl implements CatalogService {
@Override
public SelectCategoryBeanList getMyfashionCategories() {
...
...
}
}
当我调用http://localhost:8080/myfashions/catalog/categories 时,我得到 No root resource matching request path /myfashions/catalog/categories has found, Relative Path: /categories 异常。谁能帮我解决这个问题。
【问题讨论】:
-
我不确定您是否可以完全省略
@Produces注释。它是可继承的。 -
我已经编辑了我的问题。你能指出我错在哪里吗
-
曾经得到这个答案吗?我遇到了同样的问题。
-
您是否尝试过将班级级别的
@Path从CatalogServiceImpl移动到CatalogService?