谷粒商城ThirdPartyApplication启动报错: Oss endpoint can‘t be empty解决总结

谷粒商城基础篇报错集合 谷粒商城基础篇报错集合 1.完成third-party模块阿里云oss对象存储功能后,发现renren-fast模块无法启动 并报以下错误: Error creating bean with name 'ossClient' defined in class path resource [com/alibaba/alicloud/context/oss/OssContextAutoConfiguration.class]: Bean instantiation via factory method fai 阅读详情

我创建的项目引入Springboot版本:2.6.13,Springcloud版本:2021.0.5,Spring-cloud-aplibaba版本:2021.0.5.0,nacos版本:2.2.1.RELEASE。项目在父pom.xml中使用dependencyManagement减少子项目重复引入jar,统一版本的管理。

最近学习谷粒商城P63 OSS云存储练手时,运行创建第三方服务GulimallThirdPartyApplication.java报错:Oss endpoint can't be empty。

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.aliyun.oss.OSS]: Factory method 'ossClient' threw exception; nested exception is java.lang.IllegalArgumentException: Oss endpoint can't be empty.
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.23.jar:5.3.23]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.23.jar:5.3.23]
	... 19 common frames omitted
Caused by: java.lang.IllegalArgumentException: Oss endpoint can't be empty.
	at org.springframework.util.Assert.isTrue(Assert.java:121) ~[spring-core-5.3.23.jar:5.3.23]
	at com.alibaba.alicloud.context.oss.OssContextAutoConfiguration.ossClient(OssContextAutoConfiguration.java:53) ~[spring-cloud-alicloud-context-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_221]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_221]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_221]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_221]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.23.jar:5.3.23]
	... 20 common frames omitted

单独把oss.yml的配置放到application.yml中运行正常,但把oss.yml的提取出来配置到Nacos的配置中心运行就报这个错,搞得郁闷得很,一阵网上搜索解决了。

在网上搜索这种报错总结大概分为3种情况:

第一种:在oss.yml里配置错误。

第二种:在thirdparty的pom.xml里面配置springboot和springcloud版本不对应。

第三种:在application.yml配置不对。

于是乎我按网上说的方法逐一排查,先按第一种:检查nacos的配置oss.yml发现其中确实配置错了,修改后正确如下:

spring:
  cloud:
    alicloud:
      access-key: LTAI5tS6Kit9dU2KPJnBvByb
      secret-key: YCo25kTUzfbiuXz5QDNdauwJQiD2Rg
      oss:
        endpoint: oss-cn-beijing.aliyuncs.com
    util:
      enabled: false

改了这个配置后重启项目还是报相同的错,于是又按第二种:修改第三方服务(thirdparty)的pom.xml配置如下:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>mygulishop</artifactId>
        <groupId>com.tfq</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>third-party</artifactId>

    <name>third-party</name>
    <!-- FIXME change it to the project's website -->
    <url>http://www.example.com</url>
    <packaging>jar</packaging>
    <description>第三方服务</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bootstrap</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
        </dependency>
        <dependency>
            <groupId>com.tfq</groupId>
            <artifactId>guli-common</artifactId>
            <version>1.0-SNAPSHOT</version>
            <!-- 暂时不使用Mybatis,排除-->
            <exclusions>
                <exclusion>
                    <groupId>com.baomidou</groupId>
                    <artifactId>mybatis-plus-boot-starter</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alicloud-oss</artifactId>
            <version>2.2.0.RELEASE</version>
        </dependency>
    </dependencies>

    <build>

    </build>
</project>
spring-cloud-starter-bootstrap是Springboot从2.4.x以后加载bootstrap.yml必须要的。不然会报以下错:
org.springframework.cloud.commons.ConfigDataMissingEnvironmentPostProcessor$ImportException: No spring.config.import set
	at org.springframework.cloud.commons.ConfigDataMissingEnvironmentPostProcessor.postProcessEnvironment(ConfigDataMissingEnvironmentPostProcessor.java:82)
	at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:102)
	at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:87)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:85)
	at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:66)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:120)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:114)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:65)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:343)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:301)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1317)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
	at com.tfq.ThirdPartyApplication.main(ThirdPartyApplication.java:11)
17:24:09.339 [main] ERROR org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - 

***************************
APPLICATION FAILED TO START
***************************

Description:

No spring.config.import property has been defined

Action:

Add a spring.config.import=nacos: property to your configuration.
	If configuration is not required add spring.config.import=optional:nacos: instead.
	To disable this check, set spring.cloud.nacos.config.import-check.enabled=false.


Process finished with exit code 1
spring-cloud-starter-alibaba-nacos-config是加载nacos的oss.yml的文件,当你不引入此包,会报相同错:Oss endpoint can't be empty。
我用了前面两种方式后,由于当前idea2022没有重新编译,导致也报相同错误。注:大家按第一二种方式处理了一定要重新compile。
由于我做完第一二种方法没有重新编译,又试了第三种在aplication.yml中配置spring.cloud.bootstrap.enabled=true没用。官方说可以配置但没用,仍然报这个错。官方链接:

Spring Cloud Config

最后我又重新编译就不报错,能加载oss的配置了,ossclient也能实例化了。

参考:

java.lang.IllegalArgumentException: Oss endpoint can‘t be empty.*-优快云博客

Oss endpoint can‘t be empty.记录第一次弄了三四个小时的bug_spring boot_m0_63161054-华为云开发者联盟

记录一次错误解决:Oss endpoint can‘t be empty(谷粒商城P63)_oss endpoint can't be empty.-优快云博客

阿里云ossjava源码-gulimall:谷粒商城 阿里云 oss java源码 一、项目架构图 二、分布式基础概念 1、微服务 微服务架构风格,就像是把一个单独的应用程序开发为一套小服务,每个小服务运行在自己的进程中,并使用轻量级机制通信,通常是 HTTP API。这些服务围绕业务能力来构建,并通过完全自动化部署机制来独立部署。这些服务使用不同的编程语言书写,以及不同数据储存技术,并保持最低限度的集中式管理。 简而言之:拒绝大型单体应用,基于业务边界进行微服务化拆分,各个服务独立部署运行。 2、集群、分布式、节点 集群是个物理形态,分布式是个工作方式。 只要是一堆机器,就可以叫集群,他们是不是一起协作干活,这个谁也不知道。《分布式系统原理与范型》定义:分布式系统是若干独立计算机的集合,这些计算机对于用户来说就像单个相关系统,分布式系统(distribute system)是建立在网络智商的软件系统。分布式是指将不同的业务分布在不同的地方。集群指的是将几台机器集中在一起,实现同一业务。 例如:**京东是一个分布式系统,众多业务运行在不同的机器,所有业务构成一个大型的业务集群。**每一个小的业务,比如用户系统,访问压力大的时候一台服务器是 立即下载

相关推荐

Meta-World环境实战解析:pick-place-v2中的状态观测与动作控制

本文深入解析了Meta-World中pick-place-v2环境的强化学习实战要点。文章详细拆解了39维状态观测向量的构成与意义,包括机械臂末端、物体位置及目标坐标,并揭示了默认部分可观测设置的潜在影响。同时,阐述了4维动作空间的控制逻辑与奖励函数的分阶段设计,为训练高效稳定的抓放策略提供了核心指导与实用调优技巧。

weixin_29184371的博客 75

解决报错 Oss endpoint can‘t be empty

2、注释了上面公共模块的oss依赖,留下用文件上传模块的依赖。

weixin_70498111的博客 1414

速腾Helios-16P使用Lego-loam实时构建点云地图(二)——Lego-loam的编译与运行

不兼容的问题,打开lego-loam的~/lego-loam_ws/src/LeGO-LOAM/LeGO-LOAM/src下的4个源码文件,搜索/camera_init,将所有/camera_init改成camera_init,也就是去掉斜杠,这样再回到工作空间重新编译lego-loam。3、速腾16线激光雷达RS-16 ----- 3D建图算法LeGO-LOAM的使用(Ubuntu18.04 + ROS Melodic)_速腾16线 lego loam_杰尼君的博客-优快云博客。

qq_59475883的博客 2567

Oss endpoint can‘t be empty.

但当我把OSS放在Nacos配置中心上时,微服务报错提示Oss endpoint can‘t be empty.当我把OSS的配置写在application.yml上是,微服务可以正常执行。此时我排除网上所说的版本问题和配置格式问题,,于是我翻阅资料找到原因,重新运行项目,成功!

Wiken4的博客 1580

实战指南:R语言多组倾向评分逆概率加权(IPTW)建模与结果解读

本文详细介绍了如何使用R语言实现多组倾向评分逆概率加权(IPTW)建模,包括数据预处理、倾向评分估计、权重计算及结果解读。通过实战案例演示,帮助研究者掌握这一统计方法,有效平衡多组混杂因素,模拟随机对照试验效果,适用于医学、社会科学等领域的数据分析。

weixin_42528534的博客 392

ICG setup timing violation介绍?

门控时钟(clock gating)在RTL级电路设计过程中进行低功耗优化常用方法,能够有效降低动态功耗(翻转功耗)。Clock gating cell 可以由与门,与非门,或门或者或非门构成,但很容易产生Glitch。在实际使用中,一般用ICG(集成门控时钟单元)来完成clock gating。 下图展示了glitch的产生原因 在CTS时钟树综合的时候,ICG不会被看作sink,通常放置在source点附近,因此就会出现如上图这种结果。上图可以看出,在分析DFF到ICG的setup timing

m0_61003348的博客 9801

Oss endpoint can‘t be empty.记录第一次弄了三四个小时的bug

解决Oss endpoint can't be empty.问题的第三种可能

m0_63161054的博客 2920

手把手教你搭建硬件在回路(HIL)仿真系统:从Simulink建模到实时测试

本文详细介绍了如何从零开始搭建硬件在回路(HIL)仿真系统,涵盖Simulink建模、实时仿真、代码生成及调试等关键步骤。通过具体配置示例和优化技巧,帮助开发者解决复杂控制系统验证中的技术难题,提升半实物仿真的效率和可靠性。

weixin_30952535的博客 445

微服务启动报错:Caused by: java.lang.IllegalArgumentException: Oss endpoint can‘t be empty.

Oss endpoint can't be empty

Vally505的博客 2670

如何通过 GitHub Actions 使用 SSH 自动化部署到阿里云 ECS 实例

通过 GitHub Actions 和 SSH 自动化部署,可以显著提高你的开发效率和部署的可靠性。本文介绍了如何生成 SSH 密钥、将公钥添加到阿里云 ECS 实例、将私钥添加到 GitHub Secrets,以及编写 GitHub Actions 工作流来实现自动化部署。希望这篇文章对你有所帮助!

吃面不喝汤的博客 1510

SPMI协议学习总结

SPMI(System Power Management Interface)是由MIPI(Mobile Industry Processor Interface)联盟定义的一种硬件接口标准,它主要用于移动设备中,连接SoC(System on Chip)处理器系统的集成电源控制器与一个或多个电源管理IC(PMIC),以实现精确的电源管理

歌颂苦难的行为是无耻的; 1078

谷粒商城GatewayApplication报错:Oss endpoint can‘t be empty

网关部分通过传递依赖有了`oss`依赖,但本身并没有配置`oss`的相关信息,比如`endpoint`,所以运行之后会报错。

qq_53763141的博客 911

基于STM32、HAL库的TCA9555PWR I/O扩展器驱动程序设计

define TCA9555_ADDR_BASE 0x20 // 基础地址 (A0=A1=A2=0)* @param direction: 方向 (0=输出, 1=输入)* @param direction: 方向 (0=输出, 1=输入)* @param polarity: 极性 (0=正常, 1=反转)* @param polarity: 极性 (0=正常, 1=反转)

corlin6688的博客 525

记录一次错误解决:Oss endpoint can‘t be empty(谷粒商城P63)

springcloud与springboot的兼容版本链接

zsy_yyds的博客 1352

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

java.lang.IllegalArgumentException: Oss endpoint can‘t be empty.*

谷粒商城配置oss报错

weixin_43431346的博客 1438

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

阿里云图片或文件上传,启动时报错:Error creating bean with name ‘ossClient‘

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'OSSClient' defined in class path resource [com/certificate_collector_two/test/config/AliyunOssConfig.class]: Bean instantiation via factory method failed; nested except

weixin_44735825的博客 6310

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

谷粒商城:Oss endpoint can‘t be empty.

谷粒商城单独建立gulimall-third-party配置完成后启动项目报错 Error creating bean with name 'ossClient' defined in class path resource [com/alibaba/alicloud/context/oss/OssContextAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.s.

ZUCK的博客 2078

记录一下学习OOS存储的时候:Oss endpoint can‘t be empty

问题描述: 在使用OSS对象存储的时候,遇到记录一下学习OOS存储,控制台抛出 Oss endpoint can't be empty <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alicloud-oss</artifactId> <

weixin_43688870的博客 4508

Factory method 'oSSClient' threw exception; nested exception is java.lang.No 问题解决

项目使用阿里云存储,但在pom.xml又引入了http的支持依赖会发生该错误, 我移除了这两个就没事了 <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> ...

CoSword 2万+

谷粒商城错误:Caused by: java.lang.IllegalArgumentException: Oss endpoint can‘t be empty.

谷粒商城错误:Caused by: java.lang.IllegalArgumentException: Oss endpoint can’t be empty. Caused by: java.lang.IllegalArgumentException: Oss endpoint can't be empty. 错误原因:oss.yml文件格式错误

user_nTR23的博客 1434

谷粒商城 Oss endpoint can‘t be empty

Oss endpoint can‘t be empty

stephenhl的博客 2204

谷粒商城配置OSS,Oss endpoint can‘t be empty.

配置阿里云oss时第一步 <dependency> <groupId>com.aliyun.oss</groupId> <artifactId>aliyun-sdk-oss</artifactId> </dependency> 上传文件成功了,接着使用 <dependency> <groupId>com.alibaba.cloud</groupId>

gpy1240301202的博客 3321

Unsatisfied dependency expressed through field ‘ossClient‘; nested exception is org.springframework.

【代码】Unsatisfied dependency expressed through field ‘ossClient‘;

进步中~ 1108

谷粒商城网关Oss endpoint can‘t be empty

谷粒商城网关Oss endpoint can't be empty

xiajingbaobao的博客 561

OSS The bucket you are attempting to access must be addressed using the specified endpoint.

用阿里的OSS进行文件存储时候报出了下面异常:   网上搜了大家的解决方式,大家的解决方式都不太一样,然后我仔细看了看异常内容,对比我自己的配置文件,发现了end_point_extranet 是不同的,我自己用的是 http://oss-cn-hangzhou.aliyuncs.com,按照异常里的地址改成 http://oss-cn-qingdao.aliyuncs.com 就好啦。 ...

test 4万+
上一篇: vue2引入brand.vue和brand-add-or-update.vue后重启项目报错解决方案
下一篇: 学习单向链表带哨兵demo
developerFBI
博客等级 码龄15年 174粉丝 105原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值