增加 spring boot dubbo 用例
This commit is contained in:
@ -0,0 +1,16 @@
|
||||
package com.heibaiying.dubboprovider;
|
||||
|
||||
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDubbo //开启dubbo的注解支持
|
||||
public class BootDubboProviderApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BootDubboProviderApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package com.heibaiying.dubboprovider.service;
|
||||
|
||||
import com.alibaba.dubbo.config.annotation.Service;
|
||||
import com.heibaiying.api.IProductService;
|
||||
import com.heibaiying.bean.Product;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : heibaiying
|
||||
* @description : 产品提供接口实现类
|
||||
*/
|
||||
@Service(timeout = 5000)
|
||||
public class ProductService implements IProductService {
|
||||
|
||||
private static List<Product> productList = new ArrayList<>();
|
||||
|
||||
static {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
productList.add(new Product(i, "产品" + i, i / 2 == 0, new Date(), 66.66f * i));
|
||||
}
|
||||
}
|
||||
|
||||
public Product queryProductById(int id) {
|
||||
for (Product product : productList) {
|
||||
if (product.getId() == id) {
|
||||
return product;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public List<Product> queryAllProducts() {
|
||||
return productList;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
dubbo:
|
||||
application:
|
||||
name: boot-duboo-provider
|
||||
# ָ<><D6B8>ע<EFBFBD><D7A2>Э<EFBFBD><D0AD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>ַ dubbo<62>Ƽ<EFBFBD>ʹ<EFBFBD><CAB9>zookeeper<65><72>Ϊע<CEAA><D7A2><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>start<72><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>zookeeper<65><72>java<76>ͻ<EFBFBD><CDBB><EFBFBD>Curator
|
||||
registry:
|
||||
protocol: zookeeper
|
||||
address: 127.0.0.1:2181
|
||||
protocol.name: dubbo
|
Reference in New Issue
Block a user