找不到SecurityMockMvcConfigurers

Ren*_*ler 16 java spring spring-security spring-boot

我正在尝试编写一个Spring安全测试,如http://docs.spring.io/spring-security/site/docs/4.0.x/reference/htmlsingle/#test-mockmvc-setup所述.我需要导入SecurityMockMvcConfigurers为静态导入,但我的IDE找不到该类.

我的pom.xml如下所示:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.0.M2</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

Spring Boot 1.4.0.M2导入Spring Security 4.0.4.RELEASE.我在这个版本中找不到这个类.我需要哪种额外的依赖?或者我没有考虑过什么呢?

Ren*_*ler 35

缺少的依赖是:

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-test</artifactId>
    <version>4.0.4.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

  • 对于复制粘贴:请记住添加范围测试. (12认同)