1.创建maven工程
(1)首先打开idea点击idea中的File->New->Project...
(2)在左侧找到Maven如图所示:
点击Next
在配置好工程名后点击Next
确认工程路径后点击Finish创建
(3)
创建一个数据库和表如下图所示:
我的库名是19J05,表名是users
往表中添加记录
2.搭建mybatis框架
(1)新建一个文件夹,将IDEA中的project改成自己想要的名字,并打开这个文件夹
(2)右键这个项目,新建一个Module
(3)点击maven并选择模板,
(4)输入包名和项目名
(5)选择自己的maven并点击下一步
2.在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>cn</groupId>
<artifactId>ssm</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>ssm Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifac