我有一个 Maven 项目,其依赖项如下:
wink.version = 1.1.3-incubating 和 spring.version = 3.0.5.RELEASE
Spring 中的应用上下文包括:
<bean class="org.apache.wink.spring.Registrar">
<property name="classes">
<set value-type="java.lang.Class">
</set>
</property>
<property name="instances">
<set>
<ref local="restexample" />
</set>
</property>
</bean>
<bean id="restexample" class="com.example.rest.ExampleRest"></bean>
web.xml 包括:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:META-INF/wink/wink-core-context.xml
classpath:applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>restServlet</servlet-name>
<servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>restServlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
Rest Java 类包括:
@Path("/ex")
public class ExampleRest {
@GET
@Produces(MediaType.APPLICATION_JSON)
public String example() throws IOException {
return "{ 'id':'test' }";
}
}
查看日志,我没有看到任何异常或问题,正在创建“restexample”bean 但是......当我尝试调用 REST 服务时,我收到了 404。
我认为 ExampleRest 没有被 Apache Wink 注册。
有什么想法吗?
更新 02/14: 查看日志,我注意到 ExampleRest 没有被 Apache Wink 注册。也许,问题出在 beans 声明或我正在使用的依赖项中。 我还设置了另一个没有 spring 的项目,它在那里工作。我真的需要 Spring 将他的 IoD 用于 daos 和服务。
最佳答案
在您的 web.xml 中,您指向一个名为 wink-core-context.xml 的文件。这个文件的路径似乎是错误的。应该是:
META-INF/server/wink-core-context.xml
不确定为什么在这里看不到 FileNotFoundException。
关于java - REST 服务未在 Apache wink 中注册到 Spring 和 Maven,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21757152/