• Springboot -- 由于jar版本不匹配遇到的问题


    网上整合dubbo的例子很多,我这边今天整合了一个例子,但是发现启动dubbo service时候,提示log4j日志类无法找到,启动client的时候,注入的service为空,调试了半天,编码并无误

    最终发现是由于版本号的原因,

     <dependency>
                <groupId>io.dubbo.springboot</groupId>
                <artifactId>spring-boot-starter-dubbo</artifactId>
                <version>1.0.0</version>
            </dependency>

    引入的是最新的spring-boot-starter-dubbo的依赖。 
    使用springboot的版本号:2.0.4.RELEASE

    <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.0.4.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>

    http://mvnrepository.com/artifact/io.dubbo.springboot/spring-boot-starter-dubbo/1.0.0可以注意到依赖的版本关系。

     

    如上图,可以看出springboot2.0.4-RELEASE版本对应的zkclient版本应该为0.10,而spring-boot-starter-dubbo自动引入的zkclient版本为0.7所以会出现一堆难解决的问题,更新后,项目正常运行。

    完整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">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.example</groupId>
        <artifactId>spring-boot-dubbo-client</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>
    
        <name>spring-boot-dubbo-client</name>
        <description>Demo project for Spring Boot</description>
    
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.0.4.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            <java.version>1.8</java.version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
            <!-- https://mvnrepository.com/artifact/io.dubbo.springboot/spring-boot-starter-dubbo -->
            <dependency>
                <groupId>io.dubbo.springboot</groupId>
                <artifactId>spring-boot-starter-dubbo</artifactId>
                <version>1.0.0</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/com.101tec/zkclient -->
            <dependency>
                <groupId>com.101tec</groupId>
                <artifactId>zkclient</artifactId>
                <version>0.10</version>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    
    
    </project>
  • 相关阅读:
    angularjs学习之六(angularjs中directive指令的一般编程事件绑定 模板使用等)
    Flex 容器基本概念
    flex 4 布局样式
    flex 特效
    delphi ehLib 安装包下载及安装方法
    CnPack IDE 专家包(CnWizards)显示代引用单元列表
    Delphi 获取DataSet传入参数后的SQL命令
    偶写的第一个控件,一个用选择代替输入的Edit控件…
    delphi中响应鼠标进入或离开控件的方法
    Delphi常用关键字用法详解
  • 原文地址:https://www.cnblogs.com/zhaoyan001/p/9814568.html
Copyright © 2020-2023  润新知