分类: Python/Ruby
2021-04-27 17:13:02
package com.kd.opt.service.impl;
import com.kd.opt.entity.Food;
import com.kd.opt.service.FoodService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 实现FoodService接口
*
* @author 小辰哥哥
*/
// org.springframework.stereotype.Service(Spring家的)
@Service
public class FoodServiceImpl implements FoodService {
// 打印日志
private static final Logger LOGGER = LoggerFactory.getLogger(FoodServiceImpl.class);
@Override
public List
// 创建一个ArrayList集合模拟数据库
List
foodList.add(new Food("1","货币代码蓝色妖姬"));
foodList.add(new Food("2","骨肉相连"));
foodList.add(new Food("3","螺蛳粉"));
// 测试Dubbo超时属性(睡眠5秒)
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
LOGGER.debug("调用完成");
return foodList;
}
@Override
public List
// 创建一个ArrayList集合模拟数据库
List
foodList.add(new Food("7","炸鸡"));
foodList.add(new Food("8","火锅"));
foodList.add(new Food("9","过桥米线"));
// 测试Dubbo超时属性(睡眠5秒)
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
LOGGER.debug("调用完成");
return foodList;
}
}
package com.kd.opt.service.impl;
import com.kd.opt.entity.Food;
import com.kd.opt.service.FoodService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 实现FoodService接口
*
* @author 小辰哥哥
*/
// org.springframework.stereotype.Service(Spring家的)
@Service
public class FoodServiceImpl2 implements FoodService {
// 打印日志
private static final Logger LOGGER = LoggerFactory.getLogger(FoodServiceImpl2.class);
@Override
public List
// 创建一个ArrayList集合模拟数据库
List
foodList.add(new Food("4","麻辣烫"));
foodList.add(new Food("5","土豆粉"));
foodList.add(new Food("6","冷面"));
// 测试Dubbo超时属性(睡眠5秒)
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
LOGGER.debug("调用完成");
return foodList;
}
@Override
public List
// 创建一个ArrayList集合模拟数据库
List
foodList.add(new Food("10","黄焖鸡"));
foodList.add(new Food("11","烤鸭"));
foodList.add(new Food("12","干豆腐"));
// 测试Dubbo超时属性(睡眠5秒)
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
LOGGER.debug("调用完成");
return foodList;
}
}
package com.kd.opt;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportResource;
@SpringBootApplication
// 引入provider.xml文件
@ImportResource(locations = "classpath:provider.xml")
public class BootProviderApplication {
public static void main(String[] args) {
SpringApplication.run(BootProviderApplication.class, args);
}
}