1.前端上传时间,后端用Date接受,上传的时间和最后得到的时间不一样,其中相差8个小时。
解决方法:
or
2.对于多模块的问题,启动类中,idea都找的到类,但是就是说找不到
Field redisCacheTemplate in com.xxwy.ddu.webcontroller.DduWebControllerApplication required a bean of type 'xxxxxxxxxx' that could not be found.
Action:
Consider defining a bean of type 'xxxxxxxxxxxxxxx' in your configuration.
解决:
3.如果你发现你的配置不起作用,考虑你写的配置类是否被扫描上。
4.当出现问题的时候,最好能debug,看一下那句代码出现异常,而不是直接粘贴错误,然后百度。
例子:
Caused by: java.lang.IllegalStateException: Incompatible fallback instance. Fallback/fallbackFactory of type class com.xxwy.springcloud.service.DeptClientServiceFallbackFactory is not assignable to interface com.xxwy.springcloud.service.DeptClientService for feign client XXWYCLOUD-DEPT
at org.springframework.cloud.openfeign.HystrixTargeter.getFromContext(HystrixTargeter.java:100) ~[spring-cloud-openfeign-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
点进去看一下:
这个错误,查看着两个类的在哪里配置在了一起:
@FeignClient(name ="XXWYCLOUD-DEPT",fallback = DeptClientServiceFallbackFactory.class)
定位错误,应该改为:
@FeignClient(name ="XXWYCLOUD-DEPT",fallbackFactory = DeptClientServiceFallbackFactory.class)
5.各种跨域问题
1. 跨域的头文件加多了
Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. Origin '
没有加跨域的头文件
2.No 'Access-Control-Allow-Origin' header is present on the requested resource.
解决方法:
1. @CrossOrigin
产生的问题:我猜测,这个注解值只针对Web请求,因为他对于Security中的AuthenticationFailureHandler是无效的,
所以对于Security中的认证请求,还是要写head文件。
response.setHeader("Content-type", "application/json;charset=utf-8");response.setHeader("Access-Control-Allow-Origin", "*");response.setHeader("Access-Control-Allow-Credentials", "true");response.setHeader("Access-Control-Allow-Headers", "Origin,X-Requested-With,Content-Type,Accept");
response.setHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS");