SpringMVC--11基于注解的SSM整合开发

【SpringMVC 】什么是SpringMVC(二)?如何整合ssm框架以及使用mybatisPlus? MybatisPlus的基础操作封装了常见的增删改查操作,使得开发者可以更容易地使用MybatisPlus进行数据库操作。这些基础操作是通过Mapper接口和实现类来完成的,开发者只需要继承BaseMapper接口即可。以下是MybatisPlus支持的基础操作: 插入:insert、insertBatch、insertOrUpdate 等方法。 更新:updateById、update、updateBatchById 等方法。 删除:deleteById、deleteByMap、delete 等方法。 阅读详情

父工程中依赖(pom.xml)

<dependencies>
  <!--springcontext-->
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>6.1.14</version>
  </dependency>
  <!--spring-tx-->
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-tx</artifactId>
    <version>6.1.14</version>
  </dependency>
  <!--spring-jdbc-->
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>6.1.14</version>
  </dependency>
  <!--aspectj-->
  <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.9.21</version>
  </dependency>
  <!--jsr250注解-->
  <dependency>
    <groupId>jakarta.annotation</groupId>
    <artifactId>jakarta.annotation-api</artifactId>
    <version>2.1.1</version>
  </dependency>


  <!--springmvc-->
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>6.1.14</version>
  </dependency>
  <!--servlet-->
  <dependency>
    <groupId>jakarta.servlet</groupId>
    <artifactId>jakarta.servlet-api</artifactId>
    <version>6.0.0</version>
  </dependency>
  <!--jackson-->
  <dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.17.2</version>
  </dependency>
  <!--hibernate-->
  <dependency>
    <groupId>org.hibernate.validator</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>8.0.0.Final</version>
  </dependency>

  <!--mybatis-->
  <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.5.16</version>
  </dependency>
  <!--mysql-->
  <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.25</version>
  </dependency>
  <!--pagehelper-->
  <dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>6.1.0</version>
  </dependency>

  <!--spring-web-->
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>6.1.14</version>
  </dependency>
  <!--spring整合mybatis-->
  <dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-spring</artifactId>
    <version>3.0.3</version>
  </dependency>
  <!--druid-->
  <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid</artifactId>
    <version>1.2.23</version>
  </dependency>

  <!--logback-->
  <dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-core</artifactId>
    <version>1.5.12</version>
  </dependency>
  <dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
        <version>1.5.12</version>
    </dependency>
    <!--lombok-->
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.34</version>
    </dependency>
</dependencies>

配置文件(config)

此处采用全注解开发,用java类的方式进行配置,并按照三层架构,框架整合的方式将所有配置拆分成5个配置类。这5个配置类又分别用于两个IoC容器,一个专门负责处理web请求(web容器),另一个负责处理后端数据(root容器),前者作为后者的子容器,使得可以在处理前端请求的时候调用后端service层等的方法

Web容器配置文件

webMvcJavaConfig

package com.atli.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

/**
 * @ClassName:WebMvcJavaConfig
 * @Author: hasee
 * @Date: 2024.12.26 17:10
 * @Description:
 */
// 配置类
@Configuration
// 配置包扫描
@ComponentScan({"com.atli.controller","com.atli.exceptionhandler"})
// 自动添加handlerMapping,handlerAdapter
@EnableWebMvc
public class WebMvcJavaConfig implements WebMvcConfigurer {

    // 静态资源处理
    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }

    // 视图解析器
    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        registry.jsp("/WEB-INF/jsp/", ".jsp");
    }

    // 拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    }
}

Root容器配置文件

ServiceJavaConfig

package com.atli.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

/**
 * @ClassName:ServiceJavaConfig
 * @Author: hasee
 * @Date: 2024.12.26 17:25
 * @Description:
 */

// 配置类
@Configuration
// 包扫描
@ComponentScan("com.atli.service")
// 开启aspectj注解支持
@EnableAspectJAutoProxy
// 开启事务注解支持
@EnableTransactionManagement
public class ServiceJavaConfig {

    // 事务管理器实现
    @Bean
    public TransactionManager transactionManager(DataSource dataSource) {
        DataSourceTransactionManager transactionManager = new DataSourceTransactionManager();
        transactionManager.setDataSource(dataSource);
        return transactionManager;
    }
}

MapperJavaConfig

package com.atli.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.github.pagehelper.PageInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.logging.slf4j.Slf4jImpl;
import org.apache.ibatis.session.AutoMappingBehavior;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import javax.sql.DataSource;
import javax.xml.crypto.Data;
import java.util.Properties;

/**
 * @ClassName:MapperJavaConfig
 * @Author: hasee
 * @Date: 2024.12.26 17:35
 * @Description:
 */
// 配置类
@Configuration
public class MapperJavaConfig {

    // 利用mybatis提供的SqlSessionFactoryBean配置SqlSessionFactory
    // 千万注意,是mybatis提供的,如果要使用mybatisplus则需要用其他的工厂对象MybatisSqlSessionFactoryBean
    @Bean
    public SqlSessionFactoryBean sqlSessionFactory(DataSource dataSource){
        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
        // 配置数据源
        sqlSessionFactoryBean.setDataSource(dataSource);

        // 指定mybatis配置文件功能
        org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
        //开启驼峰映射
        configuration.setMapUnderscoreToCamelCase(true);
        // 开启logback
        configuration.setLogImpl(Slf4jImpl.class);
        // 开启resultMap自动映射
        configuration.setAutoMappingBehavior(AutoMappingBehavior.FULL);

        // 启用configuration实例中配置
        sqlSessionFactoryBean.setConfiguration(configuration);
        // 设置别名
        sqlSessionFactoryBean.setTypeAliasesPackage("com.atli.pojo");
        // 添加pagehelper插件
        PageInterceptor pageInterceptor = new PageInterceptor();
        Properties properties = new Properties();
        properties.setProperty("helperDialect", "mysql");
        pageInterceptor.setProperties(properties);
        sqlSessionFactoryBean.addPlugins(pageInterceptor);

        return sqlSessionFactoryBean;
    }

    // mapper代理对象
    @Bean
    public MapperScannerConfigurer mapperScannerConfigurer() {
        MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
        // 设置mapper接口与xml文件所在共同包
        mapperScannerConfigurer.setBasePackage("com.atli.mapper");
        return mapperScannerConfigurer;
    }
}

DataSourceJavaConfig

package com.atli.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import javax.sql.DataSource;

/**
 * @ClassName:DataSouceJavaConfig
 * @Author: hasee
 * @Date: 2024.12.26 18:53
 * @Description: 若将配置datasouce和mapper放一个配置类中会因为加载顺序问题使得数据库连接信息为空
 */

@Configuration
// 导入配置文件
@PropertySource("classpath:jdbc.properties")
public class DataSourceJavaConfig {

    // 导入数据库连接信息
    @Value("${jdbc.user}")
    private String user;

    @Value("${jdbc.password}")
    private String password;

    @Value("${jdbc.url}")
    private String url;

    @Value("${jdbc.driver}")
    private String driver;

    // 配置数据源
    @Bean
    public DataSource dataSource() {
        DruidDataSource ds = new DruidDataSource();
        ds.setDriverClassName(driver);
        ds.setUrl(url);
        ds.setUsername(user);
        ds.setPassword(password);
        return ds;
    }
}

IoC整合配置

SpringIoCInit

package com.atli.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

/**
 * @ClassName:SpringIoCInit
 * @Author: hasee
 * @Date: 2024.12.26 19:16
 * @Description:
 */
@Configuration
public class SpringIoCInit extends AbstractAnnotationConfigDispatcherServletInitializer {
    // rootioc容器配置类
    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{ServiceJavaConfig.class, DataSourceJavaConfig.class, MapperJavaConfig.class};
    }

    // webioc容器配置类
    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[]{WebMvcJavaConfig.class};
    }

    // dispatcherServlet拦截路径
    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }
}

实体类(pojo)

Customer

package com.atli.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import lombok.Data;

/**
 * @TableName customer
 */
@TableName(value ="customer")
@Data
public class Customer {
    private Integer id;

    private String userName;

    private Integer capital;
}

CustomerPageResult

package com.atli.pojo;

import lombok.Data;

import java.util.List;

/**
 * @ClassName:CustomerPageResut
 * @Author: hasee
 * @Date: 2024.12.29 14:48
 * @Description:用于包装分页查询结果
 */
@Data
public class CustomerPageResult {
    Integer currentPage;
    Integer pageSize;
    long totalRecords;
    List<Customer> customers;
}

控制层(controller)

package com.atli.controller;

import com.atli.pojo.Customer;
import com.atli.pojo.CustomerPageResult;
import com.atli.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName:CustomerController
 * @Author: hasee
 * @Date: 2024.12.26 20:24
 * @Description:
 * 
 * todo:api: ssm/
 *      get "/customer/{currentPage}/{pageSize}"
 *          selectAllCustomers() 查询所有信息并按照页码,页面大小返回
 *      get "/customer/{id}"
 *          selectCustomerById() 根据id查询单个用户并返回
 *      post "/customer"
 *          insertCustomer() 新增用户
 *      delete "/customer/{id}"
 *          deleteCustomer() 删除用户
 *      put "/customer"
 *          updateCustomer() 修改用户
 */
@RestController
public class CustomerController {
    @Autowired
    private CustomerService customerService;

    @GetMapping("/customer/{currentPage}/{pageSize}")
    public CustomerPageResult selectAllCustomers(@PathVariable("currentPage") Integer currentPage, @PathVariable("pageSize") Integer pageSize) {
        return customerService.selectAllaCustomer(currentPage,pageSize);
    }

    @GetMapping("/customer/{id}")
    public Customer selectCustomerById(@PathVariable("id") Integer id) {
        return customerService.selectCustomerById(id);
    }

    @PostMapping("/customer")
    public int insertCustomer(@RequestBody Customer customer) {
        return customerService.insertCustomer(customer);
    }

    @DeleteMapping("/customer/{id}")
    public int deleteCustomer(@PathVariable("id") Integer id) {
        return customerService.deleteCustomer(id);
    }

    @PutMapping("/customer")
    public int updateCustomer(@RequestBody Customer customer) {
        return customerService.updateCustomer(customer);
    }
}

业务层(service)

接口

CustomerService

package com.atli.service;

import com.atli.pojo.Customer;
import com.atli.pojo.CustomerPageResult;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;

/**
* @author hasee
* @description 针对表【customer】的数据库操作Service
* @createDate 2024-12-26 19:35:01
*/
public interface CustomerService extends IService<Customer> {
    CustomerPageResult selectAllaCustomer(Integer currentPage, Integer pageSize);

    Customer selectCustomerById(Integer id);

    int insertCustomer(Customer customer);

    int deleteCustomer(Integer id);

    int updateCustomer(Customer customer);
}

实体类

CustomerServiceImpl

package com.atli.service.impl;

import com.atli.pojo.CustomerPageResult;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atli.pojo.Customer;
import com.atli.service.CustomerService;
import com.atli.mapper.CustomerMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author hasee
* @description 针对表【customer】的数据库操作Service实现
* @createDate 2024-12-26 19:35:01
*/
@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer>
implements CustomerService{

    @Autowired
    private CustomerMapper customerMapper;

    @Override
    public CustomerPageResult selectAllaCustomer(Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage, pageSize);
        // 全体结果集
        List<Customer> all = customerMapper.selectAllCustomer();
        // 封装成pageInfo对象
        PageInfo<Customer> pageInfo = new PageInfo<>(all);
        // 创建查询结果集
        CustomerPageResult customerPageResult = new CustomerPageResult();
        // 赋值查询结果
        customerPageResult.setCustomers(pageInfo.getList());
        // 赋值当前页码
        customerPageResult.setCurrentPage(pageInfo.getPageNum());
        // 赋值单页信息条数
        customerPageResult.setPageSize(pageInfo.getPageSize());
        // 赋值总计条数
        customerPageResult.setTotalRecords(pageInfo.getTotal());

        return customerPageResult;
    }

    @Override
    public Customer selectCustomerById(Integer id) {
        return customerMapper.selectCustomerById(id);
    }

    @Override
    public int insertCustomer(Customer customer) {
        return customerMapper.insertCustomer(customer);
    }

    @Override
    public int deleteCustomer(Integer id) {
        return customerMapper.deleteCustomer(id);
    }

    @Override
    public int updateCustomer(Customer customer) {
        return customerMapper.updateCustomer(customer);
    }
}

持久层(mapper)

mapper接口

package com.atli.mapper;

import com.atli.pojo.Customer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
* @author hasee
* @description 针对表【customer】的数据库操作Mapper
* @createDate 2024-12-26 19:35:01
* @Entity com.atli.pojo.Customer
*/
@Mapper
public interface CustomerMapper extends BaseMapper<Customer> {
    List<Customer> selectAllCustomer();

    Customer selectCustomerById(Integer id);

    int insertCustomer(Customer customer);

    int deleteCustomer(Integer id);

    int updateCustomer(Customer customer);
}

mapper映射文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.atli.mapper.CustomerMapper">

  <resultMap id="BaseResultMap" type="com.atli.pojo.Customer">
    <id property="id" column="id" jdbcType="INTEGER"/>
    <result property="userName" column="user_name" jdbcType="VARCHAR"/>
    <result property="capital" column="capital" jdbcType="INTEGER"/>
  </resultMap>
  <insert id="insertCustomer" >
    insert into Customer(user_name,capital) values (#{userName},#{capital})
  </insert>

  <update id="updateCustomer">
    update customer set user_name=#{userName} , capital=#{capital} where id=#{id}
  </update>

  <delete id="deleteCustomer">
    delete from customer where id=#{id}
  </delete>

  <select id="selectAllCustomer" resultType="com.atli.pojo.Customer">
    select * from Customer
  </select>

  <select id="selectCustomerById" resultType="com.atli.pojo.Customer">
    select * from Customer where id=#{id}
  </select>
</mapper>

前端(vue+vite)

安装axios,element-plus

配置全局element-plus

main.js

import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'

const app = createApp(App)

app.use(ElementPlus)
app.mount('#app')

配置proxy代理服务器

vite.config.js

import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueDevTools(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  // 跨域
  server: {
    proxy: {
      '/ssm':{
        target: 'http://127.0.0.1:8080',
      }
    }
  },
})

App.vue

<script setup>
  import {ref, onMounted, reactive, isRef} from 'vue'
  import axios from "axios";
  // 保存查询所有客户数据
  let customers = ref([]);
  // 判断修改框是否展示
  let editFormVisible = ref(false)
  // 判断添加框是否展示
  let addFormVisible = ref(false)
  // 客户对象
  const customer = reactive({
    id:0,
    userName:'',
    capital:0,
  })
  // 存储查询条件
  const search = ref();
  // 数据页面大小
  const pageSize = ref(5);
  // 总页数
  const totalRecords = ref(1);
  // 当前页码
  const currentPage = ref(1);
  // 当前分页对象
  const customerPageResult = reactive({
    currentPage: 1,
    pageSize: pageSize,
    totalRecords: totalRecords,
    customers: customers,
  })
  // 页面挂载时触发查询所有信息操作
  onMounted(async () => {
    await getAllCustomers();
  })
  // 点击修改按钮
  function editFormOpen(index, row){
    customer.id=row.id;
    editFormVisible.value = true;
  }
  // 提交修改
  function editFormClose(){
    editFormVisible.value = false;
    handleEdit(customer);
  }
  // 点击添加按钮
  function addFormOpen(){
    addFormVisible.value = true;
  }
  // 提交添加
  function addFormClose(){
    addFormVisible.value = false;
    handleAdd(customer);
  }
  // 页面变动
  function handleCurrentChange(){
    getAllCustomers();
  }

  /*
* 获取所有用户    get:/ssm/customer
* 根据id获取用户  get:/ssm/customer/id
* 新增用户       post:/ssm/customer 请求体携带对象
* 删除用户       delete:/ssm/customer/id
* 修改用户       put:/ssm/customer   请求体携带对象*/

  // 新增用户
  async function handleAdd(customer) {
    const response = await axios.post('/ssm/customer', customer).then(
      async () => await getAllCustomers()
    );
    customer.id=0;
    customer.userName="";
    customer.capital=0;
  }
  // 删除用户
  async function handleDelete(index, row) {
    const response = await axios.delete('/ssm/customer/'+row.id).then(
      async () => await getAllCustomers()
    );
    customer.id=0;
    customer.userName="";
    customer.capital=0;

  }
  // 修改用户
  async function handleEdit(customer) {
    const response = await axios.put('/ssm/customer',customer).then(
      async () => await getAllCustomers()
    );
    customer.id=0;
    customer.userName="";
    customer.capital=0;
  }
  // 查询所有用户
  async function getAllCustomers() {
    // 千万记住ref要用.value取值
    const response = await axios.get('/ssm/customer/'+currentPage.value+'/'+pageSize.value);
    customers.value = response.data.customers;
    currentPage.value = response.data.currentPage;
    pageSize.value = response.data.pageSize;
    totalRecords.value = response.data.totalRecords;
    console.log();
  }
  // 根据id查询单个用户
  async function getCustomerById(id) {
    if(id){
      const response = await axios.get('/ssm/customer/'+id)
      customers.value = [response.data];
    }else {
      await getAllCustomers();
    }
  }

</script>

<template>
  <div class="common-layout">
    <el-container>
      <!-- 包含新增和查询的上方栏 -->
      <el-header height="auto">
        <el-row :gutter="18">
          <el-col :span="16"><el-button type="primary" @click="addFormOpen" >新增顾客</el-button></el-col>
          <el-col :span="4">
            <el-input type="text" placeholder="请输入查询id" style="width:300px" v-model="search" clearable @change="getCustomerById" />
          </el-col>
        </el-row>
      </el-header>
      <!-- 展示数据 -->
      <el-main>
        <el-table :data="customers" height="auto" style="width: 100%">
          <el-table-column prop="id" label="id" width="180" />
            <el-table-column prop="userName" label="姓名" width="180" />
          <el-table-column prop="capital" label="余额" />
          <el-table-column label="Operations">
            <template #default="scope">
              <el-button size="small" @click="editFormOpen(scope.$index, scope.row)">
                Edit
              </el-button>
              <el-button
                  size="small"
                  type="danger"
                  @click="handleDelete(scope.$index, scope.row)"
              >
                Delete
              </el-button>
              <!-- 编辑用户框 -->
              <el-dialog v-model="editFormVisible" title="编辑用户" width="500">
                <el-form :model="customer" :inline="true">
                  <el-form-item label="id" :label-width="100">
                    <el-input disabled v-model="customer.id"/>
                  </el-form-item>
                  <el-form-item label="姓名" :label-width="100">
                    <el-input v-model="customer.userName"/>
                  </el-form-item>
                  <el-form-item label="余额" :label-width="100">
                    <el-input v-model="customer.capital"/>
                  </el-form-item>
                </el-form>
                <template #footer>
                  <div class="dialog-footer">
                    <el-button @click="editFormVisible = false">Cancel</el-button>
                    <el-button type="primary" @click="editFormClose">
                      Confirm
                    </el-button>
                  </div>
                </template>
              </el-dialog>
              <!-- 新增用户框 -->
              <el-dialog v-model="addFormVisible" title="新增用户" width="500">
                <el-form :model="customer" :inline="true">
                  <el-form-item label="姓名" :label-width="100">
                    <el-input v-model="customer.userName"/>
                  </el-form-item>
                  <el-form-item label="余额" :label-width="100">
                    <el-input v-model="customer.capital"/>
                  </el-form-item>
                </el-form>
                <template #footer>
                  <div class="dialog-footer">
                    <el-button @click="editFormVisible = false">Cancel</el-button>
                    <el-button type="primary" @click=addFormClose>
                      Confirm
                    </el-button>
                  </div>
                </template>
              </el-dialog>
            </template>
          </el-table-column>
        </el-table>
        <div style="margin-top: 40px">
          <el-pagination
              v-model:current-page="currentPage"
              :page-size=pageSize
              :disabled="false"
              :background="true"
              layout="total, prev, pager, next"
              :total=totalRecords
              @current-change="handleCurrentChange"
          />
        </div>
      </el-main>
    </el-container>
  </div>
</template>

<style scoped>

</style>
SSM整合02_纯注解方式 本教程源码请访问:tutorial_demo SSM整合可以使用多种方式,我们纯注解的方式,抛弃所有的xml配置文件(包括web.xml),使用Java配置类和注解进行配置。 SSM的整体思路:整合Spring和SpringMVC,整合Spring和MyBatis,两两整合。 一、环境准备 1.1、建库建表 DROP DATABASE IF EXISTS ssm; CREATE DATABASE ssm; USE ssm; DROP TABLE IF EXISTS account; CREATE T. 阅读详情

相关推荐

SpringMvc框架及SSM框架整合

SpringMvc框架及SSM框架整合 一、SpringMvc相关知识 1、Spring和SpringMvc的关系 ​ 1.1、Spring是IOC和AOP的容器框架,SpringMVC是基于Spring功能之上添加的Web框架,想用SpringMVC必须先依赖Spring。 ​ 1.2、SpringMVC是一个MVC模式的WEB开发框架;Spring是一个通用解决方案, 最大的用处就是通过Ioc...

xfj_csdn的博客 659

SSM之注解开发

现在我们分析这一行把它变为注解开发这些不写在配置文件中,要写在类那里但是spring怎么知道我们写了呢这个就是取扫描组件,扫描我们写的注解base-package是扫描的位置这样写就是扫描它这个包下面的所有的类以及子包中的类我们不写名字也是可以加载上的没有注解的话就找不到了虽然没什么区别,但是我们可以根据名字推测有什么作用这样还是可以正常运行,使用并没有什么区别,只是为了方便区分下一节讲整合。

ck的博客 768

关于整合基于注解的SSM框架小结

整合基于注解的SSM框架 先创建一个SpringMVC项目:创建Maven项目,在创建过程中,Packaging必须选择war,创建好项目后,项目会因为缺少web.xml文件报错,则先在pom.xml中添加配置信息: <properties> <failOnMissingWebXml>false</failOnMissingWebXml> <maven.compiler.source>1.8</maven.compiler.source>

努力是为了站在万人之中,成为别人的光 5430

SSM整合之注解式开发

SSM项目结构图 Maven依赖 &amp;amp;lt;dependencies&amp;amp;gt; &amp;amp;lt;dependency&amp;amp;gt; &amp;amp;lt;groupId&amp;amp;gt;junit&amp;amp;lt;/groupId&amp;amp;gt; &amp;amp;lt;artifactId&amp;amp;gt;juni

Tyshawn的博客 3126

三、Crowd与JIRA、Confluence用户集成并SSO单点登录

补充说明: 通过此方法集成后,用户、组以及用户和组的关系都在Crowd系统中存储,但各个系统的权限仍由各系统控制,也可在JIRA和Confluence中添加和删除用户。 在做步骤4和步骤5的时候,要特别小心,确保当前系统的超级权限用户(一般为admin,具体看当前系统的全局权限配置)和组以及它们的关系已经在Crowd中同样存在了,才可切换并禁用当前系统的内部用户目录,否则可能造成权限丢失等严重问题(因为禁用了内部用户目录,而Crowd中又不存在这个超级权限用户和组或它们的关系,所以权限就丢失了) 维护示例

weixin_38621072的博客 2984

从零搭建AGV避障系统:我用激光雷达+树莓派视觉模块踩过的那些坑

本文分享了基于树莓派与国产激光雷达从零搭建低成本AGV避障系统的实战经验。针对复杂仓库环境,详细剖析了激光雷达数据噪声、视觉模块算力瓶颈、IMU漂移等核心挑战,并提供了多传感器融合、软件架构设计与避障决策的具体解决方案,为中小型自动化改造项目提供了宝贵参考。

git9versioner的博客 983

SSM全注解完整开发框架基础搭建

整套框架是以SpringBoot的为基础,使传统SSM项目抛弃了XMl的繁琐配置,又可以扩展SpringBoot存在的局限性,使之可以用于大型项目并减少配置。一、替代web.xml的启动端       这里选择的方式是实现WebApplicationInitializer接口,好处是可以使用ServletContext加载一些其他需要的Servlet或者Filter、Listener之类的web处...

Ahageete的博客 5080

AD | Altium Designer(原理图设计、电路仿真、PCB绘图)汉化版

Altium Designer(原理图设计、电路仿真、PCB绘图)

Qt历险记,专注Qt技术,三年医疗设备研发经验,1年机器视觉研发经验,半年柔性传感研发经验。 4162

SSM(注解开发)

1.注解开发定义Bean Spring提供@Conponent注解的三个衍生注解 @Controller用来定义表现层的Bean @Service用来定义业务层的Bean @Repository用来定义数据层的Bean 2.纯注解开发定义Bean @Configuration注解定义配置类 @ComponentScan注解扫描路径 读取Spring核心配置文件初始化容器对象换为java配置类初始化容器对象 ...

yu_fu_a_bu的博客 423

电脑版微信多开,最详细教程没有之一

首先桌面任意的位置右键新建文本文档输入如下代码: TASKKILL /F/IM WECHAT.EXE start " " "D:\Program Files (x86)\Tencent\WeChat\WeChat.exe" start " " "D:\Program Files (x86)\Tencent\WeChat\WeChat.exe" ...

大超子 4390

《深入浅出图神经网络:GNN原理解析》学习笔记

期末考完了,该上道了 目录一、图的概述1.基本概念2.图的存储和遍历3.应用分类二、神经网络基础1.机器学习2.神经网络三、卷积神经网络(CNN)1.卷积与池化2.卷积神经网络四、表示学习1.意义2.自编码器五、图信号处理与图卷积神经网络1.矩阵计算前置知识2.图信号与图的拉普拉斯矩阵3.图傅里叶变换4.图滤波器(Graph Filter)5.图卷积神经网络(GCN) 一、图的概述 1.基本概念 1.顶点(Vertex)表示研究的对象,边(Edge)表示两个对象之间特定的研究关系 2.图为顶点和边的集合.

且视他人之疑目如盏盏鬼火,大胆地去走你的夜路 2045

SpringMVC 入门核心笔记

MVC 是一种软件架构设计模式,将应用程序分为 3 个核心层级,实现「关注点分离」,降低耦合度,提升可维护性。Servlet 是 Java EE 规范的核心组件,是运行在 Web 服务器(如 Tomcat)上的 Java 程序,用于处理 Web 请求、生成动态响应,是 SpringMVC 的底层基础。SpringMVC 是 Spring 生态的Web 层框架,是 Spring 对 Servlet 的封装,实现了 MVC 架构,用于处理 Web 请求、响应,是 Java 后端 Web 开发的主流框架。

2402_87610050的博客 496

从零开始:用ADS仿真设计一个2.4GHz Wi-Fi低噪声放大器(含完整电路图)

本文提供了一份详细的ADS软件仿真指南,手把手教你从零开始设计一个2.4GHz Wi-Fi低噪声放大器。内容涵盖核心指标理解、晶体管选型与建模、匹配网络设计、偏置电路集成,并通过S参数仿真、噪声优化及线性度验证等步骤,最终呈现完整的优化电路图,助力射频初学者掌握LNA设计全流程。

weixin_29197835的博客 805

SpringMVC框架笔记 SSM整合

SpringMVC SpringMVC官方文档:https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc ssm : mybatis + Spring + SpringMVC MVC三层架构 JavaSE :认真学习,老师带,入门快 JavaWeb:认真学习,老师带,入门快 SSM框架:研究官方文档,锻炼自学能力,锻炼笔记能力,锻炼项目能力 SpringMVC + Vue + SpringBoot +

SwaeLeeUknow的博客 2462

关于机器人精度的总结(重复精度和绝对精度区分)

机械臂是工业生产中的重要设备,在焊接码垛 以及 非 接触测量等 领域中有 着重要应 用。然而由于机械臂本体制造中存在机械制造公差装配误差导致的运动学参数误差以及电机转角与关节转角间减速比误差等,导致机械臂存在。因此需要对机械臂进行标定,提高机械臂的绝对定位精度。ABB系列某款机器人精度参数表。

大胡子大叔的专栏 1万+

《深入掌握MongoDB数据库》 - 专栏介绍和目录

本专栏系统讲解MongoDB从基础到高级的全栈知识,涵盖安装配置、核心操作、性能优化、安全运维等核心内容。基础部分包括CRUD操作、数据类型、查询语法等入门知识;进阶部分深入索引优化、聚合查询、事务处理等高级特性;核心原理解析存储引擎与数据格式;安全运维则聚焦访问控制、认证机制、审计日志等企业级实践。通过实战案例与最佳实践,帮助开发者全面掌握MongoDB在不同场景下的应用,适合各层次技术人员系统学习。

数据知道的博客 2992

【SSM整合】SSM整合详细流程步骤,Spring整合SpringMVC,Spring整合MyBatis,c3p0数据库连接池使用,事务配置。

SSM整合 整合Spring、SpringMVC、MyBatis,搭建SSM环境,用于开发其他功能。 整合思路 搭建整合的环境,初始化环境 搭建Spring环境,配置完成并测试 再使用Spring整合SpringMVC框架,并测试 最后使用Spring整合MyBatis框架,并测试 整合方法:xml配置+注解的方式进行整合。 1. 搭建SSM环境 1.1 准备一个ssm数据库,并创建person表用于测试 CREATE DATEBASE ssm; USE ssm; SET FOREIGN_KEY_C

Java小皮孩 5227

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Java后端开发——SSM整合实验

创建名称为JdbcConfig的类,用于获取数据库连接信息并定义创建数据源的对象方法,并定义getDataSource()方法,用于创建DruidDataSource对象。id=1,页面显示效果如图所示。6.创建名称为BookService的业务层接口,在BookService接口中定义findBookById()方法,通过id获取对应的Book信息。4.创建名称为BookMapper的持久层接口,在BookMapper接口中定义findBookById()方法,通过图书id获取对应的图书信息。

专注 AI、大数据、Python、爬虫、数据分析可视化、机器学习、推荐算法、知识图谱、大模型应用与全栈系统开发,长期沉淀真实项目案例、源码解析、系统设计、部署经验与工程化实践,分享可运行、可复用、可落地的技术方案。 2021

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

【基于轻量型架构的WEB开发】课程 第14章 SSM框架整合 Java EE企业级应用开发教程 Spring+SpringMVC+MyBatis

对于Java EE应用程序的开发,行业中提供了非常多的技术框架,但是不管如何进行技术选型,Java EE应用都可以分为表现层业务逻辑层和数据持久层,当前,这3个层的主流框架分别是Spring MVCSpring和MyBatis,简称为SSM框架,Java EE应用程序也经常通过整合这3大框架来完成开发。SSM框架的整合有多种方式,本章将对图书完稿时常用的整合方式和纯注解的整合方式来对SSM框架的整合进行讲解。14.1 常用方式整合SSM框架。

Kika写代码的博客 1506

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

JavaEE企业级应用开发教程实验十二SSM框架整合

在src\mian\java\com\sun\config文件夹中创建 ServletContatinerslnitConfig类。在src\mian\java\com\sun\config文件夹中创建 SpringMvcConfig类。在src\mian\java\com\sun\config文件夹中创建MyBatisConfig类。在src\mian\java\com\sun\config文件夹中创建 SpringConfig类。

Annzz123的博客 2597

SSM整合(SpringMVC + Spring + Mybatis)

SSM整合开发 # SSM整合开发步骤 SSM = SpringMVC + Spring + Mybatis 1. 引入依赖 spring springmvc mybatis mybatis-spring mysql druid log4j servlet-api jstl fastjson(需要做ajax处理引入) 2. SM整合 = Spring + Mybatis 1). 建表 2). 实体 3). DAO接口 4). Mapper配置文件 5). Service接口 6

qq_50313418的博客 2135

SSM(springmvc+spring+mybatis)整合过程

问题?SSM(springmvc+spring+mybatis)整合过程 一、SSM框架比较S2SH框架的优缺点比较 二、整合过程 三、细节重要点 四、总结

Mr_li13的博客 1万+

Spring Boot整合SSM

Spring Boot可以帮助我们快速的搭建一个SSM框架,那建立spring boot项目之后怎样和SSM整合呢? 1.新建Model时,选择项目需要的核心依赖包 2.新建项目,建立相关对应的核心包,下图是成功之后的项目结构图 Students.java package com.ssm.springboot02.model; /** * @author 小思 * @PackageNa...

小思的博客 6848

Spring+SpringMVC+MyBatis整合

SSM全称Spring+SpringMVC+MyBatis,是spring、spring MVC 、和mybatis框架的整合,为标准的MVC模式,是目前比较主流的Java EE企业级框架,标准的SSM框架有四层,分别是dao(mapper)层,service层,controller层和View层。使用spring实现业务对象管理,使用spring MVC负责请求的转发和视图管理,mybatis作为数据对象的持久化引擎。

这河里吗l的博客 1611

SSM框架整合(注解版)

SSM框架整合概述1.Spring和SpringMVC的整合2.Spring和MyBatis的整合 概述 Spring框架的核心IoC(DI)和AOP的容器框架,最主要的目的就是帮我们管理Bean的生命周期(实例化和初始化操作),Spring的这种特性可以跟很多的框架进行整合,但是Spring MVC框架本身就隶属于Spring框架,他们两个之间不存在整合关系,只是在扫描注解的时候产生了重叠(@Controller @Service @Repository @Component @Configuration

qq_47267252的博客 2100

ssm框架整合(项目步骤)

SSM框架即是将SpringMVC框架、Spring框架、MyBatis框架整合使用。以简化在web开发中繁琐、重复的操作,让开发人员的精力专注于业务处理的开发上。1、spring和mybaits整合(数据源》sessionFactory》session) 2、spirng和springMVC整合统一指挥、让两个框架中用到的类和对象,都让spring管理。好处:无缝衔接、用到spring提供的很多工具。mybatis的主配置文件 spring的配置文件 springMVC的配置文件 web.xml@Resp

passerby的博客 3320
上一篇: SpringMVC--10Spring MVC执行流程
下一篇: SpringBoot基础--01快速入门
sisyphoslee
博客等级 码龄7年 942粉丝 142原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值