注解:
controller
@Autowiredprivate UserService userService;
service实体类
@Service("userService")@Autowiredprivate UserMapper userMapper;
mapper
@Repository
controller 接收数据
=> service 逻辑中转
=> dao 数据库查询
=> domain bean类映射
=>
service=>controller 返回数据
Controller层
@Autowired
private BlogService blogService;@RequestMapping(value = "/findAll", produces = "application/json;charset=utf-8")@ResponseBodypublic List<Good> findAll(){List<Good> list = goodService.findAll();return list;}
service层
interface 层
GoodService.java
public interface GoodService {List<Good> findAll();
}
impl中的实体类
GoodServiceImpl.java
@Service("goodService")public class GoodServiceImpl implements GoodService {@Autowiredprivate GoodDao goodDao;@Overridepublic List<Good> findAll() {return goodDao.findAll();}}
dao层
public interface GoodDao {@Select("select * from good")List<Good> findAll();
}
domain层
public class Good implements Serializable {.....
}