Java maven spring框架的Restful API不工作

Java maven spring框架的Restful API不工作,java,eclipse,spring,rest,maven,Java,Eclipse,Spring,Rest,Maven,我已经有了一个maven项目,并尝试导入spring框架 执行基本的restful应用程序。但我的restful控制器似乎可以 没有收到请求 我的控制器: package org.itri.ccma.paas.service.event.webservice; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; impor

我已经有了一个maven项目,并尝试导入spring框架 执行基本的restful应用程序。但我的restful控制器似乎可以 没有收到请求

我的控制器:

package org.itri.ccma.paas.service.event.webservice;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(produces = "application/json")
public class MyController {

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    @ResponseBody
    public String hello() {

        return "true";
    }

}
我的pom.xml

...
    <dependencies>

        <!-- Springframework -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>4.2.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.2.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.2.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.2.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>4.2.0.RELEASE</version>
        </dependency>

<build>
   <finalName>PaaS</finalName>
    <plugins>
       <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <path>/PaaS</path>
                <port>8080</port>
            </configuration>
            <dependencies>
            </dependencies>
        </plugin>
    </plugins>
</build>

...

我错过了什么?有什么建议吗?非常感谢

在rest-servlet.xml中,更改

<context:component-scan base-package="org.itri.ccma.paas.service.event.webservice.MyController" />



我看不到你在邮递员身上犯的错误。你能粘贴它吗?你能试试吗?是的,我把错误信息粘贴到邮递员的邮箱里。谢谢
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp" version="3.1"
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_1.xsd">
    <display-name>Archetype Created Web Application</display-name>

<context-param>
        <param-name>contextConfigLocation</param-name> 
        <param-value>/WEB-INF/rest-servlet.xml</param-value> 
    </context-param> 
    <listener> 
        <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> 
    </listener>
    <servlet>
        <servlet-name>rest</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>    
        <init-param>
            <param-name>contextClass</param-name>
            <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
        </init-param>           
    </servlet>
    <servlet-mapping>
        <servlet-name>rest</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
</web-app>
<html>
    <head>
        <title>Apache Tomcat/7.0.47 - Error report</title>
        <style>
            <!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}-->
        </style>
    </head>
    <body>
        <h1>HTTP Status 404 - /PaaS/rest/hello</h1>
        <HR size="1" noshade="noshade">
            <p>
                <b>type</b> Status report
            </p>
            <p>
                <b>message</b>
                <u>/PaaS/rest/hello</u>
            </p>
            <p>
                <b>description</b>
                <u>The requested resource is not available.</u>
            </p>
            <HR size="1" noshade="noshade">
                <h3>Apache Tomcat/7.0.47</h3>
            </body>
        </html>
151105 11:17:35 INFO  (FrameworkServlet.java:488) FrameworkServlet 'rest': initialization started
151105 11:17:35 INFO  (AbstractApplicationContext.java:573) Refreshing WebApplicationContext for namespace 'rest-servlet': startup date [Thu Nov 05 11:17:35 CST 2015]; parent: Root WebApplicationContext
151105 11:17:35 INFO  (AutowiredAnnotationBeanPostProcessor.java:153) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
151105 11:17:35 INFO  (FrameworkServlet.java:507) FrameworkServlet 'rest': initialization completed in 42 ms
<context:component-scan base-package="org.itri.ccma.paas.service.event.webservice.MyController" />
<context:component-scan base-package="org.itri.ccma.paas.service.event.webservice" />