├── spring-boot-env ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ ├── application-dev.properties │ │ └── application-prod.properties │ │ └── java │ │ └── com │ │ └── songguoliang │ │ └── demo │ │ ├── DemoApplication.java │ │ └── controller │ │ └── HelloController.java └── pom.xml ├── README.md ├── spring-boot-properties ├── src │ └── main │ │ ├── resources │ │ ├── test.properties │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── songguoliang │ │ └── properties │ │ ├── PropertiesApplication.java │ │ ├── controller │ │ ├── HelloController.java │ │ └── ModelController.java │ │ └── model │ │ ├── TestEntity.java │ │ ├── User.java │ │ └── RandomData.java └── pom.xml ├── .gitignore ├── spring-boot-ehcache └── src │ └── main │ ├── resources │ ├── config │ │ └── ehcache.xml │ └── mapper │ │ └── UserMapper.xml │ └── java │ └── com │ └── songguoliang │ └── springboot │ ├── base │ └── BaseMapper.java │ ├── mapper │ └── UserMapper.java │ ├── controller │ ├── IndexController.java │ ├── TestController.java │ └── UserController.java │ ├── entity │ └── User.java │ ├── model │ └── FastjsonTest.java │ ├── service │ └── UserService.java │ └── Application.java ├── spring-boot-mybatis-generator ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ ├── generatorConfig-min.xml │ │ └── generatorConfig.xml │ │ └── java │ │ └── com │ │ └── songguoliang │ │ └── springboot │ │ └── mapper │ │ └── UserMapper.java ├── db │ └── springboot.sql └── pom.xml ├── spring-boot-mybatis-generator-mysql ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ ├── generatorConfig-min.xml │ │ ├── mapper │ │ │ └── UserMapper.xml │ │ └── generatorConfig.xml │ │ └── java │ │ └── com │ │ └── songguoliang │ │ └── springboot │ │ └── mapper │ │ └── UserMapper.java ├── db │ └── springboot.sql └── pom.xml ├── spring-boot-shiro └── src │ └── main │ ├── java │ └── com │ │ └── songguoliang │ │ └── springboot │ │ ├── mapper │ │ ├── SysUserMapper.java │ │ ├── SysPermissionMapper.java │ │ └── UserMapper.java │ │ ├── base │ │ └── BaseMapper.java │ │ ├── service │ │ ├── SysUserService.java │ │ ├── SysPermissionService.java │ │ └── UserService.java │ │ ├── controller │ │ ├── IndexController.java │ │ ├── UserController.java │ │ ├── TestController.java │ │ └── LoginController.java │ │ ├── entity │ │ └── User.java │ │ ├── model │ │ └── FastjsonTest.java │ │ ├── Application.java │ │ └── shiro │ │ ├── UserRealm.java │ │ └── ShiroConfig.java │ ├── resources │ └── mapper │ │ ├── UserMapper.xml │ │ ├── SysUserMapper.xml │ │ └── SysPermissionMapper.xml │ └── webapp │ └── WEB-INF │ └── jsp │ ├── index.jsp │ └── login.jsp ├── spring-boot-upload ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ ├── java │ │ └── com │ │ │ └── songguoliang │ │ │ └── springboot │ │ │ ├── Application.java │ │ │ └── controller │ │ │ └── UploadController.java │ │ └── webapp │ │ └── WEB-INF │ │ └── jsp │ │ ├── upload.jsp │ │ └── multiUpload.jsp └── pom.xml ├── spring-boot-druid ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── songguoliang │ │ │ └── mybatis │ │ │ ├── mapper │ │ │ └── UserMapper.java │ │ │ ├── DruidApplication.java │ │ │ ├── service │ │ │ └── UserService.java │ │ │ ├── controller │ │ │ └── UserController.java │ │ │ └── entity │ │ │ └── User.java │ │ └── resources │ │ └── mapper │ │ └── UserMapper.xml └── pom.xml ├── spring-boot-mybatis ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── songguoliang │ │ │ └── mybatis │ │ │ ├── mapper │ │ │ └── UserMapper.java │ │ │ ├── MybatisApplication.java │ │ │ ├── service │ │ │ └── UserService.java │ │ │ ├── controller │ │ │ └── UserController.java │ │ │ └── entity │ │ │ └── User.java │ │ └── resources │ │ ├── mapper │ │ └── UserMapper.xml │ │ └── application.properties ├── db │ └── springboot.sql └── pom.xml ├── spring-boot-shiro-ehcache └── src │ └── main │ ├── java │ └── com │ │ └── songguoliang │ │ └── springboot │ │ ├── mapper │ │ ├── SysUserMapper.java │ │ ├── SysPermissionMapper.java │ │ └── UserMapper.java │ │ ├── base │ │ └── BaseMapper.java │ │ ├── service │ │ ├── SysPermissionService.java │ │ ├── SysUserService.java │ │ └── UserService.java │ │ ├── controller │ │ ├── IndexController.java │ │ ├── UserController.java │ │ ├── TestController.java │ │ └── LoginController.java │ │ ├── entity │ │ └── User.java │ │ ├── model │ │ └── FastjsonTest.java │ │ └── Application.java │ ├── resources │ └── mapper │ │ ├── UserMapper.xml │ │ ├── SysUserMapper.xml │ │ └── SysPermissionMapper.xml │ └── webapp │ └── WEB-INF │ └── jsp │ ├── index.jsp │ └── login.jsp ├── spring-boot-shiro-ehcache-shiro └── src │ └── main │ ├── java │ └── com │ │ └── songguoliang │ │ └── springboot │ │ ├── mapper │ │ ├── SysUserMapper.java │ │ ├── SysPermissionMapper.java │ │ └── UserMapper.java │ │ ├── base │ │ └── BaseMapper.java │ │ ├── service │ │ ├── SysPermissionService.java │ │ ├── SysUserService.java │ │ └── UserService.java │ │ ├── configuration │ │ └── EhcacheConfig.java │ │ ├── controller │ │ ├── IndexController.java │ │ ├── UserController.java │ │ ├── TestController.java │ │ └── LoginController.java │ │ ├── entity │ │ └── User.java │ │ ├── model │ │ └── FastjsonTest.java │ │ ├── Application.java │ │ └── shiro │ │ └── UserRealm.java │ ├── resources │ └── mapper │ │ ├── UserMapper.xml │ │ ├── SysUserMapper.xml │ │ └── SysPermissionMapper.xml │ └── webapp │ └── WEB-INF │ └── jsp │ ├── index.jsp │ └── login.jsp ├── spring-boot-pagehelper ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── songguoliang │ │ │ └── springboot │ │ │ ├── mapper │ │ │ └── UserMapper.java │ │ │ ├── Application.java │ │ │ ├── service │ │ │ └── UserService.java │ │ │ ├── entity │ │ │ └── User.java │ │ │ └── controller │ │ │ └── UserController.java │ │ └── resources │ │ └── mapper │ │ └── UserMapper.xml ├── db │ └── insertuser.sql └── pom.xml ├── spring-boot-jsp └── src │ └── main │ ├── resources │ └── mapper │ │ └── UserMapper.xml │ ├── java │ └── com │ │ └── songguoliang │ │ └── springboot │ │ ├── base │ │ └── BaseMapper.java │ │ ├── mapper │ │ └── UserMapper.java │ │ ├── Application.java │ │ ├── controller │ │ ├── IndexController.java │ │ └── UserController.java │ │ ├── service │ │ └── UserService.java │ │ └── entity │ │ └── User.java │ └── webapp │ └── WEB-INF │ └── jsp │ └── index.jsp ├── spring-boot-jwt ├── src │ └── main │ │ ├── resources │ │ └── mapper │ │ │ └── UserMapper.xml │ │ └── java │ │ └── com │ │ └── songguoliang │ │ └── springboot │ │ ├── base │ │ └── BaseMapper.java │ │ ├── mapper │ │ └── UserMapper.java │ │ ├── service │ │ └── UserService.java │ │ ├── controller │ │ ├── TestController.java │ │ ├── UserController.java │ │ └── JwtController.java │ │ ├── entity │ │ └── User.java │ │ ├── model │ │ └── FastjsonTest.java │ │ ├── configuration │ │ └── JwtToken.java │ │ └── Application.java └── db │ └── springboot.sql ├── spring-boot-fastjson ├── src │ └── main │ │ ├── resources │ │ └── mapper │ │ │ └── UserMapper.xml │ │ ├── java │ │ └── com │ │ │ └── songguoliang │ │ │ └── springboot │ │ │ ├── base │ │ │ └── BaseMapper.java │ │ │ ├── mapper │ │ │ └── UserMapper.java │ │ │ ├── controller │ │ │ ├── IndexController.java │ │ │ ├── TestController.java │ │ │ └── UserController.java │ │ │ ├── service │ │ │ └── UserService.java │ │ │ ├── entity │ │ │ └── User.java │ │ │ ├── model │ │ │ └── FastjsonTest.java │ │ │ └── Application.java │ │ └── webapp │ │ └── WEB-INF │ │ └── jsp │ │ └── index.jsp └── db │ └── springboot.sql ├── spring-boot-mapper4 ├── src │ └── main │ │ ├── resources │ │ └── mapper │ │ │ └── UserMapper.xml │ │ └── java │ │ └── com │ │ └── songguoliang │ │ └── springboot │ │ ├── base │ │ └── BaseMapper.java │ │ ├── mapper │ │ └── UserMapper.java │ │ ├── Application.java │ │ ├── service │ │ └── UserService.java │ │ ├── entity │ │ └── User.java │ │ └── controller │ │ └── UserController.java └── pom.xml ├── spring-boot-quartz-db ├── src │ └── main │ │ ├── resources │ │ └── mapper │ │ │ └── UserMapper.xml │ │ └── java │ │ └── com │ │ └── songguoliang │ │ └── springboot │ │ ├── base │ │ └── BaseMapper.java │ │ ├── mapper │ │ └── UserMapper.java │ │ ├── Application.java │ │ ├── quartz │ │ ├── TestTask2.java │ │ ├── TestTask1.java │ │ └── QuartzConfig.java │ │ ├── service │ │ └── UserService.java │ │ ├── entity │ │ └── User.java │ │ └── controller │ │ └── UserController.java └── pom.xml ├── spring-boot-scheduling ├── src │ └── main │ │ └── java │ │ └── com │ │ └── songguoliang │ │ └── springboot │ │ ├── service │ │ └── UserService.java │ │ ├── Application.java │ │ └── scheduling │ │ └── MyTask.java └── pom.xml ├── spring-boot-quartz ├── src │ └── main │ │ └── java │ │ └── com │ │ └── songguoliang │ │ └── springboot │ │ ├── Application.java │ │ └── quartz │ │ ├── TestTask2.java │ │ ├── TestTask1.java │ │ └── QuartzConfig.java └── pom.xml ├── spring-boot-demo ├── src │ └── main │ │ └── java │ │ └── com │ │ └── songguoliang │ │ └── demo │ │ ├── DemoApplication.java │ │ └── controller │ │ └── HelloController.java └── pom.xml ├── spring-boot-devtools ├── src │ └── main │ │ └── java │ │ └── com │ │ └── songguoliang │ │ └── springboot │ │ ├── controller │ │ └── HelloController.java │ │ └── Application.java └── pom.xml └── pom.xml /spring-boot-env/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | spring.profiles.active=dev 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spring-boot-study 2 | 3 | Spring Boot教程源码,博客地址:https://blog.csdn.net/gnail_oug 4 | 5 | 6 | -------------------------------------------------------------------------------- /spring-boot-env/src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | server.port=8081 2 | 3 | logging.level.root=debug 4 | 5 | 6 | -------------------------------------------------------------------------------- /spring-boot-env/src/main/resources/application-prod.properties: -------------------------------------------------------------------------------- 1 | 2 | server.port=8082 3 | 4 | logging.level.root=info 5 | 6 | 7 | -------------------------------------------------------------------------------- /spring-boot-properties/src/main/resources/test.properties: -------------------------------------------------------------------------------- 1 | 2 | test.name=\u6D4B\u8BD5\u81EA\u5B9A\u4E49\u914D\u7F6E\u6587\u4EF6 3 | test.num=123 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | 4 | # Compiled class file 5 | *.class 6 | 7 | # Log file 8 | *.log 9 | 10 | */target/ 11 | 12 | 13 | .DS_Store 14 | 15 | -------------------------------------------------------------------------------- /spring-boot-ehcache/src/main/resources/config/ehcache.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /spring-boot-mybatis-generator/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | ## \u6570\u636E\u6E90\u914D\u7F6E 3 | spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=utf-8&useSSL=false 4 | spring.datasource.username=root 5 | spring.datasource.password=root 6 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 7 | 8 | -------------------------------------------------------------------------------- /spring-boot-mybatis-generator-mysql/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | ## \u6570\u636E\u6E90\u914D\u7F6E 3 | spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=utf-8&useSSL=false 4 | spring.datasource.username=root 5 | spring.datasource.password=root 6 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 7 | 8 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/mapper/SysUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import com.songguoliang.springboot.entity.SysUser; 4 | 5 | /** 6 | * @Description 7 | * @Author sgl 8 | * @Date 2018-06-11 17:19 9 | */ 10 | public interface SysUserMapper { 11 | SysUser findByUserName(String userName); 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-upload/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | # \u4E0A\u4F20\u6587\u4EF6\u603B\u7684\u6700\u5927\u503C 3 | spring.servlet.multipart.max-request-size=10MB 4 | # \u5355\u4E2A\u6587\u4EF6\u7684\u6700\u5927\u503C 5 | spring.servlet.multipart.max-file-size=10MB 6 | 7 | 8 | ## jsp 9 | spring.mvc.view.prefix=/WEB-INF/jsp/ 10 | spring.mvc.view.suffix=.jsp 11 | -------------------------------------------------------------------------------- /spring-boot-druid/src/main/java/com/songguoliang/mybatis/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.mybatis.mapper; 2 | 3 | import com.songguoliang.mybatis.entity.User; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 15:02 11 | */ 12 | public interface UserMapper { 13 | 14 | List getUsers(); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/songguoliang/mybatis/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.mybatis.mapper; 2 | 3 | import com.songguoliang.mybatis.entity.User; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 15:02 11 | */ 12 | public interface UserMapper { 13 | 14 | List getUsers(); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/java/com/songguoliang/springboot/mapper/SysUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import com.songguoliang.springboot.entity.SysUser; 4 | 5 | /** 6 | * @Description 7 | * @Author sgl 8 | * @Date 2018-06-11 17:19 9 | */ 10 | public interface SysUserMapper { 11 | SysUser findByUserName(String userName); 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/mapper/SysUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import com.songguoliang.springboot.entity.SysUser; 4 | 5 | /** 6 | * @Description 7 | * @Author sgl 8 | * @Date 2018-06-11 17:19 9 | */ 10 | public interface SysUserMapper { 11 | SysUser findByUserName(String userName); 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-pagehelper/src/main/java/com/songguoliang/springboot/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.entity.User; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-05-02 15:02 10 | */ 11 | public interface UserMapper { 12 | 13 | Page getUsers(); 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-druid/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-jsp/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-ehcache/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-fastjson/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-jsp/src/main/java/com/songguoliang/springboot/base/BaseMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.base; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | /** 7 | * @Description 自己的Mapper基类,主要不能放到mapper下 8 | * @Author sgl 9 | * @Date 2018-05-07 16:57 10 | */ 11 | public interface BaseMapper extends Mapper,MySqlMapper{ 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/songguoliang/springboot/base/BaseMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.base; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | /** 7 | * @Description 自己的Mapper基类,主要不能放到mapper下 8 | * @Author sgl 9 | * @Date 2018-05-07 16:57 10 | */ 11 | public interface BaseMapper extends Mapper,MySqlMapper{ 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-mapper4/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-pagehelper/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-quartz-db/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/base/BaseMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.base; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | /** 7 | * @Description 自己的Mapper基类,主要不能放到mapper下 8 | * @Author sgl 9 | * @Date 2018-05-07 16:57 10 | */ 11 | public interface BaseMapper extends Mapper,MySqlMapper{ 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-ehcache/src/main/java/com/songguoliang/springboot/base/BaseMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.base; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | /** 7 | * @Description 自己的Mapper基类,主要不能放到mapper下 8 | * @Author sgl 9 | * @Date 2018-05-07 16:57 10 | */ 11 | public interface BaseMapper extends Mapper,MySqlMapper{ 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-fastjson/src/main/java/com/songguoliang/springboot/base/BaseMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.base; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | /** 7 | * @Description 自己的Mapper基类,主要不能放到mapper下 8 | * @Author sgl 9 | * @Date 2018-05-07 16:57 10 | */ 11 | public interface BaseMapper extends Mapper,MySqlMapper{ 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-jsp/src/main/webapp/WEB-INF/jsp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %> 2 | 3 | 4 | 5 | 6 | 7 | 首页 8 | 9 | 10 | hello ${userName} 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-mapper4/src/main/java/com/songguoliang/springboot/base/BaseMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.base; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | /** 7 | * @Description 自己的Mapper基类,主要不能放到mapper下 8 | * @Author sgl 9 | * @Date 2018-05-07 16:57 10 | */ 11 | public interface BaseMapper extends Mapper,MySqlMapper{ 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-quartz-db/src/main/java/com/songguoliang/springboot/base/BaseMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.base; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | /** 7 | * @Description 自己的Mapper基类,主要不能放到mapper下 8 | * @Author sgl 9 | * @Date 2018-05-07 16:57 10 | */ 11 | public interface BaseMapper extends Mapper,MySqlMapper{ 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/webapp/WEB-INF/jsp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %> 2 | 3 | 4 | 5 | 6 | 7 | 首页 8 | 9 | 10 | hello ${userName} 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-fastjson/src/main/webapp/WEB-INF/jsp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %> 2 | 3 | 4 | 5 | 6 | 7 | 首页 8 | 9 | 10 | hello ${userName} 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/java/com/songguoliang/springboot/base/BaseMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.base; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | /** 7 | * @Description 自己的Mapper基类,主要不能放到mapper下 8 | * @Author sgl 9 | * @Date 2018-05-07 16:57 10 | */ 11 | public interface BaseMapper extends Mapper,MySqlMapper{ 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/base/BaseMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.base; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | /** 7 | * @Description 自己的Mapper基类,主要不能放到mapper下 8 | * @Author sgl 9 | * @Date 2018-05-07 16:57 10 | */ 11 | public interface BaseMapper extends Mapper,MySqlMapper{ 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/webapp/WEB-INF/jsp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %> 2 | 3 | 4 | 5 | 6 | 7 | 首页 8 | 9 | 10 | hello ${userName} 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/webapp/WEB-INF/jsp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %> 2 | 3 | 4 | 5 | 6 | 7 | 首页 8 | 9 | 10 | hello ${userName} 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-scheduling/src/main/java/com/songguoliang/springboot/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | /** 6 | * @Description 7 | * @Author sgl 8 | * @Date 2018-06-26 11:52 9 | */ 10 | @Service 11 | public class UserService { 12 | 13 | public void test(){ 14 | System.out.println("我是注入的service中的方法"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/mapper/SysPermissionMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-06-11 17:21 11 | */ 12 | public interface SysPermissionMapper { 13 | List selectPermissionByUserId(@Param("userId") long userId); 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/java/com/songguoliang/springboot/mapper/SysPermissionMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-06-11 17:21 11 | */ 12 | public interface SysPermissionMapper { 13 | List selectPermissionByUserId(@Param("userId") long userId); 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/mapper/SysPermissionMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-06-11 17:21 11 | */ 12 | public interface SysPermissionMapper { 13 | List selectPermissionByUserId(@Param("userId") long userId); 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/resources/mapper/SysUserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/resources/mapper/SysUserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /spring-boot-jsp/src/main/java/com/songguoliang/springboot/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.base.BaseMapper; 5 | import com.songguoliang.springboot.entity.User; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 15:02 11 | */ 12 | public interface UserMapper extends BaseMapper { 13 | 14 | Page getUsers(); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/songguoliang/springboot/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.base.BaseMapper; 5 | import com.songguoliang.springboot.entity.User; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 15:02 11 | */ 12 | public interface UserMapper extends BaseMapper { 13 | 14 | Page getUsers(); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/resources/mapper/SysUserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /spring-boot-ehcache/src/main/java/com/songguoliang/springboot/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.base.BaseMapper; 5 | import com.songguoliang.springboot.entity.User; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 15:02 11 | */ 12 | public interface UserMapper extends BaseMapper { 13 | 14 | Page getUsers(); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-fastjson/src/main/java/com/songguoliang/springboot/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.base.BaseMapper; 5 | import com.songguoliang.springboot.entity.User; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 15:02 11 | */ 12 | public interface UserMapper extends BaseMapper { 13 | 14 | Page getUsers(); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-mapper4/src/main/java/com/songguoliang/springboot/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.base.BaseMapper; 5 | import com.songguoliang.springboot.entity.User; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 15:02 11 | */ 12 | public interface UserMapper extends BaseMapper { 13 | 14 | Page getUsers(); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-quartz-db/src/main/java/com/songguoliang/springboot/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.base.BaseMapper; 5 | import com.songguoliang.springboot.entity.User; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 15:02 11 | */ 12 | public interface UserMapper extends BaseMapper { 13 | 14 | Page getUsers(); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.base.BaseMapper; 5 | import com.songguoliang.springboot.entity.User; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 15:02 11 | */ 12 | public interface UserMapper extends BaseMapper { 13 | 14 | Page getUsers(); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/java/com/songguoliang/springboot/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.base.BaseMapper; 5 | import com.songguoliang.springboot.entity.User; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 15:02 11 | */ 12 | public interface UserMapper extends BaseMapper { 13 | 14 | Page getUsers(); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.base.BaseMapper; 5 | import com.songguoliang.springboot.entity.User; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 15:02 11 | */ 12 | public interface UserMapper extends BaseMapper { 13 | 14 | Page getUsers(); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-env/src/main/java/com/songguoliang/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-04-26 14:46 10 | */ 11 | @SpringBootApplication 12 | public class DemoApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(DemoApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-quartz/src/main/java/com/songguoliang/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-06-26 16:34 10 | */ 11 | @SpringBootApplication 12 | public class Application { 13 | public static void main(String[] args) { 14 | SpringApplication.run(Application.class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-demo/src/main/java/com/songguoliang/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-04-26 14:46 10 | */ 11 | @SpringBootApplication 12 | public class DemoApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(DemoApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-upload/src/main/java/com/songguoliang/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-05-15 14:03 10 | */ 11 | @SpringBootApplication 12 | public class Application { 13 | public static void main(String[] args) { 14 | SpringApplication.run(Application.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-demo/src/main/java/com/songguoliang/demo/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.demo.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-04-26 14:19 10 | */ 11 | @RestController 12 | public class HelloController { 13 | 14 | @GetMapping("/hello") 15 | public String hello() { 16 | return "hello,Spring Boot!"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-devtools/src/main/java/com/songguoliang/springboot/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-05-09 10:46 10 | */ 11 | @RestController 12 | public class HelloController { 13 | @GetMapping("/hello") 14 | public String hello(){ 15 | return "hello"; 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /spring-boot-env/src/main/java/com/songguoliang/demo/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.demo.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-04-26 14:19 10 | */ 11 | @RestController 12 | public class HelloController { 13 | 14 | @GetMapping("/hello") 15 | public String hello() { 16 | return "hello,Spring Boot!"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-devtools/src/main/java/com/songguoliang/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-05-02 14:51 10 | */ 11 | @SpringBootApplication 12 | public class Application{ 13 | public static void main(String[] args) { 14 | SpringApplication.run(Application.class, args); 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-properties/src/main/java/com/songguoliang/properties/PropertiesApplication.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.properties; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-04-27 14:31 10 | */ 11 | @SpringBootApplication 12 | public class PropertiesApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(PropertiesApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-upload/src/main/webapp/WEB-INF/jsp/upload.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %> 2 | 3 | 4 | 5 | 6 | 7 | 单文件上传 8 | 9 | 10 |
11 |
12 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/webapp/WEB-INF/jsp/login.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %> 2 | 3 | 4 | 5 | 6 | 7 | 登录 8 | 9 | 10 |

${message}

11 |
12 | 用户名:
13 | 密码:
14 | 15 |
16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/webapp/WEB-INF/jsp/login.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %> 2 | 3 | 4 | 5 | 6 | 7 | 登录 8 | 9 | 10 |

${message}

11 |
12 | 用户名:
13 | 密码:
14 | 15 |
16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/webapp/WEB-INF/jsp/login.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %> 2 | 3 | 4 | 5 | 6 | 7 | 登录 8 | 9 | 10 |

${message}

11 |
12 | 用户名:
13 | 密码:
14 | 15 |
16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /spring-boot-scheduling/src/main/java/com/songguoliang/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableScheduling; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-06-26 10:02 11 | */ 12 | @EnableScheduling 13 | @SpringBootApplication 14 | public class Application { 15 | public static void main(String[] args) { 16 | SpringApplication.run(Application.class); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-jsp/src/main/java/com/songguoliang/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import tk.mybatis.spring.annotation.MapperScan; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 14:51 11 | */ 12 | @SpringBootApplication 13 | @MapperScan("com.songguoliang.springboot.mapper") 14 | public class Application { 15 | public static void main(String[] args) { 16 | SpringApplication.run(Application.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-mapper4/src/main/java/com/songguoliang/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import tk.mybatis.spring.annotation.MapperScan; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 14:51 11 | */ 12 | @SpringBootApplication 13 | @MapperScan("com.songguoliang.springboot.mapper") 14 | public class Application { 15 | public static void main(String[] args) { 16 | SpringApplication.run(Application.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-quartz-db/src/main/java/com/songguoliang/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import tk.mybatis.spring.annotation.MapperScan; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 14:51 11 | */ 12 | @SpringBootApplication 13 | @MapperScan("com.songguoliang.springboot.mapper") 14 | public class Application { 15 | public static void main(String[] args) { 16 | SpringApplication.run(Application.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-druid/src/main/java/com/songguoliang/mybatis/DruidApplication.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.mybatis; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 14:51 11 | */ 12 | @SpringBootApplication 13 | @MapperScan("com.songguoliang.mybatis.mapper") 14 | public class DruidApplication { 15 | public static void main(String[] args) { 16 | SpringApplication.run(DruidApplication.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-pagehelper/src/main/java/com/songguoliang/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 14:51 11 | */ 12 | @SpringBootApplication 13 | @MapperScan("com.songguoliang.springboot.mapper") 14 | public class Application { 15 | public static void main(String[] args) { 16 | SpringApplication.run(Application.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/songguoliang/mybatis/MybatisApplication.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.mybatis; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-02 14:51 11 | */ 12 | @SpringBootApplication 13 | @MapperScan("com.songguoliang.mybatis.mapper") 14 | public class MybatisApplication { 15 | public static void main(String[] args) { 16 | SpringApplication.run(MybatisApplication.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-upload/src/main/webapp/WEB-INF/jsp/multiUpload.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %> 2 | 3 | 4 | 5 | 6 | 7 | 多文件上传 8 | 9 | 10 |
11 |
12 |
13 |
14 | 15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | ## \u6570\u636E\u6E90\u914D\u7F6E 3 | spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=utf-8&useSSL=false 4 | spring.datasource.username=root 5 | spring.datasource.password=root 6 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 7 | 8 | # mybatis 9 | mybatis.type-aliases-package=com.songguoliang.mybatis.entity 10 | mybatis.mapper-locations=classpath:mapper/*.xml 11 | mybatis.configuration.map-underscore-to-camel-case=true 12 | 13 | 14 | # \u9879\u76EE\u4EE3\u7801\u4F7F\u7528debug\u7EA7\u522B 15 | logging.level.com.songguoliang.mybatis=debug 16 | -------------------------------------------------------------------------------- /spring-boot-jsp/src/main/java/com/songguoliang/springboot/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-08 10:47 11 | */ 12 | @Controller 13 | public class IndexController { 14 | 15 | @GetMapping("/index") 16 | public ModelAndView index() { 17 | ModelAndView view = new ModelAndView("index"); 18 | view.addObject("userName", "蝈蝈"); 19 | return view; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-ehcache/src/main/java/com/songguoliang/springboot/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-08 10:47 11 | */ 12 | @Controller 13 | public class IndexController { 14 | 15 | @GetMapping("/index") 16 | public ModelAndView index() { 17 | ModelAndView view = new ModelAndView("index"); 18 | view.addObject("userName", "蝈蝈"); 19 | return view; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-fastjson/src/main/java/com/songguoliang/springboot/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-08 10:47 11 | */ 12 | @Controller 13 | public class IndexController { 14 | 15 | @GetMapping("/index") 16 | public ModelAndView index() { 17 | ModelAndView view = new ModelAndView("index"); 18 | view.addObject("userName", "蝈蝈"); 19 | return view; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-druid/src/main/java/com/songguoliang/mybatis/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.mybatis.service; 2 | 3 | import com.songguoliang.mybatis.entity.User; 4 | import com.songguoliang.mybatis.mapper.UserMapper; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @Description 12 | * @Author sgl 13 | * @Date 2018-05-02 15:01 14 | */ 15 | @Service 16 | public class UserService { 17 | 18 | @Autowired 19 | private UserMapper userMapper; 20 | 21 | public List getUsers() { 22 | return userMapper.getUsers(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/songguoliang/mybatis/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.mybatis.service; 2 | 3 | import com.songguoliang.mybatis.entity.User; 4 | import com.songguoliang.mybatis.mapper.UserMapper; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @Description 12 | * @Author sgl 13 | * @Date 2018-05-02 15:01 14 | */ 15 | @Service 16 | public class UserService { 17 | 18 | @Autowired 19 | private UserMapper userMapper; 20 | 21 | public List getUsers() { 22 | return userMapper.getUsers(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/service/SysUserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.songguoliang.springboot.entity.SysUser; 4 | import com.songguoliang.springboot.mapper.SysUserMapper; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * @Description 10 | * @Author sgl 11 | * @Date 2018-06-11 17:10 12 | */ 13 | @Service 14 | public class SysUserService { 15 | @Autowired 16 | private SysUserMapper userMapper; 17 | 18 | public SysUser findByUserName(String userName) { 19 | return userMapper.findByUserName(userName); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-pagehelper/src/main/java/com/songguoliang/springboot/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.entity.User; 5 | import com.songguoliang.springboot.mapper.UserMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @Description 13 | * @Author sgl 14 | * @Date 2018-05-02 15:01 15 | */ 16 | @Service 17 | public class UserService { 18 | 19 | @Autowired 20 | private UserMapper userMapper; 21 | 22 | public Page getUsers() { 23 | return userMapper.getUsers(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/service/SysPermissionService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.songguoliang.springboot.mapper.SysPermissionMapper; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @Description 11 | * @Author sgl 12 | * @Date 2018-06-11 17:10 13 | */ 14 | @Service 15 | public class SysPermissionService { 16 | @Autowired 17 | private SysPermissionMapper sysPermissionMapper; 18 | 19 | public List selectPermissionByUserId(long userId) { 20 | return sysPermissionMapper.selectPermissionByUserId(userId); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/java/com/songguoliang/springboot/service/SysPermissionService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.songguoliang.springboot.mapper.SysPermissionMapper; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @Description 11 | * @Author sgl 12 | * @Date 2018-06-11 17:10 13 | */ 14 | @Service 15 | public class SysPermissionService { 16 | @Autowired 17 | private SysPermissionMapper sysPermissionMapper; 18 | 19 | public List selectPermissionByUserId(long userId) { 20 | return sysPermissionMapper.selectPermissionByUserId(userId); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/service/SysPermissionService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.songguoliang.springboot.mapper.SysPermissionMapper; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @Description 11 | * @Author sgl 12 | * @Date 2018-06-11 17:10 13 | */ 14 | @Service 15 | public class SysPermissionService { 16 | @Autowired 17 | private SysPermissionMapper sysPermissionMapper; 18 | 19 | public List selectPermissionByUserId(long userId) { 20 | return sysPermissionMapper.selectPermissionByUserId(userId); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-quartz/src/main/java/com/songguoliang/springboot/quartz/TestTask2.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.quartz; 2 | 3 | import org.quartz.JobExecutionContext; 4 | import org.quartz.JobExecutionException; 5 | import org.springframework.scheduling.quartz.QuartzJobBean; 6 | 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | 10 | /** 11 | * @Description 12 | * @Author sgl 13 | * @Date 2018-06-26 16:52 14 | */ 15 | public class TestTask2 extends QuartzJobBean{ 16 | @Override 17 | protected void executeInternal(JobExecutionContext context) throws JobExecutionException { 18 | SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 19 | System.out.println("TestQuartz02----" + sdf.format(new Date())); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-quartz-db/src/main/java/com/songguoliang/springboot/quartz/TestTask2.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.quartz; 2 | 3 | import org.quartz.JobExecutionContext; 4 | import org.quartz.JobExecutionException; 5 | import org.springframework.scheduling.quartz.QuartzJobBean; 6 | 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | 10 | /** 11 | * @Description 12 | * @Author sgl 13 | * @Date 2018-06-26 16:52 14 | */ 15 | public class TestTask2 extends QuartzJobBean{ 16 | @Override 17 | protected void executeInternal(JobExecutionContext context) throws JobExecutionException { 18 | SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 19 | System.out.println("TestQuartz02----" + sdf.format(new Date())); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-quartz-db/src/main/java/com/songguoliang/springboot/quartz/TestTask1.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.quartz; 2 | 3 | import org.quartz.JobExecutionContext; 4 | import org.quartz.JobExecutionException; 5 | import org.springframework.scheduling.quartz.QuartzJobBean; 6 | 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | 10 | /** 11 | * @Description 12 | * @Author sgl 13 | * @Date 2018-06-26 16:43 14 | */ 15 | public class TestTask1 extends QuartzJobBean{ 16 | 17 | @Override 18 | protected void executeInternal(JobExecutionContext context) throws JobExecutionException { 19 | SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 20 | System.out.println("TestQuartz01----" + sdf.format(new Date())); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-quartz/src/main/java/com/songguoliang/springboot/quartz/TestTask1.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.quartz; 2 | 3 | import org.quartz.JobExecutionContext; 4 | import org.quartz.JobExecutionException; 5 | import org.springframework.scheduling.quartz.QuartzJobBean; 6 | 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | 10 | /** 11 | * @Description 12 | * @Author sgl 13 | * @Date 2018-06-26 16:43 14 | */ 15 | public class TestTask1 extends QuartzJobBean{ 16 | 17 | @Override 18 | protected void executeInternal(JobExecutionContext context) throws JobExecutionException { 19 | SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 20 | System.out.println("TestQuartz01----" + sdf.format(new Date())); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/songguoliang/springboot/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.entity.User; 5 | import com.songguoliang.springboot.mapper.UserMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @Description 11 | * @Author sgl 12 | * @Date 2018-05-02 15:01 13 | */ 14 | @Service 15 | public class UserService { 16 | 17 | @Autowired 18 | private UserMapper userMapper; 19 | 20 | public Page getUsers() { 21 | return userMapper.getUsers(); 22 | } 23 | 24 | public User selectById(long id){ 25 | return userMapper.selectByPrimaryKey(id); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.entity.User; 5 | import com.songguoliang.springboot.mapper.UserMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @Description 11 | * @Author sgl 12 | * @Date 2018-05-02 15:01 13 | */ 14 | @Service 15 | public class UserService { 16 | 17 | @Autowired 18 | private UserMapper userMapper; 19 | 20 | public Page getUsers() { 21 | return userMapper.getUsers(); 22 | } 23 | 24 | public User selectById(long id){ 25 | return userMapper.selectByPrimaryKey(id); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-druid/src/main/java/com/songguoliang/mybatis/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.mybatis.controller; 2 | 3 | import com.songguoliang.mybatis.entity.User; 4 | import com.songguoliang.mybatis.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @Description 13 | * @Author sgl 14 | * @Date 2018-05-02 14:59 15 | */ 16 | @RestController 17 | public class UserController { 18 | 19 | @Autowired 20 | private UserService userService; 21 | 22 | @GetMapping("/users") 23 | public List lists() { 24 | return userService.getUsers(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/songguoliang/mybatis/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.mybatis.controller; 2 | 3 | import com.songguoliang.mybatis.entity.User; 4 | import com.songguoliang.mybatis.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @Description 13 | * @Author sgl 14 | * @Date 2018-05-02 14:59 15 | */ 16 | @RestController 17 | public class UserController { 18 | 19 | @Autowired 20 | private UserService userService; 21 | 22 | @GetMapping("/users") 23 | public List lists() { 24 | return userService.getUsers(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-mybatis-generator/src/main/resources/generatorConfig-min.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 12 | 13 |
14 |
15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /spring-boot-mybatis-generator-mysql/src/main/resources/generatorConfig-min.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 12 | 13 |
14 |
15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /spring-boot-jsp/src/main/java/com/songguoliang/springboot/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.entity.User; 5 | import com.songguoliang.springboot.mapper.UserMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @Description 13 | * @Author sgl 14 | * @Date 2018-05-02 15:01 15 | */ 16 | @Service 17 | public class UserService { 18 | 19 | @Autowired 20 | private UserMapper userMapper; 21 | 22 | public Page getUsers() { 23 | return userMapper.getUsers(); 24 | } 25 | 26 | public User selectById(long id){ 27 | return userMapper.selectByPrimaryKey(id); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-mapper4/src/main/java/com/songguoliang/springboot/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.entity.User; 5 | import com.songguoliang.springboot.mapper.UserMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @Description 13 | * @Author sgl 14 | * @Date 2018-05-02 15:01 15 | */ 16 | @Service 17 | public class UserService { 18 | 19 | @Autowired 20 | private UserMapper userMapper; 21 | 22 | public Page getUsers() { 23 | return userMapper.getUsers(); 24 | } 25 | 26 | public User selectById(long id){ 27 | return userMapper.selectByPrimaryKey(id); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/service/SysUserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.songguoliang.springboot.entity.SysUser; 4 | import com.songguoliang.springboot.mapper.SysUserMapper; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.cache.annotation.Cacheable; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @Description 11 | * @Author sgl 12 | * @Date 2018-06-11 17:10 13 | */ 14 | @Service 15 | public class SysUserService { 16 | @Autowired 17 | private SysUserMapper userMapper; 18 | 19 | @Cacheable(cacheNames = "users", key = "'sysuser:'+#userName") 20 | public SysUser findByUserName(String userName) { 21 | return userMapper.findByUserName(userName); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-fastjson/src/main/java/com/songguoliang/springboot/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.entity.User; 5 | import com.songguoliang.springboot.mapper.UserMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @Description 13 | * @Author sgl 14 | * @Date 2018-05-02 15:01 15 | */ 16 | @Service 17 | public class UserService { 18 | 19 | @Autowired 20 | private UserMapper userMapper; 21 | 22 | public Page getUsers() { 23 | return userMapper.getUsers(); 24 | } 25 | 26 | public User selectById(long id){ 27 | return userMapper.selectByPrimaryKey(id); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-quartz-db/src/main/java/com/songguoliang/springboot/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.entity.User; 5 | import com.songguoliang.springboot.mapper.UserMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @Description 13 | * @Author sgl 14 | * @Date 2018-05-02 15:01 15 | */ 16 | @Service 17 | public class UserService { 18 | 19 | @Autowired 20 | private UserMapper userMapper; 21 | 22 | public Page getUsers() { 23 | return userMapper.getUsers(); 24 | } 25 | 26 | public User selectById(long id){ 27 | return userMapper.selectByPrimaryKey(id); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/configuration/EhcacheConfig.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.configuration; 2 | 3 | import org.springframework.cache.ehcache.EhCacheManagerFactoryBean; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-06-15 11:45 11 | */ 12 | @Configuration 13 | public class EhcacheConfig { 14 | /** 15 | * 设置为共享模式 16 | * @return 17 | */ 18 | @Bean 19 | public EhCacheManagerFactoryBean ehCacheManagerFactoryBean() { 20 | EhCacheManagerFactoryBean cacheManagerFactoryBean = new EhCacheManagerFactoryBean(); 21 | cacheManagerFactoryBean.setShared(true); 22 | return cacheManagerFactoryBean; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-druid/src/main/java/com/songguoliang/mybatis/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.mybatis.entity; 2 | 3 | /** 4 | * @Description 5 | * @Author sgl 6 | * @Date 2018-05-02 14:59 7 | */ 8 | public class User { 9 | private Long userId; 10 | private String userName; 11 | private Integer userAge; 12 | 13 | public Long getUserId() { 14 | return userId; 15 | } 16 | 17 | public void setUserId(Long userId) { 18 | this.userId = userId; 19 | } 20 | 21 | public String getUserName() { 22 | return userName; 23 | } 24 | 25 | public void setUserName(String userName) { 26 | this.userName = userName; 27 | } 28 | 29 | public Integer getUserAge() { 30 | return userAge; 31 | } 32 | 33 | public void setUserAge(Integer userAge) { 34 | this.userAge = userAge; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/songguoliang/mybatis/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.mybatis.entity; 2 | 3 | /** 4 | * @Description 5 | * @Author sgl 6 | * @Date 2018-05-02 14:59 7 | */ 8 | public class User { 9 | private Long userId; 10 | private String userName; 11 | private Integer userAge; 12 | 13 | public Long getUserId() { 14 | return userId; 15 | } 16 | 17 | public void setUserId(Long userId) { 18 | this.userId = userId; 19 | } 20 | 21 | public String getUserName() { 22 | return userName; 23 | } 24 | 25 | public void setUserName(String userName) { 26 | this.userName = userName; 27 | } 28 | 29 | public Integer getUserAge() { 30 | return userAge; 31 | } 32 | 33 | public void setUserAge(Integer userAge) { 34 | this.userAge = userAge; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-pagehelper/src/main/java/com/songguoliang/springboot/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.entity; 2 | 3 | /** 4 | * @Description 5 | * @Author sgl 6 | * @Date 2018-05-02 14:59 7 | */ 8 | public class User { 9 | private Long userId; 10 | private String userName; 11 | private Integer userAge; 12 | 13 | public Long getUserId() { 14 | return userId; 15 | } 16 | 17 | public void setUserId(Long userId) { 18 | this.userId = userId; 19 | } 20 | 21 | public String getUserName() { 22 | return userName; 23 | } 24 | 25 | public void setUserName(String userName) { 26 | this.userName = userName; 27 | } 28 | 29 | public Integer getUserAge() { 30 | return userAge; 31 | } 32 | 33 | public void setUserAge(Integer userAge) { 34 | this.userAge = userAge; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/songguoliang/springboot/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.songguoliang.springboot.model.FastjsonTest; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * @Description 11 | * @Author sgl 12 | * @Date 2018-05-08 13:55 13 | */ 14 | @RestController 15 | public class TestController { 16 | 17 | @GetMapping("/fastjson") 18 | public FastjsonTest getFastJson() { 19 | FastjsonTest fastjsonTest = new FastjsonTest(); 20 | fastjsonTest.setId(1); 21 | fastjsonTest.setString("fastjson test"); 22 | fastjsonTest.setIgnore("ignore field"); 23 | fastjsonTest.setDate(new Date()); 24 | return fastjsonTest; 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/java/com/songguoliang/springboot/service/SysUserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.songguoliang.springboot.entity.SysUser; 4 | import com.songguoliang.springboot.mapper.SysUserMapper; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.cache.annotation.Cacheable; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @Description 11 | * @Author sgl 12 | * @Date 2018-06-11 17:10 13 | */ 14 | @Service 15 | public class SysUserService { 16 | @Autowired 17 | private SysUserMapper userMapper; 18 | 19 | @Cacheable(cacheNames = "users", key = "'sysuser:'+#userName") 20 | public SysUser findByUserName(String userName) { 21 | System.out.println("findByUserName from db"); 22 | return userMapper.findByUserName(userName); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-ehcache/src/main/java/com/songguoliang/springboot/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.songguoliang.springboot.model.FastjsonTest; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * @Description 11 | * @Author sgl 12 | * @Date 2018-05-08 13:55 13 | */ 14 | @RestController 15 | public class TestController { 16 | 17 | @GetMapping("/fastjson") 18 | public FastjsonTest getFastJson() { 19 | FastjsonTest fastjsonTest = new FastjsonTest(); 20 | fastjsonTest.setId(1); 21 | fastjsonTest.setString("fastjson test"); 22 | fastjsonTest.setIgnore("ignore field"); 23 | fastjsonTest.setDate(new Date()); 24 | return fastjsonTest; 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-fastjson/src/main/java/com/songguoliang/springboot/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.songguoliang.springboot.model.FastjsonTest; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * @Description 11 | * @Author sgl 12 | * @Date 2018-05-08 13:55 13 | */ 14 | @RestController 15 | public class TestController { 16 | 17 | @GetMapping("/fastjson") 18 | public FastjsonTest getFastJson() { 19 | FastjsonTest fastjsonTest = new FastjsonTest(); 20 | fastjsonTest.setId(1); 21 | fastjsonTest.setString("fastjson test"); 22 | fastjsonTest.setIgnore("ignore field"); 23 | fastjsonTest.setDate(new Date()); 24 | return fastjsonTest; 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-pagehelper/db/insertuser.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO `springboot`.`tbl_user`(`user_id`, `user_name`, `user_age`) VALUES (4, 'user1', 21); 2 | INSERT INTO `springboot`.`tbl_user`(`user_id`, `user_name`, `user_age`) VALUES (5, 'user2', 22); 3 | INSERT INTO `springboot`.`tbl_user`(`user_id`, `user_name`, `user_age`) VALUES (6, 'user3', 23); 4 | INSERT INTO `springboot`.`tbl_user`(`user_id`, `user_name`, `user_age`) VALUES (7, 'user4', 24); 5 | INSERT INTO `springboot`.`tbl_user`(`user_id`, `user_name`, `user_age`) VALUES (8, 'user5', 25); 6 | INSERT INTO `springboot`.`tbl_user`(`user_id`, `user_name`, `user_age`) VALUES (9, 'user6', 26); 7 | INSERT INTO `springboot`.`tbl_user`(`user_id`, `user_name`, `user_age`) VALUES (10, 'user7', 27); 8 | INSERT INTO `springboot`.`tbl_user`(`user_id`, `user_name`, `user_age`) VALUES (11, 'user8', 28); 9 | INSERT INTO `springboot`.`tbl_user`(`user_id`, `user_name`, `user_age`) VALUES (12, 'user9', 29); -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.songguoliang.springboot.entity.SysUser; 4 | import org.apache.shiro.SecurityUtils; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | 9 | /** 10 | * @Description 11 | * @Author sgl 12 | * @Date 2018-05-08 10:47 13 | */ 14 | @Controller 15 | public class IndexController { 16 | 17 | /** 18 | * 首页,并将登录用户的全名返回前台 19 | * @param model 20 | * @return 21 | */ 22 | @RequestMapping(value = {"/", "/index"}) 23 | public String index(Model model) { 24 | SysUser sysUser = (SysUser) SecurityUtils.getSubject().getPrincipal(); 25 | model.addAttribute("userName", sysUser.getFullName()); 26 | return "index"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/java/com/songguoliang/springboot/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.songguoliang.springboot.entity.SysUser; 4 | import org.apache.shiro.SecurityUtils; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | 9 | /** 10 | * @Description 11 | * @Author sgl 12 | * @Date 2018-05-08 10:47 13 | */ 14 | @Controller 15 | public class IndexController { 16 | 17 | /** 18 | * 首页,并将登录用户的全名返回前台 19 | * @param model 20 | * @return 21 | */ 22 | @RequestMapping(value = {"/", "/index"}) 23 | public String index(Model model) { 24 | SysUser sysUser = (SysUser) SecurityUtils.getSubject().getPrincipal(); 25 | model.addAttribute("userName", sysUser.getFullName()); 26 | return "index"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-properties/src/main/java/com/songguoliang/properties/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.properties.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | /** 8 | * @Description 通过@Value使用自定义属性 9 | * @Author sgl 10 | * @Date 2018-04-27 14:41 11 | */ 12 | @RestController 13 | public class HelloController { 14 | /** 15 | * 通过${}获取application.properties里的自定义属性 16 | */ 17 | @Value("${pocket.name}") 18 | private String name; 19 | 20 | @Value("${pocket.age}") 21 | private Integer age; 22 | 23 | @Value("${pocket.address}") 24 | private String address; 25 | 26 | @GetMapping("/hello") 27 | public String hello() { 28 | return "大家好,我的名字是" + name + ",我今年" + age + "岁了,我在" + address+"工作!"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-properties/src/main/java/com/songguoliang/properties/model/TestEntity.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.properties.model; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.PropertySource; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-04-27 17:01 11 | */ 12 | @ConfigurationProperties("test") 13 | @Component 14 | @PropertySource("classpath:test.properties") 15 | public class TestEntity { 16 | private String name; 17 | private Integer num; 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public Integer getNum() { 28 | return num; 29 | } 30 | 31 | public void setNum(Integer num) { 32 | this.num = num; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.songguoliang.springboot.entity.SysUser; 4 | import org.apache.shiro.SecurityUtils; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | 9 | /** 10 | * @Description 11 | * @Author sgl 12 | * @Date 2018-05-08 10:47 13 | */ 14 | @Controller 15 | public class IndexController { 16 | 17 | /** 18 | * 首页,并将登录用户的全名返回前台 19 | * @param model 20 | * @return 21 | */ 22 | @RequestMapping(value = {"/", "/index"}) 23 | public String index(Model model) { 24 | SysUser sysUser = (SysUser) SecurityUtils.getSubject().getPrincipal(); 25 | model.addAttribute("userName", sysUser.getFullName()); 26 | return "index"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/java/com/songguoliang/springboot/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.entity.User; 5 | import com.songguoliang.springboot.mapper.UserMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.cache.annotation.Cacheable; 8 | import org.springframework.stereotype.Service; 9 | 10 | /** 11 | * @Description 12 | * @Author sgl 13 | * @Date 2018-05-02 15:01 14 | */ 15 | @Service 16 | public class UserService { 17 | 18 | @Autowired 19 | private UserMapper userMapper; 20 | 21 | public Page getUsers() { 22 | return userMapper.getUsers(); 23 | } 24 | 25 | @Cacheable(cacheNames = "users", key = "'user:'+#id") 26 | public User selectById(long id){ 27 | System.out.println("from db"); 28 | return userMapper.selectByPrimaryKey(id); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.entity.User; 5 | import com.songguoliang.springboot.mapper.UserMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.cache.annotation.Cacheable; 8 | import org.springframework.stereotype.Service; 9 | 10 | /** 11 | * @Description 12 | * @Author sgl 13 | * @Date 2018-05-02 15:01 14 | */ 15 | @Service 16 | public class UserService { 17 | 18 | @Autowired 19 | private UserMapper userMapper; 20 | 21 | public Page getUsers() { 22 | return userMapper.getUsers(); 23 | } 24 | 25 | @Cacheable(cacheNames = "users", key = "'user:'+#id") 26 | public User selectById(long id){ 27 | System.out.println("from db"); 28 | return userMapper.selectByPrimaryKey(id); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-jsp/src/main/java/com/songguoliang/springboot/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.entity; 2 | 3 | import javax.persistence.Id; 4 | import javax.persistence.Table; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-05-02 14:59 10 | */ 11 | @Table(name = "tbl_user") 12 | public class User { 13 | @Id 14 | private Long userId; 15 | private String userName; 16 | private Integer userAge; 17 | 18 | public Long getUserId() { 19 | return userId; 20 | } 21 | 22 | public void setUserId(Long userId) { 23 | this.userId = userId; 24 | } 25 | 26 | public String getUserName() { 27 | return userName; 28 | } 29 | 30 | public void setUserName(String userName) { 31 | this.userName = userName; 32 | } 33 | 34 | public Integer getUserAge() { 35 | return userAge; 36 | } 37 | 38 | public void setUserAge(Integer userAge) { 39 | this.userAge = userAge; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/songguoliang/springboot/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.entity; 2 | 3 | import javax.persistence.Id; 4 | import javax.persistence.Table; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-05-02 14:59 10 | */ 11 | @Table(name = "tbl_user") 12 | public class User { 13 | @Id 14 | private Long userId; 15 | private String userName; 16 | private Integer userAge; 17 | 18 | public Long getUserId() { 19 | return userId; 20 | } 21 | 22 | public void setUserId(Long userId) { 23 | this.userId = userId; 24 | } 25 | 26 | public String getUserName() { 27 | return userName; 28 | } 29 | 30 | public void setUserName(String userName) { 31 | this.userName = userName; 32 | } 33 | 34 | public Integer getUserAge() { 35 | return userAge; 36 | } 37 | 38 | public void setUserAge(Integer userAge) { 39 | this.userAge = userAge; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-ehcache/src/main/java/com/songguoliang/springboot/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.entity; 2 | 3 | import javax.persistence.Id; 4 | import javax.persistence.Table; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-05-02 14:59 10 | */ 11 | @Table(name = "tbl_user") 12 | public class User { 13 | @Id 14 | private Long userId; 15 | private String userName; 16 | private Integer userAge; 17 | 18 | public Long getUserId() { 19 | return userId; 20 | } 21 | 22 | public void setUserId(Long userId) { 23 | this.userId = userId; 24 | } 25 | 26 | public String getUserName() { 27 | return userName; 28 | } 29 | 30 | public void setUserName(String userName) { 31 | this.userName = userName; 32 | } 33 | 34 | public Integer getUserAge() { 35 | return userAge; 36 | } 37 | 38 | public void setUserAge(Integer userAge) { 39 | this.userAge = userAge; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-fastjson/src/main/java/com/songguoliang/springboot/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.entity; 2 | 3 | import javax.persistence.Id; 4 | import javax.persistence.Table; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-05-02 14:59 10 | */ 11 | @Table(name = "tbl_user") 12 | public class User { 13 | @Id 14 | private Long userId; 15 | private String userName; 16 | private Integer userAge; 17 | 18 | public Long getUserId() { 19 | return userId; 20 | } 21 | 22 | public void setUserId(Long userId) { 23 | this.userId = userId; 24 | } 25 | 26 | public String getUserName() { 27 | return userName; 28 | } 29 | 30 | public void setUserName(String userName) { 31 | this.userName = userName; 32 | } 33 | 34 | public Integer getUserAge() { 35 | return userAge; 36 | } 37 | 38 | public void setUserAge(Integer userAge) { 39 | this.userAge = userAge; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-mapper4/src/main/java/com/songguoliang/springboot/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.entity; 2 | 3 | import javax.persistence.Id; 4 | import javax.persistence.Table; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-05-02 14:59 10 | */ 11 | @Table(name = "tbl_user") 12 | public class User { 13 | @Id 14 | private Long userId; 15 | private String userName; 16 | private Integer userAge; 17 | 18 | public Long getUserId() { 19 | return userId; 20 | } 21 | 22 | public void setUserId(Long userId) { 23 | this.userId = userId; 24 | } 25 | 26 | public String getUserName() { 27 | return userName; 28 | } 29 | 30 | public void setUserName(String userName) { 31 | this.userName = userName; 32 | } 33 | 34 | public Integer getUserAge() { 35 | return userAge; 36 | } 37 | 38 | public void setUserAge(Integer userAge) { 39 | this.userAge = userAge; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.entity; 2 | 3 | import javax.persistence.Id; 4 | import javax.persistence.Table; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-05-02 14:59 10 | */ 11 | @Table(name = "tbl_user") 12 | public class User { 13 | @Id 14 | private Long userId; 15 | private String userName; 16 | private Integer userAge; 17 | 18 | public Long getUserId() { 19 | return userId; 20 | } 21 | 22 | public void setUserId(Long userId) { 23 | this.userId = userId; 24 | } 25 | 26 | public String getUserName() { 27 | return userName; 28 | } 29 | 30 | public void setUserName(String userName) { 31 | this.userName = userName; 32 | } 33 | 34 | public Integer getUserAge() { 35 | return userAge; 36 | } 37 | 38 | public void setUserAge(Integer userAge) { 39 | this.userAge = userAge; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-quartz-db/src/main/java/com/songguoliang/springboot/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.entity; 2 | 3 | import javax.persistence.Id; 4 | import javax.persistence.Table; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-05-02 14:59 10 | */ 11 | @Table(name = "tbl_user") 12 | public class User { 13 | @Id 14 | private Long userId; 15 | private String userName; 16 | private Integer userAge; 17 | 18 | public Long getUserId() { 19 | return userId; 20 | } 21 | 22 | public void setUserId(Long userId) { 23 | this.userId = userId; 24 | } 25 | 26 | public String getUserName() { 27 | return userName; 28 | } 29 | 30 | public void setUserName(String userName) { 31 | this.userName = userName; 32 | } 33 | 34 | public Integer getUserAge() { 35 | return userAge; 36 | } 37 | 38 | public void setUserAge(Integer userAge) { 39 | this.userAge = userAge; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/java/com/songguoliang/springboot/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.entity; 2 | 3 | import javax.persistence.Id; 4 | import javax.persistence.Table; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-05-02 14:59 10 | */ 11 | @Table(name = "tbl_user") 12 | public class User { 13 | @Id 14 | private Long userId; 15 | private String userName; 16 | private Integer userAge; 17 | 18 | public Long getUserId() { 19 | return userId; 20 | } 21 | 22 | public void setUserId(Long userId) { 23 | this.userId = userId; 24 | } 25 | 26 | public String getUserName() { 27 | return userName; 28 | } 29 | 30 | public void setUserName(String userName) { 31 | this.userName = userName; 32 | } 33 | 34 | public Integer getUserAge() { 35 | return userAge; 36 | } 37 | 38 | public void setUserAge(Integer userAge) { 39 | this.userAge = userAge; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.entity; 2 | 3 | import javax.persistence.Id; 4 | import javax.persistence.Table; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-05-02 14:59 10 | */ 11 | @Table(name = "tbl_user") 12 | public class User { 13 | @Id 14 | private Long userId; 15 | private String userName; 16 | private Integer userAge; 17 | 18 | public Long getUserId() { 19 | return userId; 20 | } 21 | 22 | public void setUserId(Long userId) { 23 | this.userId = userId; 24 | } 25 | 26 | public String getUserName() { 27 | return userName; 28 | } 29 | 30 | public void setUserName(String userName) { 31 | this.userName = userName; 32 | } 33 | 34 | public Integer getUserAge() { 35 | return userAge; 36 | } 37 | 38 | public void setUserAge(Integer userAge) { 39 | this.userAge = userAge; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-properties/src/main/java/com/songguoliang/properties/model/User.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.properties.model; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | /** 7 | * @Description 由Spring根据ConfigurationProperties自动注入属性的值 8 | * @Author sgl 9 | * @Date 2018-04-27 15:29 10 | */ 11 | @Component 12 | @ConfigurationProperties(prefix = "pocket") 13 | public class User { 14 | private String name; 15 | private Integer age; 16 | private String address; 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public void setName(String name) { 23 | this.name = name; 24 | } 25 | 26 | public Integer getAge() { 27 | return age; 28 | } 29 | 30 | public void setAge(Integer age) { 31 | this.age = age; 32 | } 33 | 34 | public String getAddress() { 35 | return address; 36 | } 37 | 38 | public void setAddress(String address) { 39 | this.address = address; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-pagehelper/src/main/java/com/songguoliang/springboot/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.songguoliang.springboot.entity.User; 6 | import com.songguoliang.springboot.service.UserService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | /** 13 | * @Description 14 | * @Author sgl 15 | * @Date 2018-05-02 14:59 16 | */ 17 | @RestController 18 | public class UserController { 19 | 20 | @Autowired 21 | private UserService userService; 22 | 23 | @GetMapping("/users") 24 | public PageInfo lists(@RequestParam(defaultValue = "1") int pageNo,@RequestParam(defaultValue = "10") int pageSize) { 25 | PageHelper.startPage(pageNo,pageSize); 26 | PageInfo pageInfo = new PageInfo<>(userService.getUsers()); 27 | return pageInfo; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-jwt/db/springboot.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50721 7 | Source Host : localhost:3306 8 | Source Schema : springboot 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50721 12 | File Encoding : 65001 13 | 14 | Date: 02/05/2018 15:35:36 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for tbl_user 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `tbl_user`; 24 | CREATE TABLE `tbl_user` ( 25 | `user_id` bigint(20) NOT NULL, 26 | `user_name` varchar(50) DEFAULT NULL, 27 | `user_age` int(11) DEFAULT NULL, 28 | PRIMARY KEY (`user_id`) 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of tbl_user 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `tbl_user` VALUES (1, '张三', 27); 36 | INSERT INTO `tbl_user` VALUES (2, '李四', 30); 37 | INSERT INTO `tbl_user` VALUES (3, '王五', 20); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /spring-boot-fastjson/db/springboot.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50721 7 | Source Host : localhost:3306 8 | Source Schema : springboot 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50721 12 | File Encoding : 65001 13 | 14 | Date: 02/05/2018 15:35:36 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for tbl_user 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `tbl_user`; 24 | CREATE TABLE `tbl_user` ( 25 | `user_id` bigint(20) NOT NULL, 26 | `user_name` varchar(50) DEFAULT NULL, 27 | `user_age` int(11) DEFAULT NULL, 28 | PRIMARY KEY (`user_id`) 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of tbl_user 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `tbl_user` VALUES (1, '张三', 27); 36 | INSERT INTO `tbl_user` VALUES (2, '李四', 30); 37 | INSERT INTO `tbl_user` VALUES (3, '王五', 20); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /spring-boot-mybatis/db/springboot.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50721 7 | Source Host : localhost:3306 8 | Source Schema : springboot 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50721 12 | File Encoding : 65001 13 | 14 | Date: 02/05/2018 15:35:36 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for tbl_user 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `tbl_user`; 24 | CREATE TABLE `tbl_user` ( 25 | `user_id` bigint(20) NOT NULL, 26 | `user_name` varchar(50) DEFAULT NULL, 27 | `user_age` int(11) DEFAULT NULL, 28 | PRIMARY KEY (`user_id`) 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of tbl_user 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `tbl_user` VALUES (1, '张三', 27); 36 | INSERT INTO `tbl_user` VALUES (2, '李四', 30); 37 | INSERT INTO `tbl_user` VALUES (3, '王五', 20); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /spring-boot-mybatis-generator/db/springboot.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50721 7 | Source Host : localhost:3306 8 | Source Schema : springboot 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50721 12 | File Encoding : 65001 13 | 14 | Date: 02/05/2018 15:35:36 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for tbl_user 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `tbl_user`; 24 | CREATE TABLE `tbl_user` ( 25 | `user_id` bigint(20) NOT NULL, 26 | `user_name` varchar(50) DEFAULT NULL, 27 | `user_age` int(11) DEFAULT NULL, 28 | PRIMARY KEY (`user_id`) 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of tbl_user 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `tbl_user` VALUES (1, '张三', 27); 36 | INSERT INTO `tbl_user` VALUES (2, '李四', 30); 37 | INSERT INTO `tbl_user` VALUES (3, '王五', 20); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /spring-boot-mybatis-generator-mysql/db/springboot.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50721 7 | Source Host : localhost:3306 8 | Source Schema : springboot 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50721 12 | File Encoding : 65001 13 | 14 | Date: 02/05/2018 15:35:36 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for tbl_user 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `tbl_user`; 24 | CREATE TABLE `tbl_user` ( 25 | `user_id` bigint(20) NOT NULL, 26 | `user_name` varchar(50) DEFAULT NULL, 27 | `user_age` int(11) DEFAULT NULL, 28 | PRIMARY KEY (`user_id`) 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of tbl_user 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `tbl_user` VALUES (1, '张三', 27); 36 | INSERT INTO `tbl_user` VALUES (2, '李四', 30); 37 | INSERT INTO `tbl_user` VALUES (3, '王五', 20); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /spring-boot-properties/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | # \u4FEE\u6539\u670D\u52A1\u7AEF\u53E3\u53F7 3 | server.port=8888 4 | 5 | # \u81EA\u5B9A\u4E49\u5C5E\u6027 6 | pocket.name=\u8748\u8748 7 | pocket.age=26 8 | pocket.county=\u957F\u5B81\u533A 9 | # \u914D\u7F6E\u6587\u4EF6\u4E5F\u53EF\u4EE5\u901A\u8FC7${}\u5F15\u7528\u5176\u4ED6\u53D8\u91CF 10 | pocket.address=\u4E0A\u6D77\u5E02${pocket.county} 11 | 12 | 13 | # \u968F\u673A\u6570 14 | # \u968F\u673Aint 15 | test.randomInt=${random.int} 16 | # \u968F\u673A10\u4EE5\u5185 17 | test.randomIntMax=${random.int(10)} 18 | # \u968F\u673A20-50 19 | test.randomIntMiddle=${random.int(20,50)} 20 | # \u968F\u673ALong 21 | test.randomLong=${random.long} 22 | # \u5B57\u7B26\u4E32 23 | test.randomValue=${random.value} 24 | # uuid 25 | test.randomUuid=${random.uuid} 26 | 27 | # key\u4E0D\u80FDrandom\u5F00\u5934\uFF0C\u4F7F\u7528\u65F6\u4F1A\u6709\u95EE\u9898 28 | #random.num=${random.int} 29 | 30 | 31 | # \u8BBE\u7F6E\u7F16\u7801\u683C\u5F0F 32 | 33 | #server.tomcat.uri-encoding=UTF-8 34 | spring.http.encoding.charset=UTF-8 35 | #spring.http.encoding.enabled=true 36 | #spring.http.encoding.force=true 37 | #spring.messages.encoding=UTF-8 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/resources/mapper/SysPermissionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/resources/mapper/SysPermissionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/resources/mapper/SysPermissionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /spring-boot-properties/src/main/java/com/songguoliang/properties/controller/ModelController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.properties.controller; 2 | 3 | import com.songguoliang.properties.model.RandomData; 4 | import com.songguoliang.properties.model.TestEntity; 5 | import com.songguoliang.properties.model.User; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | /** 11 | * @Description 12 | * @Author sgl 13 | * @Date 2018-04-27 15:31 14 | */ 15 | @RestController 16 | public class ModelController { 17 | /** 18 | * 注入user 19 | */ 20 | @Autowired 21 | private User user; 22 | 23 | @Autowired 24 | private RandomData randomData; 25 | 26 | @Autowired 27 | private TestEntity testEntity; 28 | 29 | @GetMapping("/say") 30 | public String hello() { 31 | return "大家好,我的名字是" + user.getName() + ",我今年" + user.getAge() + "岁了,我在" + user.getAddress() + "工作!"; 32 | } 33 | 34 | @GetMapping("/random") 35 | public RandomData random() { 36 | return randomData; 37 | } 38 | 39 | @GetMapping("/test") 40 | public TestEntity getTestEntity() { 41 | return testEntity; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/songguoliang/springboot/model/FastjsonTest.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.model; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-08 13:50 11 | */ 12 | public class FastjsonTest { 13 | private Integer id; 14 | private String string; 15 | /** 16 | * 格式化日期 17 | */ 18 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 19 | private Date date; 20 | 21 | /** 22 | * 转换为json时不包括该属性 23 | */ 24 | @JSONField(serialize = false) 25 | private String ignore; 26 | 27 | public Integer getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Integer id) { 32 | this.id = id; 33 | } 34 | 35 | public String getString() { 36 | return string; 37 | } 38 | 39 | public void setString(String string) { 40 | this.string = string; 41 | } 42 | 43 | public Date getDate() { 44 | return date; 45 | } 46 | 47 | public void setDate(Date date) { 48 | this.date = date; 49 | } 50 | 51 | public String getIgnore() { 52 | return ignore; 53 | } 54 | 55 | public void setIgnore(String ignore) { 56 | this.ignore = ignore; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/model/FastjsonTest.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.model; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-08 13:50 11 | */ 12 | public class FastjsonTest { 13 | private Integer id; 14 | private String string; 15 | /** 16 | * 格式化日期 17 | */ 18 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 19 | private Date date; 20 | 21 | /** 22 | * 转换为json时不包括该属性 23 | */ 24 | @JSONField(serialize = false) 25 | private String ignore; 26 | 27 | public Integer getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Integer id) { 32 | this.id = id; 33 | } 34 | 35 | public String getString() { 36 | return string; 37 | } 38 | 39 | public void setString(String string) { 40 | this.string = string; 41 | } 42 | 43 | public Date getDate() { 44 | return date; 45 | } 46 | 47 | public void setDate(Date date) { 48 | this.date = date; 49 | } 50 | 51 | public String getIgnore() { 52 | return ignore; 53 | } 54 | 55 | public void setIgnore(String ignore) { 56 | this.ignore = ignore; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /spring-boot-ehcache/src/main/java/com/songguoliang/springboot/model/FastjsonTest.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.model; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-08 13:50 11 | */ 12 | public class FastjsonTest { 13 | private Integer id; 14 | private String string; 15 | /** 16 | * 格式化日期 17 | */ 18 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 19 | private Date date; 20 | 21 | /** 22 | * 转换为json时不包括该属性 23 | */ 24 | @JSONField(serialize = false) 25 | private String ignore; 26 | 27 | public Integer getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Integer id) { 32 | this.id = id; 33 | } 34 | 35 | public String getString() { 36 | return string; 37 | } 38 | 39 | public void setString(String string) { 40 | this.string = string; 41 | } 42 | 43 | public Date getDate() { 44 | return date; 45 | } 46 | 47 | public void setDate(Date date) { 48 | this.date = date; 49 | } 50 | 51 | public String getIgnore() { 52 | return ignore; 53 | } 54 | 55 | public void setIgnore(String ignore) { 56 | this.ignore = ignore; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /spring-boot-fastjson/src/main/java/com/songguoliang/springboot/model/FastjsonTest.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.model; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-08 13:50 11 | */ 12 | public class FastjsonTest { 13 | private Integer id; 14 | private String string; 15 | /** 16 | * 格式化日期 17 | */ 18 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 19 | private Date date; 20 | 21 | /** 22 | * 转换为json时不包括该属性 23 | */ 24 | @JSONField(serialize = false) 25 | private String ignore; 26 | 27 | public Integer getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Integer id) { 32 | this.id = id; 33 | } 34 | 35 | public String getString() { 36 | return string; 37 | } 38 | 39 | public void setString(String string) { 40 | this.string = string; 41 | } 42 | 43 | public Date getDate() { 44 | return date; 45 | } 46 | 47 | public void setDate(Date date) { 48 | this.date = date; 49 | } 50 | 51 | public String getIgnore() { 52 | return ignore; 53 | } 54 | 55 | public void setIgnore(String ignore) { 56 | this.ignore = ignore; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/java/com/songguoliang/springboot/model/FastjsonTest.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.model; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-08 13:50 11 | */ 12 | public class FastjsonTest { 13 | private Integer id; 14 | private String string; 15 | /** 16 | * 格式化日期 17 | */ 18 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 19 | private Date date; 20 | 21 | /** 22 | * 转换为json时不包括该属性 23 | */ 24 | @JSONField(serialize = false) 25 | private String ignore; 26 | 27 | public Integer getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Integer id) { 32 | this.id = id; 33 | } 34 | 35 | public String getString() { 36 | return string; 37 | } 38 | 39 | public void setString(String string) { 40 | this.string = string; 41 | } 42 | 43 | public Date getDate() { 44 | return date; 45 | } 46 | 47 | public void setDate(Date date) { 48 | this.date = date; 49 | } 50 | 51 | public String getIgnore() { 52 | return ignore; 53 | } 54 | 55 | public void setIgnore(String ignore) { 56 | this.ignore = ignore; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /spring-boot-ehcache/src/main/java/com/songguoliang/springboot/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.service; 2 | 3 | import com.github.pagehelper.Page; 4 | import com.songguoliang.springboot.entity.User; 5 | import com.songguoliang.springboot.mapper.UserMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.cache.annotation.CacheEvict; 8 | import org.springframework.cache.annotation.Cacheable; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @Description 15 | * @Author sgl 16 | * @Date 2018-05-02 15:01 17 | */ 18 | @Service 19 | public class UserService { 20 | 21 | @Autowired 22 | private UserMapper userMapper; 23 | 24 | public Page getUsers() { 25 | return userMapper.getUsers(); 26 | } 27 | 28 | /** 29 | * 使用ehcache.xml配置users缓存,用用户id作为缓存主键 30 | * @param id 31 | * @return 32 | */ 33 | @Cacheable(cacheNames = "users",key = "#id") 34 | public User selectById(long id) { 35 | System.out.println("没有缓存,开始查询数据库……"); 36 | return userMapper.selectByPrimaryKey(id); 37 | } 38 | 39 | @CacheEvict(value = "users",key = "#id") 40 | public void evictUser(Long id) { 41 | System.out.println("evict user:" + id); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/model/FastjsonTest.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.model; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @Description 9 | * @Author sgl 10 | * @Date 2018-05-08 13:50 11 | */ 12 | public class FastjsonTest { 13 | private Integer id; 14 | private String string; 15 | /** 16 | * 格式化日期 17 | */ 18 | @JSONField(format = "yyyy-MM-dd HH:mm:ss") 19 | private Date date; 20 | 21 | /** 22 | * 转换为json时不包括该属性 23 | */ 24 | @JSONField(serialize = false) 25 | private String ignore; 26 | 27 | public Integer getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Integer id) { 32 | this.id = id; 33 | } 34 | 35 | public String getString() { 36 | return string; 37 | } 38 | 39 | public void setString(String string) { 40 | this.string = string; 41 | } 42 | 43 | public Date getDate() { 44 | return date; 45 | } 46 | 47 | public void setDate(Date date) { 48 | this.date = date; 49 | } 50 | 51 | public String getIgnore() { 52 | return ignore; 53 | } 54 | 55 | public void setIgnore(String ignore) { 56 | this.ignore = ignore; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /spring-boot-jsp/src/main/java/com/songguoliang/springboot/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.songguoliang.springboot.entity.User; 6 | import com.songguoliang.springboot.service.UserService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @Description 15 | * @Author sgl 16 | * @Date 2018-05-02 14:59 17 | */ 18 | @RestController 19 | public class UserController { 20 | 21 | @Autowired 22 | private UserService userService; 23 | 24 | @GetMapping("/users") 25 | public PageInfo lists(@RequestParam(defaultValue = "1") int pageNo,@RequestParam(defaultValue = "10") int pageSize) { 26 | PageHelper.startPage(pageNo,pageSize); 27 | PageInfo pageInfo = new PageInfo<>(userService.getUsers()); 28 | return pageInfo; 29 | } 30 | 31 | @GetMapping("/user/{id}") 32 | public User selectUserById(@PathVariable("id") Long id){ 33 | return userService.selectById(id); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/songguoliang/springboot/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.songguoliang.springboot.entity.User; 6 | import com.songguoliang.springboot.service.UserService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @Description 15 | * @Author sgl 16 | * @Date 2018-05-02 14:59 17 | */ 18 | @RestController 19 | public class UserController { 20 | 21 | @Autowired 22 | private UserService userService; 23 | 24 | @GetMapping("/users") 25 | public PageInfo lists(@RequestParam(defaultValue = "1") int pageNo,@RequestParam(defaultValue = "10") int pageSize) { 26 | PageHelper.startPage(pageNo,pageSize); 27 | PageInfo pageInfo = new PageInfo<>(userService.getUsers()); 28 | return pageInfo; 29 | } 30 | 31 | @GetMapping("/user/{id}") 32 | public User selectUserById(@PathVariable("id") Long id){ 33 | return userService.selectById(id); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.songguoliang.springboot.entity.User; 6 | import com.songguoliang.springboot.service.UserService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @Description 15 | * @Author sgl 16 | * @Date 2018-05-02 14:59 17 | */ 18 | @RestController 19 | public class UserController { 20 | 21 | @Autowired 22 | private UserService userService; 23 | 24 | @GetMapping("/users") 25 | public PageInfo lists(@RequestParam(defaultValue = "1") int pageNo,@RequestParam(defaultValue = "10") int pageSize) { 26 | PageHelper.startPage(pageNo,pageSize); 27 | PageInfo pageInfo = new PageInfo<>(userService.getUsers()); 28 | return pageInfo; 29 | } 30 | 31 | @GetMapping("/user/{id}") 32 | public User selectUserById(@PathVariable("id") Long id){ 33 | return userService.selectById(id); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-fastjson/src/main/java/com/songguoliang/springboot/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.songguoliang.springboot.entity.User; 6 | import com.songguoliang.springboot.service.UserService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @Description 15 | * @Author sgl 16 | * @Date 2018-05-02 14:59 17 | */ 18 | @RestController 19 | public class UserController { 20 | 21 | @Autowired 22 | private UserService userService; 23 | 24 | @GetMapping("/users") 25 | public PageInfo lists(@RequestParam(defaultValue = "1") int pageNo,@RequestParam(defaultValue = "10") int pageSize) { 26 | PageHelper.startPage(pageNo,pageSize); 27 | PageInfo pageInfo = new PageInfo<>(userService.getUsers()); 28 | return pageInfo; 29 | } 30 | 31 | @GetMapping("/user/{id}") 32 | public User selectUserById(@PathVariable("id") Long id){ 33 | return userService.selectById(id); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-mapper4/src/main/java/com/songguoliang/springboot/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.songguoliang.springboot.entity.User; 6 | import com.songguoliang.springboot.service.UserService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @Description 15 | * @Author sgl 16 | * @Date 2018-05-02 14:59 17 | */ 18 | @RestController 19 | public class UserController { 20 | 21 | @Autowired 22 | private UserService userService; 23 | 24 | @GetMapping("/users") 25 | public PageInfo lists(@RequestParam(defaultValue = "1") int pageNo,@RequestParam(defaultValue = "10") int pageSize) { 26 | PageHelper.startPage(pageNo,pageSize); 27 | PageInfo pageInfo = new PageInfo<>(userService.getUsers()); 28 | return pageInfo; 29 | } 30 | 31 | @GetMapping("/user/{id}") 32 | public User selectUserById(@PathVariable("id") Long id){ 33 | return userService.selectById(id); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-mybatis-generator-mysql/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /spring-boot-quartz-db/src/main/java/com/songguoliang/springboot/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.songguoliang.springboot.entity.User; 6 | import com.songguoliang.springboot.service.UserService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @Description 15 | * @Author sgl 16 | * @Date 2018-05-02 14:59 17 | */ 18 | @RestController 19 | public class UserController { 20 | 21 | @Autowired 22 | private UserService userService; 23 | 24 | @GetMapping("/users") 25 | public PageInfo lists(@RequestParam(defaultValue = "1") int pageNo,@RequestParam(defaultValue = "10") int pageSize) { 26 | PageHelper.startPage(pageNo,pageSize); 27 | PageInfo pageInfo = new PageInfo<>(userService.getUsers()); 28 | return pageInfo; 29 | } 30 | 31 | @GetMapping("/user/{id}") 32 | public User selectUserById(@PathVariable("id") Long id){ 33 | return userService.selectById(id); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/java/com/songguoliang/springboot/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.songguoliang.springboot.entity.User; 6 | import com.songguoliang.springboot.service.UserService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @Description 15 | * @Author sgl 16 | * @Date 2018-05-02 14:59 17 | */ 18 | @RestController 19 | public class UserController { 20 | 21 | @Autowired 22 | private UserService userService; 23 | 24 | @GetMapping("/users") 25 | public PageInfo lists(@RequestParam(defaultValue = "1") int pageNo,@RequestParam(defaultValue = "10") int pageSize) { 26 | PageHelper.startPage(pageNo,pageSize); 27 | PageInfo pageInfo = new PageInfo<>(userService.getUsers()); 28 | return pageInfo; 29 | } 30 | 31 | @GetMapping("/user/{id}") 32 | public User selectUserById(@PathVariable("id") Long id){ 33 | return userService.selectById(id); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.songguoliang.springboot.entity.User; 6 | import com.songguoliang.springboot.service.UserService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @Description 15 | * @Author sgl 16 | * @Date 2018-05-02 14:59 17 | */ 18 | @RestController 19 | public class UserController { 20 | 21 | @Autowired 22 | private UserService userService; 23 | 24 | @GetMapping("/users") 25 | public PageInfo lists(@RequestParam(defaultValue = "1") int pageNo,@RequestParam(defaultValue = "10") int pageSize) { 26 | PageHelper.startPage(pageNo,pageSize); 27 | PageInfo pageInfo = new PageInfo<>(userService.getUsers()); 28 | return pageInfo; 29 | } 30 | 31 | @GetMapping("/user/{id}") 32 | public User selectUserById(@PathVariable("id") Long id){ 33 | return userService.selectById(id); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.songguoliang.springboot.model.FastjsonTest; 4 | import org.apache.shiro.authz.annotation.RequiresPermissions; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * @Description 13 | * @Author sgl 14 | * @Date 2018-05-08 13:55 15 | */ 16 | @RestController 17 | public class TestController { 18 | 19 | @GetMapping("/fastjson") 20 | public FastjsonTest getFastJson() { 21 | FastjsonTest fastjsonTest = new FastjsonTest(); 22 | fastjsonTest.setId(1); 23 | fastjsonTest.setString("fastjson test"); 24 | fastjsonTest.setIgnore("ignore field"); 25 | fastjsonTest.setDate(new Date()); 26 | return fastjsonTest; 27 | } 28 | 29 | /** 30 | * 没有加shiro权限注解 31 | * @return 32 | */ 33 | @RequestMapping("/test1") 34 | public String test1(){ 35 | return "test1"; 36 | } 37 | 38 | /** 39 | * 添加了shiro权限注解,需要用户有"systemUserAdd"权限 40 | * @return 41 | */ 42 | @RequestMapping("/test2") 43 | @RequiresPermissions("systemUserAdd") 44 | public String test2(){ 45 | return "test2"; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/java/com/songguoliang/springboot/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.songguoliang.springboot.model.FastjsonTest; 4 | import org.apache.shiro.authz.annotation.RequiresPermissions; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * @Description 13 | * @Author sgl 14 | * @Date 2018-05-08 13:55 15 | */ 16 | @RestController 17 | public class TestController { 18 | 19 | @GetMapping("/fastjson") 20 | public FastjsonTest getFastJson() { 21 | FastjsonTest fastjsonTest = new FastjsonTest(); 22 | fastjsonTest.setId(1); 23 | fastjsonTest.setString("fastjson test"); 24 | fastjsonTest.setIgnore("ignore field"); 25 | fastjsonTest.setDate(new Date()); 26 | return fastjsonTest; 27 | } 28 | 29 | /** 30 | * 没有加shiro权限注解 31 | * @return 32 | */ 33 | @RequestMapping("/test1") 34 | public String test1(){ 35 | return "test1"; 36 | } 37 | 38 | /** 39 | * 添加了shiro权限注解,需要用户有"systemUserAdd"权限 40 | * @return 41 | */ 42 | @RequestMapping("/test2") 43 | @RequiresPermissions("systemUserAdd") 44 | public String test2(){ 45 | return "test2"; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.songguoliang.springboot.model.FastjsonTest; 4 | import org.apache.shiro.authz.annotation.RequiresPermissions; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * @Description 13 | * @Author sgl 14 | * @Date 2018-05-08 13:55 15 | */ 16 | @RestController 17 | public class TestController { 18 | 19 | @GetMapping("/fastjson") 20 | public FastjsonTest getFastJson() { 21 | FastjsonTest fastjsonTest = new FastjsonTest(); 22 | fastjsonTest.setId(1); 23 | fastjsonTest.setString("fastjson test"); 24 | fastjsonTest.setIgnore("ignore field"); 25 | fastjsonTest.setDate(new Date()); 26 | return fastjsonTest; 27 | } 28 | 29 | /** 30 | * 没有加shiro权限注解 31 | * @return 32 | */ 33 | @RequestMapping("/test1") 34 | public String test1(){ 35 | return "test1"; 36 | } 37 | 38 | /** 39 | * 添加了shiro权限注解,需要用户有"systemUserAdd"权限 40 | * @return 41 | */ 42 | @RequestMapping("/test2") 43 | @RequiresPermissions("systemUserAdd") 44 | public String test2(){ 45 | return "test2"; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /spring-boot-scheduling/src/main/java/com/songguoliang/springboot/scheduling/MyTask.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.scheduling; 2 | 3 | import com.songguoliang.springboot.service.UserService; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.scheduling.annotation.Scheduled; 8 | import org.springframework.stereotype.Component; 9 | 10 | /** 11 | * @Description 12 | * @Author sgl 13 | * @Date 2018-06-26 10:07 14 | */ 15 | @Component 16 | public class MyTask { 17 | private static final Logger LOGGER = LoggerFactory.getLogger(MyTask.class); 18 | 19 | private static final long SECOND = 1000; 20 | 21 | /** 22 | * 注入service 23 | */ 24 | @Autowired 25 | private UserService userService; 26 | 27 | /** 28 | * 固定间隔3秒,可以引用变量 29 | * fixedRate:以每次开始时间作为测量,间隔固定时间 30 | */ 31 | //@Scheduled(fixedRate = 3 * SECOND) 32 | public void task1() { 33 | LOGGER.info("当前时间:{}\t\t任务:fixedRate task,每3秒执行一次", System.currentTimeMillis()); 34 | userService.test(); 35 | } 36 | 37 | /** 38 | * 固定延迟3秒,从前一次任务结束开始计算,延迟3秒执行 39 | */ 40 | //@Scheduled(fixedDelay = 3000) 41 | public void task3(){ 42 | //do something 43 | } 44 | 45 | /** 46 | * cron表达式,每5秒执行 47 | */ 48 | @Scheduled(cron = "*/5 * * * * ?") 49 | public void task2() { 50 | LOGGER.info("当前时间:{}\t\t任务:cron task,每5秒执行一次", System.currentTimeMillis()); 51 | } 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /spring-boot-ehcache/src/main/java/com/songguoliang/springboot/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.songguoliang.springboot.entity.User; 6 | import com.songguoliang.springboot.service.UserService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @Description 15 | * @Author sgl 16 | * @Date 2018-05-02 14:59 17 | */ 18 | @RestController 19 | public class UserController { 20 | 21 | @Autowired 22 | private UserService userService; 23 | 24 | @GetMapping("/users") 25 | public PageInfo lists(@RequestParam(defaultValue = "1") int pageNo,@RequestParam(defaultValue = "10") int pageSize) { 26 | PageHelper.startPage(pageNo,pageSize); 27 | PageInfo pageInfo = new PageInfo<>(userService.getUsers()); 28 | return pageInfo; 29 | } 30 | 31 | @GetMapping("/user/{id}") 32 | public User selectUserById(@PathVariable("id") Long id){ 33 | return userService.selectById(id); 34 | } 35 | 36 | @GetMapping("/user/del/{id}") 37 | public String delUser(@PathVariable("id") Long id){ 38 | userService.evictUser(id); 39 | return "删除成功"; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.songguoliang 8 | spring-boot-study 9 | pom 10 | 1.0-SNAPSHOT 11 | 12 | spring-boot-demo 13 | spring-boot-properties 14 | spring-boot-env 15 | spring-boot-mybatis 16 | spring-boot-druid 17 | spring-boot-pagehelper 18 | spring-boot-mapper4 19 | spring-boot-jsp 20 | spring-boot-fastjson 21 | spring-boot-devtools 22 | spring-boot-upload 23 | spring-boot-ehcache 24 | spring-boot-mybatis-generator 25 | spring-boot-shiro 26 | spring-boot-shiro-ehcache 27 | spring-boot-shiro-ehcache-shiro 28 | spring-boot-scheduling 29 | spring-boot-quartz 30 | spring-boot-quartz-db 31 | spring-boot-mybatis-generator-mysql 32 | spring-boot-jwt 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /spring-boot-demo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.songguoliang 8 | spring-boot-demo 9 | 1.0-SNAPSHOT 10 | 11 | spring-boot-demo 12 | Spring Boot教程(一):体验Spring Boot源码 13 | 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.0.1.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-maven-plugin 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /spring-boot-env/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.songguoliang 8 | spring-boot-env 9 | 1.0-SNAPSHOT 10 | 11 | spring-boot-env 12 | Spring Boot教程(四):多环境配置 源码 13 | 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.0.1.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-maven-plugin 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /spring-boot-properties/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.songguoliang 8 | spring-boot-properties 9 | 1.0-SNAPSHOT 10 | 11 | spring-boot-properties 12 | Spring Boot教程(三):配置文件 13 | 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.0.1.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-maven-plugin 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/songguoliang/springboot/controller/JwtController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import com.songguoliang.springboot.configuration.JwtToken; 4 | import io.jsonwebtoken.Claims; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PostMapping; 8 | import org.springframework.web.bind.annotation.RequestHeader; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import javax.security.sasl.AuthenticationException; 12 | import java.util.Arrays; 13 | import java.util.List; 14 | 15 | /** 16 | * @author itinypocket 17 | * @date 2019-09-03 12:59 18 | */ 19 | @RestController 20 | public class JwtController { 21 | @Autowired 22 | private JwtToken jwtToken; 23 | 24 | @PostMapping("/login") 25 | public String login(String loginName, String password) { 26 | // 1. 根据登录名从数据库查询用户,验证用户名和密码,为了简单演示jwt,这里假设验证通过 27 | // Todo 28 | // 2. 验证成功生成token,并返回 29 | String token = jwtToken.generateToken(loginName); 30 | return token; 31 | } 32 | 33 | @GetMapping("/getUserInfo") 34 | public String getUserInfo(@RequestHeader("Authorization") String authHeader) throws AuthenticationException { 35 | // 黑名单token 36 | List blacklistToken = Arrays.asList("禁止访问的token"); 37 | Claims claims = jwtToken.getClaimByToken(authHeader); 38 | if (claims == null || JwtToken.isTokenExpired(claims.getExpiration()) || blacklistToken.contains(authHeader)) { 39 | throw new AuthenticationException("token 不可用"); 40 | } 41 | 42 | String userId = claims.getSubject(); 43 | // 根据用户id获取接口数据返回接口 44 | return userId; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spring-boot-scheduling/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.songguoliang 8 | spring-boot-scheduling 9 | 1.0-SNAPSHOT 10 | 11 | spring-boot-scheduling 12 | Spring Boot教程(二十):Spring Boot使用String Task定时任务 13 | 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.0.1.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-maven-plugin 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /spring-boot-quartz-db/src/main/java/com/songguoliang/springboot/quartz/QuartzConfig.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.quartz; 2 | 3 | import org.quartz.CronScheduleBuilder; 4 | import org.quartz.JobBuilder; 5 | import org.quartz.JobDetail; 6 | import org.quartz.SimpleScheduleBuilder; 7 | import org.quartz.Trigger; 8 | import org.quartz.TriggerBuilder; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | /** 13 | * @Description 14 | * @Author sgl 15 | * @Date 2018-06-26 16:45 16 | */ 17 | @Configuration 18 | public class QuartzConfig { 19 | 20 | @Bean 21 | public JobDetail testQuartz1() { 22 | return JobBuilder.newJob(TestTask1.class).withIdentity("testTask1").storeDurably().build(); 23 | } 24 | 25 | @Bean 26 | public Trigger testQuartzTrigger1() { 27 | //5秒执行一次 28 | SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule() 29 | .withIntervalInSeconds(5) 30 | .repeatForever(); 31 | return TriggerBuilder.newTrigger().forJob(testQuartz1()) 32 | .withIdentity("testTask1") 33 | .withSchedule(scheduleBuilder) 34 | .build(); 35 | } 36 | 37 | @Bean 38 | public JobDetail testQuartz2() { 39 | return JobBuilder.newJob(TestTask2.class).withIdentity("testTask2").storeDurably().build(); 40 | } 41 | 42 | @Bean 43 | public Trigger testQuartzTrigger2() { 44 | //cron方式,每隔5秒执行一次 45 | return TriggerBuilder.newTrigger().forJob(testQuartz2()) 46 | .withIdentity("testTask2") 47 | .withSchedule(CronScheduleBuilder.cronSchedule("*/5 * * * * ?")) 48 | .build(); 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /spring-boot-quartz/src/main/java/com/songguoliang/springboot/quartz/QuartzConfig.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.quartz; 2 | 3 | import org.quartz.CronScheduleBuilder; 4 | import org.quartz.JobBuilder; 5 | import org.quartz.JobDetail; 6 | import org.quartz.SimpleScheduleBuilder; 7 | import org.quartz.Trigger; 8 | import org.quartz.TriggerBuilder; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | /** 13 | * @Description 14 | * @Author sgl 15 | * @Date 2018-06-26 16:45 16 | */ 17 | @Configuration 18 | public class QuartzConfig { 19 | 20 | @Bean 21 | public JobDetail testQuartz1() { 22 | return JobBuilder.newJob(TestTask1.class).withIdentity("testTask1").storeDurably().build(); 23 | } 24 | 25 | @Bean 26 | public Trigger testQuartzTrigger1() { 27 | //5秒执行一次 28 | SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule() 29 | .withIntervalInSeconds(5) 30 | .repeatForever(); 31 | return TriggerBuilder.newTrigger().forJob(testQuartz1()) 32 | .withIdentity("testTask1") 33 | .withSchedule(scheduleBuilder) 34 | .build(); 35 | } 36 | 37 | @Bean 38 | public JobDetail testQuartz2() { 39 | return JobBuilder.newJob(TestTask2.class).withIdentity("testTask2").storeDurably().build(); 40 | } 41 | 42 | @Bean 43 | public Trigger testQuartzTrigger2() { 44 | //cron方式,每隔5秒执行一次 45 | return TriggerBuilder.newTrigger().forJob(testQuartz2()) 46 | .withIdentity("testTask2") 47 | .withSchedule(CronScheduleBuilder.cronSchedule("*/5 * * * * ?")) 48 | .build(); 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot; 2 | 3 | import com.alibaba.fastjson.serializer.SerializerFeature; 4 | import com.alibaba.fastjson.support.config.FastJsonConfig; 5 | import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.boot.autoconfigure.http.HttpMessageConverters; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.http.converter.HttpMessageConverter; 11 | import tk.mybatis.spring.annotation.MapperScan; 12 | 13 | /** 14 | * @Description 15 | * @Author sgl 16 | * @Date 2018-05-02 14:51 17 | */ 18 | @SpringBootApplication 19 | @MapperScan("com.songguoliang.springboot.mapper") 20 | public class Application { 21 | public static void main(String[] args) { 22 | SpringApplication.run(Application.class, args); 23 | } 24 | 25 | /** 26 | * 方法一、覆盖方法configureMessageConverters,使用fastJson, 27 | * 28 | * @return 29 | */ 30 | @Bean 31 | public HttpMessageConverters fastJsonHttpMessageConverters() { 32 | //1、定义一个convert转换消息的对象 33 | FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); 34 | //2、添加fastjson的配置信息 35 | FastJsonConfig fastJsonConfig = new FastJsonConfig(); 36 | fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat); 37 | //3、在convert中添加配置信息 38 | fastConverter.setFastJsonConfig(fastJsonConfig); 39 | //4、将convert添加到converters中 40 | HttpMessageConverter converter = fastConverter; 41 | return new HttpMessageConverters(converter); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /spring-boot-ehcache/src/main/java/com/songguoliang/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot; 2 | 3 | import com.alibaba.fastjson.serializer.SerializerFeature; 4 | import com.alibaba.fastjson.support.config.FastJsonConfig; 5 | import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.boot.autoconfigure.http.HttpMessageConverters; 9 | import org.springframework.cache.annotation.EnableCaching; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.http.converter.HttpMessageConverter; 12 | import tk.mybatis.spring.annotation.MapperScan; 13 | 14 | /** 15 | * @Description 16 | * @Author sgl 17 | * @Date 2018-05-02 14:51 18 | */ 19 | @EnableCaching 20 | @SpringBootApplication 21 | @MapperScan("com.songguoliang.springboot.mapper") 22 | public class Application{ 23 | public static void main(String[] args) { 24 | SpringApplication.run(Application.class, args); 25 | } 26 | /** 27 | * 方法一、覆盖方法configureMessageConverters,使用fastJson 28 | * @return 29 | */ 30 | @Bean 31 | public HttpMessageConverters fastJsonHttpMessageConverters() { 32 | //1、定义一个convert转换消息的对象 33 | FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); 34 | //2、添加fastjson的配置信息 35 | FastJsonConfig fastJsonConfig = new FastJsonConfig(); 36 | fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat); 37 | //3、在convert中添加配置信息 38 | fastConverter.setFastJsonConfig(fastJsonConfig); 39 | //4、将convert添加到converters中 40 | HttpMessageConverter converter = fastConverter; 41 | return new HttpMessageConverters(converter); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/java/com/songguoliang/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot; 2 | 3 | import com.alibaba.fastjson.serializer.SerializerFeature; 4 | import com.alibaba.fastjson.support.config.FastJsonConfig; 5 | import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.boot.autoconfigure.http.HttpMessageConverters; 9 | import org.springframework.cache.annotation.EnableCaching; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.http.converter.HttpMessageConverter; 12 | import tk.mybatis.spring.annotation.MapperScan; 13 | 14 | /** 15 | * @Description 16 | * @Author sgl 17 | * @Date 2018-05-02 14:51 18 | */ 19 | @EnableCaching 20 | @SpringBootApplication 21 | @MapperScan("com.songguoliang.springboot.mapper") 22 | public class Application { 23 | public static void main(String[] args) { 24 | SpringApplication.run(Application.class, args); 25 | } 26 | 27 | /** 28 | * 方法一、覆盖方法configureMessageConverters,使用fastJson, 29 | * 30 | * @return 31 | */ 32 | @Bean 33 | public HttpMessageConverters fastJsonHttpMessageConverters() { 34 | //1、定义一个convert转换消息的对象 35 | FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); 36 | //2、添加fastjson的配置信息 37 | FastJsonConfig fastJsonConfig = new FastJsonConfig(); 38 | fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat); 39 | //3、在convert中添加配置信息 40 | fastConverter.setFastJsonConfig(fastJsonConfig); 41 | //4、将convert添加到converters中 42 | HttpMessageConverter converter = fastConverter; 43 | return new HttpMessageConverters(converter); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot; 2 | 3 | import com.alibaba.fastjson.serializer.SerializerFeature; 4 | import com.alibaba.fastjson.support.config.FastJsonConfig; 5 | import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.boot.autoconfigure.http.HttpMessageConverters; 9 | import org.springframework.cache.annotation.EnableCaching; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.http.converter.HttpMessageConverter; 12 | import tk.mybatis.spring.annotation.MapperScan; 13 | 14 | /** 15 | * @Description 16 | * @Author sgl 17 | * @Date 2018-05-02 14:51 18 | */ 19 | @EnableCaching 20 | @SpringBootApplication 21 | @MapperScan("com.songguoliang.springboot.mapper") 22 | public class Application { 23 | public static void main(String[] args) { 24 | SpringApplication.run(Application.class, args); 25 | } 26 | 27 | /** 28 | * 方法一、覆盖方法configureMessageConverters,使用fastJson, 29 | * 30 | * @return 31 | */ 32 | @Bean 33 | public HttpMessageConverters fastJsonHttpMessageConverters() { 34 | //1、定义一个convert转换消息的对象 35 | FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); 36 | //2、添加fastjson的配置信息 37 | FastJsonConfig fastJsonConfig = new FastJsonConfig(); 38 | fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat); 39 | //3、在convert中添加配置信息 40 | fastConverter.setFastJsonConfig(fastJsonConfig); 41 | //4、将convert添加到converters中 42 | HttpMessageConverter converter = fastConverter; 43 | return new HttpMessageConverters(converter); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-boot-properties/src/main/java/com/songguoliang/properties/model/RandomData.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.properties.model; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | /** 7 | * @Description 8 | * @Author sgl 9 | * @Date 2018-04-27 15:50 10 | */ 11 | @Component 12 | @ConfigurationProperties(prefix = "test") 13 | public class RandomData { 14 | private Integer randomInt; 15 | private Integer randomIntMax; 16 | private Integer randomIntMiddle; 17 | private Long randomLong; 18 | private String randomValue; 19 | private String randomUuid; 20 | 21 | public Integer getRandomInt() { 22 | return randomInt; 23 | } 24 | 25 | public void setRandomInt(Integer randomInt) { 26 | this.randomInt = randomInt; 27 | } 28 | 29 | public Integer getRandomIntMax() { 30 | return randomIntMax; 31 | } 32 | 33 | public void setRandomIntMax(Integer randomIntMax) { 34 | this.randomIntMax = randomIntMax; 35 | } 36 | 37 | public Integer getRandomIntMiddle() { 38 | return randomIntMiddle; 39 | } 40 | 41 | public void setRandomIntMiddle(Integer randomIntMiddle) { 42 | this.randomIntMiddle = randomIntMiddle; 43 | } 44 | 45 | public Long getRandomLong() { 46 | return randomLong; 47 | } 48 | 49 | public void setRandomLong(Long randomLong) { 50 | this.randomLong = randomLong; 51 | } 52 | 53 | public String getRandomValue() { 54 | return randomValue; 55 | } 56 | 57 | public void setRandomValue(String randomValue) { 58 | this.randomValue = randomValue; 59 | } 60 | 61 | public String getRandomUuid() { 62 | return randomUuid; 63 | } 64 | 65 | public void setRandomUuid(String randomUuid) { 66 | this.randomUuid = randomUuid; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /spring-boot-mybatis-generator/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.songguoliang 8 | spring-boot-mybatis-generator 9 | 1.0-SNAPSHOT 10 | 11 | spring-boot-mybatis-generator 12 | Spring Boot教程(十五):Spring Boot集成mybatis generator自动生成代码插件 13 | 14 | 15 | 16 | 17 | org.mybatis.spring.boot 18 | mybatis-spring-boot-starter 19 | 1.3.2 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | org.mybatis.generator 29 | mybatis-generator-maven-plugin 30 | 1.3.6 31 | 32 | 33 | true 34 | 35 | 36 | 37 | 38 | mysql 39 | mysql-connector-java 40 | 5.1.45 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /spring-boot-quartz/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.songguoliang 8 | spring-boot-quartz 9 | 1.0-SNAPSHOT 10 | 11 | spring-boot-quartz 12 | Spring Boot教程(二十一):Spring Boot使用Quartz定时任务 13 | 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.0.1.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-quartz 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-maven-plugin 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /spring-boot-mybatis-generator-mysql/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.songguoliang 8 | spring-boot-mybatis-generator-mysql 9 | 1.0-SNAPSHOT 10 | 11 | spring-boot-mybatis-generator-mysql 12 | Spring Boot教程(十五):Spring Boot集成mybatis generator自动生成代码插件 13 | 14 | 15 | 16 | 17 | org.mybatis.spring.boot 18 | mybatis-spring-boot-starter 19 | 1.3.2 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | org.mybatis.generator 29 | mybatis-generator-maven-plugin 30 | 1.3.6 31 | 32 | 33 | false 34 | 35 | 36 | 37 | 38 | mysql 39 | mysql-connector-java 40 | 8.0.13 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /spring-boot-devtools/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.songguoliang 8 | spring-boot-devtools 9 | 1.0-SNAPSHOT 10 | war 11 | 12 | spring-boot-devtools 13 | SSpring Boot教程(十二):Spring Boot集成热部署插件devtools 14 | 15 | 16 | 17 | org.springframework.boot 18 | spring-boot-starter-parent 19 | 2.0.1.RELEASE 20 | 21 | 22 | 23 | 24 | UTF-8 25 | UTF-8 26 | 1.8 27 | 28 | 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-web 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-devtools 39 | true 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /spring-boot-upload/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.songguoliang 8 | spring-boot-upload 9 | 1.0-SNAPSHOT 10 | war 11 | 12 | spring-boot-upload 13 | Spring Boot教程(十三):Spring Boot文件上传 14 | 15 | 16 | 17 | org.springframework.boot 18 | spring-boot-starter-parent 19 | 2.0.1.RELEASE 20 | 21 | 22 | 23 | 24 | UTF-8 25 | UTF-8 26 | 1.8 27 | 28 | 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-web 34 | 35 | 36 | 37 | 38 | javax.servlet 39 | jstl 40 | 41 | 42 | org.apache.tomcat.embed 43 | tomcat-embed-jasper 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | org.springframework.boot 56 | spring-boot-maven-plugin 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /spring-boot-mybatis/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.songguoliang 8 | spring-boot-mybatis 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 13 | spring-boot-mybatis 14 | Spring Boot教程(六):Spring Boot集成mybatis 15 | 16 | 17 | 18 | org.springframework.boot 19 | spring-boot-starter-parent 20 | 2.0.1.RELEASE 21 | 22 | 23 | 24 | 25 | UTF-8 26 | UTF-8 27 | 1.8 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | 38 | org.mybatis.spring.boot 39 | mybatis-spring-boot-starter 40 | 1.3.2 41 | 42 | 43 | 44 | mysql 45 | mysql-connector-java 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-maven-plugin 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/songguoliang/springboot/configuration/JwtToken.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.configuration; 2 | 3 | import io.jsonwebtoken.Claims; 4 | import io.jsonwebtoken.Jwts; 5 | import io.jsonwebtoken.SignatureAlgorithm; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Value; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.util.StringUtils; 11 | 12 | import java.util.Date; 13 | 14 | /** 15 | * @author itinypocket 16 | * @date 2019-09-03 12:56 17 | */ 18 | @Configuration 19 | public class JwtToken { 20 | private static Logger logger = LoggerFactory.getLogger(JwtToken.class); 21 | /** 22 | * 秘钥 23 | */ 24 | @Value("${jwt.secret}") 25 | private String secret; 26 | 27 | /** 28 | * 过期时间(秒) 29 | */ 30 | @Value("${jwt.expire}") 31 | private long expire; 32 | 33 | 34 | /** 35 | * 生成jwt token 36 | * @author itinypocket 37 | * @date 2019-09-03 16:24:33 38 | * @param loginName 登录名 39 | * @return 40 | **/ 41 | public String generateToken(String loginName) { 42 | Date nowDate = new Date(); 43 | Date expireDate = new Date(nowDate.getTime() + expire * 1000); 44 | return Jwts.builder() 45 | .setHeaderParam("typ", "JWT") 46 | .setSubject(loginName) 47 | .setIssuedAt(nowDate) 48 | .setExpiration(expireDate) 49 | .signWith(SignatureAlgorithm.HS512, secret) 50 | .compact(); 51 | } 52 | 53 | /** 54 | * 反向解析token获取用户信息 55 | * @author itinypocket 56 | * @date 2019-09-03 16:25:01 57 | * @param token 58 | * @return 59 | **/ 60 | public Claims getClaimByToken(String token) { 61 | if (StringUtils.isEmpty(token)) { 62 | return null; 63 | } 64 | 65 | String[] header = token.split("Bearer"); 66 | token = header[1]; 67 | try { 68 | return Jwts.parser() 69 | .setSigningKey(secret) 70 | .parseClaimsJws(token) 71 | .getBody(); 72 | } catch (Exception e) { 73 | logger.debug("validate is token error ", e); 74 | return null; 75 | } 76 | } 77 | 78 | /** 79 | * token是否过期 80 | * 81 | * @return true:过期 82 | */ 83 | public static boolean isTokenExpired(Date expiration) { 84 | return expiration.before(new Date()); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /spring-boot-mybatis-generator/src/main/resources/generatorConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
46 |
47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /spring-boot-druid/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.songguoliang 8 | spring-boot-druid 9 | 1.0-SNAPSHOT 10 | 11 | 12 | spring-boot-druid 13 | Spring Boot教程(七):Spring Boot集成druid连接池 14 | 15 | 16 | 17 | org.springframework.boot 18 | spring-boot-starter-parent 19 | 2.0.1.RELEASE 20 | 21 | 22 | 23 | 24 | UTF-8 25 | UTF-8 26 | 1.8 27 | 28 | 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-web 34 | 35 | 36 | 37 | org.mybatis.spring.boot 38 | mybatis-spring-boot-starter 39 | 1.3.2 40 | 41 | 42 | 43 | mysql 44 | mysql-connector-java 45 | 46 | 47 | 48 | com.alibaba 49 | druid-spring-boot-starter 50 | 1.1.9 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-maven-plugin 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /spring-boot-fastjson/src/main/java/com/songguoliang/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot; 2 | 3 | import com.alibaba.fastjson.serializer.SerializerFeature; 4 | import com.alibaba.fastjson.support.config.FastJsonConfig; 5 | import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.boot.autoconfigure.http.HttpMessageConverters; 9 | import org.springframework.http.converter.HttpMessageConverter; 10 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 11 | import tk.mybatis.spring.annotation.MapperScan; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * @Description 17 | * @Author sgl 18 | * @Date 2018-05-02 14:51 19 | */ 20 | @SpringBootApplication 21 | @MapperScan("com.songguoliang.springboot.mapper") 22 | public class Application implements WebMvcConfigurer { 23 | public static void main(String[] args) { 24 | SpringApplication.run(Application.class, args); 25 | } 26 | /** 27 | * 方法一、覆盖方法configureMessageConverters,使用fastJson, 28 | * 此处把@Bean注释掉是为了测试方式二 29 | * @return 30 | */ 31 | //@Bean 32 | public HttpMessageConverters fastJsonHttpMessageConverters() { 33 | //1、定义一个convert转换消息的对象 34 | FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); 35 | //2、添加fastjson的配置信息 36 | FastJsonConfig fastJsonConfig = new FastJsonConfig(); 37 | fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat); 38 | //3、在convert中添加配置信息 39 | fastConverter.setFastJsonConfig(fastJsonConfig); 40 | //4、将convert添加到converters中 41 | HttpMessageConverter converter = fastConverter; 42 | return new HttpMessageConverters(converter); 43 | } 44 | 45 | @Override 46 | public void configureMessageConverters(List> converters) { 47 | //1、定义一个convert转换消息的对象 48 | FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); 49 | //2、添加fastjson的配置信息 50 | FastJsonConfig fastJsonConfig = new FastJsonConfig(); 51 | fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat); 52 | //3、在convert中添加配置信息 53 | fastConverter.setFastJsonConfig(fastJsonConfig); 54 | //4、将convert添加到converters中 55 | converters.add(fastConverter); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import org.apache.shiro.SecurityUtils; 4 | import org.apache.shiro.authc.DisabledAccountException; 5 | import org.apache.shiro.authc.IncorrectCredentialsException; 6 | import org.apache.shiro.authc.UnknownAccountException; 7 | import org.apache.shiro.authc.UsernamePasswordToken; 8 | import org.apache.shiro.subject.Subject; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.GetMapping; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | 15 | /** 16 | * @Description 17 | * @Author sgl 18 | * @Date 2018-06-11 17:51 19 | */ 20 | @Controller 21 | public class LoginController { 22 | 23 | /** 24 | * get请求,登录页面跳转 25 | * @return 26 | */ 27 | @GetMapping("/login") 28 | public String login() { 29 | //如果已经认证通过,直接跳转到首页 30 | if (SecurityUtils.getSubject().isAuthenticated()) { 31 | return "redirect:/index"; 32 | } 33 | return "login"; 34 | } 35 | 36 | /** 37 | * post表单提交,登录 38 | * @param username 39 | * @param password 40 | * @param model 41 | * @return 42 | */ 43 | @PostMapping("/login") 44 | public Object login(String username, String password, Model model) { 45 | Subject user = SecurityUtils.getSubject(); 46 | UsernamePasswordToken token = new UsernamePasswordToken(username, password); 47 | try { 48 | //shiro帮我们匹配密码什么的,我们只需要把东西传给它,它会根据我们在UserRealm里认证方法设置的来验证 49 | user.login(token); 50 | return "redirect:/index"; 51 | } catch (UnknownAccountException e) { 52 | //账号不存在和下面密码错误一般都合并为一个账号或密码错误,这样可以增加暴力破解难度 53 | model.addAttribute("message", "账号不存在!"); 54 | } catch (DisabledAccountException e) { 55 | model.addAttribute("message", "账号未启用!"); 56 | } catch (IncorrectCredentialsException e) { 57 | model.addAttribute("message", "密码错误!"); 58 | } catch (Throwable e) { 59 | model.addAttribute("message", "未知错误!"); 60 | } 61 | return "login"; 62 | } 63 | 64 | /** 65 | * 退出 66 | * @return 67 | */ 68 | @RequestMapping("/logout") 69 | public String logout() { 70 | SecurityUtils.getSubject().logout(); 71 | return "login"; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache/src/main/java/com/songguoliang/springboot/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import org.apache.shiro.SecurityUtils; 4 | import org.apache.shiro.authc.DisabledAccountException; 5 | import org.apache.shiro.authc.IncorrectCredentialsException; 6 | import org.apache.shiro.authc.UnknownAccountException; 7 | import org.apache.shiro.authc.UsernamePasswordToken; 8 | import org.apache.shiro.subject.Subject; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.GetMapping; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | 15 | /** 16 | * @Description 17 | * @Author sgl 18 | * @Date 2018-06-11 17:51 19 | */ 20 | @Controller 21 | public class LoginController { 22 | 23 | /** 24 | * get请求,登录页面跳转 25 | * @return 26 | */ 27 | @GetMapping("/login") 28 | public String login() { 29 | //如果已经认证通过,直接跳转到首页 30 | if (SecurityUtils.getSubject().isAuthenticated()) { 31 | return "redirect:/index"; 32 | } 33 | return "login"; 34 | } 35 | 36 | /** 37 | * post表单提交,登录 38 | * @param username 39 | * @param password 40 | * @param model 41 | * @return 42 | */ 43 | @PostMapping("/login") 44 | public Object login(String username, String password, Model model) { 45 | Subject user = SecurityUtils.getSubject(); 46 | UsernamePasswordToken token = new UsernamePasswordToken(username, password); 47 | try { 48 | //shiro帮我们匹配密码什么的,我们只需要把东西传给它,它会根据我们在UserRealm里认证方法设置的来验证 49 | user.login(token); 50 | return "redirect:/index"; 51 | } catch (UnknownAccountException e) { 52 | //账号不存在和下面密码错误一般都合并为一个账号或密码错误,这样可以增加暴力破解难度 53 | model.addAttribute("message", "账号不存在!"); 54 | } catch (DisabledAccountException e) { 55 | model.addAttribute("message", "账号未启用!"); 56 | } catch (IncorrectCredentialsException e) { 57 | model.addAttribute("message", "密码错误!"); 58 | } catch (Throwable e) { 59 | model.addAttribute("message", "未知错误!"); 60 | } 61 | return "login"; 62 | } 63 | 64 | /** 65 | * 退出 66 | * @return 67 | */ 68 | @RequestMapping("/logout") 69 | public String logout() { 70 | SecurityUtils.getSubject().logout(); 71 | return "login"; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import org.apache.shiro.SecurityUtils; 4 | import org.apache.shiro.authc.DisabledAccountException; 5 | import org.apache.shiro.authc.IncorrectCredentialsException; 6 | import org.apache.shiro.authc.UnknownAccountException; 7 | import org.apache.shiro.authc.UsernamePasswordToken; 8 | import org.apache.shiro.subject.Subject; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.GetMapping; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | 15 | /** 16 | * @Description 17 | * @Author sgl 18 | * @Date 2018-06-11 17:51 19 | */ 20 | @Controller 21 | public class LoginController { 22 | 23 | /** 24 | * get请求,登录页面跳转 25 | * @return 26 | */ 27 | @GetMapping("/login") 28 | public String login() { 29 | //如果已经认证通过,直接跳转到首页 30 | if (SecurityUtils.getSubject().isAuthenticated()) { 31 | return "redirect:/index"; 32 | } 33 | return "login"; 34 | } 35 | 36 | /** 37 | * post表单提交,登录 38 | * @param username 39 | * @param password 40 | * @param model 41 | * @return 42 | */ 43 | @PostMapping("/login") 44 | public Object login(String username, String password, Model model) { 45 | Subject user = SecurityUtils.getSubject(); 46 | UsernamePasswordToken token = new UsernamePasswordToken(username, password); 47 | try { 48 | //shiro帮我们匹配密码什么的,我们只需要把东西传给它,它会根据我们在UserRealm里认证方法设置的来验证 49 | user.login(token); 50 | return "redirect:/index"; 51 | } catch (UnknownAccountException e) { 52 | //账号不存在和下面密码错误一般都合并为一个账号或密码错误,这样可以增加暴力破解难度 53 | model.addAttribute("message", "账号不存在!"); 54 | } catch (DisabledAccountException e) { 55 | model.addAttribute("message", "账号未启用!"); 56 | } catch (IncorrectCredentialsException e) { 57 | model.addAttribute("message", "密码错误!"); 58 | } catch (Throwable e) { 59 | model.addAttribute("message", "未知错误!"); 60 | } 61 | return "login"; 62 | } 63 | 64 | /** 65 | * 退出 66 | * @return 67 | */ 68 | @RequestMapping("/logout") 69 | public String logout() { 70 | SecurityUtils.getSubject().logout(); 71 | return "login"; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /spring-boot-pagehelper/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.songguoliang 8 | spring-boot-pagehelper 9 | 1.0-SNAPSHOT 10 | 11 | spring-boot-pagehelper 12 | Spring Boot教程(八):Spring Boot集成pagehelper分页插件 13 | 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.0.1.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | 36 | org.mybatis.spring.boot 37 | mybatis-spring-boot-starter 38 | 1.3.2 39 | 40 | 41 | 42 | mysql 43 | mysql-connector-java 44 | 45 | 46 | 47 | com.alibaba 48 | druid-spring-boot-starter 49 | 1.1.9 50 | 51 | 52 | 53 | com.github.pagehelper 54 | pagehelper-spring-boot-starter 55 | 1.2.5 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | org.springframework.boot 66 | spring-boot-maven-plugin 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /spring-boot-mybatis-generator-mysql/src/main/resources/generatorConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 28 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
52 |
53 |
54 | 55 | 56 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/shiro/UserRealm.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.shiro; 2 | 3 | import com.songguoliang.springboot.entity.SysUser; 4 | import com.songguoliang.springboot.service.SysPermissionService; 5 | import com.songguoliang.springboot.service.SysUserService; 6 | import org.apache.shiro.authc.AuthenticationException; 7 | import org.apache.shiro.authc.AuthenticationInfo; 8 | import org.apache.shiro.authc.AuthenticationToken; 9 | import org.apache.shiro.authc.SimpleAuthenticationInfo; 10 | import org.apache.shiro.authc.UsernamePasswordToken; 11 | import org.apache.shiro.authz.AuthorizationInfo; 12 | import org.apache.shiro.authz.SimpleAuthorizationInfo; 13 | import org.apache.shiro.realm.AuthorizingRealm; 14 | import org.apache.shiro.subject.PrincipalCollection; 15 | import org.apache.shiro.util.ByteSource; 16 | import org.slf4j.Logger; 17 | import org.slf4j.LoggerFactory; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | 20 | import java.util.List; 21 | 22 | /** 23 | * @Description 24 | * @Author sgl 25 | * @Date 2018-06-11 17:07 26 | */ 27 | public class UserRealm extends AuthorizingRealm { 28 | private static final Logger LOGGER = LoggerFactory.getLogger(UserRealm.class); 29 | @Autowired 30 | private SysUserService sysUserService; 31 | 32 | @Autowired 33 | private SysPermissionService sysPermissionService; 34 | 35 | /** 36 | * 授权 37 | * 38 | * @param principals 39 | * @return 40 | */ 41 | @Override 42 | protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { 43 | SysUser sysUser = (SysUser) principals.getPrimaryPrincipal(); 44 | List sysPermissions = sysPermissionService.selectPermissionByUserId(sysUser.getUserId()); 45 | 46 | SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); 47 | info.addStringPermissions(sysPermissions); 48 | LOGGER.info("doGetAuthorizationInfo"); 49 | return info; 50 | } 51 | 52 | /** 53 | * 认证 54 | * 55 | * @param authenticationToken 56 | * @return 57 | * @throws AuthenticationException 58 | */ 59 | @Override 60 | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { 61 | UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken; 62 | SysUser sysUser = sysUserService.findByUserName(token.getUsername()); 63 | if (sysUser == null) { 64 | return null; 65 | } 66 | LOGGER.info("doGetAuthenticationInfo"); 67 | return new SimpleAuthenticationInfo(sysUser, sysUser.getPassword().toCharArray(), ByteSource.Util.bytes(sysUser.getSalt()), getName()); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /spring-boot-mapper4/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.songguoliang 8 | spring-boot-mapper4 9 | 1.0-SNAPSHOT 10 | 11 | spring-boot-mapper4 12 | Spring Boot教程(九):Spring Boot集成Mapper4 13 | 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.0.1.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | 36 | org.mybatis.spring.boot 37 | mybatis-spring-boot-starter 38 | 1.3.2 39 | 40 | 41 | 42 | mysql 43 | mysql-connector-java 44 | 45 | 46 | 47 | com.alibaba 48 | druid-spring-boot-starter 49 | 1.1.9 50 | 51 | 52 | 53 | com.github.pagehelper 54 | pagehelper-spring-boot-starter 55 | 1.2.5 56 | 57 | 58 | 59 | tk.mybatis 60 | mapper-spring-boot-starter 61 | 2.0.2 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | org.springframework.boot 73 | spring-boot-maven-plugin 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /spring-boot-upload/src/main/java/com/songguoliang/springboot/controller/UploadController.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.controller; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PostMapping; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import org.springframework.web.bind.annotation.ResponseBody; 10 | import org.springframework.web.multipart.MultipartFile; 11 | import org.springframework.web.multipart.MultipartHttpServletRequest; 12 | 13 | import javax.servlet.http.HttpServletRequest; 14 | import java.io.File; 15 | import java.io.IOException; 16 | import java.util.List; 17 | 18 | /** 19 | * @Description 20 | * @Author sgl 21 | * @Date 2018-05-15 14:04 22 | */ 23 | @Controller 24 | public class UploadController { 25 | private static final Logger LOGGER = LoggerFactory.getLogger(UploadController.class); 26 | 27 | @GetMapping("/upload") 28 | public String upload() { 29 | return "upload"; 30 | } 31 | 32 | @PostMapping("/upload") 33 | @ResponseBody 34 | public String upload(@RequestParam("file") MultipartFile file) { 35 | if (file.isEmpty()) { 36 | return "上传失败,请选择文件"; 37 | } 38 | 39 | String fileName = file.getOriginalFilename(); 40 | 41 | 42 | String filePath = "/Users/itinypocket/workspace/temp/"; 43 | File dest = new File(filePath + fileName); 44 | try { 45 | file.transferTo(dest); 46 | LOGGER.info("上传成功"); 47 | return "上传成功"; 48 | } catch (IOException e) { 49 | LOGGER.error(e.toString(), e); 50 | } 51 | return "上传失败!"; 52 | } 53 | 54 | @GetMapping("/multiUpload") 55 | public String multiUpload() { 56 | return "multiUpload"; 57 | } 58 | 59 | @PostMapping("/multiUpload") 60 | @ResponseBody 61 | public String multiUpload(HttpServletRequest request) { 62 | List files = ((MultipartHttpServletRequest) request).getFiles("file"); 63 | String filePath = "/Users/itinypocket/workspace/temp/"; 64 | for (int i = 0; i < files.size(); i++) { 65 | MultipartFile file = files.get(i); 66 | if (file.isEmpty()) { 67 | return "上传第" + (i++) + "个文件失败"; 68 | } 69 | String fileName = file.getOriginalFilename(); 70 | 71 | File dest = new File(filePath + fileName); 72 | try { 73 | file.transferTo(dest); 74 | LOGGER.info("第" + (i + 1) + "个文件上传成功"); 75 | } catch (IOException e) { 76 | LOGGER.error(e.toString(), e); 77 | return "上传第" + (i++) + "个文件失败"; 78 | } 79 | } 80 | 81 | return "上传成功"; 82 | 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /spring-boot-shiro-ehcache-shiro/src/main/java/com/songguoliang/springboot/shiro/UserRealm.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.shiro; 2 | 3 | import com.songguoliang.springboot.entity.SysUser; 4 | import com.songguoliang.springboot.service.SysPermissionService; 5 | import com.songguoliang.springboot.service.SysUserService; 6 | import org.apache.shiro.authc.AuthenticationException; 7 | import org.apache.shiro.authc.AuthenticationInfo; 8 | import org.apache.shiro.authc.AuthenticationToken; 9 | import org.apache.shiro.authc.SimpleAuthenticationInfo; 10 | import org.apache.shiro.authc.UsernamePasswordToken; 11 | import org.apache.shiro.authz.AuthorizationInfo; 12 | import org.apache.shiro.authz.SimpleAuthorizationInfo; 13 | import org.apache.shiro.realm.AuthorizingRealm; 14 | import org.apache.shiro.subject.PrincipalCollection; 15 | import org.apache.shiro.util.ByteSource; 16 | import org.slf4j.Logger; 17 | import org.slf4j.LoggerFactory; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.context.annotation.Lazy; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * @Description 25 | * @Author sgl 26 | * @Date 2018-06-11 17:07 27 | */ 28 | public class UserRealm extends AuthorizingRealm { 29 | private static final Logger LOGGER = LoggerFactory.getLogger(UserRealm.class); 30 | /** 31 | * 注意此处需要添加@Lazy注解,否则SysUserService缓存注解、事务注解不生效 32 | */ 33 | @Autowired 34 | @Lazy 35 | private SysUserService sysUserService; 36 | 37 | @Autowired 38 | @Lazy 39 | private SysPermissionService sysPermissionService; 40 | 41 | /** 42 | * 授权 43 | * 44 | * @param principals 45 | * @return 46 | */ 47 | @Override 48 | protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { 49 | SysUser sysUser = (SysUser) principals.getPrimaryPrincipal(); 50 | List sysPermissions = sysPermissionService.selectPermissionByUserId(sysUser.getUserId()); 51 | 52 | SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); 53 | info.addStringPermissions(sysPermissions); 54 | LOGGER.info("doGetAuthorizationInfo"); 55 | return info; 56 | } 57 | 58 | /** 59 | * 认证 60 | * 61 | * @param authenticationToken 62 | * @return 63 | * @throws AuthenticationException 64 | */ 65 | @Override 66 | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { 67 | UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken; 68 | SysUser sysUser = sysUserService.findByUserName(token.getUsername()); 69 | if (sysUser == null) { 70 | return null; 71 | } 72 | LOGGER.info("doGetAuthenticationInfo"); 73 | return new SimpleAuthenticationInfo(sysUser, sysUser.getPassword().toCharArray(), ByteSource.Util.bytes(sysUser.getSalt()), getName()); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/songguoliang/springboot/Application.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot; 2 | 3 | import com.alibaba.fastjson.serializer.SerializerFeature; 4 | import com.alibaba.fastjson.support.config.FastJsonConfig; 5 | import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.boot.autoconfigure.http.HttpMessageConverters; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.http.MediaType; 11 | import org.springframework.http.converter.HttpMessageConverter; 12 | import tk.mybatis.spring.annotation.MapperScan; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | /** 18 | * @Description 19 | * @Author sgl 20 | * @Date 2018-05-02 14:51 21 | */ 22 | @SpringBootApplication 23 | @MapperScan("com.songguoliang.springboot.mapper") 24 | public class Application { 25 | public static void main(String[] args) { 26 | SpringApplication.run(Application.class, args); 27 | } 28 | 29 | @Bean 30 | public HttpMessageConverters fastJsonHttpMessageConverters() { 31 | //1、定义一个convert转换消息的对象 32 | FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); 33 | 34 | //升级最新版本需加 35 | List supportedMediaTypes = new ArrayList<>(); 36 | supportedMediaTypes.add(MediaType.APPLICATION_JSON); 37 | supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8); 38 | supportedMediaTypes.add(MediaType.APPLICATION_ATOM_XML); 39 | supportedMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED); 40 | supportedMediaTypes.add(MediaType.APPLICATION_OCTET_STREAM); 41 | supportedMediaTypes.add(MediaType.APPLICATION_PDF); 42 | supportedMediaTypes.add(MediaType.APPLICATION_RSS_XML); 43 | supportedMediaTypes.add(MediaType.APPLICATION_XHTML_XML); 44 | supportedMediaTypes.add(MediaType.APPLICATION_XML); 45 | supportedMediaTypes.add(MediaType.IMAGE_GIF); 46 | supportedMediaTypes.add(MediaType.IMAGE_JPEG); 47 | supportedMediaTypes.add(MediaType.IMAGE_PNG); 48 | supportedMediaTypes.add(MediaType.TEXT_EVENT_STREAM); 49 | supportedMediaTypes.add(MediaType.TEXT_HTML); 50 | supportedMediaTypes.add(MediaType.TEXT_MARKDOWN); 51 | supportedMediaTypes.add(MediaType.TEXT_PLAIN); 52 | supportedMediaTypes.add(MediaType.TEXT_XML); 53 | fastConverter.setSupportedMediaTypes(supportedMediaTypes); 54 | 55 | //2、添加fastjson的配置信息 56 | FastJsonConfig fastJsonConfig = new FastJsonConfig(); 57 | fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat); 58 | //3、在convert中添加配置信息 59 | fastConverter.setFastJsonConfig(fastJsonConfig); 60 | //4、将convert添加到converters中 61 | HttpMessageConverter converter = fastConverter; 62 | return new HttpMessageConverters(converter); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /spring-boot-quartz-db/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.songguoliang 8 | spring-boot-quartz-db 9 | 1.0-SNAPSHOT 10 | 11 | spring-boot-quartz-db 12 | Spring Boot教程(二十一):Spring Boot使用Quartz定时任务 13 | 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.0.1.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | 36 | org.mybatis.spring.boot 37 | mybatis-spring-boot-starter 38 | 1.3.2 39 | 40 | 41 | 42 | mysql 43 | mysql-connector-java 44 | 45 | 46 | 47 | com.alibaba 48 | druid-spring-boot-starter 49 | 1.1.9 50 | 51 | 52 | 53 | com.github.pagehelper 54 | pagehelper-spring-boot-starter 55 | 1.2.5 56 | 57 | 58 | 59 | tk.mybatis 60 | mapper-spring-boot-starter 61 | 2.0.2 62 | 63 | 64 | 65 | org.springframework.boot 66 | spring-boot-starter-quartz 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | org.springframework.boot 77 | spring-boot-maven-plugin 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /spring-boot-mybatis-generator/src/main/java/com/songguoliang/springboot/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import com.songguoliang.springboot.entity.User; 4 | import com.songguoliang.springboot.entity.UserExample; 5 | import java.util.List; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | public interface UserMapper { 9 | /** 10 | * This method was generated by MyBatis Generator. 11 | * This method corresponds to the database table tbl_user 12 | * 13 | * @mbg.generated 14 | */ 15 | long countByExample(UserExample example); 16 | 17 | /** 18 | * This method was generated by MyBatis Generator. 19 | * This method corresponds to the database table tbl_user 20 | * 21 | * @mbg.generated 22 | */ 23 | int deleteByExample(UserExample example); 24 | 25 | /** 26 | * This method was generated by MyBatis Generator. 27 | * This method corresponds to the database table tbl_user 28 | * 29 | * @mbg.generated 30 | */ 31 | int deleteByPrimaryKey(Long userId); 32 | 33 | /** 34 | * This method was generated by MyBatis Generator. 35 | * This method corresponds to the database table tbl_user 36 | * 37 | * @mbg.generated 38 | */ 39 | int insert(User record); 40 | 41 | /** 42 | * This method was generated by MyBatis Generator. 43 | * This method corresponds to the database table tbl_user 44 | * 45 | * @mbg.generated 46 | */ 47 | int insertSelective(User record); 48 | 49 | /** 50 | * This method was generated by MyBatis Generator. 51 | * This method corresponds to the database table tbl_user 52 | * 53 | * @mbg.generated 54 | */ 55 | List selectByExample(UserExample example); 56 | 57 | /** 58 | * This method was generated by MyBatis Generator. 59 | * This method corresponds to the database table tbl_user 60 | * 61 | * @mbg.generated 62 | */ 63 | User selectByPrimaryKey(Long userId); 64 | 65 | /** 66 | * This method was generated by MyBatis Generator. 67 | * This method corresponds to the database table tbl_user 68 | * 69 | * @mbg.generated 70 | */ 71 | int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example); 72 | 73 | /** 74 | * This method was generated by MyBatis Generator. 75 | * This method corresponds to the database table tbl_user 76 | * 77 | * @mbg.generated 78 | */ 79 | int updateByExample(@Param("record") User record, @Param("example") UserExample example); 80 | 81 | /** 82 | * This method was generated by MyBatis Generator. 83 | * This method corresponds to the database table tbl_user 84 | * 85 | * @mbg.generated 86 | */ 87 | int updateByPrimaryKeySelective(User record); 88 | 89 | /** 90 | * This method was generated by MyBatis Generator. 91 | * This method corresponds to the database table tbl_user 92 | * 93 | * @mbg.generated 94 | */ 95 | int updateByPrimaryKey(User record); 96 | } -------------------------------------------------------------------------------- /spring-boot-mybatis-generator-mysql/src/main/java/com/songguoliang/springboot/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.mapper; 2 | 3 | import com.songguoliang.springboot.entity.User; 4 | import com.songguoliang.springboot.entity.UserExample; 5 | import java.util.List; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | public interface UserMapper { 9 | /** 10 | * This method was generated by MyBatis Generator. 11 | * This method corresponds to the database table tbl_user 12 | * 13 | * @mbg.generated 14 | */ 15 | long countByExample(UserExample example); 16 | 17 | /** 18 | * This method was generated by MyBatis Generator. 19 | * This method corresponds to the database table tbl_user 20 | * 21 | * @mbg.generated 22 | */ 23 | int deleteByExample(UserExample example); 24 | 25 | /** 26 | * This method was generated by MyBatis Generator. 27 | * This method corresponds to the database table tbl_user 28 | * 29 | * @mbg.generated 30 | */ 31 | int deleteByPrimaryKey(Long userId); 32 | 33 | /** 34 | * This method was generated by MyBatis Generator. 35 | * This method corresponds to the database table tbl_user 36 | * 37 | * @mbg.generated 38 | */ 39 | int insert(User record); 40 | 41 | /** 42 | * This method was generated by MyBatis Generator. 43 | * This method corresponds to the database table tbl_user 44 | * 45 | * @mbg.generated 46 | */ 47 | int insertSelective(User record); 48 | 49 | /** 50 | * This method was generated by MyBatis Generator. 51 | * This method corresponds to the database table tbl_user 52 | * 53 | * @mbg.generated 54 | */ 55 | List selectByExample(UserExample example); 56 | 57 | /** 58 | * This method was generated by MyBatis Generator. 59 | * This method corresponds to the database table tbl_user 60 | * 61 | * @mbg.generated 62 | */ 63 | User selectByPrimaryKey(Long userId); 64 | 65 | /** 66 | * This method was generated by MyBatis Generator. 67 | * This method corresponds to the database table tbl_user 68 | * 69 | * @mbg.generated 70 | */ 71 | int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example); 72 | 73 | /** 74 | * This method was generated by MyBatis Generator. 75 | * This method corresponds to the database table tbl_user 76 | * 77 | * @mbg.generated 78 | */ 79 | int updateByExample(@Param("record") User record, @Param("example") UserExample example); 80 | 81 | /** 82 | * This method was generated by MyBatis Generator. 83 | * This method corresponds to the database table tbl_user 84 | * 85 | * @mbg.generated 86 | */ 87 | int updateByPrimaryKeySelective(User record); 88 | 89 | /** 90 | * This method was generated by MyBatis Generator. 91 | * This method corresponds to the database table tbl_user 92 | * 93 | * @mbg.generated 94 | */ 95 | int updateByPrimaryKey(User record); 96 | } -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/songguoliang/springboot/shiro/ShiroConfig.java: -------------------------------------------------------------------------------- 1 | package com.songguoliang.springboot.shiro; 2 | 3 | import org.apache.shiro.authc.credential.HashedCredentialsMatcher; 4 | import org.apache.shiro.mgt.SecurityManager; 5 | import org.apache.shiro.spring.web.ShiroFilterFactoryBean; 6 | import org.apache.shiro.web.mgt.DefaultWebSecurityManager; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | import java.util.LinkedHashMap; 11 | import java.util.Map; 12 | 13 | /** 14 | * @Description 15 | * @Author sgl 16 | * @Date 2018-06-11 17:23 17 | */ 18 | @Configuration 19 | public class ShiroConfig { 20 | 21 | /** 22 | * 凭证匹配器 23 | * 24 | * @return 25 | */ 26 | @Bean 27 | public HashedCredentialsMatcher hashedCredentialsMatcher() { 28 | HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher(); 29 | //md5加密1次 30 | hashedCredentialsMatcher.setHashAlgorithmName("md5"); 31 | hashedCredentialsMatcher.setHashIterations(1); 32 | return hashedCredentialsMatcher; 33 | } 34 | 35 | /** 36 | * 自定义realm 37 | * 38 | * @return 39 | */ 40 | @Bean 41 | public UserRealm userRealm() { 42 | UserRealm userRealm = new UserRealm(); 43 | userRealm.setCredentialsMatcher(hashedCredentialsMatcher()); 44 | return userRealm; 45 | } 46 | 47 | /** 48 | * 安全管理器 49 | * 注:使用shiro-spring-boot-starter 1.4时,返回类型是SecurityManager会报错,直接引用shiro-spring则不报错 50 | * 51 | * @return 52 | */ 53 | @Bean 54 | public DefaultWebSecurityManager securityManager() { 55 | DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); 56 | securityManager.setRealm(userRealm()); 57 | return securityManager; 58 | } 59 | 60 | 61 | /** 62 | * 设置过滤规则 63 | * 64 | * @param securityManager 65 | * @return 66 | */ 67 | @Bean 68 | public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager) { 69 | ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); 70 | shiroFilterFactoryBean.setSecurityManager(securityManager); 71 | shiroFilterFactoryBean.setLoginUrl("/login"); 72 | shiroFilterFactoryBean.setSuccessUrl("/"); 73 | shiroFilterFactoryBean.setUnauthorizedUrl("/unauth"); 74 | 75 | //注意此处使用的是LinkedHashMap,是有顺序的,shiro会按从上到下的顺序匹配验证,匹配了就不再继续验证 76 | //所以上面的url要苛刻,宽松的url要放在下面,尤其是"/**"要放到最下面,如果放前面的话其后的验证规则就没作用了。 77 | Map filterChainDefinitionMap = new LinkedHashMap<>(); 78 | filterChainDefinitionMap.put("/static/**", "anon"); 79 | filterChainDefinitionMap.put("/login", "anon"); 80 | filterChainDefinitionMap.put("/captcha.jpg", "anon"); 81 | filterChainDefinitionMap.put("/favicon.ico", "anon"); 82 | filterChainDefinitionMap.put("/**", "authc"); 83 | 84 | shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); 85 | return shiroFilterFactoryBean; 86 | } 87 | 88 | 89 | 90 | } 91 | --------------------------------------------------------------------------------