dubbo官网的如下实例编译问题整理
https://cn.dubbo.apache.org/zh/docs3-v2/java-sdk/quick-start/idl/
报dubbo-compiler缺失,使用手动安装如下jar到mvn仓库
mvn install:install-file -DgroupId=org.apache.dubbo -DartifactId=dubbo-compiler -Dversion=3.1.5-SNAPSHOT -Dpackaging=jar -Dfile=/Users/baiyan3/Downloads/dubbo-3.1/dubbo-compiler/target/dubbo-compiler-3.1.5-SNAPSHOT.jar
下载dubbo
https://github.com/apache/dubbo
执行打包命令
mvn package -Dmaven.test.skip=true
将自动把dubbo每个组件的jar包安装到mvn的repository目录下
按照
https://cn.dubbo.apache.org/zh/docs3-v2/java-sdk/quick-start/idl/
这个说明的pom文件编译会出错
当然使用protobuf 需要安装protoc命令
Invalid multicast address /127.0.0.1, ipv4 multicast address scope: 224.0.0.0 - 239.255.255.255
修改如下代码
src/main/java/org/apache/dubbo/MyDubboServer.java
src/main/java/org/apache/dubbo/MyDubboClient.java
new RegistryConfig("zookeeper://127.0.0.1:2181")
同时需要启用zookeeper服务,借用下kafka带的zookeeper服务
bin/zookeeper-server-start.sh config/zookeeper.properties
如果maven plugin 编译proto文件报错,手动编译测试看下报错信息
protoc -I=/tri-stub-demo/src/main/proto --java_out=/java/tri-stub-demo/target/tmp/ /java/tri-stub-demo/src/main/proto/hello.proto
官网实例中调整完的pom.xml内容如下
4.0.0 org.apache.dubbo tri-stub-demo1.0-SNAPSHOT tri-stub-demo http://www.example.com UTF-8 1.8 1.8 junit junit 4.13 test org.apache.dubbo dubbo 3.0.8 org.apache.dubbo dubbo-rpc-triple 3.1.1 org.apache.dubbo dubbo-dependencies-zookeeper-curator5 pom 3.0.8 com.google.protobuf protobuf-java 3.21.10 kr.motd.maven os-maven-plugin 1.6.1 maven-clean-plugin 3.1.0 maven-resources-plugin 3.0.2 maven-compiler-plugin 3.8.0 maven-surefire-plugin 2.22.1 maven-jar-plugin 3.0.2 maven-install-plugin 2.5.2 maven-deploy-plugin 2.8.2 maven-site-plugin 3.7.1 maven-project-info-reports-plugin 3.0.0 org.codehaus.mojo build-helper-maven-plugin generate-sources add-source org.xolstice.maven.plugins protobuf-maven-plugin 0.6.1 /Users/baiyan3/java/protoc-21.9-osx-aarch_64/bin/protoc com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier} ${project.basedir}/src/main/proto dubbo org.apache.dubbo dubbo-compiler 3.1.1 org.apache.dubbo.gen.tri.Dubbo3TripleGenerator compile
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧
当前标题:dubbo官网实例(IDL定义跨语言服务)编译问题整理-创新互联
网页路径:http://scpingwu.com/article/dsioch.html