集成SpringCloud出现MvcFoundOnClasspathException

原因:spring-cloud-starter-gateway已经包含了webmvc的功能,此时再引入spring-boot-starter-web会导致此问题。

解决:去掉spring-boot-starter-web的依赖,再进行mvn install

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Spring Cloud是一个基于Spring Boot的开发工具,它为基于JVM的云应用程序开发提供了一组丰富的框架和库。Spring Cloud提供了许多有用的功能,例如服务发现、配置管理、负载均衡、断路器、智能路由等,这些功能可以帮助我们更轻松地构建分布式系统。下面是Spring集成Spring Cloud的步骤: 1.在pom.xml文件中添加Spring Cloud的依赖: ```xml <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> <version>2.2.5.RELEASE</version> </dependency> ``` 2.在启动类上添加@EnableEurekaServer注解,开启Eureka Server: ```java @SpringBootApplication @EnableEurekaServer public class EurekaServerApplication { public static void main(String[] args) { SpringApplication.run(EurekaServerApplication.class, args); } } ``` 3.在application.yml文件中配置Eureka Server: ```yaml server: port: 8761 eureka: instance: hostname: localhost client: register-with-eureka: false fetch-registry: false ``` 4.在需要注册到Eureka Server的服务中添加Eureka Client的依赖: ```xml <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <version>2.2.5.RELEASE</version> </dependency> ``` 5.在启动类上添加@EnableDiscoveryClient注解,开启Eureka Client: ```java @SpringBootApplication @EnableDiscoveryClient public class ServiceApplication { public static void main(String[] args) { SpringApplication.run(ServiceApplication.class, args); } } ``` 6.在application.yml文件中配置Eureka Client: ```yaml server: port: 8080 spring: application: name: service eureka: client: service-url: defaultZone: http://localhost:8761/eureka/ ``` 以上是Spring集成Spring Cloud的基本步骤,其中Eureka Server和Eureka Client是Spring Cloud中最常用的组件之一。除此之外,Spring Cloud还提供了许多其他有用的组件,例如Zuul、Ribbon、Hystrix等,可以根据具体需求进行选择和集成

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值