首页 > 其他分享 >创建controller/service/mapper/impl过程

创建controller/service/mapper/impl过程

时间:2023-03-21 14:55:06浏览次数:50  
标签:mapper service 创建 controller extends public

先创建entity包,在里面导入实体类

然后创建controller/mapper/service包

然后在service里创建impl包

然后在mapper包里写mapper接口,加上@Mapper注解,继承BaseMapper<Employee>,泛型是实体类

 

@Mapper
public interface EmployeeMapper extends BaseMapper<Employee> {
}

 由于继承,把常见增删改查都有了

然后创建service,继承IService<Employee>泛型是实体类

 

public interface EmployeeService extends IService<Employee> {
}

然后创建service的实现类,加上@Servise注解,extends ServiceImpl<>泛型是EmployeeMapper和Employee,实现implements EmployeeService

@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements EmployeeService {
}

然后创建controller,访问路径注解,注入service

@Slf4j
@RestController
@RequestMapping("/employee")
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;
}

 

标签:mapper,service,创建,controller,extends,public
From: https://www.cnblogs.com/dahuilang21/p/17240008.html

相关文章