SSM整合-Spring整合SringMVC、Mybatis,ssm测试

这篇具有很好参考价值的文章主要介绍了SSM整合-Spring整合SringMVC、Mybatis,ssm测试。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

SSM 整合简介

一、SSM整合介绍

​ SSM(Spring + SpringMVC + Mybatis) 整合,就是三个框架协同开发。

二、框架分工

  1. Spring 整合 Mybatis,就是将 Mybatis 核心配置分拣当中数据源的配置、事务管理、工厂的配置、Mapper接口的实现类等 交给Spring进行管理。
    • mybatisConfig.xml配置信息 整合到 SpringConfig.xml
  2. Spring 整合 SpringMVC,就是在web.xml当中添加监听器,当服务器启动,监听器触发,监听器执行了Spring的核心配置文件,核心配置文件被加载
    • 在web.xml中添加监听器,执行SpringMVCConfig.xml文件。

三、整合核心步骤

  1. Spring 基础框架单独运行
  2. SpringMVC 框架单独运行
  3. Spring 整合SpringMVC 框架
  4. Spring 整合Mybatis 框架
  5. 测试SSM 整合结果

SSM 整合环境配置

Spring 基础框架单独运行

一、项目结构

SSM整合-Spring整合SringMVC、Mybatis,ssm测试

二、项目搭建

1、创建maven项目并导入依赖-pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.etime</groupId>
    <artifactId>day0420</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <spring-version>5.2.5.RELEASE</spring-version>
        <mybatis-version>3.4.6</mybatis-version>
    </properties>
    <dependencies>
        <!--mybatis相关包-->
        <!--mysql的驱动包-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.47</version>
        </dependency>
        <!--mybatis核心-->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>${mybatis-version}</version>
        </dependency>
        <!--连接池-->
        <dependency>
            <groupId>com.mchange</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.5.2</version>
        </dependency>
        <!--junit-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <!--日志包-->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <!--分页插件-->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper</artifactId>
            <version>5.1.10</version>
        </dependency>

        <!--spring相关的-->
        <!--springIOC包-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring-version}</version>
        </dependency>
        <!--jdbc-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring-version}</version>
        </dependency>
        <!--织入器包:-->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.8.7</version>
        </dependency>

        <!--springmvc依赖:-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring-version}</version>
        </dependency>
        <!--解析器包-->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.9</version>
        </dependency>
        <!--文件上传-->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3.1</version>
        </dependency>

        <!--spring整合mybatis-->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>1.3.2</version>
        </dependency>
        <!--spring整合junit-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring-version}</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.16</version>
        </dependency>
    </dependencies>
</project>
2、创建实体类
package com.etime.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class Student {

    private int sid;
    private String name;
    private int cid;
}
3、编写业务逻辑层接口及实现类
(1)业务逻辑层接口
package com.etime.service;

import com.etime.pojo.Student;

import java.util.List;

public interface StudentService {
    
    List<Student> getAllStudent();
}
(2)业务逻辑层实现类
package com.etime.service.impl;

import com.etime.pojo.Student;
import com.etime.service.StudentService;

import java.util.List;

public class StudentServiceImpl implements StudentService {
    @Override
    public List<Student> getAllStudent() {
        System.out.println("StudentService getAllStudent Method!");
        return null;
    }
}
4、编写 Spring 核心配置文件
  • 在SpringConfig.xml文件中
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">
    <!--扫描包下的组件(注解)-->
    <context:component-scan base-package="com.etime.service"></context:component-scan>
</beans>
5、测试 Spring 独立运行
package com.etime.test;

import com.etime.service.StudentService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/*
    RunWith:是一个运行器,测试时 运行交给Spring的环境来进行
    自动创建Spring的应用上下文
 */
@RunWith(SpringJUnit4ClassRunner.class)
// 加载Spring的配置文件
@ContextConfiguration("classpath:SpringConfig.xml")
public class SsmTest {

    // 自动注入
    @Autowired
    private StudentService studentService;

    @Test
    public void SpringTest(){
        studentService.getAllStudent();
    }
}
// 结果
StudentService getAllStudent Method!

Process finished with exit code 0

SpringMVC 框架单独运行

一、项目结构

SSM整合-Spring整合SringMVC、Mybatis,ssm测试

二、项目搭建

1、在 web.xml 中配置核心控制器(DispatcherServlet)
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    <!--注册、配置前端控制器-->
    <servlet>
        <servlet-name>dispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <!--Spring整合:
        加载SpringMVC的配置文件-->
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:SpringMVCConfig.xml</param-value>
        </init-param>
    </servlet>
    <!--设置Servlet的映射路径-->
    <servlet-mapping>
        <servlet-name>dispatcherServlet</servlet-name>
        <!--/:根路径下,所有的文件都要经过该Servlet-->
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>
2、创建SpringMVC核心配置文件 SpringMVCConfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">
    <!--配置注解扫描器-->
    <context:component-scan base-package="com.etime.controller"></context:component-scan>
    <!--处理器配置-->
    <mvc:annotation-driven></mvc:annotation-driven>
    <!--配置视图解析器-->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>
</beans>
3、创建构造器 进行测试
package com.etime.controller;

import com.etime.pojo.Student;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/student")
public class StudentController {

    @GetMapping("springMvcTest")
    @ResponseBody
    public Student springMvcTest(){
        return new Student(1,"胡神",1);
    }
}

SSM整合-Spring整合SringMVC、Mybatis,ssm测试

Spring 整合SpringMVC 框架

一、项目结构

​ 与 SpringMVC 框架单独运行 的项目结构一样

二、项目搭建

1、在 web.xml中 加载Spring核心配置文件及添加监听器
<!--加载Spring的核心配置文件-->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:SpringConfig.xml</param-value>
</context-param>
<!--配置一个监听器:ServletContext-->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
2、修改StudentService实现类与控制器代码 并测试
(1)StudentServiceImpl实现类
package com.etime.service.impl;

import com.etime.pojo.Student;
import com.etime.service.StudentService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service("studentService")
public class StudentServiceImpl implements StudentService {
    @Override
    public List<Student> getAllStudent() {
        System.out.println("StudentService getAllStudent Method!");
        Student s1 = new Student(1,"tom",1);
        Student s2 = new Student(2,"jack",2);
        Student s3 = new Student(3,"macy",3);
        List<Student> list = new ArrayList<>();
        list.add(s1);
        list.add(s2);
        list.add(s3);
        return list;
    }
}
(2)StudentController
package com.etime.controller;

import com.etime.pojo.Student;
import com.etime.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @GetMapping("springMvcTest")
    @ResponseBody
    public List<Student> springMvcTest(){
        return studentService.getAllStudent();
    }
}

SSM整合-Spring整合SringMVC、Mybatis,ssm测试

Spring 整合Mybatis 框架

一、项目结构

SSM整合-Spring整合SringMVC、Mybatis,ssm测试

二、项目搭建

1、编写数据持久层接口StudentMapper.java
package com.etime.mapper;

import com.etime.pojo.Student;

import java.util.List;

public interface StudentMapper {
    List<Student> getAllStudent();
}
2、编写Mybatis核心配置文件StudentMapper.xml (或使用注解)
<?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.etime.mapper.StudentMapper">
    <select id="getAllStudent" resultType="Student">
        select * from student
    </select>
</mapper>
3、Spring 整合 Mybatis配置
(1)数据库配置文件jdbc.properties
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/db_418
root=root
password=root
(2)在 SpringConfig.xml 文件中配置数据源
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">
    <!--扫描包下的组件(注解)-->
    <context:component-scan base-package="com.etime.service"></context:component-scan>
   <!-- 注册Mybatis映射文件-->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.etime.mapper"></property>
    </bean>
    <!--数据源-->
    <!--加载jdbc.properties属性文件-->
    <context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="${driver}"/>
        <property name="jdbcUrl" value="${url}"/>
        <property name="user" value="${root}"/>
        <property name="password" value="${password}"/>
    </bean>
     <!--Mybatis的核心工厂对象-->
    <bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <!--注入数据源-->
        <property name="dataSource" ref="dataSource"></property>
        <!--实体类取别名-->
        <property name="typeAliasesPackage" value="com.etime.pojo"></property>
        <!--mapper 文件的位置-->
        <property name="mapperLocations" value="classpath:com/etime/mapper/*.xml"></property>
        <!--配置分页插件-->
        <property name="plugins">
            <array>
                <bean class="com.github.pagehelper.PageInterceptor">
                    <property name="properties">
                        <value>
                            ue>
                            helperDialect=mysql
                            reasonable=true
                            supportMethodsArguments=true
                            params=count=countSql
                            autoRuntimeDialect=true
                        </value>
                    </property>
                </bean>
            </array>
        </property>
    </bean>
</beans>
(3) 在SpringConfig.xml文件中配置事务处理及事务的注解使用权限
<!--事务管理器-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <!--注入数据源-->
    <property name="dataSource" ref="dataSource"></property>
</bean>
<!--开启注解式事务-->
<tx:annotation-driven transaction-manager="transactionManager"></tx:annotation-driven>
4、修改StudentService的实现类中的方法 并测试
package com.etime.service.impl;

import com.etime.mapper.StudentMapper;
import com.etime.pojo.Student;
import com.etime.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service("studentService")
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public List<Student> getAllStudent() {
        return studentMapper.getAllStudent();
    }
}

SSM整合-Spring整合SringMVC、Mybatis,ssm测试

SSM 整合测试

  • 需求分析:查询所有学生信息,利用Mybatis分页插件进行分页

一、实体类编写

1、班级类

package com.etime.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class Classes {

    private int cid;
    private String cname;
}

2、学生类

package com.etime.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class Student {

    private int sid;
    private String sname;
    private int cid;
    private Classes classes;
}

二、编写数据持久层

1、编写接口 StudentMapper.java中的方法

package com.etime.mapper;

import com.etime.pojo.Student;

import java.util.List;

public interface StudentMapper {
    List<Student> getAllStudent();
}

2、编写映射文件 StudentMapper.xml 配置信息

<?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.etime.mapper.StudentMapper">
    <select id="getAllStudent" resultMap="studentAndClasses">
        select * from student s,classes c where s.cid=c.cid
    </select>
    <resultMap id="studentAndClasses" type="Student">
        <id property="sid" column="sid"></id>
        <result property="sname" column="sname"></result>
        <result property="cid" column="cid"></result>
        <association property="classes" javaType="Classes">
            <id property="cid" column="cid"></id>
            <result property="cname" column="cname"></result>
        </association>
    </resultMap>
</mapper>

三、编写业务逻辑层

1、编写接口 StudentService.java中的方法

package com.etime.service;

import com.etime.pojo.Student;
import com.github.pagehelper.PageInfo;


public interface StudentService {

    PageInfo<Student> getAllStudent(int pageNum, int pageSize);
}

2、编写接口实现类中的方法

package com.etime.service.impl;

import com.etime.mapper.StudentMapper;
import com.etime.pojo.Student;
import com.etime.service.StudentService;
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.ArrayList;
import java.util.List;

@Service("studentService")
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public PageInfo<Student> getAllStudent(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Student> list = studentMapper.getAllStudent();
        PageInfo<Student> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}

四、编写控制层

1、编写 StudentController.java中的执行方法

package com.etime.controller;

import com.etime.pojo.Student;
import com.etime.service.StudentService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/student")
/*
    解决跨域问题
 */
@CrossOrigin
public class StudentController {

    @Autowired
    private StudentService studentService;

    @GetMapping("ssmTest")
    @ResponseBody
    public PageInfo<Student> ssmTset(int pageNum, int pageSize){
        return studentService.getAllStudent(pageNum,pageSize);
    }
}

五、编写前端页面

1、index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>index</title>
    <script src="js/vue.global.js"></script>
    <script src="js/axios.min.js"></script>
</head>
<body>
    <div id="app">
        <table border="1" cellspacing="0" cellpadding="0" align="center" width="500">
            <tr>
                <th>学号</th>
                <th>姓名</th>
                <th>班级编号</th>
            </tr>
            <tr v-for="(stu,index) in students">
                <td>{{stu.sid}}</td>
                <td>{{stu.sname}}</td>
                <td>{{stu.classes.cname}}</td>
            </tr>
        </table>
        <div style="width: 500px;margin: auto;">
            <a href="javaScript:void(0)" @click="getStudentByPage(1)">首页</a>
            <a href="javaScript:void(0)" @click="getStudentByPage(prePage)">上一页</a>
            {{pageNum}}/{{pageTotal}}
            <a href="javaScript:void(0)" @click="getStudentByPage(nextPage)">下一页</a>
            <a href="javaScript:void(0)" @click="getStudentByPage(pageTotal)">尾页</a>
        </div>
    </div>
    <script>
        const vueApp = Vue.createApp({
             data() {
                return {
                    students:"",
                    pageNum:"",
                    pageTotal:"",
                    prePage:"",
                    nextPage:"",
                }
             },
             methods: {
                getStudentByPage(page){
                    axios({
                        url:"http://localhost:8080/day0420_war_exploded/student/ssmTest?pageNum="+page+"&pageSize=3",
                        method:"get",
                    }).then(resp =>{
                        console.log(resp.data);
                        this.students = resp.data.list;
                        this.pageNum = resp.data.pageNum;
                        this.pageTotal = resp.data.pages;
                        this.prePage = resp.data.prePage;
                        if (this.prevPage <= 0) {
                        this.prevPage = 1;
                        }
                        this.nextPage = resp.data.nextPage;
                    });
                }
             },
             created() {
                this.getStudentByPage(1);
             },
        });
        vueApp.mount("#app");
    </script>
</body>
</html>

SSM整合-Spring整合SringMVC、Mybatis,ssm测试文章来源地址https://www.toymoban.com/news/detail-421713.html

到了这里,关于SSM整合-Spring整合SringMVC、Mybatis,ssm测试的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【SSM整合】对Spring、SpringMVC、MyBatis的整合,以及Bootstrap的使用,简单的新闻管理系统

    ✅作者简介:热爱Java后端开发的一名学习者,大家可以跟我一起讨论各种问题喔。 🍎个人主页:Hhzzy99 🍊个人信条:坚持就是胜利! 💞当前专栏:【Spring】 🥭本文内容:SSM框架的整合使用,还有bootstrap等前端框架的简单使用,做一个简单的新闻管理系统 在前文中,我们

    2024年02月06日
    浏览(36)
  • 【Spring+SpringMVC+Mybatis】SSM框架的整合、思想、工作原理和优缺点的略微讲解

    🚀欢迎来到本文🚀 🍉个人简介:陈童学哦,目前学习C/C++、算法、Python、Java等方向,一个正在慢慢前行的普通人。 🏀系列专栏:陈童学的日记 💡其他专栏:C++STL,感兴趣的小伙伴可以看看。 🎁希望各位→点赞👍 + 收藏⭐️ + 留言📝 ​ ⛱️万物从心起,心动则万物动🏄

    2024年02月10日
    浏览(38)
  • 【MyBatis学习】Spring Boot(SSM)单元测试,不用打包就可以测试我们的项目了,判断程序是否满足需求变得如此简单 ? ? ?

    前言: 大家好,我是 良辰丫 ,在上一篇文章中我们学习了MyBatis简单的查询操作,今天来介绍一下 Spring Boot(SSM)的一种单元测试 ,有人可能会感到疑惑,框架里面还有这玩意?什么东东呀,框架里面是没有这的,但是我们简单的学习一下单元测试,可以帮助我们自己测试代码,学习单元测试

    2024年02月09日
    浏览(79)
  • SpringBoot整合JUnit、MyBatis、SSM

    🐌个人主页: 🐌 叶落闲庭 💨我的专栏:💨 c语言 数据结构 javaEE 操作系统 石可破也,而不可夺坚;丹可磨也,而不可夺赤。 名称:@SpringBootTest 类型:测试类注解 位置:测试类定义上方 作用:设置JUnit加载的SpringBoot启动类 范例: 相关属性 classes:设置SpringBoot启动类 注意

    2024年02月10日
    浏览(32)
  • SpringBoot入门篇3 - 整合junit、整合mybatis、基于SpringBoot实现ssm整合

    目录 Spring整合JUnit  SpringBoot整合JUnit 测试类注解:@SpringBootTest 作用:设置JUnit加载的SpringBoot启动类 ①使用spring initializr初始化项目的时候,添加依赖。  ②设置数据源application.yml 注意: SpringBoot版本低于2.4.3,Mysql驱动版本大于8.0时,需要在url连接串中配置时区。 ③定义数据

    2024年02月10日
    浏览(33)
  • SpringMVC简介、请求与响应、REST风格、SSM整合、拦截器

    目录 SpringMVC简介 SpringMVC概述 入门案例 入门案例工作流程分析 Controller加载控制 PostMan 请求与响应 设置请求映射路径 五种类型参数传递 JSON数据传输参数  JSON对象数据 JSON对象数组 日期类型参数传递  响应  REST风格 REST风格简介 RESTful入门案例 RESTful快速开发 RESTful案例 SSM整

    2024年02月05日
    浏览(29)
  • SSM框架(Spring + SpringMVC + Mybatis)

    MVC即model view controller。(模型,视图,控制器) 用于存放我们的实体类,类中定义了多个类属性,并与数据库表的字段保持一致,一张表对应一个类。 主要用于定义与数据库对象应的属性,提供get/set方法,tostring方法,有参无参构造函数。 数据持久层,先设计接口,然后在配

    2024年02月03日
    浏览(39)
  • SSM(Spring+SpringMVC+MyBatis)框架集成

    进行SSM(Spring+SpringMVC+MyBatis)集成的主要原因是为了提高开发效率和代码可维护性。SSM是一套非常流行的Java Web开发框架,它集成了Spring框架、SpringMVC框架和MyBatis框架,各自发挥优势,形成了一个完整的开发框架。 首先,使用Spring框架可以实现组件的解耦和依赖注入,通过配

    2024年02月08日
    浏览(46)
  • 基于ssm实现图书商城(spring+springmvc+mybatis)

    一、项目功能 前台 图书基本展示,包括推荐图书展示和类图书类型展示. 推荐图书包括条幅推荐,热销推荐和新品推荐. 按照图书类型展示商品. 图书详细信息展示. 图书加入购物车. 修改购物车内图书信息,例如数量等. 用户登录. 用户注册. 修改个人信息,包括密码和收获信息. 购

    2024年02月12日
    浏览(36)
  • SSM实现学生管理系统(spring+springMVC+MyBatis)

    该项目是基于SSM框架实现的学生管理系统,能够对学生信息进行增删改查,分页查询,以及实现管理员的注册、登录 数据库:MySQL 开发工具:idea 开发环境:jdk 1.8 + tomcat 在studentManger数据库中,创建登录注册表login和学生信息表student 请参考JavaWeb实现学生管理系统 1.配置mave

    2024年02月08日
    浏览(46)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包