新建项目
![](https://i-blog.csdnimg.cn/blog_migrate/81b9a45d3cd0153828baa96fcab279b2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e7ee88bcd27708b8544ec0e891e64a08.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e348aa2c7ff334e3fbbd2b818284c3d0.png)
导入的依赖代码:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.4</version>
</dependency>
</dependencies>
![](https://i-blog.csdnimg.cn/blog_migrate/86047de848b5ba995517c33c82d75990.png)
# 应用名称
server.servlet.context-path=/newsserver
# 应用服务 WEB 访问端口
server.port=8089
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/newsdb?characterEncoding=UTF-8&useSSl=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=*****
mybatis.mapper-locations=classpath:cn/smxy/newsserver/mapper/*.xml
mybatis.type-aliases-package=cn.smxy.newsserver.entity
新建controller dao entity service
![](https://i-blog.csdnimg.cn/blog_migrate/09680b63e1f8744beea349501551eca4.png)
新建实体类写参数然后参数的get set tostring方法
![](https://i-blog.csdnimg.cn/blog_migrate/aa962458372ae79b23261c177ad4b28a.png)
下一步进入数据层对数据层DAO的编写
![](https://i-blog.csdnimg.cn/blog_migrate/d41dd5e87d0a00dbfe0758445aee2ead.png)
下一步写完DAO后进入数据配置文件反馈给数据层
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"" target="_blank">http://mybatis.org/dtd/mybatis-3-mapper.dtd"" target="_blank">>
<mapper namespace="cn.smxy.newsserver.dao.NewsDao">
</mapper>
![](https://i-blog.csdnimg.cn/blog_migrate/117a119d510e86e6a0d571766b7c5d65.png)
进入业务层先写业务层接口通过类实现接口功能(类中调用数据层)
![](https://i-blog.csdnimg.cn/blog_migrate/549502a7d85302ce7c10567a71565e27.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7cff454d5b0d99489ea2b3a8b4838ad4.png)
主程序声明所选数据层dao
![](https://i-blog.csdnimg.cn/blog_migrate/127c3752f1356a63925492d02cd7da80.png)
进入cotroller控制器编写以实现数据反馈给页面
![](https://i-blog.csdnimg.cn/blog_migrate/3869caa50e2b11ec878860b6105a059f.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6b946a69a32ee5715734859113fe20f7.png)
运行输入对应网址页面显示数据
![](https://i-blog.csdnimg.cn/blog_migrate/59005c0692a46a130687c80ab0425dd0.png)
![](https://i-blog.csdnimg.cn/blog_migrate/c8d93d62b713b683cf6a9d648d8c9df9.png)
<!-- maven 依赖阿里云仓库下载-->
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>