├── spring-boot-integration-01-starter
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── linkedbear
│ │ └── boot
│ │ └── starter
│ │ └── SpringBootStarterApplication.java
└── pom.xml
├── spring-boot-integration-02-junit
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── linkedbear
│ │ │ └── boot
│ │ │ └── junit
│ │ │ ├── SpringBootJUnitApplication.java
│ │ │ └── config
│ │ │ └── WebConfig.java
│ └── test
│ │ └── java
│ │ ├── com
│ │ └── linkedbear
│ │ │ └── boot
│ │ │ └── junit
│ │ │ ├── demo
│ │ │ └── InnerTest.java
│ │ │ └── SpringBootApplicationTest.java
│ │ └── demo
│ │ ├── OuterTest.java
│ │ ├── TestingAStackDemo.java
│ │ └── AssertTest.java
└── pom.xml
├── spring-boot-integration-11-admin
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── linkedbear
│ │ └── boot
│ │ └── actuator
│ │ └── SpringBootAdminApplication.java
└── pom.xml
├── spring-boot-integration-10-swagger
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── linkedbear
│ │ └── boot
│ │ └── swagger
│ │ ├── SpringBootSwaggerApplication.java
│ │ ├── entity
│ │ └── User.java
│ │ ├── config
│ │ ├── Swagger3Configuration.java
│ │ ├── Knife4jConfiguration.java
│ │ └── Swagger2Configuration.java
│ │ └── controller
│ │ └── DemoController.java
└── pom.xml
├── spring-boot-integration-05-elasticsearch
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── linkedbear
│ │ │ └── boot
│ │ │ └── elasticsearch
│ │ │ ├── dao
│ │ │ └── GraphicsCardRepository.java
│ │ │ ├── SpringBootElasticSearchApplication.java
│ │ │ ├── entity
│ │ │ └── GraphicsCard.java
│ │ │ └── config
│ │ │ └── ElasticSearchConfiguration.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── linkedbear
│ │ └── boot
│ │ └── elasticsearch
│ │ ├── DataElasticSearchTest.java
│ │ └── ElasticSearchClientTest.java
└── pom.xml
├── spring-boot-integration-08-rocketmq-consumer
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── linkedbear
│ │ └── boot
│ │ └── rocketmq
│ │ └── consumer
│ │ ├── SpringBootRocketMQConsumerApplication.java
│ │ ├── service
│ │ ├── SoftwareMessageReceiver.java
│ │ ├── TransactionalReceiver.java
│ │ ├── DelayMessageReceiver.java
│ │ ├── DataUpdateTransactionalReceiver.java
│ │ ├── OrderedMessageReceiver.java
│ │ ├── UserDtoMessageReceiver.java
│ │ └── MessageReceiver.java
│ │ └── dto
│ │ └── UserDTO.java
└── pom.xml
├── xxl-job-boot-starter
├── src
│ └── main
│ │ ├── resources
│ │ └── META-INF
│ │ │ └── spring.factories
│ │ └── java
│ │ └── com
│ │ └── linkedbear
│ │ └── boot
│ │ └── xxljob
│ │ ├── autoconfigure
│ │ └── XxlJobAutoConfiguration.java
│ │ └── properties
│ │ └── XxlJobProperties.java
└── pom.xml
├── spring-boot-integration-09-xxljob
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── linkedbear
│ │ └── boot
│ │ └── xxljob
│ │ ├── service
│ │ └── DemoService.java
│ │ ├── SpringBootXxlJobApplication.java
│ │ └── config
│ │ └── XxlJobConfiguration.java
└── pom.xml
├── spring-boot-integration-06-j2cache
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── caffeine.properties
│ │ │ ├── mapper
│ │ │ │ └── UserMapper.xml
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── linkedbear
│ │ │ └── boot
│ │ │ └── j2cache
│ │ │ ├── SpringBootJ2cacheApplication.java
│ │ │ ├── service
│ │ │ ├── UserService.java
│ │ │ ├── AnnotationUserService.java
│ │ │ └── CachedUserService.java
│ │ │ ├── entity
│ │ │ └── User.java
│ │ │ └── mapper
│ │ │ └── UserMapper.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── linkedbear
│ │ └── boot
│ │ └── j2cache
│ │ └── J2cacheTest.java
└── pom.xml
├── spring-boot-integration-03-mybatisplus
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── mapper
│ │ │ │ └── UserMapper.xml
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── linkedbear
│ │ │ └── boot
│ │ │ └── mybatisplus
│ │ │ ├── SpringBootMyBatisPlusApplication.java
│ │ │ ├── service
│ │ │ └── UserService.java
│ │ │ ├── config
│ │ │ └── MyBatisPlusConfiguration.java
│ │ │ ├── mapper
│ │ │ └── UserMapper.java
│ │ │ └── entity
│ │ │ └── User.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── linkedbear
│ │ └── boot
│ │ └── mybatisplus
│ │ ├── CodeGenerator.java
│ │ └── MyBatisPlusTest.java
└── pom.xml
├── spring-boot-integration-09-quartz
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── linkedbear
│ │ └── boot
│ │ └── quartz
│ │ ├── SpringBootQuartzApplication.java
│ │ ├── quartz
│ │ ├── SimpleJob.java
│ │ └── ScheduleService.java
│ │ └── controller
│ │ └── DynamicScheduleController.java
└── pom.xml
├── spring-boot-integration-08-rocketmq-producer
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── linkedbear
│ │ └── boot
│ │ └── rocketmq
│ │ └── producer
│ │ ├── template
│ │ └── DataUpdateRocketMQTemplate.java
│ │ ├── SpringBootRocketMQProducerApplication.java
│ │ ├── dto
│ │ └── UserDTO.java
│ │ ├── service
│ │ ├── DataService.java
│ │ ├── TransactionalStatusChecker.java
│ │ ├── DataUpdateTransactionalStatusChecker.java
│ │ └── MessageSender.java
│ │ └── controller
│ │ └── MessageController.java
└── pom.xml
├── spring-boot-integration-07-security-webmvc
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── linkedbear
│ │ │ │ └── boot
│ │ │ │ └── security
│ │ │ │ ├── dao
│ │ │ │ ├── ResourceDao.java
│ │ │ │ └── UserDao.java
│ │ │ │ ├── SpringBootSecurityApplication.java
│ │ │ │ ├── controller
│ │ │ │ ├── DemoController.java
│ │ │ │ └── ApiController.java
│ │ │ │ ├── jwt
│ │ │ │ ├── TokenPayload.java
│ │ │ │ ├── JsonUtils.java
│ │ │ │ ├── RefreshTokenController.java
│ │ │ │ ├── JwtTokenFilter.java
│ │ │ │ ├── RsaUtils.java
│ │ │ │ └── JwtUtils.java
│ │ │ │ ├── entity
│ │ │ │ ├── Resource.java
│ │ │ │ ├── SecurityUser.java
│ │ │ │ └── User.java
│ │ │ │ ├── service
│ │ │ │ └── UserService.java
│ │ │ │ ├── filter
│ │ │ │ └── ResourceAuthorizationFilter.java
│ │ │ │ └── config
│ │ │ │ └── WebSecurityConfiguration.java
│ │ └── resources
│ │ │ ├── jwt_rsa.pub
│ │ │ ├── application.properties
│ │ │ └── jwt_rsa
│ └── test
│ │ └── java
│ │ └── com
│ │ └── linkedbear
│ │ └── boot
│ │ └── security
│ │ └── AddUserTest.java
└── pom.xml
├── spring-boot-integration-03-mybatis
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── application.properties
│ │ │ └── mapper
│ │ │ │ └── UserMapper.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── linkedbear
│ │ │ └── boot
│ │ │ └── mybatis
│ │ │ ├── SpringBootMyBatisApplication.java
│ │ │ ├── entity
│ │ │ └── User.java
│ │ │ ├── service
│ │ │ └── UserService.java
│ │ │ └── mapper
│ │ │ └── UserMapper.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── linkedbear
│ │ └── boot
│ │ └── mybatis
│ │ └── MyBatisTest.java
└── pom.xml
├── spring-boot-integration-11-actuator
├── src
│ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── linkedbear
│ │ │ └── boot
│ │ │ └── actuator
│ │ │ ├── SpringBootActuatorApplication.java
│ │ │ ├── info
│ │ │ └── ApplicationInfoContributor.java
│ │ │ ├── controller
│ │ │ └── DemoController.java
│ │ │ └── health
│ │ │ └── XxlJobHealthIndicator.java
│ │ └── resources
│ │ └── application.properties
└── pom.xml
├── spring-boot-integration-06-cache
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── mapper
│ │ │ │ └── UserMapper.xml
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── linkedbear
│ │ │ └── boot
│ │ │ └── cache
│ │ │ ├── component
│ │ │ └── UserKeyGenerator.java
│ │ │ ├── SpringBootCacheApplication.java
│ │ │ ├── service
│ │ │ ├── UserService.java
│ │ │ ├── RedisCacheService.java
│ │ │ ├── AnnotationUserService.java
│ │ │ └── CachedUserService.java
│ │ │ ├── entity
│ │ │ └── User.java
│ │ │ ├── config
│ │ │ └── RedisConfiguration.java
│ │ │ └── mapper
│ │ │ └── UserMapper.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── linkedbear
│ │ └── boot
│ │ └── cache
│ │ ├── RedisCacheTest.java
│ │ └── CacheTest.java
└── pom.xml
├── spring-boot-integration-04-springdata
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── linkedbear
│ │ │ │ └── boot
│ │ │ │ └── springdata
│ │ │ │ ├── jpa
│ │ │ │ ├── dao
│ │ │ │ │ ├── DepartmentDao.java
│ │ │ │ │ └── UserDao.java
│ │ │ │ ├── service
│ │ │ │ │ └── UserService.java
│ │ │ │ └── entity
│ │ │ │ │ ├── User.java
│ │ │ │ │ └── Department.java
│ │ │ │ ├── mongo
│ │ │ │ ├── config
│ │ │ │ │ └── MongoConfiguration.java
│ │ │ │ ├── dao
│ │ │ │ │ └── UserRepository.java
│ │ │ │ ├── service
│ │ │ │ │ ├── DepartmentService.java
│ │ │ │ │ └── UserService.java
│ │ │ │ └── entity
│ │ │ │ │ ├── Department.java
│ │ │ │ │ └── User.java
│ │ │ │ ├── redis
│ │ │ │ └── RedisConfiguration.java
│ │ │ │ └── SpringBootDataApplication.java
│ │ └── resources
│ │ │ └── application.properties
│ └── test
│ │ └── java
│ │ └── com
│ │ └── linkedbear
│ │ └── boot
│ │ └── springdata
│ │ ├── JpaTest.java
│ │ └── MongoTest.java
└── pom.xml
└── spring-boot-integration-parent
└── pom.xml
/spring-boot-integration-01-starter/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/spring-boot-integration-02-junit/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/spring-boot-integration-11-admin/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8989
--------------------------------------------------------------------------------
/spring-boot-integration-10-swagger/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | knife4j.enable=true
2 | knife4j.production=false
--------------------------------------------------------------------------------
/spring-boot-integration-05-elasticsearch/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.elasticsearch.rest.uris=http://192.168.217.142:9200
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-consumer/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=32123
2 |
3 | rocketmq.name-server=127.0.0.1:9876
--------------------------------------------------------------------------------
/xxl-job-boot-starter/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
2 | com.linkedbear.boot.xxljob.autoconfigure.XxlJobAutoConfiguration
--------------------------------------------------------------------------------
/spring-boot-integration-09-xxljob/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | xxl.job.admin.addresses=http://127.0.0.1:18899/xxl-job-admin
2 | xxl.job.executor.appname=demo-xxl-job-executor
3 | xxl.job.accessToken=default_token
--------------------------------------------------------------------------------
/spring-boot-integration-06-j2cache/src/main/resources/caffeine.properties:
--------------------------------------------------------------------------------
1 | #########################################
2 | # Caffeine configuration
3 | # [name] = size, xxxx[s|m|h|d]
4 | #########################################
5 |
6 | default = 1000, 30m
--------------------------------------------------------------------------------
/spring-boot-integration-03-mybatisplus/src/main/resources/mapper/UserMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/spring-boot-integration-09-quartz/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver
2 | spring.datasource.url=jdbc:mysql://localhost:3306/sringboot-dao?characterEncoding=utf8
3 | spring.datasource.username=root
4 | spring.datasource.password=123456
5 |
6 | spring.quartz.job-store-type=jdbc
7 | spring.quartz.jdbc.initialize-schema=always
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-producer/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=12321
2 |
3 | rocketmq.name-server=127.0.0.1:9876
4 | rocketmq.producer.group=myproducer
5 |
6 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver
7 | spring.datasource.url=jdbc:mysql://localhost:3306/sringboot-dao?characterEncoding=utf8
8 | spring.datasource.username=root
9 | spring.datasource.password=123456
--------------------------------------------------------------------------------
/spring-boot-integration-09-xxljob/src/main/java/com/linkedbear/boot/xxljob/service/DemoService.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.xxljob.service;
2 |
3 | import com.xxl.job.core.handler.annotation.XxlJob;
4 | import org.springframework.stereotype.Service;
5 |
6 | @Service
7 | public class DemoService {
8 |
9 | @XxlJob("demoTest")
10 | public void test() {
11 | System.out.println("触发定时任务 。。。");
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/spring-boot-integration-02-junit/src/test/java/com/linkedbear/boot/junit/demo/InnerTest.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.junit.demo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | public class InnerTest {
8 |
9 | @Test
10 | public void test3() throws Exception {
11 | System.out.println("Inner test run ......");
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/spring-boot-integration-07-security-webmvc/src/main/java/com/linkedbear/boot/security/dao/ResourceDao.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.security.dao;
2 |
3 | import com.linkedbear.boot.security.entity.Resource;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.stereotype.Repository;
6 |
7 | @Repository
8 | public interface ResourceDao extends JpaRepository {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/spring-boot-integration-07-security-webmvc/src/main/resources/jwt_rsa.pub:
--------------------------------------------------------------------------------
1 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7LnU5y0FQ06iluw5H3iIHnVkAipoS3aUzF00ChmX3PyQEWlvOSQCdEezVz9jKI+vzYtuQ6YuVyppSAeRmgzjwQJPyStisJ14cjk5FBXIK/4GiCwAVfzYc2KVb8M7TazkAaKmGgUBu/4gAkIqjDotduiGCgIbhrOlze8EUi3NTl/h3wTr35lXDI+5JM6dkAfyMQj//hy5iu2Z8PbGhKpqZ1Dv3fqOnIYFW0HtqRr0Q07ATUil1OVM4u23hOy3E0R5Pl0WD6ETlkoxHLwyWcxF2poWgDQjVwTbYTrL0K59v4vNDDgi1iqVpmpIpY07jlzriEn+5hoejVw5HLJy9neGDQIDAQAB
--------------------------------------------------------------------------------
/spring-boot-integration-03-mybatis/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver
2 | spring.datasource.url=jdbc:mysql://localhost:3306/sringboot-dao?characterEncoding=utf8
3 | spring.datasource.username=root
4 | spring.datasource.password=123456
5 |
6 | mybatis.type-aliases-package=com.linkedbear.boot.mybatis.entity
7 | mybatis.mapper-locations=classpath:mapper/*.xml
8 | mybatis.configuration.map-underscore-to-camel-case=true
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-producer/src/main/java/com/linkedbear/boot/rocketmq/producer/template/DataUpdateRocketMQTemplate.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.rocketmq.producer.template;
2 |
3 | import org.apache.rocketmq.spring.annotation.ExtRocketMQTemplateConfiguration;
4 | import org.apache.rocketmq.spring.core.RocketMQTemplate;
5 |
6 | @ExtRocketMQTemplateConfiguration
7 | public class DataUpdateRocketMQTemplate extends RocketMQTemplate {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/spring-boot-integration-02-junit/src/main/java/com/linkedbear/boot/junit/SpringBootJUnitApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.junit;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringBootJUnitApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringBootJUnitApplication.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/spring-boot-integration-02-junit/src/main/java/com/linkedbear/boot/junit/config/WebConfig.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.junit.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.web.client.RestTemplate;
6 |
7 | @Configuration
8 | public class WebConfig {
9 |
10 | @Bean
11 | public RestTemplate restTemplate() {
12 | return new RestTemplate();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/spring-boot-integration-02-junit/src/test/java/demo/OuterTest.java:
--------------------------------------------------------------------------------
1 | package demo;
2 |
3 | import com.linkedbear.boot.junit.SpringBootJUnitApplication;
4 | import org.junit.jupiter.api.Test;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 |
7 | @SpringBootTest(classes = SpringBootJUnitApplication.class)
8 | public class OuterTest {
9 |
10 | @Test
11 | public void test4() throws Exception {
12 | System.out.println("Outer test run ......");
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/spring-boot-integration-09-xxljob/src/main/java/com/linkedbear/boot/xxljob/SpringBootXxlJobApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.xxljob;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringBootXxlJobApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringBootXxlJobApplication.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/spring-boot-integration-01-starter/src/main/java/com/linkedbear/boot/starter/SpringBootStarterApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.starter;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringBootStarterApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringBootStarterApplication.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/spring-boot-integration-05-elasticsearch/src/main/java/com/linkedbear/boot/elasticsearch/dao/GraphicsCardRepository.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.elasticsearch.dao;
2 |
3 | import com.linkedbear.boot.elasticsearch.entity.GraphicsCard;
4 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
5 | import org.springframework.stereotype.Repository;
6 |
7 | @Repository
8 | public interface GraphicsCardRepository extends ElasticsearchRepository {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/spring-boot-integration-11-actuator/src/main/java/com/linkedbear/boot/actuator/SpringBootActuatorApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.actuator;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringBootActuatorApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringBootActuatorApplication.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/spring-boot-integration-07-security-webmvc/src/main/java/com/linkedbear/boot/security/SpringBootSecurityApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.security;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringBootSecurityApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringBootSecurityApplication.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/spring-boot-integration-07-security-webmvc/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.security.user.name=user
2 | spring.security.user.password=000000
3 | spring.security.user.roles=admin
4 |
5 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver
6 | spring.datasource.url=jdbc:mysql://localhost:3306/sringboot-dao?characterEncoding=utf8
7 | spring.datasource.username=root
8 | spring.datasource.password=123456
9 |
10 | spring.jpa.database=mysql
11 | spring.jpa.hibernate.ddl-auto=update
12 | spring.jpa.show-sql=true
--------------------------------------------------------------------------------
/spring-boot-integration-05-elasticsearch/src/main/java/com/linkedbear/boot/elasticsearch/SpringBootElasticSearchApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.elasticsearch;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringBootElasticSearchApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringBootElasticSearchApplication.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/spring-boot-integration-03-mybatis/src/main/resources/mapper/UserMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 | insert into tbl_user (name, tel) values (#{name}, #{tel})
8 |
9 |
10 |
13 |
--------------------------------------------------------------------------------
/spring-boot-integration-06-cache/src/main/resources/mapper/UserMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 | insert into tbl_user (name, tel) values (#{name}, #{tel})
8 |
9 |
10 |
13 |
--------------------------------------------------------------------------------
/spring-boot-integration-06-j2cache/src/main/resources/mapper/UserMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 | insert into tbl_user (name, tel) values (#{name}, #{tel})
8 |
9 |
10 |
13 |
--------------------------------------------------------------------------------
/spring-boot-integration-05-elasticsearch/src/main/java/com/linkedbear/boot/elasticsearch/entity/GraphicsCard.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.elasticsearch.entity;
2 |
3 | import lombok.Data;
4 | import org.springframework.data.annotation.Id;
5 | import org.springframework.data.elasticsearch.annotations.Document;
6 |
7 | @Data
8 | @Document(indexName = "gpu")
9 | public class GraphicsCard {
10 |
11 | @Id
12 | private Integer id;
13 |
14 | private String name;
15 |
16 | private String brand;
17 |
18 | private Integer price;
19 | }
--------------------------------------------------------------------------------
/spring-boot-integration-06-cache/src/main/java/com/linkedbear/boot/cache/component/UserKeyGenerator.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.cache.component;
2 |
3 | import org.springframework.cache.interceptor.KeyGenerator;
4 | import org.springframework.stereotype.Component;
5 |
6 | import java.lang.reflect.Method;
7 |
8 | @Component
9 | public class UserKeyGenerator implements KeyGenerator {
10 |
11 | @Override
12 | public Object generate(Object target, Method method, Object... params) {
13 | return method.getName() + params[0];
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-consumer/src/main/java/com/linkedbear/boot/rocketmq/consumer/SpringBootRocketMQConsumerApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.rocketmq.consumer;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringBootRocketMQConsumerApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringBootRocketMQConsumerApplication.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-producer/src/main/java/com/linkedbear/boot/rocketmq/producer/SpringBootRocketMQProducerApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.rocketmq.producer;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringBootRocketMQProducerApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(SpringBootRocketMQProducerApplication.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/spring-boot-integration-04-springdata/src/main/java/com/linkedbear/boot/springdata/jpa/dao/DepartmentDao.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.springdata.jpa.dao;
2 |
3 | import com.linkedbear.boot.springdata.jpa.entity.Department;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 | import org.springframework.stereotype.Repository;
7 |
8 | @Repository
9 | public interface DepartmentDao extends JpaRepository, JpaSpecificationExecutor {
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/spring-boot-integration-06-cache/src/main/java/com/linkedbear/boot/cache/SpringBootCacheApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.cache;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cache.annotation.EnableCaching;
6 |
7 | @EnableCaching
8 | @SpringBootApplication
9 | public class SpringBootCacheApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringBootCacheApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/spring-boot-integration-06-j2cache/src/main/java/com/linkedbear/boot/j2cache/SpringBootJ2cacheApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.j2cache;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cache.annotation.EnableCaching;
6 |
7 | @EnableCaching
8 | @SpringBootApplication
9 | public class SpringBootJ2cacheApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringBootJ2cacheApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/spring-boot-integration-09-quartz/src/main/java/com/linkedbear/boot/quartz/SpringBootQuartzApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.quartz;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.scheduling.annotation.EnableScheduling;
6 |
7 | @EnableScheduling
8 | @SpringBootApplication
9 | public class SpringBootQuartzApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringBootQuartzApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/spring-boot-integration-11-admin/src/main/java/com/linkedbear/boot/actuator/SpringBootAdminApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.actuator;
2 |
3 | import de.codecentric.boot.admin.server.config.EnableAdminServer;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 |
7 | @EnableAdminServer
8 | @SpringBootApplication
9 | public class SpringBootAdminApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringBootAdminApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/spring-boot-integration-09-quartz/src/main/java/com/linkedbear/boot/quartz/quartz/SimpleJob.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.quartz.quartz;
2 |
3 | import org.quartz.Job;
4 | import org.quartz.JobExecutionContext;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 |
8 | public class SimpleJob implements Job {
9 |
10 | private Logger logger = LoggerFactory.getLogger(this.getClass());
11 |
12 | @Override
13 | public void execute(JobExecutionContext context) {
14 | logger.info("简单任务执行 ...... " + context.getJobDetail().getKey().getName());
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/spring-boot-integration-10-swagger/src/main/java/com/linkedbear/boot/swagger/SpringBootSwaggerApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.swagger;
2 |
3 | import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 |
7 | @SpringBootApplication
8 | @EnableKnife4j
9 | public class SpringBootSwaggerApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringBootSwaggerApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/spring-boot-integration-07-security-webmvc/src/main/java/com/linkedbear/boot/security/dao/UserDao.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.security.dao;
2 |
3 | import com.linkedbear.boot.security.entity.User;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 | import org.springframework.stereotype.Repository;
7 |
8 | import java.util.List;
9 |
10 | @Repository
11 | public interface UserDao extends JpaRepository, JpaSpecificationExecutor {
12 |
13 | List findAllByUsername(String username);
14 | }
15 |
--------------------------------------------------------------------------------
/spring-boot-integration-04-springdata/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver
2 | spring.datasource.url=jdbc:mysql://localhost:3306/sringboot-dao?characterEncoding=utf8
3 | spring.datasource.username=root
4 | spring.datasource.password=123456
5 |
6 | spring.jdbc.template.max-rows=100
7 |
8 | spring.jpa.database=mysql
9 | spring.jpa.hibernate.ddl-auto=update
10 | spring.jpa.show-sql=true
11 |
12 | spring.redis.host=localhost
13 | spring.redis.port=6379
14 |
15 | spring.data.mongodb.host=127.0.0.1
16 | spring.data.mongodb.port=27017
17 | spring.data.mongodb.database=spring-data
--------------------------------------------------------------------------------
/spring-boot-integration-11-actuator/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | management.endpoints.enabled-by-default=true
2 | management.endpoints.web.exposure.include=*
3 | management.endpoint.health.show-details=always
4 |
5 | xxl.job.admin-addresses=http://127.0.0.1:18899/xxl-job-admin
6 | xxl.job.appname=demo-xxl-job-executor
7 | xxl.job.address=http://192.168.50.130:9999
8 |
9 | info.appName=spring-boot-integration-11-actuator
10 | info.version=@project.version@
11 |
12 | spring.application.name=spring-boot-integration-11-actuator
13 | spring.boot.admin.client.url=http://localhost:8989
14 | spring.boot.admin.client.instance.prefer-ip=true
--------------------------------------------------------------------------------
/spring-boot-integration-09-quartz/src/main/java/com/linkedbear/boot/quartz/quartz/ScheduleService.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.quartz.quartz;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.scheduling.annotation.Scheduled;
6 | import org.springframework.stereotype.Service;
7 |
8 | @Service
9 | public class ScheduleService {
10 |
11 | private static final Logger LOGGER = LoggerFactory.getLogger(ScheduleService.class);
12 |
13 | @Scheduled(cron = "0/5 * * * * *")
14 | public void test() {
15 | LOGGER.info("ScheduleService test invoke ......");
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/spring-boot-integration-07-security-webmvc/src/main/java/com/linkedbear/boot/security/controller/DemoController.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.security.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 | @RestController
8 | public class DemoController {
9 |
10 | @GetMapping("/demo")
11 | public String demo() {
12 | return "demo";
13 | }
14 |
15 | @GetMapping("/getData")
16 | public String getData(String name) {
17 | return "userData-" + name;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/spring-boot-integration-03-mybatis/src/main/java/com/linkedbear/boot/mybatis/SpringBootMyBatisApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.mybatis;
2 |
3 | import org.mybatis.spring.annotation.MapperScan;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.transaction.annotation.EnableTransactionManagement;
7 |
8 | @MapperScan
9 | @EnableTransactionManagement
10 | @SpringBootApplication
11 | public class SpringBootMyBatisApplication {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(SpringBootMyBatisApplication.class, args);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/spring-boot-integration-06-cache/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver
2 | spring.datasource.url=jdbc:mysql://localhost:3306/sringboot-dao?characterEncoding=utf8
3 | spring.datasource.username=root
4 | spring.datasource.password=123456
5 | #spring.cache.type=redis
6 | spring.cache.redis.use-key-prefix=true
7 | spring.cache.redis.key-prefix=boot
8 | spring.cache.redis.time-to-live=10s
9 |
10 | mybatis.type-aliases-package=com.linkedbear.boot.cache.entity
11 | mybatis.mapper-locations=classpath:mapper/*.xml
12 | mybatis.configuration.map-underscore-to-camel-case=true
13 |
14 | logging.level.com.linkedbear.boot.cache.mapper.UserMapper=debug
--------------------------------------------------------------------------------
/spring-boot-integration-03-mybatisplus/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver
2 | spring.datasource.url=jdbc:mysql://localhost:3306/sringboot-dao?characterEncoding=utf8
3 | spring.datasource.username=root
4 | spring.datasource.password=123456
5 |
6 | mybatis-plus.type-aliases-package=com.linkedbear.boot.mybatisplus.entity
7 | mybatis-plus.mapper-locations=classpath:mapper/*.xml
8 | mybatis-plus.configuration.map-underscore-to-camel-case=true
9 |
10 | mybatis-plus.global-config.db-config.logic-delete-field=deleted
11 | mybatis-plus.global-config.db-config.logic-delete-value=1
12 | mybatis-plus.global-config.db-config.logic-not-delete-value=0
--------------------------------------------------------------------------------
/spring-boot-integration-03-mybatisplus/src/main/java/com/linkedbear/boot/mybatisplus/SpringBootMyBatisPlusApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.mybatisplus;
2 |
3 | import org.mybatis.spring.annotation.MapperScan;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.transaction.annotation.EnableTransactionManagement;
7 |
8 | @MapperScan
9 | @EnableTransactionManagement
10 | @SpringBootApplication
11 | public class SpringBootMyBatisPlusApplication {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(SpringBootMyBatisPlusApplication.class, args);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/spring-boot-integration-04-springdata/src/main/java/com/linkedbear/boot/springdata/mongo/config/MongoConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.springdata.mongo.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.data.mongodb.MongoDatabaseFactory;
6 | import org.springframework.data.mongodb.MongoTransactionManager;
7 |
8 | @Configuration(proxyBeanMethods = false)
9 | public class MongoConfiguration {
10 |
11 | @Bean
12 | public MongoTransactionManager mongoTransactionManager(MongoDatabaseFactory databaseFactory) {
13 | return new MongoTransactionManager(databaseFactory);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-consumer/src/main/java/com/linkedbear/boot/rocketmq/consumer/service/SoftwareMessageReceiver.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.rocketmq.consumer.service;
2 |
3 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
4 | import org.apache.rocketmq.spring.core.RocketMQListener;
5 | import org.springframework.stereotype.Component;
6 |
7 | @Component
8 | @RocketMQMessageListener(topic = "test-tags", consumerGroup = "tagsconsumer", selectorExpression = "software")
9 | public class SoftwareMessageReceiver implements RocketMQListener {
10 |
11 | @Override
12 | public void onMessage(String message) {
13 | System.out.println("收到software消息:" + message);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/spring-boot-integration-04-springdata/src/main/java/com/linkedbear/boot/springdata/mongo/dao/UserRepository.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.springdata.mongo.dao;
2 |
3 | import com.linkedbear.boot.springdata.mongo.entity.User;
4 | import org.springframework.data.mongodb.repository.MongoRepository;
5 | import org.springframework.stereotype.Repository;
6 |
7 | import java.util.List;
8 |
9 | @Repository
10 | public interface UserRepository extends MongoRepository {
11 |
12 | User findByName(String name);
13 |
14 | List findAllByNameLike(String nameLike);
15 |
16 | List findAllByAgeGreaterThan(Integer age);
17 |
18 | List findAllByNameInOrderByAgeDesc(List names);
19 | }
20 |
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-consumer/src/main/java/com/linkedbear/boot/rocketmq/consumer/service/TransactionalReceiver.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.rocketmq.consumer.service;
2 |
3 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
4 | import org.apache.rocketmq.spring.core.RocketMQListener;
5 | import org.springframework.stereotype.Component;
6 |
7 | @Component
8 | @RocketMQMessageListener(topic = "test-transactional", consumerGroup = "transactionalconsumer")
9 | public class TransactionalReceiver implements RocketMQListener {
10 |
11 | @Override
12 | public void onMessage(String message) {
13 | System.out.println("接收到事务消息!");
14 | System.out.println(message);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-consumer/src/main/java/com/linkedbear/boot/rocketmq/consumer/service/DelayMessageReceiver.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.rocketmq.consumer.service;
2 |
3 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
4 | import org.apache.rocketmq.spring.core.RocketMQListener;
5 | import org.springframework.stereotype.Component;
6 |
7 | @Component
8 | @RocketMQMessageListener(topic = "test-delay", consumerGroup = "delayconsumer")
9 | public class DelayMessageReceiver implements RocketMQListener {
10 |
11 | @Override
12 | public void onMessage(String message) {
13 | System.out.println("接收到消息:" + message);
14 | System.out.println(System.currentTimeMillis());
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/spring-boot-integration-parent/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | org.springframework.boot
9 | spring-boot-starter-parent
10 | 2.5.14
11 |
12 |
13 | com.linkedbear.boot
14 | spring-boot-integration-parent
15 | 1.0.0-RELEASE
16 | pom
17 |
18 |
19 |
--------------------------------------------------------------------------------
/spring-boot-integration-02-junit/src/test/java/com/linkedbear/boot/junit/SpringBootApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.junit;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.web.client.RestTemplate;
7 |
8 | @SpringBootTest
9 | public class SpringBootApplicationTest {
10 |
11 | @Autowired
12 | private RestTemplate restTemplate;
13 |
14 | @Test
15 | public void test1() {
16 | System.out.println("SpringBootApplicationTest test1 run ......");
17 | }
18 |
19 | @Test
20 | public void test2() {
21 | System.out.println(restTemplate);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-consumer/src/main/java/com/linkedbear/boot/rocketmq/consumer/service/DataUpdateTransactionalReceiver.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.rocketmq.consumer.service;
2 |
3 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
4 | import org.apache.rocketmq.spring.core.RocketMQListener;
5 | import org.springframework.stereotype.Component;
6 |
7 | @Component
8 | @RocketMQMessageListener(topic = "test-transactionalupdate", consumerGroup = "transactionalupdateconsumer")
9 | public class DataUpdateTransactionalReceiver implements RocketMQListener {
10 |
11 | @Override
12 | public void onMessage(String message) {
13 | System.out.println("接收到update事务消息!");
14 | System.out.println(message);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-consumer/src/main/java/com/linkedbear/boot/rocketmq/consumer/service/OrderedMessageReceiver.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.rocketmq.consumer.service;
2 |
3 | import org.apache.rocketmq.spring.annotation.ConsumeMode;
4 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
5 | import org.apache.rocketmq.spring.core.RocketMQListener;
6 | import org.springframework.stereotype.Component;
7 |
8 | @Component
9 | @RocketMQMessageListener(topic = "test-ordered", consumerGroup = "orderedconsumer", consumeMode = ConsumeMode.ORDERLY)
10 | public class OrderedMessageReceiver implements RocketMQListener {
11 |
12 | @Override
13 | public void onMessage(String message) {
14 | System.out.println(message);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-consumer/src/main/java/com/linkedbear/boot/rocketmq/consumer/service/UserDtoMessageReceiver.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.rocketmq.consumer.service;
2 |
3 | import com.linkedbear.boot.rocketmq.consumer.dto.UserDTO;
4 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
5 | import org.apache.rocketmq.spring.core.RocketMQListener;
6 | import org.springframework.stereotype.Component;
7 |
8 | @Component
9 | @RocketMQMessageListener(topic = "test-dto", consumerGroup = "dtoconsumer")
10 | public class UserDtoMessageReceiver implements RocketMQListener {
11 |
12 | @Override
13 | public void onMessage(UserDTO message) {
14 | System.out.println("接收到DTO消息");
15 | System.out.println(message.toString());
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/spring-boot-integration-11-actuator/src/main/java/com/linkedbear/boot/actuator/info/ApplicationInfoContributor.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.actuator.info;
2 |
3 | import org.springframework.boot.actuate.info.Info;
4 | import org.springframework.boot.actuate.info.InfoContributor;
5 | import org.springframework.stereotype.Component;
6 |
7 | import java.util.HashMap;
8 | import java.util.Map;
9 |
10 | @Component
11 | public class ApplicationInfoContributor implements InfoContributor {
12 |
13 | @Override
14 | public void contribute(Info.Builder builder) {
15 | builder.withDetail("appName", "spring-boot-integration-11-actuator-contributor");
16 | Map data = new HashMap<>();
17 | data.put("version", "1.0.0");
18 | builder.withDetails(data);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/spring-boot-integration-04-springdata/src/main/java/com/linkedbear/boot/springdata/redis/RedisConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.springdata.redis;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.data.redis.connection.RedisConnectionFactory;
6 | import org.springframework.data.redis.core.RedisTemplate;
7 |
8 | //@Configuration(proxyBeanMethods = false)
9 | public class RedisConfiguration {
10 |
11 | @Bean
12 | public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
13 | RedisTemplate redisTemplate = new RedisTemplate<>();
14 | redisTemplate.setConnectionFactory(redisConnectionFactory);
15 | return redisTemplate;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/spring-boot-integration-04-springdata/src/main/java/com/linkedbear/boot/springdata/SpringBootDataApplication.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.springdata;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
6 | import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
7 | import org.springframework.transaction.annotation.EnableTransactionManagement;
8 |
9 | @SpringBootApplication
10 | @EnableJpaRepositories
11 | @EnableMongoRepositories
12 | @EnableTransactionManagement
13 | public class SpringBootDataApplication {
14 |
15 | public static void main(String[] args) {
16 | SpringApplication.run(SpringBootDataApplication.class, args);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/spring-boot-integration-06-cache/src/main/java/com/linkedbear/boot/cache/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.cache.service;
2 |
3 | import com.linkedbear.boot.cache.entity.User;
4 | import com.linkedbear.boot.cache.mapper.UserMapper;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 |
8 | import java.util.List;
9 |
10 | @Service
11 | public class UserService {
12 |
13 | @Autowired
14 | private UserMapper userMapper;
15 |
16 | public User get(Integer id) {
17 | return userMapper.get(id);
18 | }
19 |
20 | public List findAll() {
21 | return userMapper.findAll();
22 | }
23 |
24 | public List findAllByName(String name) {
25 | return userMapper.findAllByNameLike(name);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/spring-boot-integration-06-j2cache/src/main/java/com/linkedbear/boot/j2cache/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.j2cache.service;
2 |
3 | import com.linkedbear.boot.j2cache.entity.User;
4 | import com.linkedbear.boot.j2cache.mapper.UserMapper;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 |
8 | import java.util.List;
9 |
10 | @Service
11 | public class UserService {
12 |
13 | @Autowired
14 | private UserMapper userMapper;
15 |
16 | public User get(Integer id) {
17 | return userMapper.get(id);
18 | }
19 |
20 | public List findAll() {
21 | return userMapper.findAll();
22 | }
23 |
24 | public List findAllByName(String name) {
25 | return userMapper.findAllByNameLike(name);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/spring-boot-integration-04-springdata/src/main/java/com/linkedbear/boot/springdata/mongo/service/DepartmentService.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.springdata.mongo.service;
2 |
3 | import com.linkedbear.boot.springdata.mongo.entity.Department;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.data.mongodb.core.MongoTemplate;
6 | import org.springframework.stereotype.Service;
7 | import org.springframework.transaction.annotation.Transactional;
8 |
9 | @Service
10 | public class DepartmentService {
11 |
12 | @Autowired
13 | private MongoTemplate mongoTemplate;
14 |
15 | @Transactional(rollbackFor = Exception.class)
16 | public void save() {
17 | Department department = new Department();
18 | department.setName("dept");
19 | department.setTel("1234321");
20 | mongoTemplate.save(department);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/spring-boot-integration-06-cache/src/test/java/com/linkedbear/boot/cache/RedisCacheTest.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.cache;
2 |
3 | import com.linkedbear.boot.cache.service.RedisCacheService;
4 | import org.junit.jupiter.api.Test;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.boot.test.context.SpringBootTest;
7 |
8 | @SpringBootTest
9 | public class RedisCacheTest {
10 |
11 | @Autowired
12 | private RedisCacheService redisCacheService;
13 |
14 | @Test
15 | public void test1() throws Exception {
16 | redisCacheService.getName(1);
17 | redisCacheService.getName(1);
18 | redisCacheService.getName(1);
19 | }
20 |
21 | @Test
22 | public void test2() throws Exception {
23 | redisCacheService.getUser(1);
24 | redisCacheService.getUser(1);
25 | redisCacheService.getUser(1);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/spring-boot-integration-07-security-webmvc/src/main/java/com/linkedbear/boot/security/jwt/TokenPayload.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.security.jwt;
2 |
3 | import org.springframework.security.core.userdetails.User;
4 |
5 | import java.util.Date;
6 |
7 | public class TokenPayload {
8 |
9 | private String id;
10 |
11 | private User user;
12 |
13 | private Date expiration;
14 |
15 | public String getId() {
16 | return id;
17 | }
18 |
19 | public void setId(String id) {
20 | this.id = id;
21 | }
22 |
23 | public User getUser() {
24 | return user;
25 | }
26 |
27 | public void setUser(User user) {
28 | this.user = user;
29 | }
30 |
31 | public Date getExpiration() {
32 | return expiration;
33 | }
34 |
35 | public void setExpiration(Date expiration) {
36 | this.expiration = expiration;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/spring-boot-integration-03-mybatis/src/main/java/com/linkedbear/boot/mybatis/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.mybatis.entity;
2 |
3 | public class User {
4 |
5 | private Integer id;
6 |
7 | private String name;
8 |
9 | private String tel;
10 |
11 | @Override
12 | public String toString() {
13 | return "User{" + "id=" + id + ", name='" + name + '\'' + ", tel='" + tel + '\'' + '}';
14 | }
15 |
16 | public Integer getId() {
17 | return id;
18 | }
19 |
20 | public void setId(Integer id) {
21 | this.id = id;
22 | }
23 |
24 | public String getName() {
25 | return name;
26 | }
27 |
28 | public void setName(String name) {
29 | this.name = name;
30 | }
31 |
32 | public String getTel() {
33 | return tel;
34 | }
35 |
36 | public void setTel(String tel) {
37 | this.tel = tel;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/spring-boot-integration-11-actuator/src/main/java/com/linkedbear/boot/actuator/controller/DemoController.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.actuator.controller;
2 |
3 | import io.micrometer.core.instrument.Counter;
4 | import io.micrometer.core.instrument.MeterRegistry;
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 javax.annotation.PostConstruct;
10 |
11 | @RestController
12 | public class DemoController {
13 |
14 | @Autowired
15 | private MeterRegistry meterRegistry;
16 |
17 | private Counter counter;
18 |
19 | @PostConstruct
20 | public void init() {
21 | counter = meterRegistry.counter("demo.request");
22 | }
23 |
24 | @GetMapping("/demo")
25 | public String demo() {
26 | counter.increment();
27 | return "demo";
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/spring-boot-integration-04-springdata/src/main/java/com/linkedbear/boot/springdata/mongo/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.springdata.mongo.service;
2 |
3 | import com.linkedbear.boot.springdata.mongo.dao.UserRepository;
4 | import com.linkedbear.boot.springdata.mongo.entity.User;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 | import org.springframework.transaction.annotation.Transactional;
8 |
9 | @Service("mongoUserService")
10 | public class UserService {
11 |
12 | @Autowired
13 | private UserRepository userRepository;
14 |
15 | @Transactional(rollbackFor = Exception.class)
16 | public void saveAndPrint() {
17 | User user = new User();
18 | user.setName("save");
19 | user.setAge(20);
20 | userRepository.save(user);
21 |
22 | int i = 1 / 0;
23 |
24 | System.out.println(userRepository.findAll());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/spring-boot-integration-05-elasticsearch/src/main/java/com/linkedbear/boot/elasticsearch/config/ElasticSearchConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.elasticsearch.config;
2 |
3 | import org.apache.http.HttpHost;
4 | import org.elasticsearch.client.RestClient;
5 | import org.elasticsearch.client.RestClientBuilder;
6 | import org.elasticsearch.client.RestHighLevelClient;
7 | import org.springframework.beans.factory.annotation.Value;
8 | import org.springframework.context.annotation.Bean;
9 | import org.springframework.context.annotation.Configuration;
10 |
11 | //@Configuration(proxyBeanMethods = false)
12 | public class ElasticSearchConfiguration {
13 |
14 | @Value("${spring.elasticsearch.rest.uris}")
15 | private String esHost;
16 |
17 | @Bean(destroyMethod = "close")
18 | public RestHighLevelClient restHighLevelClient() {
19 | RestClientBuilder builder = RestClient.builder(HttpHost.create(esHost));
20 | return new RestHighLevelClient(builder);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/spring-boot-integration-07-security-webmvc/src/main/java/com/linkedbear/boot/security/controller/ApiController.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.security.controller;
2 |
3 | import com.linkedbear.boot.security.entity.User;
4 | import com.linkedbear.boot.security.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.RequestMapping;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | @RestController
11 | @RequestMapping("/api")
12 | public class ApiController {
13 |
14 | @Autowired
15 | private UserService userService;
16 |
17 | @GetMapping("/test")
18 | public String test() {
19 | return "test";
20 | }
21 |
22 | @GetMapping("/getUser")
23 | public String getUser(Integer id) {
24 | System.out.println("进入getUser方法!");
25 | return userService.get(id).getName();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/spring-boot-integration-03-mybatis/src/main/java/com/linkedbear/boot/mybatis/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.mybatis.service;
2 |
3 | import com.linkedbear.boot.mybatis.entity.User;
4 | import com.linkedbear.boot.mybatis.mapper.UserMapper;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 | import org.springframework.transaction.annotation.Transactional;
8 |
9 | import java.util.List;
10 |
11 | @Service
12 | public class UserService {
13 |
14 | @Autowired
15 | private UserMapper userMapper;
16 |
17 | @Transactional(rollbackFor = Exception.class)
18 | public void test() {
19 | User user = new User();
20 | user.setName("test mybatis");
21 | user.setTel("7654321");
22 | userMapper.save(user);
23 |
24 | // int i = 1 / 0;
25 |
26 | List userList = userMapper.findAll();
27 | userList.forEach(System.out::println);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/spring-boot-integration-06-cache/src/main/java/com/linkedbear/boot/cache/service/RedisCacheService.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.cache.service;
2 |
3 | import com.linkedbear.boot.cache.entity.User;
4 | import com.linkedbear.boot.cache.mapper.UserMapper;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.cache.annotation.Cacheable;
7 | import org.springframework.data.redis.cache.RedisCacheManager;
8 | import org.springframework.stereotype.Service;
9 |
10 | import java.util.Map;
11 |
12 | @Service
13 | public class RedisCacheService {
14 |
15 | @Autowired
16 | private UserMapper userMapper;
17 |
18 | @Cacheable(value = "getName")
19 | public String getName(Integer i) {
20 | System.out.println("getName invoke ......");
21 | return "name" + i;
22 | }
23 |
24 | @Cacheable(value = "getUser", cacheManager = "userCacheManager")
25 | public User getUser(Integer id) {
26 | return userMapper.get(id);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/spring-boot-integration-04-springdata/src/main/java/com/linkedbear/boot/springdata/jpa/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.springdata.jpa.service;
2 |
3 | import com.linkedbear.boot.springdata.jpa.dao.UserDao;
4 | import com.linkedbear.boot.springdata.jpa.entity.User;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 | import org.springframework.transaction.annotation.Transactional;
8 |
9 | import java.util.List;
10 |
11 | @Service
12 | public class UserService {
13 |
14 | @Autowired
15 | private UserDao userDao;
16 |
17 | @Transactional(rollbackFor = Exception.class)
18 | public void test() {
19 | User user = new User();
20 | user.setName("test mybatis");
21 | user.setTel("7654321");
22 | userDao.save(user);
23 |
24 | // int i = 1 / 0;
25 |
26 | List userList = userDao.findAll();
27 | userList.forEach(System.out::println);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/spring-boot-integration-03-mybatis/src/test/java/com/linkedbear/boot/mybatis/MyBatisTest.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.mybatis;
2 |
3 | import com.linkedbear.boot.mybatis.entity.User;
4 | import com.linkedbear.boot.mybatis.mapper.UserMapper;
5 | import com.linkedbear.boot.mybatis.service.UserService;
6 | import org.junit.jupiter.api.Test;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.boot.test.context.SpringBootTest;
9 |
10 | import java.util.List;
11 |
12 | @SpringBootTest
13 | public class MyBatisTest {
14 |
15 | @Autowired
16 | private UserMapper userMapper;
17 |
18 | @Autowired
19 | private UserService userService;
20 |
21 | @Test
22 | public void test1() {
23 | userService.test();
24 | }
25 |
26 | @Test
27 | public void test2() {
28 | List users = userMapper.findAll();
29 | System.out.println(users);
30 | }
31 |
32 | @Test
33 | public void test3() throws Exception {
34 | userMapper.excuteDDL();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/spring-boot-integration-06-cache/src/main/java/com/linkedbear/boot/cache/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.cache.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | public class User implements Serializable {
6 | private static final long serialVersionUID = 1L;
7 |
8 | private Integer id;
9 |
10 | private String name;
11 |
12 | private String tel;
13 |
14 | @Override
15 | public String toString() {
16 | return "User{" + "id=" + id + ", name='" + name + '\'' + ", tel='" + tel + '\'' + '}';
17 | }
18 |
19 | public Integer getId() {
20 | return id;
21 | }
22 |
23 | public void setId(Integer id) {
24 | this.id = id;
25 | }
26 |
27 | public String getName() {
28 | return name;
29 | }
30 |
31 | public void setName(String name) {
32 | this.name = name;
33 | }
34 |
35 | public String getTel() {
36 | return tel;
37 | }
38 |
39 | public void setTel(String tel) {
40 | this.tel = tel;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/spring-boot-integration-06-j2cache/src/main/java/com/linkedbear/boot/j2cache/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.j2cache.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | public class User implements Serializable {
6 | private static final long serialVersionUID = 1L;
7 |
8 | private Integer id;
9 |
10 | private String name;
11 |
12 | private String tel;
13 |
14 | @Override
15 | public String toString() {
16 | return "User{" + "id=" + id + ", name='" + name + '\'' + ", tel='" + tel + '\'' + '}';
17 | }
18 |
19 | public Integer getId() {
20 | return id;
21 | }
22 |
23 | public void setId(Integer id) {
24 | this.id = id;
25 | }
26 |
27 | public String getName() {
28 | return name;
29 | }
30 |
31 | public void setName(String name) {
32 | this.name = name;
33 | }
34 |
35 | public String getTel() {
36 | return tel;
37 | }
38 |
39 | public void setTel(String tel) {
40 | this.tel = tel;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/spring-boot-integration-03-mybatisplus/src/main/java/com/linkedbear/boot/mybatisplus/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.mybatisplus.service;
2 |
3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 | import com.linkedbear.boot.mybatisplus.entity.User;
5 | import com.linkedbear.boot.mybatisplus.mapper.UserMapper;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 | import org.springframework.transaction.annotation.Transactional;
9 |
10 | import java.util.List;
11 |
12 | @Service
13 | public class UserService extends ServiceImpl {
14 |
15 | @Autowired
16 | private UserMapper userMapper;
17 |
18 | @Transactional(rollbackFor = Exception.class)
19 | public void test() {
20 | User user = new User();
21 | user.setName("test mybatisplus");
22 | user.setTel("7654321");
23 | userMapper.insert(user);
24 |
25 | // int i = 1 / 0;
26 |
27 | List userList = userMapper.selectList(null);
28 | userList.forEach(System.out::println);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/spring-boot-integration-03-mybatisplus/src/main/java/com/linkedbear/boot/mybatisplus/config/MyBatisPlusConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.mybatisplus.config;
2 |
3 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
4 | import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
5 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
6 | import com.baomidou.mybatisplus.extension.plugins.pagination.dialects.MySqlDialect;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.context.annotation.Configuration;
9 |
10 | @Configuration(proxyBeanMethods = false)
11 | public class MyBatisPlusConfiguration {
12 |
13 | @Bean
14 | public MybatisPlusInterceptor mybatisPlusInterceptor() {
15 | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
16 | // 添加乐观锁插件
17 | interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
18 | // 添加分页插件
19 | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(new MySqlDialect()));
20 | return interceptor;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/spring-boot-integration-03-mybatisplus/src/main/java/com/linkedbear/boot/mybatisplus/mapper/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.mybatisplus.mapper;
2 |
3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 | import com.baomidou.mybatisplus.core.metadata.IPage;
5 | import com.linkedbear.boot.mybatisplus.entity.User;
6 | import org.apache.ibatis.annotations.Mapper;
7 | import org.apache.ibatis.annotations.Param;
8 | import org.springframework.stereotype.Repository;
9 |
10 | import java.util.List;
11 | import java.util.Map;
12 |
13 | @Mapper
14 | @Repository
15 | public interface UserMapper extends BaseMapper {
16 |
17 | /**
18 | * 使用IPage作为入参和返回值
19 | * @param query
20 | * @return
21 | */
22 | IPage page(IPage query);
23 |
24 | /**
25 | * 使用集合作为返回值
26 | * @param query
27 | * @return
28 | */
29 | List pageList(IPage query);
30 |
31 | /**
32 | * 使用IPage和其他参数共同作为入参
33 | * @param page
34 | * @param params
35 | * @return
36 | */
37 | IPage pageParams(@Param("page") IPage page, @Param("params") Map params);
38 | }
39 |
--------------------------------------------------------------------------------
/spring-boot-integration-04-springdata/src/main/java/com/linkedbear/boot/springdata/mongo/entity/Department.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.springdata.mongo.entity;
2 |
3 | import org.springframework.data.annotation.Id;
4 | import org.springframework.data.mongodb.core.mapping.Document;
5 |
6 | @Document(collection = "doc_dept")
7 | public class Department {
8 |
9 | @Id
10 | private String id;
11 |
12 | private String name;
13 |
14 | private String tel;
15 |
16 | @Override
17 | public String toString() {
18 | return "Department{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", tel='" + tel + '\'' + '}';
19 | }
20 |
21 | public String getId() {
22 | return id;
23 | }
24 |
25 | public void setId(String id) {
26 | this.id = id;
27 | }
28 |
29 | public String getName() {
30 | return name;
31 | }
32 |
33 | public void setName(String name) {
34 | this.name = name;
35 | }
36 |
37 | public String getTel() {
38 | return tel;
39 | }
40 |
41 | public void setTel(String tel) {
42 | this.tel = tel;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/xxl-job-boot-starter/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.springframework.boot
8 | spring-boot-starter-parent
9 | 2.5.14
10 |
11 | com.linkedbear.boot
12 | xxl-job-boot-starter
13 | 1.0-SNAPSHOT
14 |
15 |
16 | 1.8
17 |
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter
23 |
24 |
25 |
26 | com.xuxueli
27 | xxl-job-core
28 | 2.3.1
29 |
30 |
31 |
--------------------------------------------------------------------------------
/spring-boot-integration-01-starter/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-integration-parent
7 | com.linkedbear.boot
8 | 1.0.0-RELEASE
9 | ../spring-boot-integration-parent/pom.xml
10 |
11 | 4.0.0
12 |
13 | spring-boot-integration-01-starter
14 |
15 |
16 |
17 | org.springframework.boot
18 | spring-boot-starter-web
19 |
20 |
21 |
22 |
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-maven-plugin
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/spring-boot-integration-04-springdata/src/main/java/com/linkedbear/boot/springdata/mongo/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.springdata.mongo.entity;
2 |
3 | import org.springframework.data.mongodb.core.mapping.Document;
4 | import org.springframework.data.mongodb.core.mapping.Field;
5 |
6 | import javax.persistence.Id;
7 |
8 | @Document(collection = "doc_user")
9 | public class User {
10 |
11 | @Id
12 | private String id;
13 |
14 | @Field("username")
15 | private String name;
16 |
17 | private Integer age;
18 |
19 | @Override
20 | public String toString() {
21 | return "User{" + "id=" + id + ", name='" + name + '\'' + ", age=" + age + '}';
22 | }
23 |
24 | public String getId() {
25 | return id;
26 | }
27 |
28 | public void setId(String id) {
29 | this.id = id;
30 | }
31 |
32 | public String getName() {
33 | return name;
34 | }
35 |
36 | public void setName(String name) {
37 | this.name = name;
38 | }
39 |
40 | public Integer getAge() {
41 | return age;
42 | }
43 |
44 | public void setAge(Integer age) {
45 | this.age = age;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/spring-boot-integration-03-mybatis/src/main/java/com/linkedbear/boot/mybatis/mapper/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.mybatis.mapper;
2 |
3 | import com.linkedbear.boot.mybatis.entity.User;
4 | import org.apache.ibatis.annotations.Delete;
5 | import org.apache.ibatis.annotations.Mapper;
6 | import org.apache.ibatis.annotations.Param;
7 | import org.apache.ibatis.annotations.Select;
8 | import org.apache.ibatis.annotations.Update;
9 | import org.springframework.stereotype.Repository;
10 |
11 | import java.util.List;
12 |
13 | @Mapper
14 | @Repository
15 | public interface UserMapper {
16 |
17 | void save(User user);
18 |
19 | List findAll();
20 |
21 | @Select("select * from tbl_user where name like concat('%', #{name}, '%')")
22 | List findAllByNameLike(@Param("name") String name);
23 |
24 | @Delete("delete from tbl_user where id = #{id}")
25 | int deleteById(String id);
26 |
27 | @Update("CREATE TABLE tbl_role (\n"
28 | + " id int(11) NOT NULL AUTO_INCREMENT,\n"
29 | + " code varchar(20) NULL,\n"
30 | + " name varchar(32) NULL,\n"
31 | + " PRIMARY KEY (id)\n"
32 | + ");")
33 | int excuteDDL();
34 | }
35 |
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-consumer/src/main/java/com/linkedbear/boot/rocketmq/consumer/dto/UserDTO.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.rocketmq.consumer.dto;
2 |
3 | public class UserDTO {
4 |
5 | private Integer userId;
6 |
7 | private String userName;
8 |
9 | private String sexName;
10 |
11 | @Override
12 | public String toString() {
13 | return "UserDTO{"
14 | + "userId="
15 | + userId
16 | + ", userName='"
17 | + userName
18 | + '\''
19 | + ", sexName='"
20 | + sexName
21 | + '\''
22 | + '}';
23 | }
24 |
25 | public Integer getUserId() {
26 | return userId;
27 | }
28 |
29 | public void setUserId(Integer userId) {
30 | this.userId = userId;
31 | }
32 |
33 | public String getUserName() {
34 | return userName;
35 | }
36 |
37 | public void setUserName(String userName) {
38 | this.userName = userName;
39 | }
40 |
41 | public String getSexName() {
42 | return sexName;
43 | }
44 |
45 | public void setSexName(String sexName) {
46 | this.sexName = sexName;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-producer/src/main/java/com/linkedbear/boot/rocketmq/producer/dto/UserDTO.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.rocketmq.producer.dto;
2 |
3 | public class UserDTO {
4 |
5 | private Integer userId;
6 |
7 | private String userName;
8 |
9 | private String sexName;
10 |
11 | @Override
12 | public String toString() {
13 | return "UserDTO{"
14 | + "userId="
15 | + userId
16 | + ", userName='"
17 | + userName
18 | + '\''
19 | + ", sexName='"
20 | + sexName
21 | + '\''
22 | + '}';
23 | }
24 |
25 | public Integer getUserId() {
26 | return userId;
27 | }
28 |
29 | public void setUserId(Integer userId) {
30 | this.userId = userId;
31 | }
32 |
33 | public String getUserName() {
34 | return userName;
35 | }
36 |
37 | public void setUserName(String userName) {
38 | this.userName = userName;
39 | }
40 |
41 | public String getSexName() {
42 | return sexName;
43 | }
44 |
45 | public void setSexName(String sexName) {
46 | this.sexName = sexName;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/spring-boot-integration-04-springdata/src/main/java/com/linkedbear/boot/springdata/jpa/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.springdata.jpa.entity;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.GenerationType;
6 | import javax.persistence.Id;
7 | import javax.persistence.Table;
8 |
9 | @Entity
10 | @Table(name = "tbl_user")
11 | public class User {
12 |
13 | @Id
14 | @GeneratedValue(strategy = GenerationType.IDENTITY)
15 | private Integer id;
16 |
17 | private String name;
18 |
19 | private String tel;
20 |
21 | @Override
22 | public String toString() {
23 | return "User{" + "id=" + id + ", name='" + name + '\'' + ", tel='" + tel + '\'' + '}';
24 | }
25 |
26 | public Integer getId() {
27 | return id;
28 | }
29 |
30 | public void setId(Integer id) {
31 | this.id = id;
32 | }
33 |
34 | public String getName() {
35 | return name;
36 | }
37 |
38 | public void setName(String name) {
39 | this.name = name;
40 | }
41 |
42 | public String getTel() {
43 | return tel;
44 | }
45 |
46 | public void setTel(String tel) {
47 | this.tel = tel;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/spring-boot-integration-10-swagger/src/main/java/com/linkedbear/boot/swagger/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.swagger.entity;
2 |
3 | import io.swagger.annotations.ApiModel;
4 | import io.swagger.annotations.ApiModelProperty;
5 |
6 | @ApiModel(value = "用户类", description = "封装用户的基本信息")
7 | public class User {
8 |
9 | @ApiModelProperty(value = "用户id", required = true)
10 | private String id;
11 |
12 | @ApiModelProperty(value = "用户姓名", required = true)
13 | private String name;
14 |
15 | @ApiModelProperty(value = "用户年龄", notes = "只能传入大于0的数")
16 | private Integer age;
17 |
18 | @Override
19 | public String toString() {
20 | return "User{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", age=" + age + '}';
21 | }
22 |
23 | public String getId() {
24 | return id;
25 | }
26 |
27 | public void setId(String id) {
28 | this.id = id;
29 | }
30 |
31 | public String getName() {
32 | return name;
33 | }
34 |
35 | public void setName(String name) {
36 | this.name = name;
37 | }
38 |
39 | public Integer getAge() {
40 | return age;
41 | }
42 |
43 | public void setAge(Integer age) {
44 | this.age = age;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/spring-boot-integration-04-springdata/src/main/java/com/linkedbear/boot/springdata/jpa/dao/UserDao.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.springdata.jpa.dao;
2 |
3 | import com.linkedbear.boot.springdata.jpa.entity.User;
4 | import org.springframework.data.domain.Pageable;
5 | import org.springframework.data.jpa.repository.JpaRepository;
6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
7 | import org.springframework.data.jpa.repository.Query;
8 | import org.springframework.data.repository.query.Param;
9 | import org.springframework.stereotype.Repository;
10 |
11 | import java.util.List;
12 |
13 | @Repository
14 | public interface UserDao extends JpaRepository, JpaSpecificationExecutor {
15 |
16 | @Query("from User")
17 | List findAllByQuery();
18 |
19 | @Query("from User where name like %?1%")
20 | List findAllByNameLike(String name);
21 |
22 | @Query("from User where tel = :tel")
23 | List findAllByTel(@Param("tel") String tel);
24 |
25 | @Query("from User where id in :ids")
26 | List findAllByIds(@Param("ids") List ids);
27 |
28 | @Query("from User where name like %?1%")
29 | List findAllByNameLikePage(Pageable pageable, String name);
30 |
31 | List findAllById(Integer id);
32 | }
33 |
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-producer/src/main/java/com/linkedbear/boot/rocketmq/producer/service/DataService.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.rocketmq.producer.service;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.jdbc.core.JdbcTemplate;
5 | import org.springframework.stereotype.Service;
6 | import org.springframework.transaction.annotation.Transactional;
7 |
8 | @Service
9 | public class DataService {
10 |
11 | @Autowired
12 | private JdbcTemplate jdbcTemplate;
13 |
14 | @Transactional(rollbackFor = Exception.class)
15 | public void saveData(String data, String txId) {
16 | System.out.println("执行数据库insert操作。。。");
17 | System.out.println(data);
18 | System.out.println("保存txId......");
19 | jdbcTemplate.update("insert into tx_id (id) value (?)", txId);
20 | int i = 1 / 0;
21 | }
22 |
23 | public boolean contains(String txId) {
24 | return jdbcTemplate.queryForObject("select count(1) from tx_id where id = ?", Integer.class, txId) > 0;
25 | }
26 |
27 | @Transactional(rollbackFor = Exception.class)
28 | public void updateData(String txId) {
29 | System.out.println("执行数据库update操作。。。");
30 | jdbcTemplate.update("insert into tx_id (id) value (?)", txId);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/spring-boot-integration-07-security-webmvc/src/main/java/com/linkedbear/boot/security/entity/Resource.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.security.entity;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.GenerationType;
6 | import javax.persistence.Id;
7 | import javax.persistence.Table;
8 |
9 | @Entity
10 | @Table(name = "sys_resource")
11 | public class Resource {
12 |
13 | @Id
14 | @GeneratedValue(strategy = GenerationType.IDENTITY)
15 | private Integer id;
16 |
17 | private String name;
18 |
19 | private String permission;
20 |
21 | @Override
22 | public String toString() {
23 | return "Resource{" + "id=" + id + ", name='" + name + '\'' + ", permission='" + permission + '\'' + '}';
24 | }
25 |
26 | public Integer getId() {
27 | return id;
28 | }
29 |
30 | public void setId(Integer id) {
31 | this.id = id;
32 | }
33 |
34 | public String getName() {
35 | return name;
36 | }
37 |
38 | public void setName(String name) {
39 | this.name = name;
40 | }
41 |
42 | public String getPermission() {
43 | return permission;
44 | }
45 |
46 | public void setPermission(String permission) {
47 | this.permission = permission;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-consumer/src/main/java/com/linkedbear/boot/rocketmq/consumer/service/MessageReceiver.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.rocketmq.consumer.service;
2 |
3 | import org.apache.rocketmq.common.message.MessageExt;
4 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
5 | import org.apache.rocketmq.spring.core.RocketMQListener;
6 | import org.springframework.stereotype.Component;
7 |
8 | import java.nio.charset.StandardCharsets;
9 |
10 | @Component
11 | @RocketMQMessageListener(topic = "test-sender", consumerGroup = "myconsumer")
12 | public class MessageReceiver implements RocketMQListener {
13 |
14 | // @Override
15 | // public void onMessage(String message) {
16 | // System.out.println(System.currentTimeMillis());
17 | // System.out.println("收到消息:" + message);
18 | // int i = 1 / 0;
19 | // }
20 |
21 | @Override
22 | public void onMessage(MessageExt ext) {
23 | int reconsumeTimes = ext.getReconsumeTimes();
24 | if (reconsumeTimes > 3) {
25 | // 将消息保存到数据库
26 | // 直接返回,代表消息已经消费成功
27 | return;
28 | }
29 | System.out.println(System.currentTimeMillis());
30 | String message = new String(ext.getBody(), StandardCharsets.UTF_8);
31 | System.out.println("收到消息:" + message);
32 | int i = 1 / 0;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/spring-boot-integration-06-cache/src/main/java/com/linkedbear/boot/cache/config/RedisConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.cache.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.data.redis.cache.RedisCacheConfiguration;
6 | import org.springframework.data.redis.cache.RedisCacheManager;
7 | import org.springframework.data.redis.connection.RedisConnectionFactory;
8 | import org.springframework.data.redis.serializer.RedisSerializationContext;
9 | import org.springframework.data.redis.serializer.RedisSerializer;
10 |
11 | import java.time.Duration;
12 |
13 | @Configuration(proxyBeanMethods = false)
14 | public class RedisConfiguration {
15 |
16 | @Bean
17 | public RedisCacheConfiguration redisCacheConfiguration() {
18 | return RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(
19 | RedisSerializationContext.SerializationPair.fromSerializer(RedisSerializer.json()));
20 | }
21 |
22 | @Bean
23 | public RedisCacheManager userCacheManager(RedisConnectionFactory connectionFactory,
24 | RedisCacheConfiguration redisCacheConfiguration) {
25 | return RedisCacheManager.builder(connectionFactory)
26 | .cacheDefaults(redisCacheConfiguration.entryTtl(Duration.ofMinutes(1))).build();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/spring-boot-integration-09-xxljob/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-integration-parent
7 | com.linkedbear.boot
8 | 1.0.0-RELEASE
9 | ../spring-boot-integration-parent/pom.xml
10 |
11 | 4.0.0
12 |
13 | spring-boot-integration-09-xxljob
14 |
15 |
16 |
17 | org.springframework.boot
18 | spring-boot-starter-web
19 |
20 |
21 |
22 | com.xuxueli
23 | xxl-job-core
24 | 2.3.1
25 |
26 |
27 |
28 |
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-maven-plugin
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/spring-boot-integration-11-admin/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-integration-parent
7 | com.linkedbear.boot
8 | 1.0.0-RELEASE
9 | ../spring-boot-integration-parent/pom.xml
10 |
11 | 4.0.0
12 |
13 | spring-boot-integration-11-admin
14 |
15 |
16 |
17 | de.codecentric
18 | spring-boot-admin-starter-server
19 | 2.5.6
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-web
24 |
25 |
26 |
27 |
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-maven-plugin
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/spring-boot-integration-02-junit/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-integration-parent
7 | com.linkedbear.boot
8 | 1.0.0-RELEASE
9 | ../spring-boot-integration-parent/pom.xml
10 |
11 | 4.0.0
12 |
13 | spring-boot-integration-02-junit
14 |
15 |
16 |
17 | org.springframework.boot
18 | spring-boot-starter-web
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-test
24 | test
25 |
26 |
27 |
28 |
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-maven-plugin
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/spring-boot-integration-08-rocketmq-consumer/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | spring-boot-integration-parent
7 | com.linkedbear.boot
8 | 1.0.0-RELEASE
9 | ../spring-boot-integration-parent/pom.xml
10 |
11 | 4.0.0
12 |
13 | spring-boot-integration-08-rocketmq-consumer
14 |
15 |
16 |
17 | org.springframework.boot
18 | spring-boot-starter-web
19 |
20 |
21 |
22 | org.apache.rocketmq
23 | rocketmq-spring-boot-starter
24 | 2.2.2
25 |
26 |
27 |
28 |
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-maven-plugin
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/spring-boot-integration-07-security-webmvc/src/main/java/com/linkedbear/boot/security/entity/SecurityUser.java:
--------------------------------------------------------------------------------
1 | package com.linkedbear.boot.security.entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonCreator;
4 | import com.fasterxml.jackson.annotation.JsonProperty;
5 | import org.springframework.security.core.GrantedAuthority;
6 | import org.springframework.security.core.authority.SimpleGrantedAuthority;
7 | import org.springframework.security.core.userdetails.User;
8 |
9 | import java.util.Collection;
10 | import java.util.List;
11 | import java.util.Map;
12 | import java.util.stream.Collectors;
13 |
14 | /**
15 | * 用于解决User无法使用jackson反序列的问题
16 | */
17 | public class SecurityUser extends User {
18 |
19 | @JsonCreator
20 | public SecurityUser(@JsonProperty("username") String username, @JsonProperty("password") String password,
21 | @JsonProperty("authorities") List