0

RequestMapping は Spring 3.2.1 から削除されましたか。

私は新しいプロジェクトに取り組んでおり、Spring 3.2.1 を使用しようとしています...しかし、私の IDEA と Maven は Spring で RequestMapping を見つけることができません.. 以下は私のコントローラーです:

package org.sample.jquery.controller;


import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;
import static org.apache.log4j.Logger.getLogger;



@Controller
@RequestMapping("/request")
public class RequestController {


    private static final Logger LOGGER = getLogger(RequestController.class);

    @RequestMapping(method = RequestMethod.GET)
    public ModelAndView displayRequestPage() {

        return new ModelAndView("input");

    }

}

ここに私の pom.xml があります.... Spring 3.2.1 から RequestMapping が削除されたようです

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>jQueryExamples</groupId>
    <artifactId>jQueryExamples</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>jQueryExamples Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <developers>
        <developer>
            ...
        </developer>
    </developers>

    <properties>
        <java-version>1.7</java-version>
        <springframework-version>3.2.1.RELEASE</springframework-version>
        <org.slf4j-version>1.6.6</org.slf4j-version>
    </properties>

    <dependencies>

        <!--  the following is for spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${springframework-version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${springframework-version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!--  This is for logging with log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>


        <!-- this is for junit testing -->

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>jQueryExamples</finalName>
    </build>
</project>
4

3 に答える 3

3

あるはずです

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${springframework-version}</version>
</dependency>

3.2.1にはバグがあり、3.2.2で修正されました。このバグでは、依存関係がとspring-webmvcをもたらさなかったため、依存関係を手動で宣言する必要がありました。spring-webspring-context

これはorg.springframework.web.bind.annotation.RequestMapping;

于 2013-03-08T14:16:44.027 に答える
1

これは、3.2.2 で修正された 3.2.1 の問題が原因です: https://jira.springsource.org/browse/SPR-10218

つまり、@RequestMapping を使用しているため、pom には spring-webmvc から spring-web への推移的な依存関係に依存するのではなく、spring-web への依存関係を含める必要があります。したがって、いずれにしてもその依存関係を追加することをお勧めします。

于 2013-03-08T14:53:05.153 に答える
0

JavaDoc によると、RequestMapping アノテーションは Spring 3.2.1 の一部のようです: http://static.springsource.org/spring/docs/3.2.x/javadoc-api/

プロジェクトに Spring MVC ライブラリを追加する必要があるのではないでしょうか?

于 2013-03-08T14:19:21.420 に答える