-
在controller同级目录下创建service

package com.spring2.service;
import com.spring2.entity.User;
import com.spring2.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;@Service
public class UserService {@Autowired private UserMapper userMapper; public int save(User user){ if(user.getId() == null){ //有id 新增 return userMapper.insert(user); }else{ return userMapper.update(user); } }}
-
在controller里出入service

【Spring Boot】service 业务层简单使用
正函数2024-04-15 19:00
相关推荐
uzong3 小时前
Mermaid: AI 时代画图的魔法工具Gerardisite3 小时前
如何在微信个人号开发中有效管理API接口?q***69773 小时前
Spring Boot与MyBatis闲人编程4 小时前
Python的导入系统:模块查找、加载和缓存机制故渊ZY4 小时前
Java 代理模式:从原理到实战的全方位解析匿者 衍4 小时前
POI读取 excel 嵌入式图片(支持wps 和 office)一个尚在学习的计算机小白4 小时前
java集合IUGEI4 小时前
synchronized的工作机制是怎样的?深入解析synchronized底层原理q***13615 小时前
Windows操作系统部署Tomcat详细讲解z***I3945 小时前
Java桌面应用案例