6

我有一个 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 注册。也许,问题出在 bean 声明中,或者可能是我正在使用的依赖项。我还建立了另一个没有弹簧的项目,它在那里工作。我真的需要 Spring 将他的 IoD 用于 daos 和服务。

4

1 回答 1

2

在您的 web.xml 中,您指向一个名为wink-core-context.xml的文件。该文件的路径似乎错误。它应该是:

META-INF/服务器/wink-core-context.xml

见源

不知道为什么在这里看不到 FileNotFoundException。

于 2014-02-18T09:36:09.737 回答