【发布时间】:2017-04-04 17:45:16
【问题描述】:
我已经使用以下 Github 存储库设置了我的 Spring Boot 工作区: https://github.com/leanstacks/spring-boot-fundamentals/tree/repository
我成功设置了 Rest API,并且还能够使用 Postman 测试所有 CRUD 操作。 现在我试图从我的 Angular 2 应用程序中调用 Rest 服务,但是当我执行 GET 操作时出现以下错误:
'http://localhost:8080/api/greetings。请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,Origin 'http://localhost:4200' 不允许访问。'
我尝试使用: @CrossOrigin(methods = RequestMethod.GET, allowCredentials = "true") 注释用于解决跨源问题,但 CrossOrigin 没有得到解决。我收到一条消息: '无法解析导入的org.springframework.web.bind.annotation.CrossOrigin'
非常感谢任何建议/反馈。
【问题讨论】:
标签: spring angular spring-boot cross-domain