1.点击左上角File--》Project--》
2.选择Maven打上对√,选择archetype-webapp,--》finish应用
2.找到pox.xml文件 导入以下依赖
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.7</version>
</dependency>
</dependencies>
3. 选择main右键 New---》Directory
选择java和resource
4.选择建的Maven文件再冲里面新建Maven
选择Maven打上对√,选择archetype-webapp,--》finish应用
1~!设置类加载:![](https://i-blog.csdnimg.cn/blog_migrate/b5786d67a559bd1f7dabe11394c2fb87.png)
package com.util; import org.apache.ibatis.io.Resources; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactoryBuilder; import java.io.IOException; import java.io.InputStream; public class BaseDaoUtil { private static SqlSessionFactory sessionFactory; //当类记载时 static{ String resource = "mybatis-config.xml"; InputStream inputStream = null; try { inputStream = Resources.getResourceAsStream(resource); sessionFactory &#