问题描述

使用 azure-spring-boot-starter-storage 来上传文件到 Storage Blob中,并把应用部署到Azure 中国区的Spring Cloud服务后,调用上传文件的接口报错:  java.net.UnknownHostException: xxxxxxxx.blob.core.windows.net: Name or service not known

使用的依赖为:

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>spring-starter-azure-storage</artifactId>
<version>1.2.8</version>
</dependency>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version>
<relativePath/>
</parent>

问题解决

从错误来分析,这是使用到了SDK中默认Global Azure Storage的Endpoint导致,在中国区,正确的Blob Endpoint为:xxxxxxxx.blob.core.chinacloudapi.cn

根据查看官方文档,对 azure storage的spring boot引用的storage 依赖名称为 com.azure.spring:azure-spring-boot-starter-storage,而当前错误的应用中引用的是 com.microsoft.azure: spring-starter-azure-storage

根据文档建议修改后,上传文件问题“Name not known”得以解决。

参考资料

Spring Boot Starter for Azure Storage: https://docs.microsoft.com/en-us/azure/developer/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-storage

【Azure Spring Cloud】使用azure-spring-boot-starter-storage来上传文件报错: java.net.UnknownHostException: xxxxxxxx.blob.core.windows.net: Name or service not known的更多相关文章

  1. Spring使用mutipartFile上传文件报错【Failed to instantiate [org.springframework.web.multipart.MultipartFile]】

    报错场景: 使用SSM框架实现文件上传时报“Failed to instantiate [org.springframework.web.multipart.MultipartFile]”错,控制器源 ...

  2. Spring MVC实现上传文件报错解决方案

    报错代码: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.sp ...

  3. Spring Boot应用上传文件时报错

    问题描述 Spring Boot应用(使用默认的嵌入式Tomcat)在上传文件时,偶尔会出现上传失败的情况,后台报错日志信息如下:"The temporary upload location ...

  4. spring cloud feign 上传文件报not a type supported by this encoder解决方案

    上传文件调用外部服务报错: not a type supported by this encoder 查看SpringFormEncoder类的源码: public class SpringFormE ...

  5. Spring boot 全局配置 properties或者yml文件报错

    主要问题是没有扫描到配置文件 在pom文件里面<build>    </build>中加上以下代码就可以保证能扫描到了 <resources> <resour ...

  6. 后台使用Spring MVC 4.15 版本 通过 ajaxFileUpload plugin插件上传文件相应时引起的一个小问题,Chrome、Firefox中出现SyntaxError:unexpected token <

    html: 使用ajaxFileUpload插件做文件上传时,后台返回json格式的数据,js代码如下: 接下来,把结果错误信息打印出来: 先在网上找了下解决办法方案,stackoverflow上有说 ...

  7. dubbo spring pom文件报错:提示no declaration can be found for element 'dubbo:service'.

    pom文件报错:The matching wildcard is strict, but no declaration can be found for  element 'dubbo:service ...

  8. spring pom文件报错:提示no declaration can be found for element 'dubbo:service'.

    转自:http://blog.csdn.net/happylife_haha/article/details/52755425 pom文件报错:The matching wildcard is str ...

  9. 【Spring Boot】关于上传文件例子的剖析

    目录 Spring Boot 上传文件 功能实现 增加ControllerFileUploadController 增加ServiceStorageService 增加一个Thymeleaf页面 修改 ...

  10. Spring Cloud学习笔记--Spring Boot初次搭建

    1. Spring Boot简介 初次接触Spring的时候,我感觉这是一个很难接触的框架,因为其庞杂的配置文件,我最不喜欢的就是xml文件,这种文件的可读性很不好.所以很久以来我的Spring学习都 ...

随机推荐

  1. date的命令使用.

    date命令的使用 1.直接用date命令显示日期时间 在命令行中输入date然后回车,显示结果"Wed Aug 7 08:58:07 CST 2019".这是系统根据设定的时区显 ...

  2. Arthas 超简单离线使用教程

    简介 Arthas 是阿里巴巴开源的一套监控java应用的工具 官网的文档地址: https://arthas.aliyun.com/doc/ 官方的简介说明: Arthas 是Alibaba开源的J ...

  3. 让你轻松看懂defer和async

    defer和async产生的原因 HTML 网页中,浏览器通过<script>标签加载 JavaScript 脚本. <!-- 页面内嵌的脚本 --> <script t ...

  4. 动态添加input,然后获取所有的input框中的值

    今天遇见一个问题. 点击按钮,动态添加input框(可以添加多个) 然后搜集用户在input中输入的值. 我刚刚在纠结,给input框中注入事件. 但是这样会很麻烦. 经过同事的指点. 我直接去拿v- ...

  5. AppCan 打包无限次下载解决方案

    1.下载AppCan 官网上打包好的文件apk文件 2.将apk文件放在指定的服务器文件内,谇文件发布到IIS,一般都会用已发布发的网站上面随便一个目录就可以了. 3.MIME类型中填写apk的MIM ...

  6. 关于Curl命令的使用

    最常用的curl命令 1.发送GET请求 curl URL 例: curl URL?a=1&b=nihao 2.发送POST请求 curl -X POST -d 'a=1&b=niha ...

  7. Linux 配置Quota磁盘配额

    由于Linux是一个多用户管理的操作系统,而Linux默认情况下并不限制每个用户使用磁盘空间的大小,假如某个用户疏忽或者恶意占满磁盘空间,将导致系统磁盘无法写入甚至崩溃,为了保证系统磁盘的有足够的剩余 ...

  8. idea2018 破解

    本人使用的是idea2018.1.11,对2018其它版本的应该都是管用的 idea2018-1.11 下载地址 链接:https://pan.baidu.com/s/1_RlJGZtfMxr1Nx9 ...

  9. P4396 [AHOI2013] 作业 题解

    题目链接:作业 其实可以类似"HH的项链"转化为偏序问题再 cdq 分治.不过这题感觉莫队然后值域分块很好写啊,基本不用动脑. 考虑查询的两个信息: \(a \le x\le b\ ...

  10. Linux中如何查找特定的数据是否在目录或文件中

    一个很简单的方式就是使用grep命令,grep命令是一个强大有效可靠并且很流行的命令行工具,用于查找对应的数据包含文件或者目录中在Linux环境中. 为了便于学习,我们准备了以下文件,具体想要查找以实 ...