Requires2.5.7
or higher
Service
annotation for exportingimport com.alibaba.dubbo.config.annotation.Service; @Service(timeout = 5000) public class AnnotateServiceImpl implements AnnotateService { // ... }
@Configuration public class DubboConfiguration { @Bean public ApplicationConfig applicationConfig() { ApplicationConfig applicationConfig = new ApplicationConfig(); applicationConfig.setName("provider-test"); return applicationConfig; } @Bean public RegistryConfig registryConfig() { RegistryConfig registryConfig = new RegistryConfig(); registryConfig.setAddress("zookeeper://127.0.0.1:2181"); registryConfig.setClient("curator"); return registryConfig; } }
@SpringBootApplication @DubboComponentScan(basePackages = "com.alibaba.dubbo.test.service.impl") public class ProviderTestApp { // ... }
Reference
annotation for referencepublic class AnnotationConsumeService { @com.alibaba.dubbo.config.annotation.Reference public AnnotateService annotateService; // ... }
@Configuration public class DubboConfiguration { @Bean public ApplicationConfig applicationConfig() { ApplicationConfig applicationConfig = new ApplicationConfig(); applicationConfig.setName("consumer-test"); return applicationConfig; } @Bean public ConsumerConfig consumerConfig() { ConsumerConfig consumerConfig = new ConsumerConfig(); consumerConfig.setTimeout(3000); return consumerConfig; } @Bean public RegistryConfig registryConfig() { RegistryConfig registryConfig = new RegistryConfig(); registryConfig.setAddress("zookeeper://127.0.0.1:2181"); registryConfig.setClient("curator"); return registryConfig; } }
@SpringBootApplication @DubboComponentScan(basePackages = "com.alibaba.dubbo.test.service") public class ConsumerTestApp { // ... }
All annotations in 2.5.7 will be removed later, if you have used these annotations in your project, please upgrade to the latest version.
<dubbo:annotation package="com.alibaba.dubbo.test.service" />