org.springframework.context.ApplicationContextException: SpringBoot项目启动报错

原因:在我写一个服务模块,pom文件引入另一个util模块时,启动服务模块报的这个错,原因是util模块的pom文件中依赖引入错误,因为我要用到MultipartFile这个类,所以想着直接快速添加这个依赖,添加的依赖就是导致我报错的原因:

        <dependency>
            <groupId>repository_usian-leannews.org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>5.3.13</version>
        </dependency>

解决办法:将依赖更改为

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.1.5.RELEASE</version>
        </dependency>
启动EnableEurekaServer时遇到org.springframework.beans.factory.BeanCreationException错误通常是由于配置问题或依赖项缺失引起的。以下是一些可能的解决方法: 1. 检查依赖项:确保在pom.xml文件中正确添加了所需的依赖项。特别是,确保已添加spring-boot-starter-web和spring-cloud-starter-netflix-eureka-server依赖项。 2. 检查配置:检查application.properties或application.yml文件中的配置是否正确。特别是,确保已正确配置Eureka Server的相关属性,如server.port和eureka.client.register-with-eureka。 3. 检查包扫描:确保@EnableEurekaServer注解位于Spring Boot应用程序的主类上,并且正确扫描了所有的包。 4. 检查端口冲突:如果在启动Eureka Server时遇到端口冲突错误,请确保所选的端口未被其他应用程序占用。 5. 检查日志:查看详细的错误日志以获取更多信息。日志通常会提供有关错误的更多上下文和堆栈跟踪信息,以帮助你定位问题。 以下是一个示例的启动EnableEurekaServer的代码: ```java import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; @SpringBootApplication @EnableEurekaServer public class EurekaServerApplication { public static void main(String[] args) { SpringApplication.run(EurekaServerApplication.class, args); } } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值