在Spring Boot中使用@CrossOrigin
我正在使用最新的Spring Boot(1.2.7.RELEASE).我想使用org.springframework.web.bind.annotation包中的@CrossOrigin注释,如Spring文档中的CORS Support部分所述.
我认为我已经拥有了所有必要的依赖项(通过Spring Boot默认值),但这很令人困惑:找不到CrossOrigin,即使像同一个程序包中的RestController这样的东西也可以工作!
Error:(8, 47) java: cannot find symbol
symbol: class CrossOrigin
location: package org.springframework.web.bind.annotation
这是怎么回事? CrossOrigin是否已从更高版本的Spring-MVC中删除,还是我错过了一些依赖?
pom.xml中:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.7.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Error:(8, 47) java: cannot find symbol
symbol: class CrossOrigin
location: package org.springframework.web.bind.annotation
这是怎么回事? CrossOrigin是否已从更高版本的Spring-MVC中删除,还是我错过了一些依赖?
pom.xml中:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.7.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
...全文
相关推荐
Spring Boot 2.X优雅的解决跨域问题
主要给大家介绍了关于Spring Boot 2.X如何优雅的解决跨域问题的相关资料,文中通过示例代码介绍的非常详细,对大家学习或者使用Spring Boot 2.X具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧
Spring Boot如何通过CORS处理跨域问题
主要介绍了Spring Boot如何通过CORS处理跨域问题,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
Spring Boot Web应用开发 CORS 跨域请求支持
本篇文章主要介绍了Spring Boot Web应用开发 CORS 跨域请求支持,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
Java Spring boot 2.0 跨域问题的解决
本篇文章主要介绍了Java Spring boot 2.0 跨域问题的解决,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
Spring Boot(五)之跨域、自定义查询及分页
主要介绍了Spring Boot(五)之跨域、自定义查询及分页的的相关资料,需要的朋友可以参考下


其他技术讨论专区

