本次演示的代码结构如下,基于maven,整合SpringBoot、Spring、Mybaits的SSM框架。同时测试logback日志框架的使用及配置。
1.创建maven工程,修改pom.xml文件
4.0.0
yan.li
spring-boot-demo
0.0.1-SNAPSHOT
org.springframework.boot
spring-boot-starter-parent
1.5.8.RELEASE
UTF-8
UTF-8
1.8
org.springframework.boot
spring-boot-starter-cache
org.mybatis.spring.boot
mybatis-spring-boot-starter
1.3.1
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-devtools
true
com.alibaba
fastjson
1.2.9
mysql
mysql-connector-java
runtime
org.springframework.boot
spring-boot-starter-test
test
org.springframework.boot
spring-boot-maven-plugin
true
2.创建com.liyan.model包,同时创建两个PO类
(1)User.java类
package com.liyan.model;
import java.io.Serializable;
/**
* 员工实体类
*
Title: User
* @author Liyan
* @date 2018年1月11日 上午10:45:20
*/
public class User implements Serializable{
private static final long serialVersionUID = 1L;
/** 自增主键 */
private Integer id;
/** 员工工号 */
private String userId;
/** 员工姓名 */
private String userName;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
(2)ResponseResult.java类
package com.liyan.model;
/**
* 返回值实体类
*
Title: ResponseResult
* @author Liyan
* @date 2018年1月11日 下午5:23:41
*/
public class ResponseResult {
private Integer code;
private String msg;
private Object data;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Object getData() {
return da