1.在controller 上加上
@CrossOrigin(origins = {"http://localhost:7777", "http://someserver:8080"})
eg:localhost 意思是允许本地跨域访问
7777:允许访问的端口号
@RestController @RequestMapping("/order") //@CrossOrigin(origins = {"http://localhost:7777", "http://someserver:8080"}) @CrossOrigin(origins = {"http://192.168.18.156:4200"}) public class OrderController { @Autowired private OrderService orderService;