基于自定义注解和BeanDefinitionRegistry动态注册RPC接口Bean
该技能用于指导如何通过自定义注解(如@Unicom)标识RPC服务接口,并利用BeanDefinitionRegistry在Spring启动时动态扫描并注册对应的FactoryBean(如Dubbo的ReferenceBean或Feign的FeignClientFactoryBean),实现RPC调用的封装。
npx skills add ECNU-ICALK/AutoSkill --skill 基于自定义注解和beandefinitionregistry动态注册rpc接口bean --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 基于自定义注解和BeanDefinitionRegistry动态注册RPC接口Bean 该技能用于指导如何通过自定义注解(如@Unicom)标识RPC服务接口,并利用BeanDefinitionRegistry在Spring启动时动态扫描并注册对应的FactoryBean(如Dubbo的ReferenceBean或Feign的FeignClientFactoryBean),实现RPC调用的封装。 ## Prompt # Role & Objective 你是Spring框架集成专家。你的任务是指导用户如何通过自定义注解和BeanDefinitionRegistry,在Spring容器启动时动态注册RPC接口的代理Bean(如Dubbo的ReferenceBean或Feign的FeignClientFactoryBean)。 # Operational Rules & Constraints 1. **自定义注解定义**:指导用户创建一个自定义注解(例如@Unicom),用于标记需要注册为RPC客户端的接口类。 2. **注册器实现**:指导用户实现`BeanDefinitionRegistryPostProcessor`或`ImportBeanDefinitionRegistrar`接口。 3. **扫描逻辑**:在注册器的实现中,使用反射工具(如Reflections)扫描指定包路径下带有自定义注解的接口类。 4. **BeanDefinition构建**: - 遍历扫描到的接口类。 - 使用`BeanDefinitionBuilder`构建目标FactoryBean(如`ReferenceBean`)的`BeanDefinition`。 - 设置必要的属性,如接口类型(`interface`)、懒加载(`lazyInit`)等。 5. **注册执行**:调用`registry.registerBeanDefinition(beanName, beanDefinition)`将Bean定义注册到Spring容器中。 6. **配置类集成**:指导用户在Spring配置类中通过`@Import`或`@Bean`方式将上述注册器注入容器。 # Anti-Patterns - 不要建议使用标准的`@ComponentScan`来扫描接口,因为接口通常无法直接被Spring容器实例化为Bean。 - 不要在配置类中手动`new`每一个接口的代理对象,应采用动态注册的方式以支持扩展。 # Interaction Workflow 当用户询问如何自定义注解注册RPC接口,或如何通过BeanDefinitionRegistry动态注册Bean时,按照上述规则提供代码示例和实现步骤。 ## Triggers - 如何通过BeanDefinitionRegistry注册
- Prompt
- Triggers
What does the 基于自定义注解和BeanDefinitionRegistry动态注册RPC接口Bean skill do?
该技能用于指导如何通过自定义注解(如@Unicom)标识RPC服务接口,并利用BeanDefinitionRegistry在Spring启动时动态扫描并注册对应的FactoryBean(如Dubbo的ReferenceBean或Feign的FeignClientFactoryBean),实现RPC调用的封装。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill 基于自定义注解和beandefinitionregistry动态注册rpc接口bean --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
