├── springboot-first-demo
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── li
│ │ │ └── springbootfirstdemo
│ │ │ ├── SpringbootFirstDemoApplication.java
│ │ │ ├── controller
│ │ │ └── HelloController.java
│ │ │ └── test
│ │ │ └── HelloControllerITest.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── li
│ │ └── springbootfirstdemo
│ │ └── SpringbootFirstDemoApplicationTests.java
├── .DS_Store
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── .gitignore
└── pom.xml
├── springboot-swagger2
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── application.properties
│ │ ├── .DS_Store
│ │ └── java
│ │ │ ├── .DS_Store
│ │ │ └── com
│ │ │ ├── .DS_Store
│ │ │ └── li
│ │ │ ├── .DS_Store
│ │ │ └── springbootswagger2
│ │ │ ├── .DS_Store
│ │ │ ├── SpringbootSwagger2Application.java
│ │ │ ├── model
│ │ │ └── User.java
│ │ │ └── config
│ │ │ └── Swagger2Config.java
│ ├── .DS_Store
│ └── test
│ │ └── java
│ │ └── com
│ │ └── li
│ │ └── springbootswagger2
│ │ └── SpringbootSwagger2ApplicationTests.java
├── .DS_Store
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── .gitignore
└── pom.xml
├── springboot-timing
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── li
│ │ │ └── springboottiming
│ │ │ ├── SpringbootTimingApplication.java
│ │ │ └── task
│ │ │ └── ScheduledTasks.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── li
│ │ └── springboottiming
│ │ └── SpringbootTimingApplicationTests.java
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── .gitignore
└── pom.xml
├── springbootgrpc
├── lib-server
│ ├── src
│ │ ├── main
│ │ │ ├── resources
│ │ │ │ └── application.properties
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── li
│ │ │ │ │ └── libserver
│ │ │ │ │ └── LibServerApplication.java
│ │ │ └── proto
│ │ │ │ └── greeter.proto
│ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── li
│ │ │ └── libserver
│ │ │ └── LibServerApplicationTests.java
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ └── .gitignore
├── springbootgrpc.iml
├── grpc-server
│ ├── src
│ │ ├── main
│ │ │ ├── resources
│ │ │ │ └── application.properties
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── li
│ │ │ │ └── grpcserver
│ │ │ │ ├── GrpcServerApplication.java
│ │ │ │ └── GreeterService.java
│ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── li
│ │ │ └── grpcserver
│ │ │ └── GrpcServerApplicationTests.java
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── .gitignore
│ └── pom.xml
├── grpc-client
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── src
│ │ ├── main
│ │ │ ├── resources
│ │ │ │ └── application.properties
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── li
│ │ │ │ └── grpcclient
│ │ │ │ ├── GrpcClientApplication.java
│ │ │ │ ├── GrpcClientController.java
│ │ │ │ └── GrpcClientService.java
│ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── li
│ │ │ └── grpcclient
│ │ │ └── GrpcClientApplicationTests.java
│ ├── .gitignore
│ └── pom.xml
├── .idea
│ ├── encodings.xml
│ ├── misc.xml
│ └── compiler.xml
└── pom.xml
├── .DS_Store
├── springboot-resttemplate
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── li
│ │ │ └── springbootresttemplate
│ │ │ ├── SpringbootResttemplateApplication.java
│ │ │ ├── model
│ │ │ └── User.java
│ │ │ └── config
│ │ │ └── RestTemplateConfig.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── li
│ │ └── springbootresttemplate
│ │ └── SpringbootResttemplateApplicationTests.java
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── .gitignore
└── pom.xml
├── springboot-config
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── application-dev.properties
│ │ │ ├── my.properties
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── li
│ │ │ └── springbootconfig
│ │ │ ├── SpringbootConfigApplication.java
│ │ │ ├── controller
│ │ │ ├── ConfigController.java
│ │ │ ├── MyController.java
│ │ │ └── ConfigBeanController.java
│ │ │ └── model
│ │ │ ├── User.java
│ │ │ └── ConfigBean.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── li
│ │ └── springbootconfig
│ │ └── SpringbootConfigApplicationTests.java
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── .gitignore
└── pom.xml
├── springboot-mongdb
├── .DS_Store
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── li
│ │ │ └── springbootmongdb
│ │ │ ├── SpringbootMongdbApplication.java
│ │ │ ├── model
│ │ │ └── MongoTest.java
│ │ │ └── test
│ │ │ └── MongdbTest.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── li
│ │ └── springbootmongdb
│ │ └── SpringbootMongdbApplicationTests.java
└── .gitignore
├── springboot-redis
├── .DS_Store
├── src
│ ├── .DS_Store
│ ├── main
│ │ ├── .DS_Store
│ │ ├── java
│ │ │ ├── .DS_Store
│ │ │ └── com
│ │ │ │ ├── .DS_Store
│ │ │ │ └── li
│ │ │ │ ├── .DS_Store
│ │ │ │ └── springbootredis
│ │ │ │ ├── .DS_Store
│ │ │ │ ├── server
│ │ │ │ ├── RedisService.java
│ │ │ │ └── Impl
│ │ │ │ │ └── RedisServiceImpl.java
│ │ │ │ ├── SpringbootRedisApplication.java
│ │ │ │ ├── model
│ │ │ │ └── User.java
│ │ │ │ ├── redis
│ │ │ │ ├── FastJsonRedisSerializer.java
│ │ │ │ └── RedisConfig.java
│ │ │ │ └── test
│ │ │ │ └── RedisTest.java
│ │ └── resources
│ │ │ └── application.properties
│ └── test
│ │ └── java
│ │ └── com
│ │ └── li
│ │ └── springbootredis
│ │ └── SpringbootRedisApplicationTests.java
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
└── .gitignore
├── springboot-elasticsearch
├── .DS_Store
├── src
│ ├── .DS_Store
│ ├── main
│ │ ├── .DS_Store
│ │ ├── java
│ │ │ ├── .DS_Store
│ │ │ └── com
│ │ │ │ ├── .DS_Store
│ │ │ │ └── li
│ │ │ │ ├── .DS_Store
│ │ │ │ ├── ElasticsearchApplication.java
│ │ │ │ ├── model
│ │ │ │ ├── EsModel.java
│ │ │ │ └── Book.java
│ │ │ │ └── elasticsearch
│ │ │ │ └── alone
│ │ │ │ └── EsAloneConfig.java
│ │ └── resources
│ │ │ └── application.properties
│ └── test
│ │ └── java
│ │ └── com
│ │ └── li
│ │ └── ElasticsearchApplicationTests.java
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
└── .gitignore
├── springboot-mail
├── weixin_qrcode.jpg
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── templates
│ │ │ │ └── mail.ftl
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── li
│ │ │ └── springbootmail
│ │ │ └── SpringbootMailApplication.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── li
│ │ └── springbootmail
│ │ └── SpringbootMailApplicationTests.java
├── .gitignore
└── pom.xml
├── redis-lua-limit
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── .gitignore
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── xd
│ │ │ │ └── redislualimit
│ │ │ │ ├── RedisLuaLimitApplication.java
│ │ │ │ ├── annotation
│ │ │ │ └── RateLimit.java
│ │ │ │ ├── controller
│ │ │ │ └── LimiterController.java
│ │ │ │ ├── utils
│ │ │ │ └── IPUtil.java
│ │ │ │ └── config
│ │ │ │ └── commons.java
│ │ └── resources
│ │ │ ├── application.properties
│ │ │ └── redisLimit.lua
│ └── test
│ │ └── java
│ │ └── com
│ │ └── xd
│ │ └── redislualimit
│ │ └── RedisLuaLimitApplicationTests.java
└── pom.xml
├── springboot-async
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── .gitignore
└── src
│ ├── test
│ └── java
│ │ └── com
│ │ └── li
│ │ └── springbootasync
│ │ └── SpringbootAsyncApplicationTests.java
│ └── main
│ ├── java
│ └── com
│ │ └── li
│ │ └── springbootasync
│ │ ├── SpringbootAsyncApplication.java
│ │ ├── config
│ │ └── TaskPoolConfig.java
│ │ └── task
│ │ └── Task.java
│ └── resources
│ └── application.properties
├── springboot-mybatis
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── li
│ │ │ └── springbootmybatis
│ │ │ ├── SpringbootMybatisApplication.java
│ │ │ ├── server
│ │ │ ├── UserServer.java
│ │ │ └── impl
│ │ │ │ └── UserServiceImpl.java
│ │ │ ├── model
│ │ │ └── User.java
│ │ │ ├── dao
│ │ │ └── UserMapper.java
│ │ │ └── controller
│ │ │ └── UserController.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── li
│ │ └── springbootmybatis
│ │ └── SpringbootMybatisApplicationTests.java
├── .gitignore
└── pom.xml
├── springboot-redismq
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── .gitignore
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── li
│ │ │ │ └── springbootredismq
│ │ │ │ ├── SpringbootRedismqApplication.java
│ │ │ │ ├── test
│ │ │ │ └── RedismqTest.java
│ │ │ │ ├── message
│ │ │ │ └── Receiver.java
│ │ │ │ └── redis
│ │ │ │ └── redismq.java
│ │ └── resources
│ │ │ └── application.properties
│ └── test
│ │ └── java
│ │ └── com
│ │ └── li
│ │ └── springbootredismq
│ │ └── SpringbootRedismqApplicationTests.java
└── pom.xml
├── springboot-freemarker
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── templates
│ │ │ │ └── hello.ftl
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── li
│ │ │ └── springbootfreemarker
│ │ │ └── SpringbootFreemarkerApplication.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── li
│ │ └── springbootfreemarker
│ │ └── SpringbootFreemarkerApplicationTests.java
├── .gitignore
└── pom.xml
├── springboot-mybatis-tx
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── li
│ │ │ │ └── springbootmybatistx
│ │ │ │ ├── server
│ │ │ │ ├── UserServer.java
│ │ │ │ └── impl
│ │ │ │ │ └── UserServiceImpl.java
│ │ │ │ ├── dao
│ │ │ │ └── UserMapper.java
│ │ │ │ ├── SpringbootMybatisTxApplication.java
│ │ │ │ ├── controller
│ │ │ │ └── UserController.java
│ │ │ │ └── model
│ │ │ │ └── User.java
│ │ └── resources
│ │ │ ├── application.properties
│ │ │ └── mapper
│ │ │ └── UserMapper.xml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── li
│ │ └── springbootmybatistx
│ │ └── SpringbootMybatisTxApplicationTests.java
├── .gitignore
└── pom.xml
├── springboot-rabbitmq
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── .gitignore
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── li
│ │ │ │ └── springbootrabbitmq
│ │ │ │ ├── SpringbootRabbitmqApplication.java
│ │ │ │ ├── test
│ │ │ │ └── MqTest.java
│ │ │ │ └── rabbitmq
│ │ │ │ ├── MqReceiver.java
│ │ │ │ └── MqSender.java
│ │ └── resources
│ │ │ └── application.properties
│ └── test
│ │ └── java
│ │ └── com
│ │ └── li
│ │ └── springbootrabbitmq
│ │ └── SpringbootRabbitmqApplicationTests.java
└── pom.xml
├── springboot-security
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── .gitignore
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── li
│ │ │ └── springbootsecurity
│ │ │ ├── controller
│ │ │ ├── RoleController.java
│ │ │ └── UserController.java
│ │ │ ├── bo
│ │ │ ├── ResponseUserToken.java
│ │ │ ├── ResultCode.java
│ │ │ ├── ResultUtil.java
│ │ │ └── ResultJson.java
│ │ │ ├── mapper
│ │ │ ├── RoleMapper.java
│ │ │ └── UserMapper.java
│ │ │ ├── exception
│ │ │ ├── CustomException.java
│ │ │ └── DefaultExceptionHandler.java
│ │ │ ├── SpringbootSecurityApplication.java
│ │ │ ├── service
│ │ │ ├── IRoleService.java
│ │ │ ├── impl
│ │ │ │ └── RoleServiceImpl.java
│ │ │ └── IUserService.java
│ │ │ ├── model
│ │ │ ├── Role.java
│ │ │ └── User.java
│ │ │ └── config
│ │ │ ├── RestAuthenticationAccessDeniedHandler.java
│ │ │ └── JwtAuthenticationEntryPoint.java
│ └── resources
│ │ ├── mapper
│ │ ├── UserMapper.xml
│ │ └── RoleMapper.xml
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── li
│ └── springbootsecurity
│ └── SpringbootSecurityApplicationTests.java
├── springboot-thymeleaf
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── templates
│ │ │ │ └── hello.html
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── li
│ │ │ └── springbootthymeleaf
│ │ │ └── SpringbootThymeleafApplication.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── li
│ │ └── springbootthymeleaf
│ │ └── SpringbootThymeleafApplicationTests.java
├── .gitignore
└── pom.xml
├── mybatis-plus-multi-tenancy
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── .gitignore
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── xd
│ │ │ └── mybatisplusmultitenancy
│ │ │ ├── MybatisPlusMultiTenancyApplication.java
│ │ │ ├── mapper
│ │ │ └── UserMapper.java
│ │ │ ├── config
│ │ │ ├── MyContext.java
│ │ │ ├── MyTenantHandler.java
│ │ │ └── MybatisPlusConfig.java
│ │ │ └── entity
│ │ │ └── User.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── xd
│ └── mybatisplusmultitenancy
│ └── MybatisPlusMultiTenancyApplicationTests.java
├── spring-boot-sharding-table
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── xd
│ │ │ │ └── springbootshardingtable
│ │ │ │ ├── mapper
│ │ │ │ └── UserMapper.java
│ │ │ │ ├── SpringBootShardingTableApplication.java
│ │ │ │ ├── service
│ │ │ │ ├── UserService.java
│ │ │ │ └── Impl
│ │ │ │ │ └── UserServiceImpl.java
│ │ │ │ ├── entity
│ │ │ │ └── User.java
│ │ │ │ └── controller
│ │ │ │ └── UserController.java
│ │ └── resources
│ │ │ └── application.properties
│ └── test
│ │ └── java
│ │ └── com
│ │ └── xd
│ │ └── springbootshardingtable
│ │ └── SpringBootShardingTableApplicationTests.java
└── .gitignore
├── spring-boot-sharding-read-write
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── xd
│ │ │ │ └── springbootshardingreadwrite
│ │ │ │ ├── mapper
│ │ │ │ └── UserMapper.java
│ │ │ │ ├── SpringBootShardingReadWriteApplication.java
│ │ │ │ ├── service
│ │ │ │ ├── UserService.java
│ │ │ │ └── Impl
│ │ │ │ │ └── UserServiceImpl.java
│ │ │ │ ├── entity
│ │ │ │ └── User.java
│ │ │ │ └── controller
│ │ │ │ └── UserController.java
│ │ └── resources
│ │ │ └── application.properties
│ └── test
│ │ └── java
│ │ └── com
│ │ └── xd
│ │ └── springbootshardingreadwrite
│ │ └── SpringBootShardingReadWriteApplicationTests.java
└── .gitignore
├── .gitignore
└── README.md
/springboot-first-demo/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/springboot-swagger2/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/springboot-timing/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/springbootgrpc/lib-server/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/.DS_Store
--------------------------------------------------------------------------------
/springboot-resttemplate/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8089
2 |
--------------------------------------------------------------------------------
/springboot-config/src/main/resources/application-dev.properties:
--------------------------------------------------------------------------------
1 | server.port=8081
2 |
3 |
4 |
--------------------------------------------------------------------------------
/springboot-config/src/main/resources/my.properties:
--------------------------------------------------------------------------------
1 | my.name=lihaodong
2 | my.age=21
3 |
4 |
5 |
--------------------------------------------------------------------------------
/springboot-mongdb/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-mongdb/.DS_Store
--------------------------------------------------------------------------------
/springboot-redis/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-redis/.DS_Store
--------------------------------------------------------------------------------
/springbootgrpc/springbootgrpc.iml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/springboot-swagger2/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-swagger2/.DS_Store
--------------------------------------------------------------------------------
/springboot-first-demo/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-first-demo/.DS_Store
--------------------------------------------------------------------------------
/springboot-redis/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-redis/src/.DS_Store
--------------------------------------------------------------------------------
/springboot-elasticsearch/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-elasticsearch/.DS_Store
--------------------------------------------------------------------------------
/springboot-mail/weixin_qrcode.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-mail/weixin_qrcode.jpg
--------------------------------------------------------------------------------
/springboot-swagger2/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-swagger2/src/.DS_Store
--------------------------------------------------------------------------------
/springboot-redis/src/main/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-redis/src/main/.DS_Store
--------------------------------------------------------------------------------
/springboot-elasticsearch/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-elasticsearch/src/.DS_Store
--------------------------------------------------------------------------------
/springboot-swagger2/src/main/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-swagger2/src/main/.DS_Store
--------------------------------------------------------------------------------
/springbootgrpc/grpc-server/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name= local-grpc-server
2 | grpc.server.port=9898
3 |
--------------------------------------------------------------------------------
/springboot-redis/src/main/java/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-redis/src/main/java/.DS_Store
--------------------------------------------------------------------------------
/springboot-elasticsearch/src/main/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-elasticsearch/src/main/.DS_Store
--------------------------------------------------------------------------------
/springboot-redis/src/main/java/com/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-redis/src/main/java/com/.DS_Store
--------------------------------------------------------------------------------
/springboot-swagger2/src/main/java/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-swagger2/src/main/java/.DS_Store
--------------------------------------------------------------------------------
/redis-lua-limit/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/redis-lua-limit/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-async/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-async/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-mail/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-mail/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-redis/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-redis/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-redis/src/main/java/com/li/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-redis/src/main/java/com/li/.DS_Store
--------------------------------------------------------------------------------
/springboot-swagger2/src/main/java/com/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-swagger2/src/main/java/com/.DS_Store
--------------------------------------------------------------------------------
/springboot-config/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-config/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-elasticsearch/src/main/java/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-elasticsearch/src/main/java/.DS_Store
--------------------------------------------------------------------------------
/springboot-mongdb/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-mongdb/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-mybatis/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-mybatis/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-redismq/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-redismq/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-timing/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-timing/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-elasticsearch/src/main/java/com/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-elasticsearch/src/main/java/com/.DS_Store
--------------------------------------------------------------------------------
/springboot-first-demo/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-first-demo/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-freemarker/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-freemarker/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-mail/src/main/resources/templates/mail.ftl:
--------------------------------------------------------------------------------
1 |
2 |
3 | 你好, ${userName}, 这是一封模板邮件!
4 |
5 |
--------------------------------------------------------------------------------
/springboot-mybatis-tx/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-mybatis-tx/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-rabbitmq/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-rabbitmq/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-security/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-security/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-swagger2/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-swagger2/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-swagger2/src/main/java/com/li/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-swagger2/src/main/java/com/li/.DS_Store
--------------------------------------------------------------------------------
/springboot-thymeleaf/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-thymeleaf/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/redis-lua-limit/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-mail/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-resttemplate/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-resttemplate/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/mybatis-plus-multi-tenancy/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/mybatis-plus-multi-tenancy/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/spring-boot-sharding-table/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/spring-boot-sharding-table/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-async/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-config/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-elasticsearch/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-elasticsearch/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-elasticsearch/src/main/java/com/li/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-elasticsearch/src/main/java/com/li/.DS_Store
--------------------------------------------------------------------------------
/springboot-mongdb/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-mybatis/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-redis/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-redismq/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-security/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-swagger2/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-thymeleaf/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-timing/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springbootgrpc/grpc-client/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springbootgrpc/grpc-client/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springbootgrpc/grpc-server/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springbootgrpc/grpc-server/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springbootgrpc/lib-server/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springbootgrpc/lib-server/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/springboot-elasticsearch/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-first-demo/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-freemarker/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-mybatis-tx/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-resttemplate/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springbootgrpc/lib-server/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/mybatis-plus-multi-tenancy/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/spring-boot-sharding-read-write/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/spring-boot-sharding-read-write/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/spring-boot-sharding-table/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springbootgrpc/grpc-client/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springbootgrpc/grpc-server/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/spring-boot-sharding-read-write/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
2 |
--------------------------------------------------------------------------------
/springboot-redis/src/main/java/com/li/springbootredis/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-redis/src/main/java/com/li/springbootredis/.DS_Store
--------------------------------------------------------------------------------
/springboot-config/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | my.publicNumber=lihaodong_blog
2 | my.blog=www.lhdyx.cn
3 | my.name=lihaodong
4 | my.age=21
5 |
6 | spring.profiles.active=dev
7 |
8 |
9 |
--------------------------------------------------------------------------------
/springboot-swagger2/src/main/java/com/li/springbootswagger2/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiHaodong888/SpringBootLearn/HEAD/springboot-swagger2/src/main/java/com/li/springbootswagger2/.DS_Store
--------------------------------------------------------------------------------
/springboot-mybatis-tx/src/main/java/com/li/springbootmybatistx/server/UserServer.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmybatistx.server;
2 |
3 |
4 | public interface UserServer {
5 |
6 | void transfer();
7 | }
8 |
--------------------------------------------------------------------------------
/springboot-freemarker/src/main/resources/templates/hello.ftl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | ${host}
8 |
9 |
--------------------------------------------------------------------------------
/springboot-elasticsearch/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #es集群名称
2 | spring.data.elasticsearch.cluster-name=es6.2
3 | #集群机器ip
4 | spring.data.elasticsearch.cluster-nodes=xxx,xxx
5 | #端口号
6 | elasticsearch.cluster.port=9300
--------------------------------------------------------------------------------
/springboot-mybatis/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #数据库配置
2 | spring.datasource.driverClassName=com.mysql.jdbc.Driver
3 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&useSSL=false
4 | spring.datasource.username=root
5 | spring.datasource.password=root
6 |
--------------------------------------------------------------------------------
/springboot-mongdb/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.data.mongodb.uri=mongodb://用户名:密码@localhost:27017/数据库
2 |
3 | spring.data.mongodb.host=localhost
4 | spring.data.mongodb.port=27017
5 | spring.data.mongodb.database=数据库
6 | spring.data.mongodb.username=用户名
7 | spring.data.mongodb.password=密码
8 |
--------------------------------------------------------------------------------
/springboot-thymeleaf/src/main/resources/templates/hello.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 我的博客
7 |
8 |
9 |
10 | 我的博客地址
11 |
12 |
--------------------------------------------------------------------------------
/springbootgrpc/grpc-client/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8088
2 | spring.application.name= local-grpc-client
3 | grpc.client.local-grpc-server.host=${LOCAL-GRPC-HOST:127.0.0.1}
4 | grpc.client.local-grpc-server.port=9898
5 | grpc.client.local-grpc-server.enableKeepAlive= true
6 | grpc.client.local-grpc-server.keepAliveWithoutCalls=true
--------------------------------------------------------------------------------
/springboot-thymeleaf/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # 默认路径
2 | spring.thymeleaf.prefix=classpath:/templates/
3 | # 后缀
4 | spring.thymeleaf.suffix=.html
5 | # 模板格式
6 | spring.thymeleaf.mode=HTML5
7 | # 字符编码
8 | spring.thymeleaf.encoding=UTF-8
9 | # 内容格式
10 | spring.thymeleaf.servlet.content-type=text/html
11 | # 是否打开缓存 一般在开发过程中不建议打开
12 | spring.thymeleaf.cache=false
13 |
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 |
--------------------------------------------------------------------------------
/spring-boot-sharding-table/src/main/java/com/xd/springbootshardingtable/mapper/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.xd.springbootshardingtable.mapper;
2 |
3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 | import com.xd.springbootshardingtable.entity.User;
5 |
6 | /**
7 | * user dao层
8 | * @author lihaodong
9 | */
10 | public interface UserMapper extends BaseMapper {
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/springboot-mybatis-tx/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #数据库配置
2 | spring.datasource.driverClassName=com.mysql.jdbc.Driver
3 | spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&useSSL=false
4 | spring.datasource.username=root
5 | spring.datasource.password=root
6 |
7 | mybatis.type-aliases-package=com.li.springbootmybatistx.model
8 | mybatis.mapper-locations=classpath:mapper/*.xml
--------------------------------------------------------------------------------
/springboot-async/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 | .sts4-cache
12 |
13 | ### IntelliJ IDEA ###
14 | .idea
15 | *.iws
16 | *.iml
17 | *.ipr
18 |
19 | ### NetBeans ###
20 | /nbproject/private/
21 | /nbbuild/
22 | /dist/
23 | /nbdist/
24 | /.nb-gradle/
25 | /build/
26 |
--------------------------------------------------------------------------------
/springboot-config/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 | .sts4-cache
12 |
13 | ### IntelliJ IDEA ###
14 | .idea
15 | *.iws
16 | *.iml
17 | *.ipr
18 |
19 | ### NetBeans ###
20 | /nbproject/private/
21 | /nbbuild/
22 | /dist/
23 | /nbdist/
24 | /.nb-gradle/
25 | /build/
26 |
--------------------------------------------------------------------------------
/springboot-mail/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 | .sts4-cache
12 |
13 | ### IntelliJ IDEA ###
14 | .idea
15 | *.iws
16 | *.iml
17 | *.ipr
18 |
19 | ### NetBeans ###
20 | /nbproject/private/
21 | /nbbuild/
22 | /dist/
23 | /nbdist/
24 | /.nb-gradle/
25 | /build/
26 |
--------------------------------------------------------------------------------
/springboot-redis/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 | .sts4-cache
12 |
13 | ### IntelliJ IDEA ###
14 | .idea
15 | *.iws
16 | *.iml
17 | *.ipr
18 |
19 | ### NetBeans ###
20 | /nbproject/private/
21 | /nbbuild/
22 | /dist/
23 | /nbdist/
24 | /.nb-gradle/
25 | /build/
26 |
--------------------------------------------------------------------------------
/springboot-timing/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 | .sts4-cache
12 |
13 | ### IntelliJ IDEA ###
14 | .idea
15 | *.iws
16 | *.iml
17 | *.ipr
18 |
19 | ### NetBeans ###
20 | /nbproject/private/
21 | /nbbuild/
22 | /dist/
23 | /nbdist/
24 | /.nb-gradle/
25 | /build/
26 |
--------------------------------------------------------------------------------
/spring-boot-sharding-read-write/src/main/java/com/xd/springbootshardingreadwrite/mapper/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.xd.springbootshardingreadwrite.mapper;
2 |
3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 | import com.xd.springbootshardingreadwrite.entity.User;
5 |
6 | /**
7 | * user dao层
8 | * @author lihaodong
9 | */
10 | public interface UserMapper extends BaseMapper {
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/springboot-elasticsearch/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 | .sts4-cache
12 |
13 | ### IntelliJ IDEA ###
14 | .idea
15 | *.iws
16 | *.iml
17 | *.ipr
18 |
19 | ### NetBeans ###
20 | /nbproject/private/
21 | /build/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
--------------------------------------------------------------------------------
/springboot-first-demo/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 | .sts4-cache
12 |
13 | ### IntelliJ IDEA ###
14 | .idea
15 | *.iws
16 | *.iml
17 | *.ipr
18 |
19 | ### NetBeans ###
20 | /nbproject/private/
21 | /nbbuild/
22 | /dist/
23 | /nbdist/
24 | /.nb-gradle/
25 | /build/
26 |
--------------------------------------------------------------------------------
/springboot-mybatis-tx/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 | .sts4-cache
12 |
13 | ### IntelliJ IDEA ###
14 | .idea
15 | *.iws
16 | *.iml
17 | *.ipr
18 |
19 | ### NetBeans ###
20 | /nbproject/private/
21 | /nbbuild/
22 | /dist/
23 | /nbdist/
24 | /.nb-gradle/
25 | /build/
26 |
--------------------------------------------------------------------------------
/springboot-mybatis/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 | .sts4-cache
12 |
13 | ### IntelliJ IDEA ###
14 | .idea
15 | *.iws
16 | *.iml
17 | *.ipr
18 |
19 | ### NetBeans ###
20 | /nbproject/private/
21 | /nbbuild/
22 | /dist/
23 | /nbdist/
24 | /.nb-gradle/
25 | /build/
26 |
--------------------------------------------------------------------------------
/springboot-freemarker/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # 设定ftl文件路径
2 | spring.freemarker.template-loader-path=classpath:/templates
3 | # 关闭缓存,及时刷新,上线生产环境需要修改为true
4 | spring.freemarker.cache=false
5 | # 字符集
6 | spring.freemarker.charset=UTF-8
7 | # 检查模板
8 | spring.freemarker.check-template-location=true
9 | # 模板内容格式
10 | spring.freemarker.content-type=text/html
11 | # 文件后缀
12 | spring.freemarker.suffix=.ftl
13 |
--------------------------------------------------------------------------------
/springbootgrpc/grpc-client/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 | .sts4-cache
12 |
13 | ### IntelliJ IDEA ###
14 | .idea
15 | *.iws
16 | *.iml
17 | *.ipr
18 |
19 | ### NetBeans ###
20 | /nbproject/private/
21 | /nbbuild/
22 | /dist/
23 | /nbdist/
24 | /.nb-gradle/
25 | /build/
26 |
--------------------------------------------------------------------------------
/springbootgrpc/lib-server/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 | .sts4-cache
12 |
13 | ### IntelliJ IDEA ###
14 | .idea
15 | *.iws
16 | *.iml
17 | *.ipr
18 |
19 | ### NetBeans ###
20 | /nbproject/private/
21 | /nbbuild/
22 | /dist/
23 | /nbdist/
24 | /.nb-gradle/
25 | /build/
26 |
--------------------------------------------------------------------------------
/springboot-mongdb/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | /target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | .sts4-cache
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | /nbproject/private/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
26 | /build/
27 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | /target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | .sts4-cache
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | /nbproject/private/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
26 | /build/
27 |
--------------------------------------------------------------------------------
/springboot-redismq/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | /target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | .sts4-cache
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | /nbproject/private/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
26 | /build/
27 |
--------------------------------------------------------------------------------
/springboot-security/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | /target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | .sts4-cache
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | /nbproject/private/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
26 | /build/
27 |
--------------------------------------------------------------------------------
/springboot-swagger2/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | /target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | .sts4-cache
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | /nbproject/private/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
26 | /build/
27 |
--------------------------------------------------------------------------------
/springboot-freemarker/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | /target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | .sts4-cache
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | /nbproject/private/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
26 | /build/
27 |
--------------------------------------------------------------------------------
/springboot-resttemplate/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | /target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | .sts4-cache
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | /nbproject/private/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
26 | /build/
27 |
--------------------------------------------------------------------------------
/springboot-thymeleaf/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | /target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | .sts4-cache
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | /nbproject/private/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
26 | /build/
27 |
--------------------------------------------------------------------------------
/springbootgrpc/grpc-server/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | /target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | .sts4-cache
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | /nbproject/private/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
26 | /build/
27 |
--------------------------------------------------------------------------------
/springboot-elasticsearch/src/main/java/com/li/ElasticsearchApplication.java:
--------------------------------------------------------------------------------
1 | package com.li;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class ElasticsearchApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(ElasticsearchApplication.class, args);
11 | }
12 |
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/springbootgrpc/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/redis-lua-limit/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | /target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | .sts4-cache
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | /nbproject/private/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
26 | /build/
27 |
28 | ### VS Code ###
29 | .vscode/
30 |
--------------------------------------------------------------------------------
/springbootgrpc/lib-server/src/main/java/com/li/libserver/LibServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.libserver;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class LibServerApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(LibServerApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/springboot-redis/src/main/java/com/li/springbootredis/server/RedisService.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootredis.server;
2 |
3 | public interface RedisService {
4 |
5 | /**
6 | * redis字符串操作 设置key value
7 | * @param key
8 | * @param value
9 | */
10 | void setValue(String key,Object value);
11 |
12 | /**
13 | * redis字符串操作 通过key取值
14 | * @param key
15 | * @return
16 | */
17 | Object getValue(String key);
18 | }
19 |
--------------------------------------------------------------------------------
/springbootgrpc/grpc-client/src/main/java/com/li/grpcclient/GrpcClientApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.grpcclient;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class GrpcClientApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(GrpcClientApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/springbootgrpc/grpc-server/src/main/java/com/li/grpcserver/GrpcServerApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.grpcserver;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class GrpcServerApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(GrpcServerApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/redis-lua-limit/src/main/java/com/xd/redislualimit/RedisLuaLimitApplication.java:
--------------------------------------------------------------------------------
1 | package com.xd.redislualimit;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class RedisLuaLimitApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(RedisLuaLimitApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-boot-sharding-table/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | /target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | .sts4-cache
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | /nbproject/private/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
26 | /build/
27 |
28 | ### VS Code ###
29 | .vscode/
30 |
--------------------------------------------------------------------------------
/spring-boot-sharding-read-write/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | /target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | .sts4-cache
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | /nbproject/private/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
26 | /build/
27 |
28 | ### VS Code ###
29 | .vscode/
30 |
--------------------------------------------------------------------------------
/springboot-mail/src/main/java/com/li/springbootmail/SpringbootMailApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmail;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootMailApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootMailApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/springboot-redis/src/main/java/com/li/springbootredis/SpringbootRedisApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootredis;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootRedisApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootRedisApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/springboot-config/src/main/java/com/li/springbootconfig/SpringbootConfigApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootconfig;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootConfigApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootConfigApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/springboot-mongdb/src/main/java/com/li/springbootmongdb/SpringbootMongdbApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmongdb;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootMongdbApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootMongdbApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/springboot-elasticsearch/src/test/java/com/li/ElasticsearchApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ElasticsearchApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/springboot-mybatis/src/main/java/com/li/springbootmybatis/SpringbootMybatisApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmybatis;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootMybatisApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootMybatisApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/springboot-redismq/src/main/java/com/li/springbootredismq/SpringbootRedismqApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootredismq;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootRedismqApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootRedismqApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/springboot-mail/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # QQ邮箱
2 | spring.mail.host=smtp.qq.com
3 | #发送者邮箱需要和实际发送者一致,否则报错501
4 | spring.mail.username=757479746@qq.com
5 | #发送者邮箱的授权码,不是密码,自己去qq邮箱设置
6 | spring.mail.password=weuhwykxbmxmbdeg
7 | # 设置是否需要认证,如果为true,那么用户名和密码就必须的,
8 | # 如果设置false,可以不设置用户名和密码,当然也得看你的对接的平台是否支持无密码进行访问的
9 | spring.mail.properties.mail.smtp.auth=true
10 | spring.mail.properties.mail.smtp.starttls.enable=true
11 | spring.mail.properties.mail.smtp.starttls.required=true
12 |
--------------------------------------------------------------------------------
/springbootgrpc/lib-server/src/test/java/com/li/libserver/LibServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.libserver;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class LibServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/src/main/java/com/li/springbootrabbitmq/SpringbootRabbitmqApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootrabbitmq;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootRabbitmqApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootRabbitmqApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/springboot-swagger2/src/main/java/com/li/springbootswagger2/SpringbootSwagger2Application.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootswagger2;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootSwagger2Application {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootSwagger2Application.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/springbootgrpc/grpc-client/src/test/java/com/li/grpcclient/GrpcClientApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.grpcclient;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class GrpcClientApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springbootgrpc/grpc-server/src/test/java/com/li/grpcserver/GrpcServerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.grpcserver;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class GrpcServerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/redis-lua-limit/src/test/java/com/xd/redislualimit/RedisLuaLimitApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.xd.redislualimit;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class RedisLuaLimitApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-mail/src/test/java/com/li/springbootmail/SpringbootMailApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmail;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootMailApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/mybatis-plus-multi-tenancy/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**
5 | !**/src/test/**
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 |
30 | ### VS Code ###
31 | .vscode/
32 |
--------------------------------------------------------------------------------
/springboot-async/src/test/java/com/li/springbootasync/SpringbootAsyncApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootasync;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootAsyncApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-redis/src/test/java/com/li/springbootredis/SpringbootRedisApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootredis;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootRedisApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/controller/RoleController.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.controller;
2 |
3 |
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 |
6 | import org.springframework.web.bind.annotation.RestController;
7 |
8 | /**
9 | *
10 | * 前端控制器
11 | *
12 | *
13 | * @author lihaodong
14 | * @since 2019-03-14
15 | */
16 | @RestController
17 | @RequestMapping("/role")
18 | public class RoleController {
19 |
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/controller/UserController.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.controller;
2 |
3 |
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 | import org.springframework.web.bind.annotation.RestController;
6 |
7 | /**
8 | *
9 | * 前端控制器
10 | *
11 | *
12 | * @author lihaodong
13 | * @since 2019-03-14
14 | */
15 | @RestController
16 | @RequestMapping("/user")
17 | public class UserController {
18 |
19 |
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/springboot-config/src/test/java/com/li/springbootconfig/SpringbootConfigApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootconfig;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootConfigApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-mongdb/src/test/java/com/li/springbootmongdb/SpringbootMongdbApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmongdb;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootMongdbApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-timing/src/test/java/com/li/springboottiming/SpringbootTimingApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springboottiming;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootTimingApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-mybatis/src/test/java/com/li/springbootmybatis/SpringbootMybatisApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmybatis;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootMybatisApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-redismq/src/test/java/com/li/springbootredismq/SpringbootRedismqApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootredismq;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootRedismqApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-resttemplate/src/main/java/com/li/springbootresttemplate/SpringbootResttemplateApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootresttemplate;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootResttemplateApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringbootResttemplateApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/springboot-first-demo/src/test/java/com/li/springbootfirstdemo/SpringbootFirstDemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootfirstdemo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootFirstDemoApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/src/test/java/com/li/springbootrabbitmq/SpringbootRabbitmqApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootrabbitmq;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootRabbitmqApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-security/src/test/java/com/li/springbootsecurity/SpringbootSecurityApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootSecurityApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-swagger2/src/test/java/com/li/springbootswagger2/SpringbootSwagger2ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootswagger2;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootSwagger2ApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springbootgrpc/lib-server/src/main/proto/greeter.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | option java_package = "com.li.libserver";
4 |
5 | // The greeter service definition.
6 | service Greeter {
7 | // Sends a greeting
8 | rpc SayHello ( HelloRequest) returns ( HelloReply) {}
9 |
10 | }
11 | // The request message containing the user's name.
12 | message HelloRequest {
13 | string name = 1;
14 | }
15 | // The response message containing the greetings
16 | message HelloReply {
17 | string message = 1;
18 | }
19 |
--------------------------------------------------------------------------------
/mybatis-plus-multi-tenancy/src/main/java/com/xd/mybatisplusmultitenancy/MybatisPlusMultiTenancyApplication.java:
--------------------------------------------------------------------------------
1 | package com.xd.mybatisplusmultitenancy;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class MybatisPlusMultiTenancyApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(MybatisPlusMultiTenancyApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/mybatis-plus-multi-tenancy/src/main/java/com/xd/mybatisplusmultitenancy/mapper/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.xd.mybatisplusmultitenancy.mapper;
2 |
3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 | import com.xd.mybatisplusmultitenancy.entity.User;
5 |
6 | /**
7 | * @Classname UserMapper
8 | * @Description mapper
9 | * @Author Created by Lihaodong (alias:小东啊) lihaodongmail@163.com
10 | * @Date 2019-08-09 22:49
11 | * @Version 1.0
12 | */
13 | public interface UserMapper extends BaseMapper {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/springboot-mybatis-tx/src/main/java/com/li/springbootmybatistx/dao/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmybatistx.dao;
2 |
3 | import org.apache.ibatis.annotations.*;
4 |
5 | import java.math.BigDecimal;
6 |
7 | /**
8 | * @ClassName UserMapper
9 | * @Author lihaodong
10 | * @Date 2019/2/19 09:18
11 | * @Mail lihaodongmail@163.com
12 | * @Description
13 | * @Version 1.0
14 | **/
15 | public interface UserMapper {
16 |
17 | boolean updateUser(@Param("money") BigDecimal money, @Param("id") int id);
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/springboot-thymeleaf/src/test/java/com/li/springbootthymeleaf/SpringbootThymeleafApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootthymeleaf;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootThymeleafApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-freemarker/src/test/java/com/li/springbootfreemarker/SpringbootFreemarkerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootfreemarker;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootFreemarkerApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-mybatis-tx/src/test/java/com/li/springbootmybatistx/SpringbootMybatisTxApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmybatistx;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootMybatisTxApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/bo/ResponseUserToken.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.bo;
2 |
3 | import com.li.springbootsecurity.security.SecurityUser;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Data;
6 |
7 | /**
8 | * @Author 李号东
9 | * @Description //TODO
10 | * @Date 00:42 2019-03-17
11 | * @Param
12 | * @return
13 | **/
14 | @Data
15 | @AllArgsConstructor
16 | public class ResponseUserToken {
17 | private String token;
18 | private SecurityUser userDetail;
19 | }
20 |
--------------------------------------------------------------------------------
/springboot-resttemplate/src/test/java/com/li/springbootresttemplate/SpringbootResttemplateApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootresttemplate;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringbootResttemplateApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-mybatis/src/main/java/com/li/springbootmybatis/server/UserServer.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmybatis.server;
2 |
3 | import com.li.springbootmybatis.model.User;
4 | import org.apache.ibatis.annotations.*;
5 |
6 | import java.util.List;
7 |
8 | public interface UserServer {
9 |
10 | int add(@Param("name") String name);
11 |
12 | int update(@Param("name") String name, @Param("id") int id);
13 |
14 | int delete(int id);
15 |
16 | User findUser(@Param("id") int id);
17 |
18 | List findUserList();
19 | }
20 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/mapper/RoleMapper.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.mapper;
2 |
3 | import com.li.springbootsecurity.model.Role;
4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 | import org.apache.ibatis.annotations.Param;
6 |
7 | /**
8 | *
9 | * Mapper 接口
10 | *
11 | *
12 | * @author lihaodong
13 | * @since 2019-03-14
14 | */
15 | public interface RoleMapper extends BaseMapper {
16 |
17 | Role findRoleByUserId(@Param("userId") Integer userId);
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/mybatis-plus-multi-tenancy/src/test/java/com/xd/mybatisplusmultitenancy/MybatisPlusMultiTenancyApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.xd.mybatisplusmultitenancy;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class MybatisPlusMultiTenancyApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/spring-boot-sharding-table/src/test/java/com/xd/springbootshardingtable/SpringBootShardingTableApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.xd.springbootshardingtable;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringBootShardingTableApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-async/src/main/java/com/li/springbootasync/SpringbootAsyncApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootasync;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.scheduling.annotation.EnableAsync;
6 |
7 | @EnableAsync
8 | @SpringBootApplication
9 | public class SpringbootAsyncApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringbootAsyncApplication.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/springboot-redismq/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | ## Redis数据库索引(默认为0)
2 | spring.redis.database=1
3 | # Redis服务器地址
4 | spring.redis.host=localhost
5 | # Redis服务器连接端口
6 | spring.redis.port=6379
7 | # Redis服务器连接密码
8 | spring.redis.password=root
9 | # 连接池最大连接数(使用负值表示没有限制)
10 | spring.redis.jedis.pool.max-active=8
11 | # 连接池最大阻塞等待时间(使用负值表示没有限制)
12 | spring.redis.jedis.pool.max-wait=30000ms
13 | # 连接池中的最大空闲连接
14 | spring.redis.jedis.pool.max-idle=8
15 | # 连接池中的最小空闲连接
16 | spring.redis.jedis.pool.min-idle=1
17 | # 连接超时时间(毫秒)
18 | spring.redis.timeout=6000ms
19 |
--------------------------------------------------------------------------------
/springboot-async/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | ## Redis数据库索引(默认为0)
2 | spring.redis.database=1
3 | # Redis服务器地址
4 | spring.redis.host=localhost
5 | # Redis服务器连接端口
6 | spring.redis.port=6379
7 | # Redis服务器连接密码
8 | spring.redis.password=root
9 | # 连接池最大连接数(使用负值表示没有限制)
10 | spring.redis.jedis.pool.max-active=8
11 | # 连接池最大阻塞等待时间(使用负值表示没有限制)
12 | spring.redis.jedis.pool.max-wait=30000ms
13 | # 连接池中的最大空闲连接
14 | spring.redis.jedis.pool.max-idle=8
15 | # 连接池中的最小空闲连接
16 | spring.redis.jedis.pool.min-idle=1
17 | # 连接超时时间(毫秒)
18 | spring.redis.timeout=6000ms
19 |
20 |
--------------------------------------------------------------------------------
/spring-boot-sharding-read-write/src/test/java/com/xd/springbootshardingreadwrite/SpringBootShardingReadWriteApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.xd.springbootshardingreadwrite;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class SpringBootShardingReadWriteApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springboot-redis/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #Redis配置
2 | ## Redis数据库索引(默认为0)
3 | spring.redis.database=1
4 | # Redis服务器地址
5 | spring.redis.host=localhost
6 | # Redis服务器连接端口
7 | spring.redis.port=6379
8 | # Redis服务器连接密码
9 | spring.redis.password=root
10 | # 连接池最大连接数(使用负值表示没有限制)
11 | spring.redis.jedis.pool.max-active=8
12 | # 连接池最大阻塞等待时间(使用负值表示没有限制)
13 | spring.redis.jedis.pool.max-wait=30000ms
14 | # 连接池中的最大空闲连接
15 | spring.redis.jedis.pool.max-idle=8
16 | # 连接池中的最小空闲连接
17 | spring.redis.jedis.pool.min-idle=1
18 | # 连接超时时间(毫秒)
19 | spring.redis.timeout=6000ms
20 |
--------------------------------------------------------------------------------
/springboot-timing/src/main/java/com/li/springboottiming/SpringbootTimingApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.springboottiming;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.scheduling.annotation.EnableScheduling;
6 |
7 | @SpringBootApplication
8 | @EnableScheduling
9 | public class SpringbootTimingApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringbootTimingApplication.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/springboot-elasticsearch/src/main/java/com/li/model/EsModel.java:
--------------------------------------------------------------------------------
1 | package com.li.model;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 | import lombok.ToString;
6 |
7 | import java.util.Date;
8 |
9 | /**
10 | * @ClassName EsModel
11 | * @Author lihaodong
12 | * @Date 2018/12/20 09:27
13 | * @Mail lihaodongmail@163.com
14 | * @Description
15 | * @Version 1.0
16 | **/
17 | @Getter
18 | @Setter
19 | @ToString
20 | public class EsModel {
21 |
22 | private String id;
23 | private Integer age;
24 | private String name;
25 | private Date date;
26 | }
27 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/exception/CustomException.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.exception;
2 |
3 | import com.li.springbootsecurity.bo.ResultJson;
4 | import lombok.Getter;
5 |
6 | /**
7 | * @Author 李号东
8 | * @Description 自定义异常
9 | * @Date 00:38 2019-03-17
10 | * @Param
11 | * @return
12 | **/
13 | @Getter
14 | public class CustomException extends RuntimeException{
15 | private ResultJson resultJson;
16 |
17 | public CustomException(ResultJson resultJson) {
18 | this.resultJson = resultJson;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/SpringbootSecurityApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity;
2 |
3 | import org.mybatis.spring.annotation.MapperScan;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 |
7 | @MapperScan("com.li.springbootsecurity.mapper")
8 | @SpringBootApplication
9 | public class SpringbootSecurityApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringbootSecurityApplication.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/springboot-security/src/main/resources/mapper/UserMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/springboot-mybatis-tx/src/main/java/com/li/springbootmybatistx/SpringbootMybatisTxApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmybatistx;
2 |
3 | import org.mybatis.spring.annotation.MapperScan;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 |
7 | @MapperScan("com.li.springbootmybatistx.dao")
8 | @SpringBootApplication
9 | public class SpringbootMybatisTxApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringbootMybatisTxApplication.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/redis-lua-limit/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=spring-boot-redis-lua-limit
2 |
3 | # Redis数据库索引 默认为0
4 | spring.redis.database=0
5 | # Redis地址
6 | spring.redis.host=localhost
7 | # Redis端口 默认6379
8 | spring.redis.port=6379
9 | # Redis服务器连接密码(默认为空)
10 | spring.redis.password=
11 | # 连接池最大连接数(使用负值表示没有限制)
12 | spring.redis.jedis.pool.max-active=8
13 | # 连接池最大阻塞等待时间(使用负值表示没有限制)
14 | spring.redis.jedis.pool.max-wait=-1
15 | # 连接池中的最大空闲连接
16 | spring.redis.jedis.pool.max-idle=8
17 | # 连接池中的最小空闲连接
18 | spring.redis.jedis.pool.min-idle=0
19 | # 连接超时时间(毫秒)
20 | spring.redis.timeout=10000
21 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/mapper/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.mapper;
2 |
3 | import com.baomidou.mybatisplus.core.conditions.Wrapper;
4 | import com.li.springbootsecurity.model.User;
5 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6 | import org.apache.ibatis.annotations.Param;
7 |
8 | /**
9 | *
10 | * Mapper 接口
11 | *
12 | *
13 | * @author lihaodong
14 | * @since 2019-03-14
15 | */
16 | public interface UserMapper extends BaseMapper {
17 |
18 | @Override
19 | User selectOne(@Param("ew") Wrapper wrapper);
20 | }
21 |
--------------------------------------------------------------------------------
/spring-boot-sharding-table/src/main/java/com/xd/springbootshardingtable/SpringBootShardingTableApplication.java:
--------------------------------------------------------------------------------
1 | package com.xd.springbootshardingtable;
2 |
3 | import org.mybatis.spring.annotation.MapperScan;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 |
7 | @MapperScan("com.xd.springbootshardingtable.mapper")
8 | @SpringBootApplication
9 | public class SpringBootShardingTableApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringBootShardingTableApplication.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/springboot-elasticsearch/src/main/java/com/li/model/Book.java:
--------------------------------------------------------------------------------
1 | package com.li.model;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import lombok.ToString;
7 |
8 | import java.util.Date;
9 |
10 | /**
11 | * @ClassName Book
12 | * @Author lihaodong
13 | * @Date 2018/12/20 09:29
14 | * @Mail lihaodongmail@163.com
15 | * @Description
16 | * @Version 1.0
17 | **/
18 | @Getter
19 | @Setter
20 | @ToString
21 | @AllArgsConstructor
22 | public class Book {
23 |
24 |
25 |
26 | String id;
27 | String name;
28 | String message;
29 | Double price;
30 | Date creatDate;
31 | }
32 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/service/IRoleService.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.service;
2 |
3 | import com.li.springbootsecurity.model.Role;
4 | import com.baomidou.mybatisplus.extension.service.IService;
5 | import org.apache.ibatis.annotations.Param;
6 |
7 | /**
8 | *
9 | * 服务类
10 | *
11 | *
12 | * @author lihaodong
13 | * @since 2019-03-14
14 | */
15 | public interface IRoleService extends IService {
16 |
17 | /**
18 | * 根据用户id查找该用户角色
19 | * @param userId
20 | * @return
21 | */
22 | Role findRoleByUserId(@Param("userId") Integer userId);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/mybatis-plus-multi-tenancy/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # 数据源配置
2 | spring.datasource.type=com.zaxxer.hikari.HikariDataSource
3 | spring.datasource.hikari.minimum-idle=3
4 | spring.datasource.hikari.maximum-pool-size=10
5 | # 不能小于30秒,否则默认回到1800秒
6 | spring.datasource.hikari.max-lifetime=30000
7 | spring.datasource.hikari.connection-test-query=SELECT 1
8 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver
9 | spring.datasource.url=jdbc:mysql://localhost:3306/multi?useUnicode=true&characterEncoding=UTF-8
10 | spring.datasource.username=root
11 | spring.datasource.password=root
12 |
13 | logging.level.com.xd.mybatisplusmultitenancy=debug
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/model/Role.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.model;
2 |
3 | import com.baomidou.mybatisplus.annotation.TableName;
4 | import com.baomidou.mybatisplus.extension.activerecord.Model;
5 | import lombok.*;
6 | import lombok.experimental.Accessors;
7 |
8 | /**
9 | * 角色类
10 | * @author lihaodong
11 | * @since 2019-03-14
12 | */
13 | @Setter
14 | @Getter
15 | @Builder
16 | @TableName("role")
17 | public class Role extends Model {
18 |
19 | private static final long serialVersionUID = 1L;
20 |
21 | private Integer id;
22 |
23 | private String name;
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/springboot-mybatis-tx/src/main/resources/mapper/UserMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | UPDATE user set money=#{money} WHERE id=#{id}
13 |
14 |
15 |
--------------------------------------------------------------------------------
/spring-boot-sharding-read-write/src/main/java/com/xd/springbootshardingreadwrite/SpringBootShardingReadWriteApplication.java:
--------------------------------------------------------------------------------
1 | package com.xd.springbootshardingreadwrite;
2 |
3 | import org.mybatis.spring.annotation.MapperScan;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 |
7 |
8 | @MapperScan("com.xd.springbootshardingreadwrite.mapper")
9 | @SpringBootApplication
10 | public class SpringBootShardingReadWriteApplication {
11 |
12 | public static void main(String[] args) {
13 | SpringApplication.run(SpringBootShardingReadWriteApplication.class, args);
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/springbootgrpc/grpc-client/src/main/java/com/li/grpcclient/GrpcClientController.java:
--------------------------------------------------------------------------------
1 | package com.li.grpcclient;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 | import org.springframework.web.bind.annotation.RequestParam;
6 | import org.springframework.web.bind.annotation.RestController;
7 |
8 | @RestController
9 | public class GrpcClientController {
10 |
11 | @Autowired
12 | private GrpcClientService grpcClientService;
13 |
14 | @RequestMapping("/")
15 | public String printMessage(String name) {
16 | return grpcClientService.sendMessage(name);
17 | }
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/springboot-mybatis/src/main/java/com/li/springbootmybatis/model/User.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmybatis.model;
2 |
3 | /**
4 | * @ClassName User
5 | * @Author lihaodong
6 | * @Date 2019/2/19 09:20
7 | * @Mail lihaodongmail@163.com
8 | * @Description
9 | * @Version 1.0
10 | **/
11 |
12 | public class User {
13 |
14 | private int id;
15 | private String name;
16 |
17 | public int getId() {
18 | return id;
19 | }
20 |
21 | public void setId(int id) {
22 | this.id = id;
23 | }
24 |
25 | public String getName() {
26 | return name;
27 | }
28 |
29 | public void setName(String name) {
30 | this.name = name;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/springboot-first-demo/src/main/java/com/li/springbootfirstdemo/SpringbootFirstDemoApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootfirstdemo;
2 |
3 | import org.springframework.boot.CommandLineRunner;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.context.ApplicationContext;
7 | import org.springframework.context.annotation.Bean;
8 |
9 | import java.util.Arrays;
10 |
11 | @SpringBootApplication
12 | public class SpringbootFirstDemoApplication {
13 |
14 | public static void main(String[] args) {
15 | SpringApplication.run(SpringbootFirstDemoApplication.class, args);
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/redis-lua-limit/src/main/java/com/xd/redislualimit/annotation/RateLimit.java:
--------------------------------------------------------------------------------
1 | package com.xd.redislualimit.annotation;
2 |
3 |
4 | import java.lang.annotation.*;
5 |
6 | /**
7 | * @Author 李号东
8 | * @Description 限流注解
9 | * @Date 17:49 2019-05-25
10 | **/
11 | @Target({ElementType.TYPE, ElementType.METHOD})
12 | @Retention(RetentionPolicy.RUNTIME)
13 | @Documented
14 | public @interface RateLimit {
15 |
16 | /**
17 | * 限流唯一标示
18 | *
19 | * @return
20 | */
21 | String key() default "";
22 |
23 | /**
24 | * 限流时间
25 | *
26 | * @return
27 | */
28 | int time();
29 |
30 | /**
31 | * 限流次数
32 | *
33 | * @return
34 | */
35 | int count();
36 | }
37 |
--------------------------------------------------------------------------------
/springboot-first-demo/src/main/java/com/li/springbootfirstdemo/controller/HelloController.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootfirstdemo.controller;
2 |
3 | import org.springframework.web.bind.annotation.GetMapping;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 | import org.springframework.web.bind.annotation.RestController;
6 |
7 | /**
8 | * @ClassName HelloController
9 | * @Author lihaodong
10 | * @Date 2019/2/18 17:28
11 | * @Mail lihaodongmail@163.com
12 | * @Description
13 | * @Version 1.0
14 | **/
15 |
16 | @RestController
17 | public class HelloController {
18 |
19 | @RequestMapping("/index")
20 | public String index() {
21 | return "Hello from Spring Boot!";
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/springboot-security/src/main/resources/mapper/RoleMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
15 |
--------------------------------------------------------------------------------
/springbootgrpc/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/spring-boot-sharding-table/src/main/java/com/xd/springbootshardingtable/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.xd.springbootshardingtable.service;
2 |
3 | import com.baomidou.mybatisplus.extension.service.IService;
4 | import com.xd.springbootshardingtable.entity.User;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * @Classname UserService
10 | * @Description 用户服务类
11 | * @Author 李号东 lihaodongmail@163.com
12 | * @Date 2019-05-26 17:31
13 | * @Version 1.0
14 | */
15 | public interface UserService extends IService {
16 |
17 | /**
18 | * 保存用户信息
19 | * @param entity
20 | * @return
21 | */
22 | @Override
23 | boolean save(User entity);
24 |
25 | /**
26 | * 查询全部用户信息
27 | * @return
28 | */
29 | List getUserList();
30 | }
31 |
--------------------------------------------------------------------------------
/spring-boot-sharding-read-write/src/main/java/com/xd/springbootshardingreadwrite/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.xd.springbootshardingreadwrite.service;
2 |
3 | import com.baomidou.mybatisplus.extension.service.IService;
4 | import com.xd.springbootshardingreadwrite.entity.User;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * @Classname UserService
10 | * @Description 用户服务类
11 | * @Author 李号东 lihaodongmail@163.com
12 | * @Date 2019-05-26 17:31
13 | * @Version 1.0
14 | */
15 | public interface UserService extends IService {
16 |
17 | /**
18 | * 保存用户信息
19 | * @param entity
20 | * @return
21 | */
22 | @Override
23 | boolean save(User entity);
24 |
25 | /**
26 | * 查询全部用户信息
27 | * @return
28 | */
29 | List getUserList();
30 | }
31 |
--------------------------------------------------------------------------------
/springboot-first-demo/src/main/java/com/li/springbootfirstdemo/test/HelloControllerITest.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootfirstdemo.test;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | /**
9 | * @ClassName HelloControllerITest
10 | * @Author lihaodong
11 | * @Date 2019/2/18 17:42
12 | * @Mail lihaodongmail@163.com
13 | * @Description
14 | * @Version 1.0
15 | **/
16 |
17 | @RunWith(SpringRunner.class)
18 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
19 | public class HelloControllerITest {
20 |
21 |
22 | @Test
23 | public void testHello() {
24 | System.out.println("测试");
25 | }
26 |
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/springboot-mybatis-tx/src/main/java/com/li/springbootmybatistx/controller/UserController.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmybatistx.controller;
2 |
3 | import com.li.springbootmybatistx.server.UserServer;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.web.bind.annotation.*;
6 |
7 | /**
8 | * @ClassName UserController
9 | * @Author lihaodong
10 | * @Date 2019/2/19 09:25
11 | * @Mail lihaodongmail@163.com
12 | * @Description
13 | * @Version 1.0
14 | **/
15 |
16 | @RestController
17 | @RequestMapping("/user")
18 | public class UserController {
19 |
20 | @Autowired
21 | UserServer userServer;
22 |
23 | @RequestMapping(value = "/tran", method = RequestMethod.GET)
24 | public void getAccounts() {
25 | userServer.transfer();
26 | }
27 |
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/springbootgrpc/grpc-client/src/main/java/com/li/grpcclient/GrpcClientService.java:
--------------------------------------------------------------------------------
1 | package com.li.grpcclient;
2 |
3 | import com.li.libserver.GreeterGrpc;
4 | import com.li.libserver.GreeterOuterClass;
5 | import io.grpc.Channel;
6 | import lombok.extern.slf4j.Slf4j;
7 | import net.devh.springboot.autoconfigure.grpc.client.GrpcClient;
8 | import org.springframework.stereotype.Service;
9 |
10 | @Service
11 | public class GrpcClientService {
12 |
13 | @GrpcClient("local-grpc-server")
14 | private Channel serverChannel;
15 |
16 | String sendMessage(String name) {
17 | GreeterGrpc.GreeterBlockingStub stub= GreeterGrpc.newBlockingStub(serverChannel);
18 | GreeterOuterClass.HelloReply response = stub.sayHello(GreeterOuterClass.HelloRequest.newBuilder().setName(name).build());
19 | return response.getMessage();
20 |
21 |
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/springboot-swagger2/src/main/java/com/li/springbootswagger2/model/User.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootswagger2.model;
2 |
3 | /**
4 | * @ClassName User
5 | * @Author lihaodong
6 | * @Date 2019/2/21 15:33
7 | * @Mail lihaodongmail@163.com
8 | * @Description
9 | * @Version 1.0
10 | **/
11 |
12 | public class User {
13 |
14 | private int id;
15 | private int age;
16 | private String name;
17 |
18 | public int getId() {
19 | return id;
20 | }
21 |
22 | public void setId(int id) {
23 | this.id = id;
24 | }
25 |
26 | public int getAge() {
27 | return age;
28 | }
29 |
30 | public void setAge(int age) {
31 | this.age = age;
32 | }
33 |
34 | public String getName() {
35 | return name;
36 | }
37 |
38 | public void setName(String name) {
39 | this.name = name;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/springboot-freemarker/src/main/java/com/li/springbootfreemarker/SpringbootFreemarkerApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootfreemarker;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.stereotype.Controller;
6 | import org.springframework.ui.ModelMap;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 |
9 | @Controller
10 | @SpringBootApplication
11 | public class SpringbootFreemarkerApplication {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(SpringbootFreemarkerApplication.class, args);
15 | }
16 |
17 | @RequestMapping("/index")
18 | public String index(ModelMap modelMap){
19 |
20 | modelMap.addAttribute("host","www.lhdyx.cn");
21 |
22 | return "hello";
23 | }
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/springboot-config/src/main/java/com/li/springbootconfig/controller/ConfigController.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootconfig.controller;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 | import org.springframework.web.bind.annotation.RestController;
6 |
7 | /**
8 | * @ClassName ConfigController
9 | * @Author lihaodong
10 | * @Date 2019/2/18 23:10
11 | * @Mail lihaodongmail@163.com
12 | * @Description
13 | * @Version 1.0
14 | **/
15 | @RestController
16 | public class ConfigController {
17 |
18 | @Value("${my.publicNumber}")
19 | private String publicNumber;
20 |
21 | @Value("${my.blog}")
22 | private String webBlog;
23 |
24 | @RequestMapping(value = "/my")
25 | public String miya() {
26 | return "公众号:" + publicNumber + ",网页博客:" + webBlog;
27 | }
28 |
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/spring-boot-sharding-table/src/main/java/com/xd/springbootshardingtable/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.xd.springbootshardingtable.entity;
2 |
3 | import com.baomidou.mybatisplus.annotation.TableName;
4 | import com.baomidou.mybatisplus.extension.activerecord.Model;
5 | import groovy.transform.EqualsAndHashCode;
6 | import lombok.Data;
7 | import lombok.experimental.Accessors;
8 |
9 | /**
10 | * @Classname User
11 | * @Description 用户实体类
12 | * @Author 李号东 lihaodongmail@163.com
13 | * @Date 2019-05-26 17:24
14 | * @Version 1.0
15 | */
16 | @Data
17 | @EqualsAndHashCode(callSuper = true)
18 | @Accessors(chain = true)
19 | @TableName("user")
20 | public class User extends Model {
21 |
22 | /**
23 | * 主键Id
24 | */
25 | private int id;
26 |
27 | /**
28 | * 名称
29 | */
30 | private String name;
31 |
32 | /**
33 | * 年龄
34 | */
35 | private int age;
36 | }
37 |
--------------------------------------------------------------------------------
/springboot-redis/src/main/java/com/li/springbootredis/model/User.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootredis.model;
2 |
3 | /**
4 | * @ClassName User
5 | * @Author lihaodong
6 | * @Date 2019/2/19 21:15
7 | * @Mail lihaodongmail@163.com
8 | * @Description
9 | * @Version 1.0
10 | **/
11 |
12 | public class User {
13 |
14 | private String name;
15 | private String age;
16 |
17 | public String getName() {
18 | return name;
19 | }
20 |
21 | public void setName(String name) {
22 | this.name = name;
23 | }
24 |
25 | public String getAge() {
26 | return age;
27 | }
28 |
29 | public void setAge(String age) {
30 | this.age = age;
31 | }
32 |
33 | @Override
34 | public String toString() {
35 | return "User{" +
36 | "name='" + name + '\'' +
37 | ", age='" + age + '\'' +
38 | '}';
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/spring-boot-sharding-read-write/src/main/java/com/xd/springbootshardingreadwrite/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.xd.springbootshardingreadwrite.entity;
2 |
3 | import com.baomidou.mybatisplus.annotation.TableName;
4 | import com.baomidou.mybatisplus.extension.activerecord.Model;
5 | import groovy.transform.EqualsAndHashCode;
6 | import lombok.Data;
7 | import lombok.experimental.Accessors;
8 |
9 | /**
10 | * @Classname User
11 | * @Description 用户实体类
12 | * @Author 李号东 lihaodongmail@163.com
13 | * @Date 2019-05-26 17:24
14 | * @Version 1.0
15 | */
16 | @Data
17 | @EqualsAndHashCode(callSuper = true)
18 | @Accessors(chain = true)
19 | @TableName("user")
20 | public class User extends Model {
21 |
22 | /**
23 | * 主键Id
24 | */
25 | private int id;
26 |
27 | /**
28 | * 名称
29 | */
30 | private String name;
31 |
32 | /**
33 | * 年龄
34 | */
35 | private int age;
36 | }
37 |
--------------------------------------------------------------------------------
/redis-lua-limit/src/main/resources/redisLimit.lua:
--------------------------------------------------------------------------------
1 | --Lua脚本
2 |
3 | --- 限流KEY资源唯一标识
4 | local key = "rate.limit:" .. KEYS[1]
5 | --- 时间窗最大并发数
6 | local limit = tonumber(ARGV[1])
7 | --- 时间窗内当前并发数
8 | local current = tonumber(redis.call('get', key) or "0")
9 | --如果超出限流大小
10 | if current + 1 > limit then
11 | return 0
12 | else --请求数+1,并设置2秒过期
13 | redis.call("INCRBY", key,"1")
14 | redis.call("expire", key,"2")
15 | return current + 1
16 | end
17 |
18 |
19 |
20 | --IP限流Lua脚本
21 |
22 | --local key = "rate.limit:" .. KEYS[1]
23 | --local limit = tonumber(ARGV[1])
24 | --local expire_time = ARGV[2]
25 | --
26 | --local is_exists = redis.call("EXISTS", key)
27 | --if is_exists == 1 then
28 | -- if redis.call("INCR", key) > limit then
29 | -- return 0
30 | -- else
31 | -- return 1
32 | -- end
33 | --else
34 | -- redis.call("SET", key, 1)
35 | -- redis.call("EXPIRE", key, expire_time)
36 | -- return 1
37 | --end
38 |
--------------------------------------------------------------------------------
/springboot-timing/src/main/java/com/li/springboottiming/task/ScheduledTasks.java:
--------------------------------------------------------------------------------
1 | package com.li.springboottiming.task;
2 |
3 | import org.springframework.scheduling.annotation.Scheduled;
4 | import org.springframework.stereotype.Component;
5 |
6 | import java.text.SimpleDateFormat;
7 | import java.util.Date;
8 |
9 | /**
10 | * @ClassName ScheduledTasks
11 | * @Author lihaodong
12 | * @Date 2019/2/28 12:03
13 | * @Mail lihaodongmail@163.com
14 | * @Description
15 | * @Version 1.0
16 | **/
17 |
18 | @Component
19 | public class ScheduledTasks {
20 |
21 | private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("HH:mm:ss");
22 |
23 | /**
24 | * fixedRate = 3000 每过3秒执行一次
25 | *
26 | */
27 | // @Scheduled(fixedRate = 3000)
28 | @Scheduled(cron = "*/3 * * * * ?")
29 | public void reportCurrentTime() {
30 | System.out.println("现在时间:" + DATE_FORMAT.format(new Date()));
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/service/impl/RoleServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.service.impl;
2 |
3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 | import com.li.springbootsecurity.model.Role;
5 | import com.li.springbootsecurity.mapper.RoleMapper;
6 | import com.li.springbootsecurity.service.IRoleService;
7 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8 | import org.springframework.stereotype.Service;
9 |
10 | import javax.annotation.Resource;
11 |
12 | /**
13 | * 角色服务实现类
14 | * @author lihaodong
15 | * @since 2019-03-14
16 | */
17 | @Service
18 | public class RoleServiceImpl extends ServiceImpl implements IRoleService {
19 |
20 | @Resource
21 | private RoleMapper roleMapper;
22 |
23 | @Override
24 | public Role findRoleByUserId(Integer userId) {
25 | return roleMapper.findRoleByUserId(userId);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/springboot-mybatis-tx/src/main/java/com/li/springbootmybatistx/model/User.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmybatistx.model;
2 |
3 | import java.math.BigDecimal;
4 |
5 | /**
6 | * @ClassName User
7 | * @Author lihaodong
8 | * @Date 2019/2/19 09:20
9 | * @Mail lihaodongmail@163.com
10 | * @Description
11 | * @Version 1.0
12 | **/
13 |
14 | public class User {
15 |
16 | private int id;
17 | private String name;
18 | private BigDecimal money;
19 |
20 | public int getId() {
21 | return id;
22 | }
23 |
24 | public void setId(int id) {
25 | this.id = id;
26 | }
27 |
28 | public String getName() {
29 | return name;
30 | }
31 |
32 | public void setName(String name) {
33 | this.name = name;
34 | }
35 |
36 | public BigDecimal getMoney() {
37 | return money;
38 | }
39 |
40 | public void setMoney(BigDecimal money) {
41 | this.money = money;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/mybatis-plus-multi-tenancy/src/main/java/com/xd/mybatisplusmultitenancy/config/MyContext.java:
--------------------------------------------------------------------------------
1 | package com.xd.mybatisplusmultitenancy.config;
2 |
3 | import org.springframework.stereotype.Component;
4 |
5 | import java.util.Map;
6 | import java.util.concurrent.ConcurrentHashMap;
7 |
8 | /**
9 | * @Classname ApiContext
10 | * @Description 当前系统的上下文
11 | * @Author Created by Lihaodong (alias:小东啊) lihaodongmail@163.com
12 | * @Date 2019-08-09 22:47
13 | * @Version 1.0
14 | */
15 | @Component
16 | public class MyContext {
17 |
18 | private static final String KEY_CURRENT_TENANT_ID = "KEY_CURRENT_PROVIDER_ID";
19 | private static final Map M_CONTEXT = new ConcurrentHashMap<>();
20 |
21 | public void setCurrentTenantId(Long tenantId) {
22 | M_CONTEXT.put(KEY_CURRENT_TENANT_ID, tenantId);
23 | }
24 |
25 | public Long getCurrentTenantId() {
26 | return (Long) M_CONTEXT.get(KEY_CURRENT_TENANT_ID);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # rabbitmq
2 | spring.rabbitmq.host=localhost
3 | # 15672 是管理端端口
4 | spring.rabbitmq.port=5672
5 | # 用户账号
6 | spring.rabbitmq.username=guest
7 | # 用户密码
8 | spring.rabbitmq.password=guest
9 | spring.rabbitmq.virtual-host=/
10 | # 消息发送到交换机确认机制,是否确认回调
11 | spring.rabbitmq.publisher-confirms=true
12 | # 消费者数量
13 | spring.rabbitmq.listener.simple.concurrency= 10
14 | spring.rabbitmq.listener.simple.max-concurrency= 10
15 | # 消费者每次从队列获取的消息数量
16 | spring.rabbitmq.listener.simple.prefetch= 1
17 | # 消费者自动启动
18 | spring.rabbitmq.listener.simple.auto-startup=true
19 | # 消费失败,自动重新入队
20 | spring.rabbitmq.listener.simple.default-requeue-rejected= true
21 | # 启用发送重试
22 | spring.rabbitmq.template.retry.enabled=true
23 | spring.rabbitmq.template.retry.initial-interval=1000ms
24 | spring.rabbitmq.template.retry.max-attempts=3
25 | spring.rabbitmq.template.retry.max-interval=10000ms
26 | spring.rabbitmq.template.retry.multiplier=1.0
27 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/bo/ResultCode.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.bo;
2 |
3 | import lombok.Getter;
4 |
5 | /**
6 | * @Author 李号东
7 | * @Description 状态码
8 | * @Date 00:41 2019-03-17
9 | * @Param
10 | * @return
11 | **/
12 | @Getter
13 | public enum ResultCode {
14 | /*
15 | 请求返回状态码和说明信息
16 | */
17 | SUCCESS(200, "成功"),
18 | BAD_REQUEST(400, "参数或者语法不对"),
19 | UNAUTHORIZED(401, "认证失败"),
20 | LOGIN_ERROR(401, "登陆失败,用户名或密码错误"),
21 | NO_TOKEN(401, "认证失败,缺少头部token值"),
22 | TOKEN_INVALID(401, "认证失败,token值认证失败"),
23 | FORBIDDEN(403, "权限不足,禁止访问"),
24 | NOT_FOUND(404, "请求的资源不存在"),
25 | OPERATE_ERROR(405, "操作失败,请求操作的资源不存在"),
26 | TIME_OUT(408, "请求超时"),
27 | SERVER_ERROR(500, "服务器内部错误");
28 |
29 | private int code;
30 | private String msg;
31 |
32 | ResultCode(int code, String msg) {
33 | this.code = code;
34 | this.msg = msg;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/springboot-thymeleaf/src/main/java/com/li/springbootthymeleaf/SpringbootThymeleafApplication.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootthymeleaf;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.stereotype.Controller;
6 | import org.springframework.ui.ModelMap;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 |
9 | @Controller
10 | @SpringBootApplication
11 | public class SpringbootThymeleafApplication {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(SpringbootThymeleafApplication.class, args);
15 | }
16 |
17 |
18 | @RequestMapping("/index")
19 | public String index(ModelMap modelMap){
20 | // 加入一个属性,模板通过这个属性读取对应的值
21 | modelMap.addAttribute("host","https://www.lhdyx.cn");
22 | // return模板文件的名称,对应src/main/resources/templates/hello.html
23 | return "hello";
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/springbootgrpc/grpc-server/src/main/java/com/li/grpcserver/GreeterService.java:
--------------------------------------------------------------------------------
1 | package com.li.grpcserver;
2 |
3 | import com.li.libserver.GreeterGrpc;
4 | import com.li.libserver.GreeterOuterClass;
5 | import io.grpc.stub.StreamObserver;
6 | import lombok.extern.slf4j.Slf4j;
7 | import net.devh.springboot.autoconfigure.grpc.server.GrpcService;
8 |
9 | @Slf4j
10 | @GrpcService(GreeterOuterClass.class)
11 | public class GreeterService extends GreeterGrpc.GreeterImplBase{
12 |
13 | @Override
14 | public void sayHello(GreeterOuterClass.HelloRequest request, StreamObserver responseObserver) {
15 | String message = "Hello " + request.getName();
16 | final GreeterOuterClass.HelloReply.Builder replyBuilder = GreeterOuterClass.HelloReply.newBuilder().setMessage(message);
17 | responseObserver.onNext(replyBuilder.build());
18 | responseObserver.onCompleted();
19 |
20 | log.info("Returning " +message);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/mybatis-plus-multi-tenancy/src/main/java/com/xd/mybatisplusmultitenancy/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.xd.mybatisplusmultitenancy.entity;
2 |
3 | import com.baomidou.mybatisplus.annotation.IdType;
4 | import com.baomidou.mybatisplus.annotation.TableField;
5 | import com.baomidou.mybatisplus.annotation.TableId;
6 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
7 | import lombok.Data;
8 | import lombok.ToString;
9 | import lombok.experimental.Accessors;
10 |
11 | /**
12 | * @Classname User
13 | * @Description 用户实体类
14 | * @Author Created by Lihaodong (alias:小东啊) lihaodongmail@163.com
15 | * @Date 2019-08-09 22:49
16 | * @Version 1.0
17 | */
18 | @Data
19 | @ToString
20 | @Accessors(chain = true)
21 | public class User {
22 | /**
23 | * 主键
24 | */
25 | @TableId(value = "id", type = IdType.AUTO)
26 | private Long id;
27 | /**
28 | * 姓名
29 | */
30 | private String name;
31 | /**
32 | * 多租户Id
33 | */
34 | private Long tenantId;
35 | }
36 |
--------------------------------------------------------------------------------
/springboot-mybatis/src/main/java/com/li/springbootmybatis/dao/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmybatis.dao;
2 |
3 | import com.li.springbootmybatis.model.User;
4 | import org.apache.ibatis.annotations.*;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * @ClassName UserMapper
10 | * @Author lihaodong
11 | * @Date 2019/2/19 09:18
12 | * @Mail lihaodongmail@163.com
13 | * @Description
14 | * @Version 1.0
15 | **/
16 | @Mapper
17 | public interface UserMapper {
18 |
19 | @Insert("insert into user(name) values(#{name})")
20 | int add(@Param("name") String name);
21 |
22 | @Update("update user set name = #{name} where id = #{id}")
23 | int update(@Param("name") String name, @Param("id") int id);
24 |
25 | @Delete("delete from user where id = #{id}")
26 | int delete(int id);
27 |
28 | @Select("select id, name from user where id = #{id}")
29 | User findUser(@Param("id") int id);
30 |
31 | @Select("select id, name from user")
32 | List findUserList();
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/springboot-redismq/src/main/java/com/li/springbootredismq/test/RedismqTest.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootredismq.test;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.boot.test.context.SpringBootTest;
7 | import org.springframework.data.redis.core.StringRedisTemplate;
8 | import org.springframework.test.context.junit4.SpringRunner;
9 |
10 | /**
11 | * @ClassName RedismqTest
12 | * @Author lihaodong
13 | * @Date 2019/2/23 18:31
14 | * @Mail lihaodongmail@163.com
15 | * @Description
16 | * @Version 1.0
17 | **/
18 |
19 | @RunWith(SpringRunner.class)
20 | @SpringBootTest
21 | public class RedismqTest {
22 |
23 |
24 | @Autowired
25 | StringRedisTemplate stringRedisTemplate;
26 |
27 | @Test
28 | public void test() {
29 | for (int i = 0; i < 10; i++) {
30 | stringRedisTemplate.convertAndSend("chat", "这是我发第" + i + "条的消息啊");
31 | }
32 | }
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/springboot-config/src/main/java/com/li/springbootconfig/model/User.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootconfig.model;
2 |
3 | import org.springframework.boot.context.properties.ConfigurationProperties;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.context.annotation.PropertySource;
6 |
7 | /**
8 | * @ClassName User
9 | * @Author lihaodong
10 | * @Date 2019/2/18 23:39
11 | * @Mail lihaodongmail@163.com
12 | * @Description
13 | * @Version 1.0
14 | **/
15 |
16 | @Configuration
17 | @PropertySource(value = "classpath:my.properties")
18 | @ConfigurationProperties(prefix = "my")
19 | public class User {
20 | private String name;
21 | private int age;
22 |
23 | public String getName() {
24 | return name;
25 | }
26 |
27 | public void setName(String name) {
28 | this.name = name;
29 | }
30 |
31 | public int getAge() {
32 | return age;
33 | }
34 |
35 | public void setAge(int age) {
36 | this.age = age;
37 | }
38 |
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/springboot-mybatis-tx/src/main/java/com/li/springbootmybatistx/server/impl/UserServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmybatistx.server.impl;
2 |
3 | import com.li.springbootmybatistx.dao.UserMapper;
4 | import com.li.springbootmybatistx.server.UserServer;
5 | import org.springframework.stereotype.Service;
6 | import org.springframework.transaction.annotation.Transactional;
7 |
8 | import javax.annotation.Resource;
9 | import java.math.BigDecimal;
10 |
11 | /**
12 | * @ClassName UserServiceImpl
13 | * @Author lihaodong
14 | * @Date 2019/2/19 09:22
15 | * @Mail lihaodongmail@163.com
16 | * @Description
17 | * @Version 1.0
18 | **/
19 | @Service
20 | public class UserServiceImpl implements UserServer {
21 |
22 | @Resource
23 | private UserMapper userMapper;
24 |
25 |
26 | @Transactional
27 | @Override
28 | public void transfer() {
29 | //用户1减10块 用户2加10块
30 | userMapper.updateUser(BigDecimal.valueOf(90), 1);
31 | int i = 1 / 0;
32 | userMapper.updateUser(BigDecimal.valueOf(110), 2);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/service/IUserService.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.service;
2 |
3 | import com.li.springbootsecurity.bo.ResponseUserToken;
4 | import com.li.springbootsecurity.model.User;
5 | import com.baomidou.mybatisplus.extension.service.IService;
6 | import com.li.springbootsecurity.security.SecurityUser;
7 |
8 | /**
9 | *
10 | * 用户服务类
11 | *
12 | *
13 | * @author lihaodong
14 | * @since 2019-03-14
15 | */
16 | public interface IUserService extends IService {
17 |
18 |
19 | /**
20 | * 通过用户名查找用户
21 | *
22 | * @param username 用户名
23 | * @return 用户信息
24 | */
25 | User findByUserName(String username);
26 |
27 | /**
28 | * 登陆
29 | * @param username
30 | * @param password
31 | * @return
32 | */
33 | ResponseUserToken login(String username, String password);
34 |
35 |
36 | /**
37 | * 根据Token获取用户信息
38 | * @param token
39 | * @return
40 | */
41 | SecurityUser getUserByToken(String token);
42 | }
43 |
--------------------------------------------------------------------------------
/springbootgrpc/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/spring-boot-sharding-table/src/main/java/com/xd/springbootshardingtable/controller/UserController.java:
--------------------------------------------------------------------------------
1 | package com.xd.springbootshardingtable.controller;
2 |
3 | import com.xd.springbootshardingtable.entity.User;
4 | import com.xd.springbootshardingtable.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 | * @Classname UserController
13 | * @Description 用户测试控制类
14 | * @Author 李号东 lihaodongmail@163.com
15 | * @Date 2019-05-26 17:36
16 | * @Version 1.0
17 | */
18 | @RestController
19 | public class UserController {
20 |
21 | @Autowired
22 | private UserService userService;
23 |
24 | @GetMapping("/select")
25 | public List select() {
26 | return userService.getUserList();
27 | }
28 |
29 | @GetMapping("/insert")
30 | public Boolean insert(User user) {
31 | return userService.save(user);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/spring-boot-sharding-read-write/src/main/java/com/xd/springbootshardingreadwrite/controller/UserController.java:
--------------------------------------------------------------------------------
1 | package com.xd.springbootshardingreadwrite.controller;
2 |
3 | import com.xd.springbootshardingreadwrite.entity.User;
4 | import com.xd.springbootshardingreadwrite.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 | * @Classname UserController
13 | * @Description 用户测试控制类
14 | * @Author 李号东 lihaodongmail@163.com
15 | * @Date 2019-05-26 17:36
16 | * @Version 1.0
17 | */
18 | @RestController
19 | public class UserController {
20 |
21 | @Autowired
22 | private UserService userService;
23 |
24 | @GetMapping("/select")
25 | public List select() {
26 | return userService.getUserList();
27 | }
28 |
29 | @GetMapping("/insert")
30 | public Boolean insert(User user) {
31 | return userService.save(user);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/model/User.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.model;
2 |
3 | import com.baomidou.mybatisplus.annotation.IdType;
4 | import com.baomidou.mybatisplus.annotation.TableId;
5 | import com.baomidou.mybatisplus.annotation.TableName;
6 | import com.baomidou.mybatisplus.extension.activerecord.Model;
7 | import lombok.*;
8 | import lombok.experimental.Accessors;
9 | import org.springframework.security.core.GrantedAuthority;
10 | import org.springframework.security.core.authority.SimpleGrantedAuthority;
11 | import org.springframework.security.core.userdetails.UserDetails;
12 |
13 | import java.util.ArrayList;
14 | import java.util.Collection;
15 | import java.util.List;
16 |
17 | /**
18 | * 用户类
19 | * @author lihaodong
20 | * @since 2019-03-14
21 | */
22 | @Setter
23 | @Getter
24 | @ToString
25 | @TableName("user")
26 | public class User extends Model{
27 |
28 | private static final long serialVersionUID = 1L;
29 |
30 | private Integer id;
31 |
32 | private String username;
33 |
34 | private String password;
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/spring-boot-sharding-table/src/main/java/com/xd/springbootshardingtable/service/Impl/UserServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.xd.springbootshardingtable.service.Impl;
2 |
3 | import com.baomidou.mybatisplus.core.toolkit.Wrappers;
4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5 | import com.xd.springbootshardingtable.entity.User;
6 | import com.xd.springbootshardingtable.mapper.UserMapper;
7 | import com.xd.springbootshardingtable.service.UserService;
8 | import org.springframework.stereotype.Service;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * @Classname UserServiceImpl
14 | * @Description 用户服务实现类
15 | * @Author 李号东 lihaodongmail@163.com
16 | * @Date 2019-05-26 17:32
17 | * @Version 1.0
18 | */
19 | @Service
20 | public class UserServiceImpl extends ServiceImpl implements UserService {
21 | @Override
22 | public boolean save(User entity) {
23 | return super.save(entity);
24 | }
25 |
26 | @Override
27 | public List getUserList() {
28 | return baseMapper.selectList(Wrappers.lambdaQuery());
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/bo/ResultUtil.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.bo;
2 |
3 | import com.alibaba.fastjson.JSON;
4 | import com.li.springbootsecurity.bo.ResultCode;
5 |
6 | import javax.servlet.http.HttpServletResponse;
7 | import java.io.IOException;
8 | import java.io.PrintWriter;
9 |
10 | /**
11 | * @Classname ResultUtil
12 | * @Description TODO
13 | * @Author 李号东 lihaodongmail@163.com
14 | * @Date 2019-03-17 08:33
15 | * @Version 1.0
16 | */
17 | public class ResultUtil {
18 |
19 | public static void writeJavaScript(HttpServletResponse response, ResultCode resultCode, String msg) throws IOException {
20 | response.setHeader("Access-Control-Allow-Origin", "*");
21 | // 状态
22 | response.setStatus(200);
23 | response.setCharacterEncoding("UTF-8");
24 | response.setContentType("application/json; charset=utf-8");
25 | PrintWriter printWriter = response.getWriter();
26 | printWriter.write(JSON.toJSONString(ResultJson.failure(resultCode,msg)));
27 | printWriter.flush();
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/spring-boot-sharding-read-write/src/main/java/com/xd/springbootshardingreadwrite/service/Impl/UserServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.xd.springbootshardingreadwrite.service.Impl;
2 |
3 | import com.baomidou.mybatisplus.core.toolkit.Wrappers;
4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5 | import com.xd.springbootshardingreadwrite.entity.User;
6 | import com.xd.springbootshardingreadwrite.mapper.UserMapper;
7 | import com.xd.springbootshardingreadwrite.service.UserService;
8 | import org.springframework.stereotype.Service;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * @Classname UserServiceImpl
14 | * @Description 用户服务实现类
15 | * @Author 李号东 lihaodongmail@163.com
16 | * @Date 2019-05-26 17:32
17 | * @Version 1.0
18 | */
19 | @Service
20 | public class UserServiceImpl extends ServiceImpl implements UserService {
21 | @Override
22 | public boolean save(User entity) {
23 | return super.save(entity);
24 | }
25 |
26 | @Override
27 | public List getUserList() {
28 | return baseMapper.selectList(Wrappers.lambdaQuery());
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/springboot-resttemplate/src/main/java/com/li/springbootresttemplate/model/User.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootresttemplate.model;
2 |
3 | /**
4 | * @ClassName User
5 | * @Author lihaodong
6 | * @Date 2019/2/21 15:33
7 | * @Mail lihaodongmail@163.com
8 | * @Description
9 | * @Version 1.0
10 | **/
11 |
12 | public class User {
13 |
14 | private int id;
15 | private int age;
16 | private String name;
17 |
18 | public int getId() {
19 | return id;
20 | }
21 |
22 | public void setId(int id) {
23 | this.id = id;
24 | }
25 |
26 | public int getAge() {
27 | return age;
28 | }
29 |
30 | public void setAge(int age) {
31 | this.age = age;
32 | }
33 |
34 | public String getName() {
35 | return name;
36 | }
37 |
38 | public void setName(String name) {
39 | this.name = name;
40 | }
41 |
42 | @Override
43 | public String toString() {
44 | return "User{" +
45 | "id=" + id +
46 | ", age=" + age +
47 | ", name='" + name + '\'' +
48 | '}';
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/springboot-redismq/src/main/java/com/li/springbootredismq/message/Receiver.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootredismq.message;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 |
7 | import java.util.concurrent.CountDownLatch;
8 |
9 | /**
10 | * @ClassName Receiver
11 | * @Author lihaodong
12 | * @Date 2019/2/23 18:19
13 | * @Mail lihaodongmail@163.com
14 | * @Description 接收者
15 | * @Version 1.0
16 | **/
17 |
18 |
19 | /**
20 | * 这里声明了一个接受者,里面是提供了一个receiveMessage方法
21 | * 下面会使用MessageListenerAdapter对这个接收者进行代理,
22 | * 通过反射把消息传到receiveMessage中,也可以通过实现MessageListener接口来实现消息接受者,
23 | * 这里为了简单使用代理的方式
24 | */
25 | public class Receiver {
26 |
27 | private static final Logger LOGGER = LoggerFactory.getLogger(Receiver.class);
28 |
29 |
30 | private CountDownLatch latch;
31 |
32 | @Autowired
33 | public Receiver(CountDownLatch latch) {
34 | this.latch = latch;
35 | }
36 |
37 |
38 | public void receiveMessage(String message) {
39 | LOGGER.info("Received:" + message + "");
40 | latch.countDown();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/springboot-config/src/main/java/com/li/springbootconfig/controller/MyController.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootconfig.controller;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.boot.context.properties.ConfigurationProperties;
5 | import org.springframework.context.annotation.Configuration;
6 | import org.springframework.context.annotation.PropertySource;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | /**
11 | * @ClassName MyController
12 | * @Author lihaodong
13 | * @Date 2019/2/18 23:33
14 | * @Mail lihaodongmail@163.com
15 | * @Description
16 | * @Version 1.0
17 | **/
18 |
19 | @Configuration
20 | @PropertySource(value = "classpath:my.properties")
21 | @ConfigurationProperties(prefix = "my")
22 | @RestController
23 | public class MyController {
24 |
25 | @Value("${my.name}")
26 | private String name;
27 |
28 | @Value("${my.age}")
29 | private int age;
30 |
31 | @RequestMapping(value = "/user")
32 | public String miya() {
33 | return name + "," + age;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/springboot-resttemplate/src/main/java/com/li/springbootresttemplate/config/RestTemplateConfig.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootresttemplate.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.http.client.ClientHttpRequestFactory;
6 | import org.springframework.http.client.SimpleClientHttpRequestFactory;
7 | import org.springframework.web.client.RestTemplate;
8 |
9 | /**
10 | * @ClassName RestTemplateConfig
11 | * @Author lihaodong
12 | * @Date 2019/2/22 18:14
13 | * @Mail lihaodongmail@163.com
14 | * @Description
15 | * @Version 1.0
16 | **/
17 |
18 | @Configuration
19 | public class RestTemplateConfig {
20 |
21 | @Bean
22 | public RestTemplate restTemplate(ClientHttpRequestFactory factory){
23 | return new RestTemplate(factory);
24 | }
25 |
26 | @Bean
27 | public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
28 | SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
29 | factory.setConnectTimeout(15000);
30 | factory.setReadTimeout(5000);
31 | return factory;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/src/main/java/com/li/springbootrabbitmq/test/MqTest.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootrabbitmq.test;
2 |
3 | import com.li.springbootrabbitmq.rabbitmq.MqSender;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.context.SpringBootTest;
8 | import org.springframework.test.context.junit4.SpringRunner;
9 |
10 | /**
11 | * @ClassName MqTest
12 | * @Author lihaodong
13 | * @Date 2019/2/24 20:54
14 | * @Mail lihaodongmail@163.com
15 | * @Description mq测试
16 | * @Version 1.0
17 | **/
18 | @RunWith(SpringRunner.class)
19 | @SpringBootTest
20 | public class MqTest {
21 |
22 | @Autowired
23 | private MqSender mqSender;
24 |
25 | @Test
26 | public void mq() {
27 | mqSender.send("LiHaodong you're the hero,李浩东是成为海贼王的男人!");
28 | }
29 |
30 | @Test
31 | public void mq01() {
32 | mqSender.sendTopic("LiHaodong you're the hero,李浩东是成为海贼王的男人!");
33 | }
34 | @Test
35 | public void mq02() {
36 | mqSender.sendFanout("LiHaodong you're the hero,李浩东是成为海贼王的男人!");
37 | }
38 |
39 | @Test
40 | public void mq03() {
41 | mqSender.sendHeaders("LiHaodong you're the hero,李浩东是成为海贼王的男人!");
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/springboot-redis/src/main/java/com/li/springbootredis/server/Impl/RedisServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootredis.server.Impl;
2 |
3 | import com.li.springbootredis.server.RedisService;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.data.redis.core.RedisTemplate;
6 | import org.springframework.data.redis.core.StringRedisTemplate;
7 | import org.springframework.stereotype.Service;
8 |
9 | /**
10 | * @ClassName RedisServiceImpl
11 | * @Author lihaodong
12 | * @Date 2019/2/19 21:00
13 | * @Mail lihaodongmail@163.com
14 | * @Description
15 | * @Version 1.0
16 | **/
17 | @Service
18 | public class RedisServiceImpl implements RedisService {
19 |
20 |
21 | /**
22 | * RedisTemplate 优雅操作redis的客户端
23 | * ValueOperations:简单K-V操作
24 | * SetOperations:set类型数据操作
25 | * ZSetOperations:zset类型数据操作
26 | * HashOperations:针对map类型的数据操作
27 | * ListOperations:针对list类型的数据操作
28 | */
29 | @Autowired
30 | RedisTemplate redisTemplate;
31 |
32 | @Override
33 | public void setValue(String key, Object value) {
34 | redisTemplate.opsForValue().set(key, value);
35 | }
36 |
37 | @Override
38 | public Object getValue(String key) {
39 | return redisTemplate.opsForValue().get(key);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/springboot-config/src/main/java/com/li/springbootconfig/controller/ConfigBeanController.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootconfig.controller;
2 |
3 | import com.li.springbootconfig.model.ConfigBean;
4 | import com.li.springbootconfig.model.User;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | /**
11 | * @ClassName ConfigBeanController
12 | * @Author lihaodong
13 | * @Date 2019/2/18 23:26
14 | * @Mail lihaodongmail@163.com
15 | * @Description
16 | * @Version 1.0
17 | **/
18 |
19 | @RestController
20 | @EnableConfigurationProperties({ConfigBean.class,User.class})
21 | public class ConfigBeanController {
22 |
23 | @Autowired
24 | ConfigBean configBean;
25 |
26 | @RequestMapping(value = "/miya")
27 | public String my() {
28 | return configBean.getPublicNumber() + "," + configBean.getName() + ","
29 | + configBean.getBlog() + "," + configBean.getAge();
30 | }
31 |
32 | @Autowired
33 | User user;
34 |
35 | @RequestMapping(value = "/user1")
36 | public String user(){
37 | return user.getName()+user.getAge();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/springboot-mybatis/src/main/java/com/li/springbootmybatis/server/impl/UserServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmybatis.server.impl;
2 |
3 | import com.li.springbootmybatis.dao.UserMapper;
4 | import com.li.springbootmybatis.model.User;
5 | import com.li.springbootmybatis.server.UserServer;
6 | import org.springframework.stereotype.Service;
7 |
8 | import javax.annotation.Resource;
9 | import java.util.List;
10 |
11 | /**
12 | * @ClassName UserServiceImpl
13 | * @Author lihaodong
14 | * @Date 2019/2/19 09:22
15 | * @Mail lihaodongmail@163.com
16 | * @Description
17 | * @Version 1.0
18 | **/
19 | @Service
20 | public class UserServiceImpl implements UserServer {
21 |
22 | @Resource
23 | private UserMapper userMapper;
24 |
25 | @Override
26 | public int add(String name) {
27 | return userMapper.add(name);
28 | }
29 |
30 | @Override
31 | public int update(String name, int id) {
32 | return update(name, id);
33 | }
34 |
35 | @Override
36 | public int delete(int id) {
37 | return userMapper.delete(id);
38 | }
39 |
40 | @Override
41 | public User findUser(int id) {
42 | return userMapper.findUser(id);
43 | }
44 |
45 | @Override
46 | public List findUserList() {
47 | return userMapper.findUserList();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/springboot-config/src/main/java/com/li/springbootconfig/model/ConfigBean.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootconfig.model;
2 |
3 | import org.springframework.boot.context.properties.ConfigurationProperties;
4 | import org.springframework.stereotype.Component;
5 |
6 | /**
7 | * @ClassName ConfigBean
8 | * @Author lihaodong
9 | * @Date 2019/2/18 23:20
10 | * @Mail lihaodongmail@163.com
11 | * @Description
12 | * @Version 1.0
13 | **/
14 | @ConfigurationProperties(prefix = "my")
15 | @Component
16 | public class ConfigBean {
17 |
18 | private String publicNumber;
19 | private String blog;
20 | private String name;
21 | private int age;
22 |
23 | public String getPublicNumber() {
24 | return publicNumber;
25 | }
26 |
27 | public void setPublicNumber(String publicNumber) {
28 | this.publicNumber = publicNumber;
29 | }
30 |
31 | public String getBlog() {
32 | return blog;
33 | }
34 |
35 | public void setBlog(String blog) {
36 | this.blog = blog;
37 | }
38 |
39 | public String getName() {
40 | return name;
41 | }
42 |
43 | public void setName(String name) {
44 | this.name = name;
45 | }
46 |
47 | public int getAge() {
48 | return age;
49 | }
50 |
51 | public void setAge(int age) {
52 | this.age = age;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/redis-lua-limit/src/main/java/com/xd/redislualimit/controller/LimiterController.java:
--------------------------------------------------------------------------------
1 | package com.xd.redislualimit.controller;
2 |
3 | import com.xd.redislualimit.annotation.RateLimit;
4 | import org.apache.commons.lang3.time.DateFormatUtils;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.data.redis.core.RedisTemplate;
7 | import org.springframework.data.redis.support.atomic.RedisAtomicInteger;
8 | import org.springframework.web.bind.annotation.GetMapping;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | import java.util.Date;
12 |
13 | /**
14 | * @Classname LimiterController
15 | * @Description 测试控制层
16 | * @Author 李号东 lihaodongmail@163.com
17 | * @Date 2019-05-25 20:16
18 | * @Version 1.0
19 | */
20 | @RestController
21 | public class LimiterController {
22 |
23 | @Autowired
24 | private RedisTemplate redisTemplate;
25 |
26 | // 10 秒中,可以访问5次
27 | @RateLimit(key = "test", time = 10, count = 5)
28 | @GetMapping("/test")
29 | public String luaLimiter() {
30 | // 简单测试方法
31 | RedisAtomicInteger entityIdCounter = new RedisAtomicInteger("counter", redisTemplate.getConnectionFactory());
32 | String date = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
33 | return date + " 累计访问次数:" + entityIdCounter.getAndIncrement();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/spring-boot-sharding-read-write/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # 配置真实数据源
2 | sharding.jdbc.datasource.names=master1,slave0
3 | # 主数据库
4 | sharding.jdbc.datasource.master1.type=com.zaxxer.hikari.HikariDataSource
5 | sharding.jdbc.datasource.master1.hikari.driver-class-name=com.mysql.cj.jdbc.Driver
6 | sharding.jdbc.datasource.master1.jdbc-url=jdbc:mysql://192.168.0.3:3306/ds0?characterEncoding=utf-8&autoReconnect=true&serverTimezone=Asia/Shanghai
7 | sharding.jdbc.datasource.master1.username=test
8 | sharding.jdbc.datasource.master1.password=12root
9 | # 从数据库
10 | sharding.jdbc.datasource.slave0.type=com.zaxxer.hikari.HikariDataSource
11 | sharding.jdbc.datasource.slave0.hikari.driver-class-name=com.mysql.cj.jdbc.Driver
12 | sharding.jdbc.datasource.slave0.jdbc-url=jdbc:mysql://192.168.0.3:3306/ds0?characterEncoding=utf-8&autoReconnect=true&serverTimezone=Asia/Shanghai
13 | sharding.jdbc.datasource.slave0.username=test
14 | sharding.jdbc.datasource.slave0.password=12root
15 | # 配置读写分离
16 | # 配置从库选择策略,提供轮询与随机,这里选择用轮询
17 | sharding.jdbc.config.masterslave.load-balance-algorithm-type=round_robin
18 | sharding.jdbc.config.masterslave.name=ms
19 | sharding.jdbc.config.masterslave.master-data-source-name=master1
20 | sharding.jdbc.config.masterslave.slave-data-source-names=slave0
21 | # 开启SQL显示,默认值: false,注意:仅配置读写分离时不会打印日志
22 | sharding.jdbc.config.props.sql.show=true
23 | spring.main.allow-bean-definition-overriding=true
--------------------------------------------------------------------------------
/springboot-security/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # 数据源
2 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver
3 | spring.datasource.url=jdbc:mysql://localhost:3306/spring_security?useUnicode=true&characterEncoding=utf-8
4 | spring.datasource.username=root
5 | spring.datasource.password=root
6 |
7 | #mybatis-plus配置
8 | #mapper对应文件
9 | mybatis-plus.mapper-locations=classpath:mapper/*.xml
10 | #实体扫描,多个package用逗号或者分号分隔
11 | mybatis-plus.typeAliasesPackage=com.li.springbootsecurity.model
12 | #执行的sql打印出来 开发/测试
13 | mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
14 |
15 | #Hikari 连接池配置
16 | #最小空闲连接数量
17 | spring.datasource.hikari.minimum-idle=5
18 | #空闲连接存活最大时间,默认600000(10分钟)
19 | spring.datasource.hikari.idle-timeout=180000
20 | #连接池最大连接数,默认是10
21 | spring.datasource.hikari.maximum-pool-size=10
22 | #此属性控制从池返回的连接的默认自动提交行为,默认值:true
23 | spring.datasource.hikari.auto-commit=true
24 | #连接池名字
25 | spring.datasource.hikari.pool-name=HwHikariCP
26 | #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
27 | spring.datasource.hikari.max-lifetime=1800000
28 | #数据库连接超时时间,默认30秒,即30000
29 | spring.datasource.hikari.connection-timeout=30000
30 | spring.datasource.hikari.connection-test-query=SELECT 1
31 |
32 | # JWT配置
33 | # 自定义 服务端根据secret生成token
34 | jwt.secret=mySecret
35 | # 头部
36 | jwt.header=Authorization
37 | # token有效时间
38 | jwt.expiration=604800
39 | # token头部
40 | jwt.tokenHead=Bearer
--------------------------------------------------------------------------------
/springbootgrpc/grpc-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.li
7 | springboot-grpc
8 | 1.0-SNAPSHOT
9 | ../
10 |
11 | grpc-server
12 | 0.0.1-SNAPSHOT
13 | grpc-server
14 | Demo project for Spring Boot
15 |
16 |
17 |
18 | org.springframework.boot
19 | spring-boot-starter-web
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-test
25 | test
26 |
27 |
28 |
29 | io.grpc
30 | grpc-all
31 | ${grpc.version}
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/config/RestAuthenticationAccessDeniedHandler.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.config;
2 |
3 | import com.li.springbootsecurity.bo.ResultCode;
4 | import com.li.springbootsecurity.bo.ResultJson;
5 | import com.li.springbootsecurity.bo.ResultUtil;
6 | import lombok.extern.slf4j.Slf4j;
7 | import org.springframework.security.access.AccessDeniedException;
8 | import org.springframework.security.web.access.AccessDeniedHandler;
9 | import org.springframework.stereotype.Component;
10 |
11 | import javax.servlet.http.HttpServletRequest;
12 | import javax.servlet.http.HttpServletResponse;
13 | import java.io.IOException;
14 | import java.io.PrintWriter;
15 |
16 | /**
17 | * @Author 李号东
18 | * @Description 权限不足处理类 返回403
19 | * @Date 00:31 2019-03-17
20 | * @Param
21 | * @return
22 | **/
23 | @Slf4j
24 | @Component("RestAuthenticationAccessDeniedHandler")
25 | public class RestAuthenticationAccessDeniedHandler implements AccessDeniedHandler {
26 |
27 | @Override
28 | public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException {
29 | StringBuilder msg = new StringBuilder("请求: ");
30 | msg.append(httpServletRequest.getRequestURI()).append(" 权限不足,无法访问系统资源.");
31 | log.info(msg.toString());
32 | ResultUtil.writeJavaScript(httpServletResponse, ResultCode.FORBIDDEN, msg.toString());
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/springboot-mongdb/src/main/java/com/li/springbootmongdb/model/MongoTest.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmongdb.model;
2 |
3 | import org.springframework.data.annotation.Id;
4 | import org.springframework.data.mongodb.core.mapping.Document;
5 | import org.springframework.data.mongodb.core.mapping.Field;
6 |
7 |
8 | @Document(collection = "mongo_test")
9 | public class MongoTest {
10 |
11 | @Id
12 | private String id;
13 | @Field("age")
14 | private Integer age;
15 | @Field("name")
16 | private String name;
17 |
18 | @Field("create_time")
19 | private Long create_time;
20 |
21 | public String getId() {
22 | return id;
23 | }
24 |
25 | public void setId(String id) {
26 | this.id = id;
27 | }
28 |
29 | public Integer getAge() {
30 | return age;
31 | }
32 |
33 | public void setAge(Integer age) {
34 | this.age = age;
35 | }
36 |
37 | public String getName() {
38 | return name;
39 | }
40 |
41 | public void setName(String name) {
42 | this.name = name;
43 | }
44 |
45 | public Long getCreate_time() {
46 | return create_time;
47 | }
48 |
49 | public void setCreate_time(Long create_time) {
50 | this.create_time = create_time;
51 | }
52 |
53 | @Override
54 | public String toString() {
55 | return "MongoTest{" +
56 | "id='" + id + '\'' +
57 | ", age=" + age +
58 | ", name='" + name + '\'' +
59 | '}';
60 | }
61 | }
--------------------------------------------------------------------------------
/springboot-elasticsearch/src/main/java/com/li/elasticsearch/alone/EsAloneConfig.java:
--------------------------------------------------------------------------------
1 | package com.li.elasticsearch.alone;
2 |
3 | import org.elasticsearch.client.transport.TransportClient;
4 | import org.elasticsearch.common.settings.Settings;
5 | import org.elasticsearch.common.transport.TransportAddress;
6 | import org.elasticsearch.transport.client.PreBuiltTransportClient;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.context.annotation.Configuration;
9 |
10 | import java.net.InetAddress;
11 | import java.net.UnknownHostException;
12 |
13 | /**
14 | * @ClassName EsAloneConfig
15 | * @Author lihaodong
16 | * @Date 2018/12/24 09:59
17 | * @Mail lihaodongmail@163.com
18 | * @Description elasticsearch单机配置
19 | * @Version 1.0
20 | **/
21 | @Configuration
22 | public class EsAloneConfig {
23 |
24 | /**
25 | * es的构造
26 | * @return
27 | * @throws UnknownHostException
28 | */
29 | @Bean("TransportClient")
30 | public TransportClient client() throws UnknownHostException {
31 |
32 | // 机器IP 端口号
33 | TransportAddress node = new TransportAddress(
34 | InetAddress.getByName("ip"),
35 | 9300
36 | );
37 |
38 | // 集群名称
39 | Settings settings = Settings.builder()
40 | .put("cluster.name", "es6.2")
41 | .build();
42 |
43 | TransportClient client = new PreBuiltTransportClient(settings);
44 | client.addTransportAddress(node);
45 | return client;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/springboot-redis/src/main/java/com/li/springbootredis/redis/FastJsonRedisSerializer.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootredis.redis;
2 |
3 | import com.alibaba.fastjson.JSON;
4 | import com.alibaba.fastjson.parser.ParserConfig;
5 | import com.alibaba.fastjson.serializer.SerializerFeature;
6 | import org.springframework.data.redis.serializer.RedisSerializer;
7 | import org.springframework.data.redis.serializer.SerializationException;
8 |
9 | import java.nio.charset.Charset;
10 |
11 | /**
12 | *
13 | * @param
14 | */
15 |
16 | public class FastJsonRedisSerializer implements RedisSerializer {
17 |
18 | public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
19 |
20 | static {
21 | ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
22 | }
23 |
24 | private Class clazz;
25 |
26 |
27 |
28 | public FastJsonRedisSerializer(Class clazz) {
29 | super();
30 | this.clazz = clazz;
31 | }
32 |
33 | @Override
34 | public byte[] serialize(T t) throws SerializationException {
35 | if (null == t) {
36 | return new byte[0];
37 | }
38 | return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET);
39 | }
40 |
41 | @Override
42 | public T deserialize(byte[] bytes) throws SerializationException {
43 | if (null == bytes || bytes.length <= 0) {
44 | return null;
45 | }
46 | String str = new String(bytes, DEFAULT_CHARSET);
47 | return (T) JSON.parseObject(str, clazz);
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/springboot-redis/src/main/java/com/li/springbootredis/test/RedisTest.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootredis.test;
2 |
3 | import com.li.springbootredis.model.User;
4 | import com.li.springbootredis.server.RedisService;
5 | import org.junit.Test;
6 | import org.junit.runner.RunWith;
7 | import org.slf4j.Logger;
8 | import org.slf4j.LoggerFactory;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.boot.test.context.SpringBootTest;
11 | import org.springframework.test.context.junit4.SpringRunner;
12 |
13 | /**
14 | * @ClassName RedisTest
15 | * @Author lihaodong
16 | * @Date 2019/2/19 21:04
17 | * @Mail lihaodongmail@163.com
18 | * @Description
19 | * @Version 1.0
20 | **/
21 |
22 | @RunWith(SpringRunner.class)
23 | @SpringBootTest
24 | public class RedisTest {
25 | private static Logger logger = LoggerFactory.getLogger(RedisTest.class);
26 |
27 |
28 | @Autowired
29 | RedisService redisService;
30 |
31 | @Test
32 | public void testRedis() {
33 | redisService.setValue("name", "lihaodong");
34 | redisService.setValue("age", "18");
35 | logger.info(String.valueOf(redisService.getValue("name")));
36 | logger.info(String.valueOf(redisService.getValue("age")));
37 | }
38 |
39 | @Test
40 | public void testModelRedis() {
41 | User user = new User();
42 | user.setName("小王");
43 | user.setAge("22");
44 | redisService.setValue("first",user);
45 | User first = (User) redisService.getValue("first");
46 | logger.info("取出对象为{}",first);
47 | }
48 |
49 |
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/exception/DefaultExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.exception;
2 |
3 | import com.li.springbootsecurity.bo.ResultCode;
4 | import com.li.springbootsecurity.bo.ResultJson;
5 | import lombok.extern.slf4j.Slf4j;
6 | import org.springframework.web.bind.MethodArgumentNotValidException;
7 | import org.springframework.web.bind.annotation.ExceptionHandler;
8 | import org.springframework.web.bind.annotation.RestControllerAdvice;
9 |
10 | import java.util.Objects;
11 |
12 | /**
13 | * @Author 李号东
14 | * @Description 异常处理类
15 | * controller层异常无法捕获处理,需要自己处理
16 | * @Date 00:38 2019-03-17
17 | * @Param
18 | * @return
19 | **/
20 | @RestControllerAdvice
21 | @Slf4j
22 | public class DefaultExceptionHandler {
23 |
24 | /**
25 | * 处理所有自定义异常
26 | * @param e
27 | * @return
28 | */
29 | @ExceptionHandler(CustomException.class)
30 | public ResultJson handleCustomException(CustomException e){
31 | log.error(e.getResultJson().getMsg());
32 | return e.getResultJson();
33 | }
34 |
35 | /**
36 | * 处理参数校验异常
37 | * @param e
38 | * @return
39 | */
40 | @ExceptionHandler(MethodArgumentNotValidException.class)
41 | public ResultJson handleMethodArgumentNotValidException(MethodArgumentNotValidException e){
42 | log.error(Objects.requireNonNull(e.getBindingResult().getFieldError()).getField() + e.getBindingResult().getFieldError().getDefaultMessage());
43 | return ResultJson.failure(ResultCode.BAD_REQUEST, e.getBindingResult().getFieldError().getDefaultMessage());
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/spring-boot-sharding-table/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # 数据源 ds0,ds1
2 | sharding.jdbc.datasource.names=ds0,ds1
3 | # 第一个数据库
4 | sharding.jdbc.datasource.ds0.type=com.zaxxer.hikari.HikariDataSource
5 | sharding.jdbc.datasource.ds0.driver-class-name=com.mysql.jdbc.Driver
6 | sharding.jdbc.datasource.ds0.jdbc-url=jdbc:mysql://localhost:3306/ds0?characterEncoding=utf-8
7 | sharding.jdbc.datasource.ds0.username=root
8 | sharding.jdbc.datasource.ds0.password=root
9 |
10 | # 第二个数据库
11 | sharding.jdbc.datasource.ds1.type=com.zaxxer.hikari.HikariDataSource
12 | sharding.jdbc.datasource.ds1.driver-class-name=com.mysql.jdbc.Driver
13 | sharding.jdbc.datasource.ds1.jdbc-url=jdbc:mysql://localhost:3306/ds1?characterEncoding=utf-8
14 | sharding.jdbc.datasource.ds1.username=root
15 | sharding.jdbc.datasource.ds1.password=root
16 |
17 | # 水平拆分的数据库(表) 配置分库 + 分表策略 行表达式分片策略
18 | # 分库策略
19 | sharding.jdbc.config.sharding.default-database-strategy.inline.sharding-column=id
20 | sharding.jdbc.config.sharding.default-database-strategy.inline.algorithm-expression=ds$->{id % 2}
21 |
22 | # 分表策略 其中user为逻辑表 分表主要取决于age行
23 | sharding.jdbc.config.sharding.tables.user.actual-data-nodes=ds$->{0..1}.user_$->{0..1}
24 | sharding.jdbc.config.sharding.tables.user.table-strategy.inline.sharding-column=age
25 | # 分片算法表达式
26 | sharding.jdbc.config.sharding.tables.user.table-strategy.inline.algorithm-expression=user_$->{age % 2}
27 |
28 | # 主键 UUID 18位数 如果是分布式还要进行一个设置 防止主键重复
29 | #sharding.jdbc.config.sharding.tables.user.key-generator-column-name=id
30 |
31 | # 打印执行的数据库以及语句
32 | sharding.jdbc.config.props..sql.show=true
33 | spring.main.allow-bean-definition-overriding=true
--------------------------------------------------------------------------------
/springboot-timing/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.1.3.RELEASE
9 |
10 |
11 | com.li
12 | springboot-timing
13 | 0.0.1-SNAPSHOT
14 | springboot-timing
15 | Demo project for Spring Boot
16 |
17 |
18 | 1.8
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter
25 |
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-test
30 | test
31 |
32 |
33 |
34 |
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-maven-plugin
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/springboot-config/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.1.0.RELEASE
9 |
10 |
11 | com.li
12 | springboot-config
13 | 0.0.1-SNAPSHOT
14 | springboot-config
15 | Demo project for Spring Boot
16 |
17 |
18 | 1.8
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-web
25 |
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-test
30 | test
31 |
32 |
33 |
34 |
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-maven-plugin
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/bo/ResultJson.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.bo;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * @Author 李号东
9 | * @Description 封装返回
10 | * @Date 00:42 2019-03-17
11 | * @Param
12 | * @return
13 | **/
14 | @Data
15 | public class ResultJson implements Serializable{
16 |
17 | private static final long serialVersionUID = 783015033603078674L;
18 | private int code;
19 | private String msg;
20 | private T data;
21 |
22 | public static ResultJson ok() {
23 | return ok("");
24 | }
25 |
26 | public static ResultJson ok(Object o) {
27 | return new ResultJson(ResultCode.SUCCESS, o);
28 | }
29 |
30 | public static ResultJson failure(ResultCode code) {
31 | return failure(code, "");
32 | }
33 |
34 | public static ResultJson failure(ResultCode code, Object o) {
35 | return new ResultJson(code, o);
36 | }
37 |
38 | public ResultJson (ResultCode resultCode) {
39 | setResultCode(resultCode);
40 | }
41 |
42 | public ResultJson (ResultCode resultCode,T data) {
43 | setResultCode(resultCode);
44 | this.data = data;
45 | }
46 |
47 | public void setResultCode(ResultCode resultCode) {
48 | this.code = resultCode.getCode();
49 | this.msg = resultCode.getMsg();
50 | }
51 |
52 | @Override
53 | public String toString() {
54 | return "{" +
55 | "\"code\":" + code +
56 | ", \"msg\":\"" + msg + '\"' +
57 | ", \"data\":\"" + data + '\"'+
58 | '}';
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/springboot-async/src/main/java/com/li/springbootasync/config/TaskPoolConfig.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootasync.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.scheduling.annotation.AsyncConfigurer;
6 | import org.springframework.scheduling.annotation.EnableAsync;
7 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
8 |
9 | import java.util.concurrent.Executor;
10 | import java.util.concurrent.ThreadPoolExecutor;
11 |
12 | /**
13 | * @ClassName TaskPoolConfig
14 | * @Author lihaodong
15 | * @Date 2019/2/26 22:24
16 | * @Mail lihaodongmail@163.com
17 | * @Description
18 | * @Version 1.0
19 | **/
20 |
21 | @Configuration
22 | public class TaskPoolConfig {
23 |
24 | @Bean(name = "taskExecutor")
25 | public Executor taskExecutor() {
26 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
27 | // 核心线程数
28 | executor.setCorePoolSize(10);
29 | // 最大线程数
30 | executor.setMaxPoolSize(20);
31 | // 缓存队列
32 | executor.setQueueCapacity(200);
33 | // 允许线程的空闲时间60秒
34 | executor.setKeepAliveSeconds(60);
35 | // 线程池名的前缀
36 | executor.setThreadNamePrefix("taskExecutor-");
37 | // 线程池对拒绝任务的处理策略
38 | executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
39 | // 设置线程池关闭的时候等待所有任务都完成再继续销毁其他的Bean
40 | executor.setWaitForTasksToCompleteOnShutdown(true);
41 | // 设置线程池中任务的等待时间,如果超过这个时候还没有销毁就强制销毁,以确保应用最后能够被关闭
42 | executor.setAwaitTerminationSeconds(60);
43 | return executor;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/redis-lua-limit/src/main/java/com/xd/redislualimit/utils/IPUtil.java:
--------------------------------------------------------------------------------
1 | package com.xd.redislualimit.utils;
2 |
3 | import javax.servlet.http.HttpServletRequest;
4 |
5 | /**
6 | * @Classname IPUtil
7 | * @Description TODO
8 | * @Author 李号东 lihaodongmail@163.com
9 | * @Date 2019-05-25 21:07
10 | * @Version 1.0
11 | */
12 | public class IPUtil {
13 |
14 |
15 | /**
16 | * @Author 李号东
17 | * @Description 获取真实IP地址
18 | * @Date 21:08 2019-05-25
19 | **/
20 | public static String getIp(HttpServletRequest request) {
21 | String ipAddress = null;
22 | try {
23 | ipAddress = request.getHeader("x-forwarded-for");
24 | if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
25 | ipAddress = request.getHeader("Proxy-Client-IP");
26 | }
27 | if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
28 | ipAddress = request.getHeader("WL-Proxy-Client-IP");
29 | }
30 | if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
31 | ipAddress = request.getRemoteAddr();
32 | }
33 | // 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
34 | if (ipAddress != null && ipAddress.length() > 15) { // "***.***.***.***".length()
35 | // = 15
36 | if (ipAddress.indexOf(",") > 0) {
37 | ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
38 | }
39 | }
40 | } catch (Exception e) {
41 | ipAddress = "";
42 | }
43 | return ipAddress;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/springboot-thymeleaf/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.1.3.RELEASE
9 |
10 |
11 | com.li
12 | springboot-thymeleaf
13 | 0.0.1-SNAPSHOT
14 | springboot-thymeleaf
15 | Demo project for Spring Boot
16 |
17 |
18 | 1.8
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-thymeleaf
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-starter-web
29 |
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-test
34 | test
35 |
36 |
37 |
38 |
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-maven-plugin
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/springboot-freemarker/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.1.3.RELEASE
9 |
10 |
11 | com.li
12 | springboot-freemarker
13 | 0.0.1-SNAPSHOT
14 | springboot-freemarker
15 | Demo project for Spring Boot
16 |
17 |
18 | 1.8
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-freemarker
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-starter-web
29 |
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-test
34 | test
35 |
36 |
37 |
38 |
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-maven-plugin
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/src/main/java/com/li/springbootrabbitmq/rabbitmq/MqReceiver.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootrabbitmq.rabbitmq;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.amqp.rabbit.annotation.RabbitListener;
6 | import org.springframework.stereotype.Service;
7 |
8 | /**
9 | * @author lihaodong
10 | **/
11 |
12 | @Service
13 | public class MqReceiver {
14 |
15 | private Logger logger = LoggerFactory.getLogger(MqReceiver.class);
16 |
17 | /**
18 | * Direct 交换机模式
19 | */
20 | @RabbitListener(queues = MqConfig.QUEUE)
21 | public void receive(String message){
22 | logger.info("receive message" + message);
23 | }
24 |
25 | /**
26 | * Topic 交换机模式
27 | */
28 | @RabbitListener(queues = MqConfig.TOPIC_QUEUE1)
29 | public void receiveTopic1(String message){
30 | logger.info("receive topic queue1 message: " + message);
31 | }
32 |
33 | @RabbitListener(queues = MqConfig.TOPIC_QUEUE2)
34 | public void receiveTopic2(String message){
35 | logger.info("receive topic queue2 message: " + message);
36 | }
37 |
38 | /**
39 | * Fanout模式 交换机Exchange
40 | */
41 | @RabbitListener(queues = MqConfig.FANOUT_QUEUE1)
42 | public void receiveFanout1(String message){
43 | logger.info("receive fanout queue1 message: " + message);
44 | }
45 |
46 | @RabbitListener(queues = MqConfig.FANOUT_QUEUE2)
47 | public void receiveFanout2(String message){
48 | logger.info("receive fanout queue2 message: " + message);
49 | }
50 |
51 | /**
52 | * Header模式 交换机Exchange
53 | */
54 | @RabbitListener(queues = MqConfig.HEADERS_QUEUE)
55 | public void receiveFanout2(byte[] message){
56 | logger.info("receive headers queue message: " + new String(message));
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/springboot-swagger2/src/main/java/com/li/springbootswagger2/config/Swagger2Config.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootswagger2.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import springfox.documentation.builders.ApiInfoBuilder;
6 | import springfox.documentation.builders.PathSelectors;
7 | import springfox.documentation.builders.RequestHandlerSelectors;
8 | import springfox.documentation.service.ApiInfo;
9 | import springfox.documentation.service.Contact;
10 | import springfox.documentation.spi.DocumentationType;
11 | import springfox.documentation.spring.web.plugins.Docket;
12 | import springfox.documentation.swagger2.annotations.EnableSwagger2;
13 |
14 | /**
15 | * @ClassName Swagger2Config
16 | * @Author lihaodong
17 | * @Date 2019/2/21 15:25
18 | * @Mail lihaodongmail@163.com
19 | * @Description
20 | * @Version 1.0
21 | **/
22 |
23 | @Configuration
24 | @EnableSwagger2
25 | public class Swagger2Config {
26 | @Bean
27 | public Docket createRestApi() {
28 | return new Docket(DocumentationType.SWAGGER_2)
29 | .apiInfo(apiInfo())
30 | .select()
31 | // 请求所在的包
32 | .apis(RequestHandlerSelectors.basePackage("com.li.springbootswagger2.controller"))
33 | .paths(PathSelectors.any())
34 | .build();
35 | }
36 |
37 | private ApiInfo apiInfo() {
38 | return new ApiInfoBuilder()
39 | // 文档标题
40 | .title("springboot利用swagger构建api文档")
41 | // 文档详细描述
42 | .description("简单优雅的restfun风格,http://www.lhdyx.cn")
43 | // 作者
44 | .contact(new Contact("小东", "http://www.lhdyx.cn", "lihaodongmail@163.com"))
45 | // 版本号
46 | .version("1.0")
47 | .build();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/springboot-mongdb/src/main/java/com/li/springbootmongdb/test/MongdbTest.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmongdb.test;
2 |
3 | import com.li.springbootmongdb.SpringbootMongdbApplication;
4 | import com.li.springbootmongdb.dao.MongoTestDao;
5 | import com.li.springbootmongdb.model.MongoTest;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 | import org.slf4j.Logger;
9 | import org.slf4j.LoggerFactory;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.boot.test.context.SpringBootTest;
12 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
13 |
14 |
15 | @RunWith(SpringJUnit4ClassRunner.class)
16 | @SpringBootTest(classes = SpringbootMongdbApplication.class)
17 | public class MongdbTest {
18 |
19 | private final Logger logger = LoggerFactory.getLogger(getClass());
20 |
21 |
22 | @Autowired
23 | private MongoTestDao mtdao;
24 |
25 | @Test
26 | public void saveTest() {
27 | MongoTest mgtest = new MongoTest();
28 | mgtest.setId(String.valueOf(12));
29 | mgtest.setAge(33);
30 | mgtest.setName("ceshi");
31 | mgtest.setCreate_time(System.currentTimeMillis());
32 | mtdao.saveTest(mgtest);
33 | }
34 |
35 | @Test
36 | public void findTestByName() {
37 | MongoTest mgtest = mtdao.findTestByName("ceshi");
38 | System.out.println("mgtest is " + mgtest);
39 | }
40 |
41 | @Test
42 | public void updateTest() {
43 | MongoTest mgtest = new MongoTest();
44 | mgtest.setId(String.valueOf(12));
45 | mgtest.setAge(44);
46 | mgtest.setName("ceshi2");
47 | mtdao.updateTest(mgtest);
48 | }
49 |
50 | @Test
51 | public void deleteTestById() {
52 | mtdao.deleteTestById(String.valueOf(12));
53 | }
54 | @Test
55 | public void distinct() {
56 | mtdao.distinct();
57 | }
58 | }
--------------------------------------------------------------------------------
/springboot-first-demo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 |
7 | org.springframework.boot
8 | spring-boot-starter-parent
9 | 2.1.0.RELEASE
10 |
11 |
12 | com.li
13 | springboot-first-demo
14 | 0.0.1-SNAPSHOT
15 | springboot-first-demo
16 | Demo project for Spring Boot
17 |
18 |
19 | 1.8
20 |
21 |
22 |
23 |
24 | org.springframework.boot
25 | spring-boot-starter-web
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-test
31 | test
32 |
33 |
34 | junit
35 | junit
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-test
40 |
41 |
42 | org.springframework
43 | spring-test
44 | 5.1.2.RELEASE
45 | compile
46 |
47 |
48 |
49 |
50 |
51 |
52 | org.springframework.boot
53 | spring-boot-maven-plugin
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/springbootgrpc/grpc-client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.li
7 | springboot-grpc
8 | 1.0-SNAPSHOT
9 |
10 |
11 |
12 | grpc-client
13 | 0.0.1-SNAPSHOT
14 | grpc-client
15 | Demo project for Spring Boot
16 |
17 |
18 | 1.8
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter
25 |
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-test
30 | test
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-web
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-starter-web
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | org.springframework.boot
47 | spring-boot-maven-plugin
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/redis-lua-limit/src/main/java/com/xd/redislualimit/config/commons.java:
--------------------------------------------------------------------------------
1 | package com.xd.redislualimit.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.core.io.ClassPathResource;
5 | import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
6 | import org.springframework.data.redis.core.RedisTemplate;
7 | import org.springframework.data.redis.core.script.DefaultRedisScript;
8 | import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
9 | import org.springframework.data.redis.serializer.StringRedisSerializer;
10 | import org.springframework.scripting.support.ResourceScriptSource;
11 | import org.springframework.stereotype.Component;
12 |
13 | import java.io.Serializable;
14 |
15 | /**
16 | * @Classname commons
17 | * @Description 配置
18 | * @Author 李号东 lihaodongmail@163.com
19 | * @Date 2019-05-25 20:13
20 | * @Version 1.0
21 | */
22 | @Component
23 | public class commons {
24 |
25 | /**
26 | * 读取限流脚本
27 | *
28 | * @return
29 | */
30 | @Bean
31 | public DefaultRedisScript redisluaScript() {
32 | DefaultRedisScript redisScript = new DefaultRedisScript<>();
33 | redisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("redisLimit.lua")));
34 | //返回类型
35 | redisScript.setResultType(Number.class);
36 | return redisScript;
37 | }
38 |
39 | /**
40 | * RedisTemplate
41 | *
42 | * @return
43 | */
44 | @Bean
45 | public RedisTemplate limitRedisTemplate(LettuceConnectionFactory redisConnectionFactory) {
46 | RedisTemplate template = new RedisTemplate<>();
47 | template.setKeySerializer(new StringRedisSerializer());
48 | template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
49 | template.setConnectionFactory(redisConnectionFactory);
50 | return template;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SpringBootLearn
2 | Spring Boot教程
3 | 转载请标明出处: 原文首发于:https://www.52lhd.com 本文出自李浩东的博客 欢迎star
4 | 
5 |
6 | 扫一扫 支持下作者 谢谢
7 |
8 | # springboot详细教程 文章汇总
9 | springboot详细教程,大多数案例都来自于官方文档,和看到网上的教程,为了更好的理解,加入了个人的改造。
10 |
11 | 源码下载:https://github.com/LiHaodong888/SpringBootLearn,谢谢支持,记得star哦。
12 |
13 | 欢迎访问我的个人博客:https://www.52lhd.com
14 | # 入门篇
15 | [SpringBoot详细教程 | 第一篇:构建第一个Spring Boot工程](https://www.lhdyx.cn/article/54)
16 | # 配置篇
17 | [SpringBoot详细教程 | 第二篇:Spring Boot配置文件详解](https://www.lhdyx.cn/article/55)
18 | # 数据库篇
19 | [SpringBoot详细教程 | 第三篇:Spring Boot整合Mybatis](https://www.lhdyx.cn/article/56)
20 | [SpringBoot详细教程 | 第四篇:Spring Boot开启声明式事务](https://www.lhdyx.cn/article/57)
21 | [SpringBoot详细教程 | 第五篇:Spring Boot整合Redis](https://www.lhdyx.cn/article/58)
22 | [SpringBoot详细教程 | 第六篇:Spring Boot整合Mongdb](https://www.lhdyx.cn/article/59)
23 | # Web开发
24 | [SpringBoot详细教程 | 第七篇:Spring Boot集成swagger2,构建优雅的Restful API](https://www.lhdyx.cn/article/60)
25 | [SpringBoot详细教程 | 第八篇:Spring Boot整合restTemplate消费服务](https://www.lhdyx.cn/article/61)
26 | # 消息服务
27 | [SpringBoot详细教程 | 第九篇:Spring Boot整合Redis简单实现消息队列](https://www.lhdyx.cn/article/62)
28 | [SpringBoot详细教程 | 第十篇:Spring Boot整合RabbitMQ](https://www.lhdyx.cn/article/64)
29 | # 邮箱发送
30 | [SpringBoot详细教程 | 第十一篇:Spring Boot中使用JavaMailSender实现邮件发送:简单邮件、附件邮件、嵌入资源的邮件、模板邮件](https://www.lhdyx.cn/article/63)
31 | # 定时任务和异步任务
32 | [SpringBoot详细教程 | 第十三篇:Spring Boot定时任务](https://www.lhdyx.cn/article/66)
33 | [SpringBoot详细教程 | 第十四篇:Spring Boot使用@Async实现异步调用,线程池以及Future的使用](https://www.lhdyx.cn/article/65)
34 | # 整合分布式
35 | [SpringBoot详细教程 | 第十五篇:Spring Boot整合gRPC](https://www.lhdyx.cn/article/67)
36 | # 模板引擎
37 | [SpringBoot详细教程 | 第十六篇:Spring Boot整合Thymeleaf模板引擎开发Web应用](https://www.lhdyx.cn/article/72)
38 | [SpringBoot详细教程 | 第十七篇:Spring Boot整合FreeMarker模板引擎开发Web应用](https://www.lhdyx.cn/article/74)
39 | # 安全权限
40 | [Spring Boot整合实战Spring Security JWT权限鉴权系统](https://www.lhdyx.cn/article/76)
41 |
42 |
--------------------------------------------------------------------------------
/springboot-mybatis/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.1.3.RELEASE
9 |
10 |
11 | com.li
12 | springboot-mybatis
13 | 0.0.1-SNAPSHOT
14 | springboot-mybatis
15 | Demo project for Spring Boot
16 |
17 |
18 | 1.8
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-web
25 |
26 |
27 | org.mybatis.spring.boot
28 | mybatis-spring-boot-starter
29 | 2.0.0
30 |
31 |
32 |
33 | mysql
34 | mysql-connector-java
35 | runtime
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.boot
48 | spring-boot-maven-plugin
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/springboot-swagger2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.1.3.RELEASE
9 |
10 |
11 | com.li
12 | springboot-swagger2
13 | 0.0.1-SNAPSHOT
14 | springboot-swagger2
15 | Demo project for Spring Boot
16 |
17 |
18 | 1.8
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-web
25 |
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-test
30 | test
31 |
32 |
33 |
34 | io.springfox
35 | springfox-swagger2
36 | 2.6.1
37 |
38 |
39 | io.springfox
40 | springfox-swagger-ui
41 | 2.6.1
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | org.springframework.boot
50 | spring-boot-maven-plugin
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/springboot-mybatis-tx/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.1.0.RELEASE
9 |
10 |
11 | com.li
12 | springboot-mybatis-tx
13 | 0.0.1-SNAPSHOT
14 | springboot-mybatis-tx
15 | Demo project for Spring Boot
16 |
17 |
18 | 1.8
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-web
25 |
26 |
27 | org.mybatis.spring.boot
28 | mybatis-spring-boot-starter
29 | 2.0.0
30 |
31 |
32 |
33 | mysql
34 | mysql-connector-java
35 | runtime
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.boot
48 | spring-boot-maven-plugin
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/src/main/java/com/li/springbootrabbitmq/rabbitmq/MqSender.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootrabbitmq.rabbitmq;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.amqp.core.AmqpTemplate;
6 | import org.springframework.amqp.core.Message;
7 | import org.springframework.amqp.core.MessageProperties;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.stereotype.Service;
10 |
11 | /**
12 | * @author lihaodong
13 | **/
14 | @Service
15 | public class MqSender {
16 |
17 | private Logger logger = LoggerFactory.getLogger(MqSender.class);
18 |
19 | @Autowired
20 | private AmqpTemplate amqpTemplate;
21 |
22 |
23 | /**
24 | * Direct 交换机模式
25 | */
26 | public void send(Object message){
27 | logger.info("send topic message: " + message);
28 | amqpTemplate.convertAndSend(MqConfig.QUEUE, message);
29 | }
30 |
31 | /**
32 | * Topic 交换机模式
33 | */
34 | public void sendTopic(Object message){
35 | logger.info("send topic message: " + message);
36 | amqpTemplate.convertAndSend(MqConfig.TOPIC_EXCHANGE,"topic.key1",message+"1");
37 | amqpTemplate.convertAndSend(MqConfig.TOPIC_EXCHANGE,"topic.key2",message+"2");
38 | }
39 |
40 | /**
41 | * Fanout模式 交换机Exchange
42 | */
43 | public void sendFanout(Object message){
44 | logger.info("send fanout message: " + message);
45 | amqpTemplate.convertAndSend(MqConfig.FANOUT_EXCHANGE,"",message+"1");
46 | }
47 |
48 | /**
49 | * Header模式 交换机Exchange
50 | *"header1","value1"要与队列初始化的时候一样
51 | */
52 | public void sendHeaders(Object message){
53 | logger.info("send headers message: " + message);
54 | MessageProperties properties = new MessageProperties();
55 | properties.setHeader("header1","value1");
56 | properties.setHeader("header2","value2");
57 | Message obj = new Message(message.toString().getBytes(),properties);
58 | amqpTemplate.convertAndSend(MqConfig.HEADERS_EXCHANGE,"",obj);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/springboot-mybatis/src/main/java/com/li/springbootmybatis/controller/UserController.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootmybatis.controller;
2 |
3 | import com.li.springbootmybatis.model.User;
4 | import com.li.springbootmybatis.server.UserServer;
5 | import org.apache.ibatis.annotations.Param;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.web.bind.annotation.*;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * @ClassName UserController
13 | * @Author lihaodong
14 | * @Date 2019/2/19 09:25
15 | * @Mail lihaodongmail@163.com
16 | * @Description
17 | * @Version 1.0
18 | **/
19 |
20 | @RestController
21 | @RequestMapping("/user")
22 | public class UserController {
23 |
24 | @Autowired
25 | UserServer userServer;
26 |
27 | @RequestMapping(value = "/list", method = RequestMethod.GET)
28 | public List getAccounts() {
29 | return userServer.findUserList();
30 | }
31 |
32 | @RequestMapping(value = "/{id}", method = RequestMethod.GET)
33 | public User getAccountById(@PathVariable("id") int id) {
34 | return userServer.findUser(id);
35 | }
36 |
37 | @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
38 | public String updateAccount(@PathVariable("id") int id, @RequestParam(value = "name", required = true) String name) {
39 | int t = userServer.update(name, id);
40 | if (t == 1) {
41 | return "success";
42 | } else {
43 | return "fail";
44 | }
45 | }
46 |
47 | @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
48 | public String delete(@PathVariable(value = "id") int id) {
49 | int t = userServer.delete(id);
50 | if (t == 1) {
51 | return "success";
52 | } else {
53 | return "fail";
54 | }
55 | }
56 |
57 | @RequestMapping(value = "/add", method = RequestMethod.POST)
58 | public String postAccount(String name) {
59 | int t = userServer.add(name);
60 | if (t == 1) {
61 | return "success";
62 | } else {
63 | return "fail";
64 | }
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/springboot-rabbitmq/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.1.3.RELEASE
9 |
10 |
11 | com.li
12 | springboot-rabbitmq
13 | 0.0.1-SNAPSHOT
14 | springboot-rabbitmq
15 | Demo project for Spring Boot
16 |
17 |
18 | 1.8
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-amqp
25 |
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-test
30 | test
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-test
35 |
36 |
37 | junit
38 | junit
39 |
40 |
41 | org.springframework
42 | spring-test
43 | 5.1.2.RELEASE
44 | compile
45 |
46 |
47 |
48 |
49 |
50 |
51 | org.springframework.boot
52 | spring-boot-maven-plugin
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/springboot-resttemplate/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.1.3.RELEASE
9 |
10 |
11 | com.li
12 | springboot-resttemplate
13 | 0.0.1-SNAPSHOT
14 | springboot-resttemplate
15 | Demo project for Spring Boot
16 |
17 |
18 | 1.8
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-web
25 |
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-test
30 | test
31 |
32 |
33 | junit
34 | junit
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-test
39 |
40 |
41 | org.springframework
42 | spring-test
43 | 5.1.2.RELEASE
44 | compile
45 |
46 |
47 |
48 |
49 |
50 |
51 | org.springframework.boot
52 | spring-boot-maven-plugin
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/springboot-security/src/main/java/com/li/springbootsecurity/config/JwtAuthenticationEntryPoint.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootsecurity.config;
2 |
3 | import com.li.springbootsecurity.bo.ResultCode;
4 | import com.li.springbootsecurity.bo.ResultUtil;
5 | import lombok.extern.slf4j.Slf4j;
6 | import org.springframework.security.authentication.BadCredentialsException;
7 | import org.springframework.security.authentication.InsufficientAuthenticationException;
8 | import org.springframework.security.core.AuthenticationException;
9 | import org.springframework.security.web.AuthenticationEntryPoint;
10 | import org.springframework.stereotype.Component;
11 |
12 | import javax.servlet.http.HttpServletRequest;
13 | import javax.servlet.http.HttpServletResponse;
14 | import java.io.IOException;
15 | import java.io.Serializable;
16 |
17 | /**
18 | * @Author 李号东
19 | * @Description 认证失败处理类 返回401
20 | * @Date 00:32 2019-03-17
21 | * @Param
22 | * @return
23 | **/
24 | @Slf4j
25 | @Component
26 | public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint, Serializable {
27 |
28 | private static final long serialVersionUID = -8970718410437077606L;
29 |
30 | @Override
31 | public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException {
32 | StringBuilder msg = new StringBuilder("请求访问: ");
33 | msg.append(httpServletRequest.getRequestURI()).append(" 接口, 经jwt 认证失败,无法访问系统资源.");
34 | log.info(msg.toString());
35 | log.info(e.toString());
36 | // 用户登录时身份认证未通过
37 | if (e instanceof BadCredentialsException) {
38 | log.info("用户登录时身份认证失败.");
39 | ResultUtil.writeJavaScript(httpServletResponse, ResultCode.UNAUTHORIZED, msg.toString());
40 | } else if (e instanceof InsufficientAuthenticationException) {
41 | log.info("缺少请求头参数,Authorization传递是token值所以参数是必须的.");
42 | ResultUtil.writeJavaScript(httpServletResponse, ResultCode.NO_TOKEN, msg.toString());
43 | } else {
44 | log.info("用户token无效.");
45 | ResultUtil.writeJavaScript(httpServletResponse, ResultCode.TOKEN_INVALID, msg.toString());
46 | }
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/mybatis-plus-multi-tenancy/src/main/java/com/xd/mybatisplusmultitenancy/config/MyTenantHandler.java:
--------------------------------------------------------------------------------
1 | package com.xd.mybatisplusmultitenancy.config;
2 |
3 | import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;
4 | import lombok.extern.slf4j.Slf4j;
5 | import net.sf.jsqlparser.expression.Expression;
6 | import net.sf.jsqlparser.expression.LongValue;
7 | import net.sf.jsqlparser.expression.NullValue;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.stereotype.Component;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | /**
15 | * @Classname PreTenantHandler
16 | * @Description 租户处理器 -主要实现mybatis-plus https://mp.baomidou.com/guide/tenant.html
17 | * @Author Created by Lihaodong (alias:小东啊) lihaodongmail@163.com
18 | * @Date 2019-08-09 23:34
19 | * @Version 1.0
20 | */
21 | @Slf4j
22 | @Component
23 | public class MyTenantHandler implements TenantHandler {
24 |
25 | /**
26 | * 多租户标识
27 | */
28 | private static final String SYSTEM_TENANT_ID = "tenant_id";
29 |
30 | /**
31 | * 需要过滤的表
32 | */
33 | private static final List IGNORE_TENANT_TABLES = new ArrayList<>();
34 |
35 | @Autowired
36 | private MyContext apiContext;
37 |
38 |
39 | /**
40 | * 租户Id
41 | *
42 | * @return
43 | */
44 | @Override
45 | public Expression getTenantId() {
46 | // 从当前系统上下文中取出当前请求的服务商ID,通过解析器注入到SQL中。
47 | Long tenantId = apiContext.getCurrentTenantId();
48 | log.debug("当前租户为{}", tenantId);
49 | if (tenantId == null) {
50 | return new NullValue();
51 | }
52 | return new LongValue(tenantId);
53 | }
54 |
55 | /**
56 | * 租户字段名
57 | *
58 | * @return
59 | */
60 | @Override
61 | public String getTenantIdColumn() {
62 | return SYSTEM_TENANT_ID;
63 | }
64 |
65 | /**
66 | * 根据表名判断是否进行过滤
67 | * 忽略掉一些表:如租户表(sys_tenant)本身不需要执行这样的处理
68 | *
69 | * @param tableName
70 | * @return
71 | */
72 | @Override
73 | public boolean doTableFilter(String tableName) {
74 | return IGNORE_TENANT_TABLES.stream().anyMatch((e) -> e.equalsIgnoreCase(tableName));
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/springboot-redis/src/main/java/com/li/springbootredis/redis/RedisConfig.java:
--------------------------------------------------------------------------------
1 | package com.li.springbootredis.redis;
2 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
3 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
4 | import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
5 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.Configuration;
8 | import org.springframework.data.redis.connection.RedisConnectionFactory;
9 | import org.springframework.data.redis.core.RedisOperations;
10 | import org.springframework.data.redis.core.RedisTemplate;
11 | import org.springframework.data.redis.core.StringRedisTemplate;
12 | import org.springframework.data.redis.serializer.StringRedisSerializer;
13 |
14 | /**
15 | * redis配置
16 | */
17 |
18 | @Configuration
19 | @ConditionalOnClass(RedisOperations.class)
20 | @EnableConfigurationProperties(RedisProperties.class)
21 | public class RedisConfig {
22 |
23 | @Bean
24 | @ConditionalOnMissingBean(name = "redisTemplate")
25 | public RedisTemplate