-
在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
相关推荐
毕业设计-小慧8 分钟前
计算机毕业设计springboot游戏数据管理系统 基于SpringBoot的电竞赛事数据管理平台 基于SpringBoot的在线游戏运营数据分析系统平生不喜凡桃李10 分钟前
浅谈 Linux 中 namespace 相关系统调用zb2006412015 分钟前
CVE-2024-38819:Spring 框架路径遍历 PoC 漏洞复现uzong24 分钟前
AI Agent 是什么,如何理解它,未来挑战和思考2401_8955213425 分钟前
spring-ai 下载不了依赖spring-ai-openai-spring-boot-starter追逐时光者37 分钟前
DotNetGuide突破了10K + Star,一份全面且免费的C#/.NET/.NET Core学习、工作、面试指南知识库!何仙鸟1 小时前
GarmageSet下载和处理wefly20171 小时前
免安装!m3u8live.cn在线 M3U8 播放器,小白也能快速上手yuweiade1 小时前
springboot和springframework版本依赖关系ywf12151 小时前
springboot设置多环境配置文件