第三章【Maven项目】测试整合后的SSM框架
2018-01-18 14:46
666 查看
接着 第二章【Maven项目】maven项目的创建及配置ssm框架
测试整合后的ssm框架
1.可以使用mybatis逆向工程生成 pojo mapper 如图:
2.创建如图几个包:
测试框架,使用逆向工程生成的dao就可以,jiu不用考虑dao层
service层
@Service
public class PriceServiceImpl implements PriceService {
@Autowired
private PriceMapper priceMapper;
public Price getPriceById(int id) {
PriceExample example = new PriceExample();
Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(id);
List<Price> list = priceMapper.selectByExample(example);
if (list.size() > 0 && list != null) {
Price price = list.get(0);
return price;
}
return null;
}
}controller@Controller
public class PriceController {
@Autowired
private PriceService priceService;
@RequestMapping("/price/{id}")
@ResponseBody
public Price getPriceById(@PathVariable int id) {
Price price = priceService.getPriceById(id);
return price;
}
}浏览器输入 http://localhost:8080/price/1 如图:
框架测试-OK
测试整合后的ssm框架
1.可以使用mybatis逆向工程生成 pojo mapper 如图:
2.创建如图几个包:
测试框架,使用逆向工程生成的dao就可以,jiu不用考虑dao层
service层
@Service
public class PriceServiceImpl implements PriceService {
@Autowired
private PriceMapper priceMapper;
public Price getPriceById(int id) {
PriceExample example = new PriceExample();
Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(id);
List<Price> list = priceMapper.selectByExample(example);
if (list.size() > 0 && list != null) {
Price price = list.get(0);
return price;
}
return null;
}
}controller@Controller
public class PriceController {
@Autowired
private PriceService priceService;
@RequestMapping("/price/{id}")
@ResponseBody
public Price getPriceById(@PathVariable int id) {
Price price = priceService.getPriceById(id);
return price;
}
}浏览器输入 http://localhost:8080/price/1 如图:
框架测试-OK
相关文章推荐
- 基于IdeaIDE的ssm整合框架的maven管理项目,利用映射自动生成dao层,pojo层,mappers层
- 基于IdeaIDE的ssm整合框架的maven管理项目,利用映射自动生成dao层,pojo层,mappers层
- 【SSM】Eclipse使用Maven创建Web项目+整合SSM框架
- 基于IdeaIDE的ssm整合框架的maven管理项目,利用映射自动生成dao层,pojo层,mappers层
- 01 整合IDEA+Maven+SSM框架的高并发的商品秒杀项目之业务分析与DAO层
- maven 项目 ssm 框架整合<2>
- 构建Maven多模块项目+SSM框架整合+Thymeleaf(二)
- 基于IdeaIDE的ssm整合框架的maven管理项目,利用映射自动生成dao层,pojo层,mappers层
- SSM框架整合之maven项目
- 【SSM】Eclipse使用Maven创建Web项目+整合SSM框架
- 基于IdeaIDE的ssm整合框架的maven管理项目,利用映射自动生成dao层,pojo层,mappers层
- 02 整合IDEA+Maven+SSM框架的高并发的商品秒杀项目之Service层
- eclipse maven项目整合SSM框架(亲测有效)
- 【SSM】Eclipse使用Maven创建Web项目+整合SSM框架
- eclipse构建maven项目整合SSM(spring+springMVC+mybatis)框架
- 基于IdeaIDE的ssm整合框架的maven管理项目,利用映射自动生成dao层,pojo层,mappers层
- 03 整合IDEA+Maven+SSM框架的高并发的商品秒杀项目之web层
- IntelliJ IDEA下SSM框架整合、创建Maven项目流程(Spring + SpringMVC + MyBatis)
- Eclipse使用Maven创建Web项目+整合SSM框架
- 【SSM】Eclipse使用Maven创建Web项目+整合SSM框架