dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

dubbo相关包在gradle配置下的重复类问题

Open soiz-tor opened this issue 2 years ago • 2 comments

环境:

jdk:19
dubbo:3.2.0-beta5

我的gradle配置:

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.0.4'
    id 'io.spring.dependency-management' version '1.1.0'
}

group = 'org.example'
version = '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.json:json:20230227'
    implementation 'org.springframework.boot:spring-boot-starter'
    implementation 'org.apache.dubbo:dubbo-spring-boot-starter:3.2.0-beta.5'
    implementation 'org.apache.dubbo:dubbo-registry-nacos:3.2.0-beta.5'
    testImplementation platform('org.junit:junit-bom:5.9.1')
    testImplementation 'org.junit.jupiter:junit-jupiter'
}

test {
    useJUnitPlatform()
}

测试代码:

public class DubboTest {
    public static void main(String[] args) {
        LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
        loggerContext.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME).setLevel(Level.ERROR);
        // 应用配置
        ApplicationConfig application = new ApplicationConfig();
        application.setName("dubbo-test");
        application.setQosPort(22223);

        // 注册中心配置
        RegistryConfig registry = new RegistryConfig();
        registry.setAddress("nacos://192.168.220.128:8848");

        // 引用远程服务
        ReferenceConfig<GenericService> reference = new ReferenceConfig<>();
        reference.setApplication(application);
        reference.setRegistry(registry);
        reference.setInterface("com.psyjournel.api.user.UserService");
        reference.setGeneric("true");
        
        // 获取远程服务代理
        GenericService genericService = reference.get();

        // 调用远程方法
        Object result = genericService.$invoke("loginService", new String[] {"java.lang.String"}, new Object[] {"world"});
        Map<String, Object> resultMap = (HashMap<String, Object>) result;
        JSONObject json = new JSONObject(resultMap);
        System.out.println(json);
    }
}

重复的类报错:

13:34:04.799 [main] ERROR org.apache.dubbo.common.Version -  [DUBBO] Duplicate class org/apache/dubbo/common/Version.class in 2 jar [file:/C:/Users/isyan/.gradle/caches/modules-2/files-2.1/org.apache.dubbo/dubbo/3.2.0-beta.5/ac509f1bf4b796ae06e40e973f9208786c270878/dubbo-3.2.0-beta.5.jar!/org/apache/dubbo/common/Version.class, file:/C:/Users/isyan/.gradle/caches/modules-2/files-2.1/org.apache.dubbo/dubbo-common/3.2.0-beta.5/5ae76b4dfe23fd85b08e203accab805922056b87/dubbo-common-3.2.0-beta.5.jar!/org/apache/dubbo/common/Version.class], dubbo version: 3.2.0-beta.5, current host: 192.168.189.1, error code: 0-12. This may be caused by , go to https://dubbo.apache.org/faq/0/12 to find instructions. 
13:34:05.617 [main] ERROR org.apache.dubbo.common.Version -  [DUBBO] Duplicate class org/apache/dubbo/remoting/exchange/Exchangers.class in 2 jar [file:/C:/Users/isyan/.gradle/caches/modules-2/files-2.1/org.apache.dubbo/dubbo-remoting-api/3.2.0-beta.5/2edf1e11b6a135fb5b821666f3d4f0735cb4f60e/dubbo-remoting-api-3.2.0-beta.5.jar!/org/apache/dubbo/remoting/exchange/Exchangers.class, file:/C:/Users/isyan/.gradle/caches/modules-2/files-2.1/org.apache.dubbo/dubbo/3.2.0-beta.5/ac509f1bf4b796ae06e40e973f9208786c270878/dubbo-3.2.0-beta.5.jar!/org/apache/dubbo/remoting/exchange/Exchangers.class], dubbo version: 3.2.0-beta.5, current host: 192.168.189.1, error code: 0-12. This may be caused by , go to https://dubbo.apache.org/faq/0/12 to find instructions. 
13:34:05.623 [main] ERROR org.apache.dubbo.common.Version -  [DUBBO] Duplicate class org/apache/dubbo/remoting/Transporters.class in 2 jar [file:/C:/Users/isyan/.gradle/caches/modules-2/files-2.1/org.apache.dubbo/dubbo-remoting-api/3.2.0-beta.5/2edf1e11b6a135fb5b821666f3d4f0735cb4f60e/dubbo-remoting-api-3.2.0-beta.5.jar!/org/apache/dubbo/remoting/Transporters.class, file:/C:/Users/isyan/.gradle/caches/modules-2/files-2.1/org.apache.dubbo/dubbo/3.2.0-beta.5/ac509f1bf4b796ae06e40e973f9208786c270878/dubbo-3.2.0-beta.5.jar!/org/apache/dubbo/remoting/Transporters.class], dubbo version: 3.2.0-beta.5, current host: 192.168.189.1, error code: 0-12. This may be caused by , go to https://dubbo.apache.org/faq/0/12 to find instructions. 
13:34:05.623 [main] ERROR org.apache.dubbo.common.Version -  [DUBBO] Duplicate class org/apache/dubbo/remoting/RemotingException.class in 2 jar [file:/C:/Users/isyan/.gradle/caches/modules-2/files-2.1/org.apache.dubbo/dubbo-remoting-api/3.2.0-beta.5/2edf1e11b6a135fb5b821666f3d4f0735cb4f60e/dubbo-remoting-api-3.2.0-beta.5.jar!/org/apache/dubbo/remoting/RemotingException.class, file:/C:/Users/isyan/.gradle/caches/modules-2/files-2.1/org.apache.dubbo/dubbo/3.2.0-beta.5/ac509f1bf4b796ae06e40e973f9208786c270878/dubbo-3.2.0-beta.5.jar!/org/apache/dubbo/remoting/RemotingException.class], dubbo version: 3.2.0-beta.5, current host: 192.168.189.1, error code: 0-12. This may be caused by , go to https://dubbo.apache.org/faq/0/12 to find instructions. 

soiz-tor avatar Mar 07 '23 05:03 soiz-tor

Version 的这个检查与 dubbo-all shade 有关系,这个后面需要整个删掉。最好换成每个 jar 带一个 commit 的配置文件,在 Version 中检查对应的版本是否都对齐,如果不对齐则报错

AlbumenJ avatar Mar 13 '23 11:03 AlbumenJ

duplicate with #10228, fixed in 3.2.0

xtyuns avatar May 18 '24 02:05 xtyuns