1.基于spring boot创建web项目.参考https://mp.csdn.net/postedit/80103144;
2.访问html页面.
pom.xml文件中需要配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
编写indexController.(之前已经有编写index.html.html和css的位置在上篇博客也有写)
直接访问
controller层
service层
mapper层
对应的mapper.xml文件和pom.xml对应的mybatis的配置
<?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.example.demo.mapper.UserMapper">
<select id="getUser" resultType="com.example.demo.pojo.User">
SELECT * FROM USER
</select>
</mapper>
mybatis.mapper-locations=classpath:/mybatis/*Mapper.xml
mybatis.type-aliases-package=com.example.demo.pojo
访问成功: