微服务服务间调用出现未授权

提问 未结 1 84
后裔
后裔 VIP3 2022-06-13
悬赏:50积分
版本:renren-cloud 3.6 开发环境:JDK8
请求路径:http://localhost:8080/api/test/upload cloud-oss-server: ResourceServerConfig权限配置: @Override public void configure(HttpSecurity http) throws Exception { http .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) .and() .authorizeRequests() .antMatchers(ResourceConstant.IGNORING_URLS).permitAll() .antMatchers("/file/upload").permitAll() .anyRequest().authenticated() ; } cloud-oss-client: @FeignClient(name = "cloud-oss-server", fallbackFactory = OssFeignClientFallbackFactory.class, configuration = OssFeignClient.MultipartSupportConfig.class) public interface OssFeignClient { /** * 文件上传 * @param file 文件 * @return 返回路径 */ @PostMapping(value = "oss/file/upload", produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) Result<UploadDTO> upload(@RequestPart("file") MultipartFile file); class MultipartSupportConfig { @Bean public Encoder feignFormEncoder() { return new SpringFormEncoder(); } } } 操作结果: { "code": 401, "msg": "未授权", "data": null }
回帖