ssm创建一个查询接口
生活随笔
收集整理的這篇文章主要介紹了
ssm创建一个查询接口
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
注解:
controller
@Autowiredprivate UserService userService;service實(shí)體類
@Service("userService")@Autowiredprivate UserMapper userMapper;mapper
@Repositorycontroller 接收數(shù)據(jù)
=> service 邏輯中轉(zhuǎn)
=> dao 數(shù)據(jù)庫(kù)查詢
=> domain bean類映射
=>
service=>controller 返回?cái)?shù)據(jù)
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中的實(shí)體類
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 {..... }總結(jié)
以上是生活随笔為你收集整理的ssm创建一个查询接口的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 黑神话悟空经典语录?
- 下一篇: spring boot使用注解的方式整合