Spring Boot 整合 Dubbo3 + Nacos 2.4.0
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@EnableDubbo(scanBasePackages = "com.example.service")
@ComponentScan(value = {"com.example.service", "com.example.facade"})
public class DubboProviderApplication {
public static void main(String[] args) {
SpringApplication.run(DubboProviderApplication.class, args);
}
}
这个示例展示了如何在Spring Boot应用中启用Dubbo服务。@EnableDubbo
注解用于启用Dubbo并指定扫描的包路径。@ComponentScan
注解用于指定Spring需要扫描的额外的包路径。这样,Dubbo服务提供者可以在Spring Boot应用中进行配置和启动。
评论已关闭