配置环境
- 在goldnurse-rnc-dubbo-service/pom.xml 中dubbo、zookeeper添加依赖
<!--整合dubbo-->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>2.7.6</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.6.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>4.3.0</version>
</dependency>
- 在 application-local.yml 中添加配置信息
embedded:
zookeeper:
port: 2181
dubbo:
scan:
base-packages: com.goldnurse.rnc
protocol:
name: dubbo
port: 20880
registry:
address: 127.0.0.1:2181
protocol: zookeeper
application:
name: rnc-dubbo-service
- 在接口实现类上添加 @org.apache.dubbo.config.annotation.Service(version = “1.0.0”)
@org.apache.dubbo.config.annotation.Service(version = "1.0.0")
4. 启动main函数,如图,启动成功
5. 启动dubbo-admin-server
dubbo-admin 打包详见官方文档,需多次尝试打包,经历多次失败。
java -jar dubbo-admin-server-0.1.jar
6. 通过dubbo管理后台,查看已开发完成的dubbo服务