zoukankan      html  css  js  c++  java
  • springboot注册到consul中报错:Spring MVC found on classpath, which is incompatible with Spring Cloud

    今天在做springboot整合成springCloud并注册到consul中时,发现若注册到consule中成功 则不能启动swagger,且不能提供任何API服务,要是能提供API服务则不能注册到consule中,并报错“

    1. Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway at this time. "+
    2. "Please remove spring-boot-starter-web dependency

    分析了一下,发现在如下代码中会报这个log信息

    1. @Configuration
    2. @AutoConfigureBefore(GatewayAutoConfiguration.class)
    3. public class GatewayClassPathWarningAutoConfiguration {
    4. private static final Log log = LogFactory.getLog(GatewayClassPathWarningAutoConfiguration.class);
    5. private static final String BORDER = " ********************************************************** ";
    6. @Configuration
    7. @ConditionalOnClass(name = "org.springframework.web.servlet.DispatcherServlet")
    8. protected static class SpringMvcFoundOnClasspathConfiguration {
    9. public SpringMvcFoundOnClasspathConfiguration() {
    10. log.warn(BORDER+"Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway at this time. "+
    11. "Please remove spring-boot-starter-web dependency."+BORDER);
    12. }
    13. }
    14. @Configuration
    15. @ConditionalOnMissingClass("org.springframework.web.reactive.DispatcherHandler")
    16. protected static class WebfluxMissingFromClasspathConfiguration {
    17. public WebfluxMissingFromClasspathConfiguration() {
    18. log.warn(BORDER+"Spring Webflux is missing from the classpath, which is required for Spring Cloud Gateway at this time. "+
    19. "Please add spring-boot-starter-webflux dependency."+BORDER);
    20. }
    21. }
    22. }

    最终,我们分析是swagger启动时所要的jar包和springCloud有所冲突,修改我们的POM文件如下,主要是版本的问题:

       发现consul 1.2版本需要和SpringCloud的Finchley版本才能整合

    1. <parent>
    2. <groupId>org.springframework.boot</groupId>
    3. <artifactId>spring-boot-starter-parent</artifactId>
    4. <version>2.0.3.RELEASE</version>
    5. <relativePath/> <!-- lookup parent from repository -->
    6. </parent>
    7. <dependencyManagement>
    8. <dependencies>
    9. <dependency>
    10. <groupId>org.springframework.cloud</groupId>
    11. <artifactId>spring-cloud-dependencies</artifactId>
    12. <version>Finchley.RELEASE</version>
    13. <type>pom</type>
    14. <scope>import</scope>
    15. </dependency>
    16. </dependencies>
    17. </dependencyManagement>

    原文地址:https://blog.csdn.net/qq116165600/article/details/90640451

  • 相关阅读:
    杜马岛
    Type interface com.zhaoka.mapper.DatKcardKmMapper is not known to the MapperRegistry
    jsp实现自动登录
    Struts2中的get、set方法重要性 .
    struts2 通过前台标签name属性将值传到后台,没有name属性传值,则后台对象有默认值,不为null。
    Jsp 操作 Cookie 实现自动登录
    struts2的bean类名首字母和第二个字母都不能大写
    mybatis自动生成的ExamMapper.xml方法总结
    Mybatis插入时注意,没有主键值。所以主键一般为自增类型
    <ywaf:code code="${project.projectType}" typeCode="PROJECT_TYPE"/>
  • 原文地址:https://www.cnblogs.com/jpfss/p/11912988.html
Copyright © 2011-2022 走看看