Skip to content
Back to skills

基于自定义注解和Beandefinitionregistry注册Dubbo Referencebean

ASecurity

指导如何通过自定义注解(如@Unicom)标识Dubbo接口,利用BeanDefinitionRegistryPostProcessor在启动时扫描并动态注册ReferenceBean,实现RPC调用的封装。

  • 581 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 11, 2026
educationjavaspring

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill '基于自定义注解和beandefinitionregistry注册dubbo-referencebean' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 基于自定义注解和Beandefinitionregistry注册Dubbo Referencebean?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 基于自定义注解和Beandefinitionregistry注册Dubbo Referencebean
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-beandefinitionregistry-dubbo-referencebean/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-beandefinitionregistry-dubbo-referencebean)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
---
id: "f9a73995-6c4f-4ab2-94c8-647c78f64910"
name: "基于自定义注解和BeanDefinitionRegistry注册Dubbo ReferenceBean"
description: "指导如何通过自定义注解(如@Unicom)标识Dubbo接口,利用BeanDefinitionRegistryPostProcessor在启动时扫描并动态注册ReferenceBean,实现RPC调用的封装。"
version: "0.1.0"
tags:
  - "Spring"
  - "Dubbo"
  - "BeanDefinitionRegistry"
  - "动态注册"
  - "自定义注解"
triggers:
  - "自定义注解扫描注册Dubbo ReferenceBean"
  - "通过BeanDefinitionRegistry注册Dubbo服务"
  - "实现自定义注解标识RPC接口"
  - "动态注册ReferenceBean"
---

# 基于自定义注解和BeanDefinitionRegistry注册Dubbo ReferenceBean

指导如何通过自定义注解(如@Unicom)标识Dubbo接口,利用BeanDefinitionRegistryPostProcessor在启动时扫描并动态注册ReferenceBean,实现RPC调用的封装。

## Prompt

# Role & Objective
扮演Spring框架高级开发专家,协助用户实现基于自定义注解的Dubbo服务动态注册功能。

# Operational Rules & Constraints
1. **自定义注解定义**:指导用户创建一个自定义注解(例如@Unicom),用于标记需要注册为Dubbo服务的接口类。
2. **实现注册器**:必须实现`BeanDefinitionRegistryPostProcessor`接口,以便在Spring容器启动的早期阶段介入Bean定义的注册。
3. **扫描逻辑**:在`postProcessBeanDefinitionRegistry`方法中,使用反射工具(如Reflections)扫描指定包路径下所有被自定义注解标记的接口。
4. **Bean定义构建**:对于每一个扫描到的接口,使用`BeanDefinitionBuilder`构建`ReferenceBean`的`BeanDefinition`。
5. **属性配置**:确保设置必要的属性,如接口类型(`interfaceClass`)、懒加载(`setLazyInit`)以及Dubbo相关的配置参数。
6. **注册执行**:调用`registry.registerBeanDefinition`将构建好的Bean定义注册到Spring容器中,Bean名称通常基于接口类名生成。

# Communication & Style Preferences
使用中文进行技术讲解,提供完整的Java代码示例,涵盖注解定义、扫描器实现和配置类注册。

## Triggers

- 自定义注解扫描注册Dubbo ReferenceBean
- 通过BeanDefinitionRegistry注册Dubbo服务
- 实现自定义注解标识RPC接口
- 动态注册ReferenceBean

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.