当前位置:网站首页>SSM integration
SSM integration
2022-06-24 10:23:00 【Dream and sea depth @ none】
1、 Guide pack
<!-- Import our Servlet Of API -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- Import US jstl The package of the tag library -->
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>javax.servlet.jsp.jstl-api</artifactId>
<version>1.2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/jsp-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.taglibs</groupId>
<artifactId>taglibs-standard-impl</artifactId>
<version>1.2.5</version>
</dependency>
<!-- The first step should be to import our mybatis My bag -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.4</version>
</dependency>
<!-- Import our mybatis Some of the runtime dependencies are related to the package log -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- The imported packages are related to logs -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<!-- Into the cglib Agent's package -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.2.4</version>
</dependency>
<!-- This is the package of our plug-in -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
<!-- introduce junit class -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- Import myBatis and Spring Integrated tundish -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.0.0</version>
</dependency>
<!-- Import US Spring The relevant package -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>5.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>5.1.3.RELEASE</version>
</dependency>
<!-- intervention aspectj The relevant package -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.11</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency>
<!--MySQL Driver package -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.20</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.23.1-GA</version>
</dependency>
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
<version>3.1.12</version>
</dependency>
2、 To write web.xml
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<!-- To configure Spring-->
<!-- introduce Spring Configuration file for -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:bean-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- To configure SpringMVC-->
<servlet>
<servlet-name>DispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-mvc.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>DispatcherServlet</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>
</web-app>
3、 To write bean-ibatis.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.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">
<!-- Configure the connection pool of the database -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="url" value="jdbc:mysql:///lkx"></property>
<property name="username" value="root"></property>
<property name="password" value="root"></property>
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
</bean>
<!-- To configure SqlSessionfactorybean This object -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="mapperLocations" value="classpath:mapper/*.xml"></property>
</bean>
<!-- Configure that MapperScannerConfigurer-->
<bean id="scannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
<property name="basePackage" value="com.qf.ibatis.mapper"></property>
</bean>
<!-- To configure aop Automatic proxy -->
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<!-- Configure package scanning -->
<context:component-scan base-package="com.qf.ibatis"></context:component-scan>
</beans>
4、 To write spring-mvc.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- Can make MVC Annotations -->
<mvc:annotation-driven></mvc:annotation-driven>
<!-- The configuration is SpringMVC Scan -->
<context:component-scan base-package="com.qf.ibatis.controller"></context:component-scan>
</beans>
5、 To write Controller
package com.qf.ibatis.controller;
import com.qf.ibatis.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/** * @Auther: lkx * @Date: 2021/3/10 15:55 * @Description: */
@Controller
public class UserController {
@Autowired
private IUserService userService;
@RequestMapping("add")
public String add(){
userService.add();
return "/index.jsp";
}
}
6、 To write Service
package com.qf.ibatis.service.impl;
import com.qf.ibatis.mapper.UserMapper;
import com.qf.ibatis.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/** * @Auther: lkx * @Date: 2021/3/10 15:56 * @Description: */
@Service
public class UserService implements IUserService {
@Autowired
private UserMapper userMapper;
@Override
public void add() {
userMapper.add();
}
}
7、 To write mapper
public interface UserMapper {
/** * Add users */
void add();
}
8、 To write mapper.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">
<!-- This one below userMapper It can be written casually This means namespace As long as this value is unique in the system You can't write two names nameSpace The general way of writing is pojo object Mapper, In this way, we can see the meaning of name -->
<mapper namespace="com.qf.ibatis.mapper.UserMapper">
<!-- Here is how to use tags to describe methods -->
<insert id="add">
insert into t_user(userName,password) values("lkx","123");
</insert>
</mapper>
边栏推荐
- 23. Opencv——图像拼接项目
- 1.项目环境搭建
- 利用pandas读取SQL Sever数据表
- How does home office manage the data center network infrastructure?
- YOLOv6:又快又准的目标检测框架开源啦
- 解决Deprecated: Methods with the same name as their class will not be constructors in报错方案
- numpy. logical_ and()
- tf.contrib.layers.batch_norm
- 分布式 | 如何与 DBLE 进行“秘密通话”
- 415 binary tree (144. preorder traversal of binary tree, 145. postorder traversal of binary tree, 94. inorder traversal of binary tree)
猜你喜欢

p5.js实现的炫酷交互式动画js特效

Machine learning - principal component analysis (PCA)

Using pandas to read SQL server data table

canvas无限扫描js特效代码

Role of message queuing

线程的 sleep() 方法与 wait() 方法的区别

4.分类管理业务开发

Yolov6: the fast and accurate target detection framework is open source

leetCode-1823: 找出游戏的获胜者

Nvisual digital infrastructure operation management software platform
随机推荐
Network of test and development - Common Service Protocols
2. login and exit function development
415 binary tree (144. preorder traversal of binary tree, 145. postorder traversal of binary tree, 94. inorder traversal of binary tree)
p5.js千纸鹤动画背景js特效
线程的 sleep() 方法与 wait() 方法的区别
Uniapp implements the function of clicking to make a call
Leetcode - 498: traversée diagonale
[db2] sql0805n solution and thinking
Wechat applet learning to achieve list rendering and conditional rendering
uniapp开发微信小程序,显示地图功能,且点击后打开高德或腾讯地图。
tf. contrib. layers. batch_ norm
牛客-TOP101-BM28
学习使用KindEditor富文本编辑器,点击上传图片遮罩太大或白屏解决方案
用扫描的方法分发书稿校样
Leetcode-498: diagonal traversal
Troubleshooting steps for Oracle pool connection request timeout
学习使用phpstripslashe函数去除反斜杠
tf. errors
Leetcode-1089: replication zero
消息队列的作用