Java项目:CRM客户关系管理系统(Spring+SpringMVC+MyBatis + maven)(二)

简介: Java项目:CRM客户关系管理系统(Spring+SpringMVC+MyBatis + maven)(二)

3. 客户管理


3.1 查询所有客户


3.1.1 查询所有


需求:查询所有客户


步骤:


步骤1:入口


步骤2:编写Controller


步骤3:编写Service 接口、实现类


步骤4:修改 list.jsp展示数据


步骤1:入口


步骤2:编写Controller


package com.czxy.crm.controller;
import com.czxy.crm.domain.Customer;
import com.czxy.crm.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import java.util.List;
/**
 * @author 桐叔
 * @email liangtong@itcast.cn
 */
@Controller
@RequestMapping("/customer")
public class CustomerController {
    @Resource
    private CustomerService customerService;
    @RequestMapping("/findAll")
    public String findAll( Model model){
        List<Customer> allCustomer = customerService.findAll();
        model.addAttribute("allCustomer", allCustomer);
        return "customer/list";
    }
}

步骤3:编写Service 接口、实现类

  • 接口
package com.czxy.crm.service;
import com.czxy.crm.domain.Customer;
import java.util.List;
/**
 * @author 桐叔
 * @email liangtong@itcast.cn
 */
public interface CustomerService {
    /**
     * 查询所有
     * @return
     */
    List<Customer> findAll();
}

实现类

package com.czxy.crm.service.impl;
import com.czxy.crm.domain.BaseDict;
import com.czxy.crm.domain.Customer;
import com.czxy.crm.mapper.BaseDictMapper;
import com.czxy.crm.mapper.CustomerMapper;
import com.czxy.crm.service.CustomerService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
/**
 * @author 桐叔
 * @email liangtong@itcast.cn
 */
@Service
@Transactional
public class CustomerServiceImpl implements CustomerService {
    @Resource
    private CustomerMapper customerMapper;
    @Resource
    private BaseDictMapper baseDictMapper;
    @Override
    public List<Customer> findAll() {
        // 查询所有
        List<Customer> list = customerMapper.selectAll();
        // 关联查询
        list.forEach(customer -> {
            // 客户来源
            BaseDict custSourceBaseDict = baseDictMapper.selectByPrimaryKey(customer.getCustSource());
            customer.setCustSourceBaseDict(custSourceBaseDict);
            //客户行业
            BaseDict custIndustryBaseDict = baseDictMapper.selectByPrimaryKey(customer.getCustIndustry());
            customer.setCustIndustryBaseDict(custIndustryBaseDict);
            //客户级别
            BaseDict custLevelBaseDict = baseDictMapper.selectByPrimaryKey(customer.getCustLevel());
            customer.setCustLevelBaseDict(custLevelBaseDict);
        });
        return list;
    }
}

步骤4:修改 list.jsp展示数据

<c:forEach items="${allCustomer}" var="customer">
    <TR style="FONT-WEIGHT: normal; FONT-STYLE: normal; BACKGROUND-COLOR: white; TEXT-DECORATION: none">
        <TD>${customer.custName }</TD>
        <TD>${customer.custLevelBaseDict.dictItemName }</TD>
        <TD>${customer.custSourceBaseDict.dictItemName }</TD>
        <TD>${customer.custIndustryBaseDict.dictItemName }</TD>
        <TD>${customer.custAddress }</TD>
        <TD>${customer.custPhone }</TD>
        <TD>
        <a href="${pageContext.request.contextPath }/customer/editUI.action?custId=${customer.custId}">修改</a>
        &nbsp;&nbsp;
        <a href="${pageContext.request.contextPath }/customer/delete.action?custId=${customer.custId}" οnclick="return confirm('您确定要删除【${customer.custName }】吗?')">删除</a>
        </TD>
    </TR>   
</c:forEach>


3.1.2 条件查询


需求:


步骤


步骤1:入口,确定查询表单


步骤2:创建CustomerVo,用于封装查询条件


步骤3:修改controller,获得查询条件


步骤4:修改service,使用查询条件


步骤1:入口,确定查询表单


步骤2:创建CustomerVo,用于封装查询条件


///

package com.czxy.crm.vo;
/**
 * @author 桐叔
 * @email liangtong@itcast.cn
 */
public class CustomerVo {
    private String custName;
    public String getCustName() {
        return custName;
    }
    public void setCustName(String custName) {
        this.custName = custName;
    }
}

步骤3:修改controller,获得查询条件

package com.czxy.crm.controller;
import com.czxy.crm.domain.Customer;
import com.czxy.crm.service.CustomerService;
import com.czxy.crm.vo.CustomerVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import java.util.List;
/**
 * @author 桐叔
 * @email liangtong@itcast.cn
 */
@Controller
@RequestMapping("/customer")
public class CustomerController {
    @Resource
    private CustomerService customerService;
    @RequestMapping("/findAll")
    public String findAll(CustomerVo customerVo, Model model){
        List<Customer> allCustomer = customerService.findAll(customerVo);
        model.addAttribute("allCustomer", allCustomer);
        return "customer/list";
    }
}

步骤4:修改service,使用查询条件

  • 接口
  • 实现类
package com.czxy.crm.service.impl;
import com.czxy.crm.domain.BaseDict;
import com.czxy.crm.domain.Customer;
import com.czxy.crm.mapper.BaseDictMapper;
import com.czxy.crm.mapper.CustomerMapper;
import com.czxy.crm.service.CustomerService;
import com.czxy.crm.vo.CustomerVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.util.List;
/**
 * @author 桐叔
 * @email liangtong@itcast.cn
 */
@Service
@Transactional
public class CustomerServiceImpl implements CustomerService {
    @Resource
    private CustomerMapper customerMapper;
    @Resource
    private BaseDictMapper baseDictMapper;
    @Override
    public List<Customer> findAll(CustomerVo customerVo) {
        // 1 条件查询
        Example example = new Example(Customer.class);
        Example.Criteria criteria = example.createCriteria();
        if(StringUtils.isNotBlank(customerVo.getCustName())) {
            criteria.andLike("custName", "%"+customerVo.getCustName()+"%");
        }
        // 2 分页查询
        // 3 查询所有
        List<Customer> list = customerMapper.selectByExample(example);
        // 4 关联查询
        list.forEach(customer -> {
            // 客户来源
            BaseDict custSourceBaseDict = baseDictMapper.selectByPrimaryKey(customer.getCustSource());
            customer.setCustSourceBaseDict(custSourceBaseDict);
            //客户行业
            BaseDict custIndustryBaseDict = baseDictMapper.selectByPrimaryKey(customer.getCustIndustry());
            customer.setCustIndustryBaseDict(custIndustryBaseDict);
            //客户级别
            BaseDict custLevelBaseDict = baseDictMapper.selectByPrimaryKey(customer.getCustLevel());
            customer.setCustLevelBaseDict(custLevelBaseDict);
        });
        // 5 封装分页
        return list;
    }
}


3.1.3 分页查询


需求


步骤:



步骤1:修改CustomerVo,获得分页参数


步骤2:修改controller,返回pageInfo


步骤3:修改service,封装PageInfo


步骤4:修改jsp,展示列表数据


步骤5:修改jsp,展示分页条


步骤1:修改CustomerVo,获得分页参数

package com.czxy.crm.vo;
/**
 * @author 桐叔
 * @email liangtong@itcast.cn
 */
public class CustomerVo {
    private String custName;
    private Integer pageNum = 1;
    private Integer pageSize = 2;
    // getter和setter
}

步骤2:修改controller,返回pageInfo


步骤3:修改service,封装PageInfo


接口


实现类



/

package com.czxy.crm.service.impl;
import com.czxy.crm.domain.BaseDict;
import com.czxy.crm.domain.Customer;
import com.czxy.crm.mapper.BaseDictMapper;
import com.czxy.crm.mapper.CustomerMapper;
import com.czxy.crm.service.CustomerService;
import com.czxy.crm.vo.CustomerVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.util.List;
/**
 * @author 桐叔
 * @email liangtong@itcast.cn
 */
@Service
@Transactional
public class CustomerServiceImpl implements CustomerService {
    @Resource
    private CustomerMapper customerMapper;
    @Resource
    private BaseDictMapper baseDictMapper;
    @Override
    public PageInfo<Customer> findAll(CustomerVo customerVo) {
        // 1 条件查询
        Example example = new Example(Customer.class);
        Example.Criteria criteria = example.createCriteria();
        if(StringUtils.isNotBlank(customerVo.getCustName())) {
            criteria.andLike("custName", "%"+customerVo.getCustName()+"%");
        }
        // 2 分页查询
        PageHelper.startPage(customerVo.getPageNum(),customerVo.getPageSize());
        // 3 查询所有
        List<Customer> list = customerMapper.selectByExample(example);
        // 4 关联查询
        list.forEach(customer -> {
            // 客户来源
            BaseDict custSourceBaseDict = baseDictMapper.selectByPrimaryKey(customer.getCustSource());
            customer.setCustSourceBaseDict(custSourceBaseDict);
            //客户行业
            BaseDict custIndustryBaseDict = baseDictMapper.selectByPrimaryKey(customer.getCustIndustry());
            customer.setCustIndustryBaseDict(custIndustryBaseDict);
            //客户级别
            BaseDict custLevelBaseDict = baseDictMapper.selectByPrimaryKey(customer.getCustLevel());
            customer.setCustLevelBaseDict(custLevelBaseDict);
        });
        // 5 封装分页
        return new PageInfo<>(list);
    }
}

步骤4:修改jsp,展示列表数据


步骤5:修改jsp,展示分页条


查询表单


分页条


当前第[<B>${pageInfo.pageNum}</B>]页,共[<B>${pageInfo.total}</B>]条

,每页显示


//

<select οnchange="change(this)">
    <option value="1" ${pageInfo.pageSize == 1 ? 'selected' : ''}>1</option>
    <option value="2" ${pageInfo.pageSize == 2 ? 'selected' : ''}>2</option>
    <option value="3" ${pageInfo.pageSize == 3 ? 'selected' : ''}>3</option>
    <option value="5" ${pageInfo.pageSize == 5 ? 'selected' : ''}>5</option>
    <option value="10" ${pageInfo.pageSize == 10 ? 'selected' : ''}>10</option>
</select>
<c:if test="${pageInfo.pageNum > 1}">
    [<a href="javascript:void(0)" οnclick="page(1)">首页</a>]
    [<a href="javascript:void(0)" οnclick="page(${pageInfo.pageNum - 1})">上一页</a>]
</c:if>
<c:forEach begin="1" end="${pageInfo.pages}" var="num">
    <b><a href="javascript:void(0)" οnclick="page(${num})">${num}</a></b>
</c:forEach>
<c:if test="${pageInfo.pageNum < pageInfo.pages}">
    [<a href="javascript:void(0)" οnclick="page(${pageInfo.pageNum + 1})">下一页</a>]
    [<a href="javascript:void(0)" οnclick="page(${pageInfo.pages})">尾页</a>]
</c:if>
<input type="number" style="width: 35px;" value="${customerVo.pageNum}" id="goId"/>
<input type="button" value="Go" οnclick="page(goId.value)"/>

js函数


function change(obj) {
    // 重置,如果修改了pageSize,从1开始
    pageNumId.value = 1
    // 修改隐藏字段 pageSize
    pageSizeId.value = obj.value
    // 提交表单
    customerFormId.submit()
}
function page(pageNum) {
    // 修改pageNum的值
    pageNumId.value = pageNum
    // 提交表单
    customerFormId.submit()
}


3.2 添加客户


3.2.1 需求


3.2.2 显示表单


步骤:


  • 步骤1:入口


  • 步骤2:修改CustomerController,用于显示 customer/add.jsp 页面


  • 查询数据字典:客户来源(typeCode=002)


  • 查询数据字典:客户行业(typeCode=001)


  • 查询数据字典:客户级别(typeCode=006)


  • 步骤3:编写BaseDictService,通过typeCode查询所有数据字典信息。


  • 步骤4:修改add.jsp,显示字典相关信息


  • 步骤1:入口


  • 步骤2:修改CustomerController,用于显示 customer/add.jsp 页面


  • 查询数据字典:客户来源(typeCode=002)


  • 查询数据字典:客户行业(typeCode=001)


  • 查询数据字典:客户级别(typeCode=006)


package com.czxy.crm.controller;
import com.czxy.crm.domain.BaseDict;
import com.czxy.crm.domain.Customer;
import com.czxy.crm.service.BaseDictService;
import com.czxy.crm.service.CustomerService;
import com.czxy.crm.vo.CustomerVo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import java.util.List;
/**
 * @author 桐叔
 * @email liangtong@itcast.cn
 */
@Controller
@RequestMapping("/customer")
public class CustomerController {
    @Resource
    private CustomerService customerService;
    @Resource
    private BaseDictService baseDictService;
    /**
     * 添加页面
     * @return
     */
    @RequestMapping("/addUI")
    public String addUI(Model model) {
        // 客户行业 (typeCode=001)
        List<BaseDict> custIndustryBaseDictList = baseDictService.selectAllByTypeCode("001");
        model.addAttribute("custIndustryBaseDictList",custIndustryBaseDictList);
        // 客户来源(typeCode=002)
        List<BaseDict> custSourceBaseDictList = baseDictService.selectAllByTypeCode("002");
        model.addAttribute("custSourceBaseDictList",custSourceBaseDictList);
        // 客户级别(typeCode=006)
        List<BaseDict> custLevelBaseDictList = baseDictService.selectAllByTypeCode("006");
        model.addAttribute("custLevelBaseDictList",custLevelBaseDictList);
        return "customer/add";
    }
}

步骤3:编写BaseDictService,通过typeCode查询所有数据字典信息。


接口


package com.czxy.crm.service;
import com.czxy.crm.domain.BaseDict;
import java.util.List;
/**
 * @author 桐叔
 * @email liangtong@itcast.cn
 */
public interface BaseDictService {
    /**
     * 通过类别代码查询数据字典信息
     * @param dictTypeCode
     * @return
     */
    List<BaseDict> selectAllByTypeCode(String dictTypeCode);
}

实现类


///

package com.czxy.crm.service.impl;
import com.czxy.crm.domain.BaseDict;
import com.czxy.crm.mapper.BaseDictMapper;
import com.czxy.crm.service.BaseDictService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.util.List;
/**
 * @author 桐叔
 * @email liangtong@itcast.cn
 */
@Service
@Transactional
public class BaseDictServiceImpl implements BaseDictService {
    @Resource
    private BaseDictMapper baseDictMapper;
    @Override
    public List<BaseDict> selectAllByTypeCode(String dictTypeCode) {
        // 条件
        Example example = Example.builder(BaseDict.class).build();
        example.createCriteria().andEqualTo("dictTypeCode",dictTypeCode);
        // 查询
        return baseDictMapper.selectByExample(example);
    }
}

步骤4:修改add.jsp,显示字典相关信息

<td>所属行业 :</td>
<td>
    <select name="custIndustry" class=textbox style="WIDTH: 180px">
        <option value="">---请选择---</option>
        <c:forEach items="${custIndustryBaseDictList}" var="industry">
            <option value="${industry.dictId}">${industry.dictItemName}</option>
        </c:forEach>
    </select>
</td>
<td>信息来源 :</td>
<td>
    <select name="custSource" class=textbox style="WIDTH: 180px">
        <option value="non">---请选择---</option>
        <c:forEach items="${custSourceBaseDictList}" var="source">
            <option value="${source.dictId}">${source.dictItemName}</option>
        </c:forEach>
    </select>
</td>
<td>客户级别:</td>
<td>
    <select name="custLevel" class=textbox style="WIDTH: 180px">
        <option value="non">---请选择---</option>
        <c:forEach items="${custLevelBaseDictList}" var="level">
            <option value="${level.dictId}">${level.dictItemName}</option>
        </c:forEach>
    </select>                               
</td>


3.2.3 添加


步骤:


步骤1:修改add.jsp页面,确定表单提交路径 /customer/add.action


步骤2:修改CustomerController,添加add方法,并处理成功和失败。


步骤3:修改CustomerService,添加add方法


步骤4:修改add.jsp,显示错误信息


步骤1:修改add.jsp页面,确定表单提交路径 /customer/add.action


步骤2:修改CustomerController,添加add方法,并处理成功和失败。



/

/**
     * 添加
     * @param customer
     * @return
     */
    @RequestMapping("/add")
    public String add(Customer customer, Model model) {
        try {
            // 添加
            boolean result = customerService.add(customer);
            if(result) {
                // 成功
                return "redirect:/customer/findAll.action";
            } else {
                // 失败
                model.addAttribute("error","添加客户失败");
                return "customer/add";
            }
        } catch (Exception e) {
            e.printStackTrace();
            model.addAttribute("error",e.getMessage());
            return "customer/add";
        }
    }

步骤3:修改CustomerService,添加add方法


接口


 

/**
     * 添加客户
     * @param customer
     * @return
     */
    boolean add(Customer customer);

实现类


 

@Override
    public boolean add(Customer customer) {
        int insert = customerMapper.insertSelective(customer);
        return insert == 1;
    }

步骤4:修改add.jsp,显示错误信息

<%-- 显示错误信息--%>
<span style="color:red">${error}</span>

3.3 修改客户


3.3.1 需求


3.3.2 显示表单,回显数据


步骤:


步骤1:入口 /customer/editUI.action?custId=1


步骤2:修改CustomerController,用于显示 customer/edit.jsp 页面


查询数据字典:客户来源(typeCode=002)


查询数据字典:客户行业(typeCode=001)


查询数据字典:客户级别(typeCode=006)


通过custId查询客户详情


步骤3:编写CustomerService,查询客户详情。


步骤4:修改edit.jsp,显示字典相关信息,回显客户信息。


步骤1:入口 /customer/editUI.action?custId=1


步骤2:修改CustomerController,用于显示 customer/edit.jsp 页面


查询数据字典:客户来源(typeCode=002)


查询数据字典:客户行业(typeCode=001)


查询数据字典:客户级别(typeCode=006)


通过custId查询客户详情

 /**
     * 修改页面
     * @return
     */
    @RequestMapping("/editUI")
    public String editUI(Long custId, Model model) {
        // 客户行业 (typeCode=001)
        List<BaseDict> custIndustryBaseDictList = baseDictService.selectAllByTypeCode("001");
        model.addAttribute("custIndustryBaseDictList",custIndustryBaseDictList);
        // 客户来源(typeCode=002)
        List<BaseDict> custSourceBaseDictList = baseDictService.selectAllByTypeCode("002");
        model.addAttribute("custSourceBaseDictList",custSourceBaseDictList);
        // 客户级别(typeCode=006)
        List<BaseDict> custLevelBaseDictList = baseDictService.selectAllByTypeCode("006");
        model.addAttribute("custLevelBaseDictList",custLevelBaseDictList);
        // 查询客户项
        Customer customer = customerService.selectById(custId);
        model.addAttribute("customer",customer);
        return "customer/edit";
    }

步骤3:编写CustomerService,查询客户详情。

  • 接口
 /**
     * 通过id查询详情
     * @param custId
     * @return
     */
    Customer selectById(Long custId);

实现类

  @Override
    public Customer selectById(Long custId) {
        return customerMapper.selectByPrimaryKey(custId);
    }

步骤4:修改edit.jsp,显示字典相关信息,回显客户信息。

<select name="custIndustry" class=textbox style="WIDTH: 180px">
    <option value="">---请选择---</option>
    <c:forEach items="${custIndustryBaseDictList}" var="industry">
        <option value="${industry.dictId}" ${customer.custIndustry== industry.dictId?"selected":""}>${industry.dictItemName}</option>
    </c:forEach>
</select>
<td>信息来源 :</td>
<td>
    <select name="custSource" class=textbox style="WIDTH: 180px">
        <option value="non">---请选择---</option>
        <c:forEach items="${custSourceBaseDictList}" var="source">
            <option value="${source.dictId}" ${customer.custSource== source.dictId?"selected":""}>${source.dictItemName}</option>
        </c:forEach>
    </select>
</td>
<td>客户级别:</td>
<td>
    <select name="custLevel" class=textbox style="WIDTH: 180px">
        <option value="non">---请选择---</option>
        <c:forEach items="${custLevelBaseDictList}" var="level">
            <option value="${level.dictId}"  ${customer.custLevel==level.dictId?"selected":""}>${level.dictItemName}</option>
        </c:forEach>
    </select>                               
</td>

3.3.3 修改

步骤:


步骤1:修改edit.jsp页面,确定表单提交路径 /customer/edit.action


步骤2:修改CustomerController,添加edit方法,并处理成功和失败。


步骤3:修改CustomerService,添加edit方法


步骤4:修改edit.jsp,显示错误信息


步骤1:修改edit.jsp页面,确定表单提交路径 /customer/edit.action


步骤2:修改CustomerController,添加edit方法,并处理成功和失败。


/

/**
     * 修改
     * @param customer
     * @return
     */
    @RequestMapping("/edit")
    public String edit(Customer customer, Model model) {
        try {
            // 修改
            boolean result = customerService.update(customer);
            if(result) {
                // 成功
                return "redirect:/customer/findAll.action";
            } else {
                // 失败
                model.addAttribute("error","修改客户失败");
                return "customer/edit";
            }
        } catch (Exception e) {
            e.printStackTrace();
            model.addAttribute("error",e.getMessage());
            return "customer/edit";
        }

步骤3:修改CustomerService,添加edit方法

  • 接口
/**
     * 修改
     * @param customer
     * @return
     */
    boolean update(Customer customer);

实现类

   @Override
    public boolean update(Customer customer) {
        int update = customerMapper.updateByPrimaryKeySelective(customer);
        return update == 1;
    }

步骤4:修改edit.jsp,显示错误信息


3.4 删除客户


步骤:


步骤1:入口 customer/delete.action?custId=1


步骤2:修改CustomerController,添加delete方法,删除成功重定向到列表页。


步骤3:修改CustomerService,添加delete方法


步骤1:入口 customer/delete.action?custId=1

<a href="${pageContext.request.contextPath }/customer/delete.action?custId=${customer.custId}" οnclick="return confirm('您确定要删除【${customer.custName }】吗?')">删除</a>

步骤2:修改CustomerController,添加delete方法,删除成功重定向到列表页。

 /**
     * 通过id删除客户
     * @param custId
     * @return
     */
    @RequestMapping("/delete")
    public String delete(Long custId) {
        // 删除
        customerService.deleteById(custId);
        // 重定向列表页
        return "redirect:/customer/findAll.action";
       }

步骤3:修改CustomerService,添加delete方法

  • 接口

    /**
     * 通过id删除
     * @param custId
     */
    void deleteById(Long custId);

实现类

@Override
    public void deleteById(Long custId) {
        customerMapper.deleteByPrimaryKey(custId);
    }


相关文章
|
19天前
|
SQL Java 数据库连接
对Spring、SpringMVC、MyBatis框架的介绍与解释
Spring 框架提供了全面的基础设施支持,Spring MVC 专注于 Web 层的开发,而 MyBatis 则是一个高效的持久层框架。这三个框架结合使用,可以显著提升 Java 企业级应用的开发效率和质量。通过理解它们的核心特性和使用方法,开发者可以更好地构建和维护复杂的应用程序。
110 29
|
8天前
|
网络协议 Java Shell
java spring 项目若依框架启动失败,启动不了服务提示端口8080占用escription: Web server failed to start. Port 8080 was already in use. Action: Identify and stop the process that’s listening on port 8080 or configure this application to listen on another port-优雅草卓伊凡解决方案
java spring 项目若依框架启动失败,启动不了服务提示端口8080占用escription: Web server failed to start. Port 8080 was already in use. Action: Identify and stop the process that’s listening on port 8080 or configure this application to listen on another port-优雅草卓伊凡解决方案
40 7
|
30天前
|
前端开发 Java 数据库连接
Java后端开发-使用springboot进行Mybatis连接数据库步骤
本文介绍了使用Java和IDEA进行数据库操作的详细步骤,涵盖从数据库准备到测试类编写及运行的全过程。主要内容包括: 1. **数据库准备**:创建数据库和表。 2. **查询数据库**:验证数据库是否可用。 3. **IDEA代码配置**:构建实体类并配置数据库连接。 4. **测试类编写**:编写并运行测试类以确保一切正常。
56 2
|
1月前
|
SQL JavaScript Java
Spring Boot 3 整合 Mybatis-Plus 实现数据权限控制
本文介绍了如何在Spring Boot 3中整合MyBatis-Plus实现数据权限控制,通过使用MyBatis-Plus提供的`DataPermissionInterceptor`插件,在不破坏原有代码结构的基础上实现了细粒度的数据访问控制。文中详细描述了自定义注解`DataScope`的使用方法、`DataPermissionHandler`的具体实现逻辑,以及根据用户的不同角色和部门动态添加SQL片段来限制查询结果。此外,还展示了基于Spring Boot 3和Vue 3构建的前后端分离快速开发框架的实际应用案例,包括项目的核心功能模块如用户管理、角色管理等,并提供Gitee上的开源仓库
247 11
|
1月前
|
监控 搜索推荐
构建长期客户关系:CRM全周期销售管理指南
在现代商业环境中,CRM(客户关系管理)系统作为企业销售和市场营销的核心工具,通过全周期管理体系帮助企业从潜在客户识别、需求挖掘、销售转化到客户维护和再销售,系统化管理销售流程,提升销售效率和客户满意度。本文探讨CRM销售全周期管理体系的重要性、关键组成部分及如何通过数据驱动决策、自动化工作流程、客户洞察、团队协作和绩效监控等手段提升销售绩效,助力企业在竞争中脱颖而出。
|
2月前
|
存储 JSON 前端开发
【Spring项目】表白墙,留言板项目的实现
本文主要介绍了表白墙项目的实现,包含前端和后端代码,以及测试
|
2月前
|
JSON 前端开发 Java
|
2月前
|
缓存 前端开发 Java
【Spring】——SpringBoot项目创建
SpringBoot项目创建,SpringBootApplication启动类,target文件,web服务器,tomcat,访问服务器
|
2月前
|
缓存 Java 数据库连接
深入探讨:Spring与MyBatis中的连接池与缓存机制
Spring 与 MyBatis 提供了强大的连接池和缓存机制,通过合理配置和使用这些机制,可以显著提升应用的性能和可扩展性。连接池通过复用数据库连接减少了连接创建和销毁的开销,而 MyBatis 的一级缓存和二级缓存则通过缓存查询结果减少了数据库访问次数。在实际应用中,结合具体的业务需求和系统架构,优化连接池和缓存的配置,是提升系统性能的重要手段。
147 4
|
2月前
|
SQL Java 数据库连接
spring和Mybatis的各种查询
Spring 和 MyBatis 的结合使得数据访问层的开发变得更加简洁和高效。通过以上各种查询操作的详细讲解,我们可以看到 MyBatis 在处理简单查询、条件查询、分页查询、联合查询和动态 SQL 查询方面的强大功能。熟练掌握这些操作,可以极大提升开发效率和代码质量。
166 3

推荐镜像

更多