static import compile time error in spring-test-mvc

95 views Asked by At

I am writing one test case for testing Spring MVC controllers. I have defined below entry in pom.xml:

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring.version>4.1.5.RELEASE</spring.version>
    </properties>

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

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <version>1.3</version>
        </dependency>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <version>1.3</version>
        </dependency>

But Eclipse IDE not able to understand below static imports: import static org.springframework.test.web.server.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.server.result.MockMvcResultMatchers.*;

Can anyone suggest what I missing here

1

There are 1 answers

2
questionaire On

As far as I can see, you are missing the dependency for 'spring-test-mvc'.

You need to add the springsource repository and the following dependency:

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-test-mvc</artifactId>
  <version>1.0.0.M2</version>
  <scope>test</scope>
</dependency>