The import org.springframework.web.bind.annotation.CrossOrigin can not be resolved

1

I'm not able to import the annotation @CrossOrigin . Ide does not find the required package even though all other annotations are working normally. The error that occurs is this:

  

The import org.springframework.web.bind.annotation.CrossOrigin can not be resolved

Is there any dependency on my maven?

    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.3.1</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>com.thetransactioncompany</groupId>
        <artifactId>cors-filter</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>com.thetransactioncompany</groupId>
        <artifactId>java-property-utils</artifactId>
        <version>1.10</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>1.5.1.RELEASE</version>
    </dependency>
<springframework.version>4.0.6.RELEASE</springframework.version>
    
asked by anonymous 08.02.2017 / 23:33

1 answer

3

The @CrossOrigin annotation was added to Spring in version 4.2 and you are using the 4.0.6.RELEASE version. Change your version to the latest Spring 4.3.6.RELEASE and this will solve the problem.

In addition, since you are using Spring Boot, the following dependencies do not have to be declared in your pom.xml since they are Spring Boot dependencies:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${springframework.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${springframework.version}</version>
</dependency>
    
09.02.2017 / 00:39