├── spring-boot-logback ├── logs │ └── spring-boot-logback │ │ ├── error.log │ │ └── log.log ├── src │ ├── main │ │ ├── resources │ │ │ ├── application-dev.properties │ │ │ ├── application-prod.properties │ │ │ ├── application-test.properties │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootlogback │ │ │ └── SpringBootLogbackApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootlogback │ │ └── SpringBootLogbackApplicationTests.java ├── .gitignore └── pom.xml ├── spring-boot-async ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootasync │ │ │ ├── service │ │ │ ├── MsgService.java │ │ │ ├── impl │ │ │ │ └── MsgServiceImpl.java │ │ │ └── OrderService.java │ │ │ ├── SpringBootAsyncApplication.java │ │ │ └── config │ │ │ └── AsyncConfig.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootasync │ │ └── SpringBootAsyncApplicationTests.java ├── .gitignore └── pom.xml ├── spring-boot-jwt ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootjwt │ │ │ ├── config │ │ │ ├── annotation │ │ │ │ ├── Token.java │ │ │ │ └── CurrentUser.java │ │ │ ├── web │ │ │ │ └── WebMvcConfig.java │ │ │ └── resolver │ │ │ │ └── UserArgumentResolver.java │ │ │ ├── service │ │ │ ├── UserService.java │ │ │ └── impl │ │ │ │ └── UserServiceImpl.java │ │ │ ├── SpringBootJwtApplication.java │ │ │ ├── model │ │ │ └── User.java │ │ │ ├── controller │ │ │ └── UserController.java │ │ │ └── utils │ │ │ └── JwtUtil.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootjwt │ │ └── SpringBootJwtApplicationTests.java └── .gitignore ├── spring-boot-aoplog ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootaoplog │ │ │ ├── model │ │ │ └── User.java │ │ │ ├── aop │ │ │ └── annotation │ │ │ │ └── AppLog.java │ │ │ ├── SpringBootAoplogApplication.java │ │ │ └── controller │ │ │ └── HelloController.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootaoplog │ │ └── SpringBootAoplogApplicationTests.java └── .gitignore ├── spring-boot-banner ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.properties │ │ │ ├── generateBannerLink │ │ │ └── banner.txt │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootbanner │ │ │ └── SpringBootBannerApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootbanner │ │ └── SpringBootBannerApplicationTests.java ├── .gitignore └── pom.xml ├── spring-boot-condition ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootcondition │ │ │ ├── CatBean.java │ │ │ ├── DogBean.java │ │ │ ├── BirdBean.java │ │ │ ├── SpringBootConditionApplication.java │ │ │ ├── ConditionConfig.java │ │ │ └── MyCondition.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootcondition │ │ └── SpringBootConditionApplicationTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── .gitignore └── pom.xml ├── spring-boot-easypoi ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbooteasypoi │ │ ├── SpringBootEasypoiApplication.java │ │ └── model │ │ └── User.java └── .gitignore ├── spring-boot-exception ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootexception │ │ │ ├── service │ │ │ ├── TestService.java │ │ │ └── impl │ │ │ │ └── TestServiceImpl.java │ │ │ ├── SpringBootExceptionApplication.java │ │ │ ├── enums │ │ │ └── AppResultCode.java │ │ │ ├── exception │ │ │ └── BusinessException.java │ │ │ ├── controller │ │ │ └── TestController.java │ │ │ └── dto │ │ │ └── Result.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootexception │ │ └── ExceptionApplicationTests.java └── .gitignore ├── spring-boot-scheduler ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootscheduler │ │ │ ├── SpringBootSchedulerApplication.java │ │ │ └── job │ │ │ └── HelloJob.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootscheduler │ │ └── SpringBootSchedulerApplicationTests.java ├── .gitignore └── pom.xml ├── spring-boot-swagger ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootswagger │ │ │ ├── model │ │ │ └── User.java │ │ │ ├── SpringBootSwaggerApplication.java │ │ │ ├── controller │ │ │ └── HelloController.java │ │ │ └── config │ │ │ └── SwaggerConfig.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootswagger │ │ └── SpringBootSwaggerApplicationTests.java └── .gitignore ├── spring-boot-bloomfilter ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootbloomfilter │ │ │ ├── service │ │ │ ├── TestService.java │ │ │ └── impl │ │ │ │ └── TestServiceImpl.java │ │ │ └── SpringBootBloomfilterApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootbloomfilter │ │ └── SpringBootBloomfilterApplicationTests.java └── .gitignore ├── spring-boot-design-pattern ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootdesignpattern │ │ │ ├── service │ │ │ ├── A.java │ │ │ └── observer │ │ │ │ ├── OrderObserverService.java │ │ │ │ ├── OrderSubjectService.java │ │ │ │ └── impl │ │ │ │ ├── SmsObserveServiceImpl.java │ │ │ │ └── WeChatObserveServiceImpl.java │ │ │ ├── SpringBootDesignPatternApplication.java │ │ │ └── bo │ │ │ └── OrderEvent.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootdesignpattern │ │ └── SpringBootDesignPatternApplicationTests.java ├── .gitignore └── pom.xml ├── spring-boot-java8stream ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── java8stream │ │ │ ├── Java8streamApplication.java │ │ │ └── User.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── java8stream │ │ └── StreamDistinctTest.java ├── .gitignore └── pom.xml ├── spring-boot-thymeleaf ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.properties │ │ │ └── templates │ │ │ │ └── index.html │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootthymeleaf │ │ │ ├── SpringBootThymeleafApplication.java │ │ │ ├── model │ │ │ └── User.java │ │ │ └── controller │ │ │ └── HelloController.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootthymeleaf │ │ └── SpringBootThymeleafApplicationTests.java ├── .gitignore └── pom.xml ├── springbootdemos.iml ├── spring-boot-websocket ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ └── templates │ │ │ └── index.html │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootwebsocket │ │ ├── model │ │ └── User.java │ │ ├── SpringBootWebsocketApplication.java │ │ ├── config │ │ ├── WebSocketConfig.java │ │ └── HttpSessionWSHelper.java │ │ └── controller │ │ └── HomeController.java └── .gitignore ├── spring-boot-mongodb ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootmongodb │ │ │ ├── base │ │ │ ├── constance │ │ │ │ ├── DateConstance.java │ │ │ │ └── MongoDBConstance.java │ │ │ ├── aop │ │ │ │ └── annotation │ │ │ │ │ └── AppLog.java │ │ │ ├── enums │ │ │ │ └── AppResultCode.java │ │ │ ├── exception │ │ │ │ └── BusinessException.java │ │ │ └── utils │ │ │ │ └── IpUtil.java │ │ │ ├── SpringBootMongodbApplication.java │ │ │ ├── entity │ │ │ ├── model │ │ │ │ ├── User.java │ │ │ │ └── AppVisitLog.java │ │ │ └── dto │ │ │ │ └── Result.java │ │ │ ├── service │ │ │ └── AppVisitLogService.java │ │ │ └── controller │ │ │ └── HelloController.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootmongodb │ │ └── SpringBootMongodbApplicationTests.java └── .gitignore ├── .gitignore ├── spring-boot-docker ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootdocker │ │ │ └── SpringBootDockerApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootdocker │ │ └── SpringBootDockerApplicationTests.java ├── DockerFile ├── .gitignore └── pom.xml ├── spring-boot-shiro ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootshiro │ │ │ ├── service │ │ │ ├── PermService.java │ │ │ ├── RoleService.java │ │ │ ├── UserService.java │ │ │ └── impl │ │ │ │ ├── RoleServiceImpl.java │ │ │ │ ├── PermServiceImpl.java │ │ │ │ └── UserServiceImpl.java │ │ │ ├── SpringBootShiroApplication.java │ │ │ ├── enums │ │ │ └── AppResultCode.java │ │ │ ├── exception │ │ │ └── BusinessException.java │ │ │ └── model │ │ │ ├── User.java │ │ │ └── dto │ │ │ └── Result.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootshiro │ │ └── SpringBootShiroApplicationTests.java └── .gitignore ├── spring-boot-activemq ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootactivemq │ │ ├── SpringBootActivemqApplication.java │ │ ├── model │ │ └── User.java │ │ ├── service │ │ └── ProductService.java │ │ └── config │ │ └── Consumer2.java ├── .gitignore └── pom.xml ├── spring-boot-elasticsearch ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootelasticsearch │ │ ├── SpringBootElasticsearchApplication.java │ │ ├── repository │ │ └── ProductRepository.java │ │ ├── service │ │ └── ProductService.java │ │ └── model │ │ └── Product.java └── .gitignore ├── spring-boot-rabbitmq ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootrabbitmq │ │ │ ├── SpringBootRabbitmqApplication.java │ │ │ ├── model │ │ │ └── User.java │ │ │ └── config │ │ │ ├── RabbitMQDelayConfig.java │ │ │ ├── RabbitMQAlternateExchangeConfig.java │ │ │ ├── RabbitMQTTLDLXConfig.java │ │ │ └── RabbitMQProduct.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootrabbitmq │ │ └── SpringBootRabbitmqApplicationTests.java ├── .gitignore └── pom.xml ├── spring-boot-command ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── zh │ │ │ └── springbootcommand │ │ │ ├── SpringBootCommandApplication.java │ │ │ ├── controller │ │ │ └── HelloController.java │ │ │ └── command │ │ │ ├── SecondLoadResourseCommangRunner.java │ │ │ ├── FirstLoadResourseCommangRunner.java │ │ │ └── GoogleCommandRunner.java │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootcommand │ │ └── SpringBootCommandApplicationTests.java ├── .gitignore └── pom.xml ├── spring-boot-redisson ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── zh │ │ │ │ └── springbootredisson │ │ │ │ ├── service │ │ │ │ ├── OrderService.java │ │ │ │ └── impl │ │ │ │ │ └── OrderServiceImpl.java │ │ │ │ ├── SpringBootRedissonApplication.java │ │ │ │ ├── config │ │ │ │ └── RedissonConfig.java │ │ │ │ └── controller │ │ │ │ └── OrderController.java │ │ └── resources │ │ │ ├── application.properties │ │ │ └── redisson.yml │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootredisson │ │ └── RedissonApplicationTests.java └── .gitignore ├── spring-boot-redis ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootredis │ │ ├── SpringBootRedisApplication.java │ │ └── User.java └── .gitignore ├── spring-boot-atomikos-jta ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── zh │ │ │ │ └── springbootatomikosjta │ │ │ │ ├── service │ │ │ │ ├── BookProductService.java │ │ │ │ ├── OrderService.java │ │ │ │ ├── StockService.java │ │ │ │ └── impl │ │ │ │ │ ├── StockServiceImpl.java │ │ │ │ │ ├── BookProductServiceImpl.java │ │ │ │ │ └── OrderServiceImpl.java │ │ │ │ ├── config │ │ │ │ └── properties │ │ │ │ │ ├── Test1Config.java │ │ │ │ │ └── Test2Config.java │ │ │ │ ├── model │ │ │ │ ├── test2 │ │ │ │ │ └── Stock.java │ │ │ │ └── test1 │ │ │ │ │ └── Order.java │ │ │ │ ├── SpringBootAtomikosJtaApplication.java │ │ │ │ └── dao │ │ │ │ ├── test1 │ │ │ │ └── OrderMapper.java │ │ │ │ └── test2 │ │ │ │ └── StockMapper.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootatomikosjta │ │ └── SpringBootAtomikosJtaApplicationTests.java └── .gitignore ├── spring-boot-multidatasource ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── zh │ │ │ │ └── springbootmultidatasource │ │ │ │ ├── service │ │ │ │ ├── BookProductService.java │ │ │ │ ├── OrderService.java │ │ │ │ ├── StockService.java │ │ │ │ └── impl │ │ │ │ │ ├── StockServiceImpl.java │ │ │ │ │ ├── BookProductServiceImpl.java │ │ │ │ │ └── OrderServiceImpl.java │ │ │ │ ├── model │ │ │ │ ├── test2 │ │ │ │ │ └── Stock.java │ │ │ │ └── test1 │ │ │ │ │ └── Order.java │ │ │ │ ├── SpringBootMultidatasourceApplication.java │ │ │ │ └── dao │ │ │ │ ├── test1 │ │ │ │ └── OrderMapper.java │ │ │ │ └── test2 │ │ │ │ └── StockMapper.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootmultidatasource │ │ └── SpringBootMultidatasourceApplicationTests.java └── .gitignore ├── spring-boot-mail ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootmail │ │ ├── SpringBootMailApplication.java │ │ └── service │ │ └── MailService.java ├── .gitignore └── pom.xml ├── spring-boot-jpa ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootjpa │ │ ├── SpringBootJpaApplication.java │ │ ├── service │ │ ├── UserService.java │ │ └── impl │ │ │ └── UserServiceImpl.java │ │ ├── dao │ │ └── UserRepository.java │ │ └── model │ │ └── User.java └── .gitignore ├── .idea ├── encodings.xml ├── misc.xml ├── compiler.xml └── inspectionProfiles │ └── Project_Default.xml ├── spring-boot-mybatis ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── zh │ │ └── springbootmybatis │ │ ├── service │ │ ├── UserService.java │ │ └── impl │ │ │ └── UserServiceImpl.java │ │ ├── SpringBootMybatisApplication.java │ │ ├── model │ │ └── User.java │ │ └── dao │ │ └── UserMapper.java └── .gitignore └── pom.xml /spring-boot-logback/logs/spring-boot-logback/error.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-boot-async/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-aoplog/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-banner/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-condition/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-easypoi/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-exception/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-scheduler/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-bloomfilter/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-design-pattern/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-java8stream/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.thymeleaf.cache=false 2 | -------------------------------------------------------------------------------- /springbootdemos.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8888 2 | 3 | spring.thymeleaf.cache=false -------------------------------------------------------------------------------- /spring-boot-banner/src/main/resources/generateBannerLink: -------------------------------------------------------------------------------- 1 | http://www.network-science.de/ascii/ 2 | http://patorjk.com/software/taag/ -------------------------------------------------------------------------------- /spring-boot-logback/src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | spring.profiles=dev 2 | 3 | logging.path=spring-boot-logback/logs -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | spring.data.mongodb.uri=mongodb://admin:admin@localhost:27017/test -------------------------------------------------------------------------------- /spring-boot-logback/src/main/resources/application-prod.properties: -------------------------------------------------------------------------------- 1 | spring.profiles=pro 2 | 3 | logging.path=/home/springbootlogback/logs -------------------------------------------------------------------------------- /spring-boot-logback/src/main/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | spring.profiles=test 2 | 3 | logging.path=/home/springbootlogback/logs -------------------------------------------------------------------------------- /spring-boot-condition/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubblessss/spring-boot-demo/HEAD/spring-boot-condition/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | springbootdemos.iml 3 | .idea 4 | .mvn 5 | mvnw 6 | mvnw.cmd 7 | vcs.xml 8 | compiler.xml 9 | 10 | 11 | -------------------------------------------------------------------------------- /spring-boot-condition/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-boot-docker/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubblessss/spring-boot-demo/HEAD/spring-boot-docker/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubblessss/spring-boot-demo/HEAD/spring-boot-shiro/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-activemq/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubblessss/spring-boot-demo/HEAD/spring-boot-activemq/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-elasticsearch/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | spring.data.elasticsearch.cluster-name=elasticsearch 3 | 4 | spring.data.elasticsearch.cluster-nodes=127.0.0.1:9300 -------------------------------------------------------------------------------- /spring-boot-logback/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubblessss/spring-boot-demo/HEAD/spring-boot-logback/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bubblessss/spring-boot-demo/HEAD/spring-boot-rabbitmq/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-docker/DockerFile: -------------------------------------------------------------------------------- 1 | 2 | FROM java:8 3 | 4 | ADD target/*.jar spring-boot-docker-0.0.1.jar 5 | 6 | EXPOSE 8080 7 | 8 | ENTRYPOINT ["java", "-jar", "spring-boot-docker-0.0.1.jar"] -------------------------------------------------------------------------------- /spring-boot-design-pattern/src/main/java/com/zh/springbootdesignpattern/service/A.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootdesignpattern.service; 2 | 3 | /** 4 | * @author zhanghang 5 | * @date 2019/7/18 6 | */ 7 | public class A { 8 | } 9 | -------------------------------------------------------------------------------- /spring-boot-async/src/main/java/com/zh/springbootasync/service/MsgService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootasync.service; 2 | 3 | /** 4 | * @author zhanghang 5 | * @date 2019/6/17 6 | */ 7 | public interface MsgService { 8 | void sendMsg(); 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-command/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | server.port=8080 3 | 4 | spring.auto.openurl=true 5 | spring.web.indexUrl=http://localhost:${server.port}/hello 6 | spring.web.googleexcute=C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe -------------------------------------------------------------------------------- /spring-boot-thymeleaf/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 |

9 | 10 | -------------------------------------------------------------------------------- /spring-boot-redisson/src/main/java/com/zh/springbootredisson/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootredisson.service; 2 | 3 | /** 4 | * @author zhanghang 5 | * @date 2019/6/6 6 | */ 7 | public interface OrderService { 8 | String book(); 9 | 10 | String bookWithLock(); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-redis/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.redis.database=0 2 | spring.redis.host=127.0.0.1 3 | spring.redis.port=6379 4 | spring.redis.password= 5 | spring.redis.lettuce.pool.max-active=8 6 | spring.redis.lettuce.pool.max-idle=8 7 | spring.redis.lettuce.pool.max-wait=-1 8 | spring.redis.lettuce.pool.min-idle=0 -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/zh/springbootshiro/service/PermService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootshiro.service; 2 | 3 | import java.util.Set; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/6/25 8 | */ 9 | public interface PermService { 10 | 11 | Set findByUserId(Integer userId); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/zh/springbootshiro/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootshiro.service; 2 | 3 | import java.util.Set; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/6/25 8 | */ 9 | public interface RoleService { 10 | 11 | Set findByUserId(Integer userId); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/zh/springbootmongodb/base/constance/DateConstance.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmongodb.base.constance; 2 | 3 | /** 4 | * @author zhanghang 5 | * @date 2019/6/14 6 | */ 7 | public class DateConstance { 8 | 9 | public static final String FORMATTER_YYYY_MM_DD = "yyyy/MM/dd"; 10 | } 11 | -------------------------------------------------------------------------------- /spring-boot-redisson/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.redis.database=0 2 | spring.redis.host=127.0.0.1 3 | spring.redis.port=6379 4 | spring.redis.password= 5 | spring.redis.lettuce.pool.max-active=8 6 | spring.redis.lettuce.pool.max-idle=8 7 | spring.redis.lettuce.pool.max-wait=-1 8 | spring.redis.lettuce.pool.min-idle=0 9 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/src/main/java/com/zh/springbootatomikosjta/service/BookProductService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootatomikosjta.service; 2 | 3 | /** 4 | * @author zhanghang 5 | * @date 2019/6/6 6 | */ 7 | public interface BookProductService { 8 | 9 | void bookProduct(Integer productId, Integer userId); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-bloomfilter/src/main/java/com/zh/springbootbloomfilter/service/TestService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootbloomfilter.service; 2 | 3 | /** 4 | * @author zhanghang 5 | * @date 2019/7/1 6 | */ 7 | public interface TestService { 8 | 9 | void printAccidentHit(); 10 | 11 | boolean checkExist(Integer num); 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-exception/src/main/java/com/zh/springbootexception/service/TestService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootexception.service; 2 | 3 | import com.zh.springbootexception.dto.Result; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/6/5 8 | */ 9 | public interface TestService { 10 | Result test(Integer index); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/java/com/zh/springbootwebsocket/model/User.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootwebsocket.model; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/6/21 8 | */ 9 | @Data 10 | public class User { 11 | 12 | private String id; 13 | 14 | private String name; 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-multidatasource/src/main/java/com/zh/springbootmultidatasource/service/BookProductService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmultidatasource.service; 2 | 3 | /** 4 | * @author zhanghang 5 | * @date 2019/6/6 6 | */ 7 | public interface BookProductService { 8 | 9 | void bookProduct(Integer productId,Integer userId); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/zh/springbootshiro/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootshiro.service; 2 | 3 | import com.zh.springbootshiro.model.User; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/6/25 8 | */ 9 | public interface UserService { 10 | 11 | User findByUserName(String userName); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-design-pattern/src/main/java/com/zh/springbootdesignpattern/service/observer/OrderObserverService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootdesignpattern.service.observer; 2 | 3 | /** 4 | * 订单观察者接口类 5 | * @author zhanghang 6 | * @date 2019/7/18 7 | */ 8 | public interface OrderObserverService { 9 | 10 | void afterCreateOrder(); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-mail/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.mail.username=zhanghang9202@163.com 2 | spring.mail.password=zhsr1992217 3 | spring.mail.host=smtp.163.com 4 | spring.mail.port=25 5 | spring.mail.properties.mail.smtp.auth=true 6 | spring.mail.properties.mail.smtp.starttls.enable=true 7 | spring.mail.properties.mail.smtp.starttls.required=true -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/zh/springbootmongodb/base/constance/MongoDBConstance.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmongodb.base.constance; 2 | 3 | /** 4 | * @author zhanghang 5 | * @date 2019/6/14 6 | */ 7 | public class MongoDBConstance { 8 | 9 | public static final String COLLECTION_NAME_PRE_APP_VISIT_LOG = "app_visit_log_"; 10 | } 11 | -------------------------------------------------------------------------------- /spring-boot-aoplog/src/main/java/com/zh/springbootaoplog/model/User.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootaoplog.model; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/5/29 8 | */ 9 | @Data 10 | public class User { 11 | 12 | private Integer id; 13 | 14 | private String name; 15 | 16 | private Integer age; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/zh/springbootjwt/config/annotation/Token.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjwt.config.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/6/25 8 | */ 9 | @Target({ElementType.METHOD}) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Documented 12 | public @interface Token { 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/java/com/zh/springbootswagger/model/User.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootswagger.model; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/5/29 8 | */ 9 | @Data 10 | public class User { 11 | 12 | private Integer id; 13 | 14 | private String name; 15 | 16 | private Integer age; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-aoplog/src/main/java/com/zh/springbootaoplog/aop/annotation/AppLog.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootaoplog.aop.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/6/3 8 | */ 9 | @Target({ElementType.METHOD}) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Documented 12 | public @interface AppLog { 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/zh/springbootjwt/config/annotation/CurrentUser.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjwt.config.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/6/25 8 | */ 9 | @Target({ElementType.PARAMETER}) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Documented 12 | public @interface CurrentUser { 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/zh/springbootmongodb/base/aop/annotation/AppLog.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmongodb.base.aop.annotation; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/6/3 8 | */ 9 | @Target({ElementType.METHOD}) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Documented 12 | public @interface AppLog { 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-design-pattern/src/main/java/com/zh/springbootdesignpattern/service/observer/OrderSubjectService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootdesignpattern.service.observer; 2 | 3 | /** 4 | * @author zhanghang 5 | * @date 2019/7/18 6 | */ 7 | public interface OrderSubjectService { 8 | 9 | void createOrder(); 10 | 11 | void createOrder2(); 12 | 13 | void createOrder3(); 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-jpa/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 2 | spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf-8&useSSL=false&serverTimezone=UTC 3 | spring.datasource.username=root 4 | spring.datasource.password=123456 5 | 6 | spring.jpa.database=MYSQL 7 | spring.jpa.show-sql=true 8 | spring.jpa.hibernate.ddl-auto=none -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /spring-boot-condition/src/main/java/com/zh/springbootcondition/CatBean.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootcondition; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/5/29 8 | */ 9 | @Slf4j 10 | public class CatBean { 11 | 12 | public void say(){ 13 | log.info("---------------------------I am a cat:喵喵喵-----------------------------------"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-condition/src/main/java/com/zh/springbootcondition/DogBean.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootcondition; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/5/29 8 | */ 9 | @Slf4j 10 | public class DogBean { 11 | 12 | public void say(){ 13 | log.info("---------------------------I am a dog:汪汪汪-----------------------------------"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 2 | spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf-8&useSSL=false&serverTimezone=UTC 3 | spring.datasource.username=root 4 | spring.datasource.password=123456 5 | 6 | mybatis.mapper-locations=classpath:mapper/*.xml 7 | mybatis.type-aliases-package=com.zh.springbootmybatis.model 8 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/src/main/java/com/zh/springbootatomikosjta/config/properties/Test1Config.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootatomikosjta.config.properties; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/6/10 8 | */ 9 | @Data 10 | public class Test1Config { 11 | 12 | private String jdbcUrl; 13 | 14 | private String username; 15 | 16 | private String password; 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-condition/src/main/java/com/zh/springbootcondition/BirdBean.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootcondition; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/5/29 8 | */ 9 | @Slf4j 10 | public class BirdBean { 11 | 12 | public void say(){ 13 | log.info("---------------------------I am a bird:叽叽喳喳-----------------------------------"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/src/main/java/com/zh/springbootatomikosjta/config/properties/Test2Config.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootatomikosjta.config.properties; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/6/10 8 | */ 9 | @Data 10 | public class Test2Config { 11 | 12 | private String jdbcUrl; 13 | 14 | private String username; 15 | 16 | private String password; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/src/main/java/com/zh/springbootatomikosjta/model/test2/Stock.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootatomikosjta.model.test2; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | /** 7 | * @author zhanghang 8 | * @date 2019/6/6 9 | */ 10 | @Data 11 | @ToString 12 | public class Stock { 13 | private Integer id; 14 | 15 | private Integer productId; 16 | 17 | private Integer count; 18 | 19 | } -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/zh/springbootjwt/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjwt.service; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.zh.springbootjwt.model.User; 5 | 6 | /** 7 | * @author zhanghang 8 | * @date 2019/6/25 9 | */ 10 | public interface UserService { 11 | 12 | User findByUserId(Integer userId); 13 | 14 | JSONObject login(String username,String password); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/src/main/java/com/zh/springbootatomikosjta/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootatomikosjta.service; 2 | 3 | 4 | import com.zh.springbootatomikosjta.model.test1.Order; 5 | 6 | /** 7 | * @author zhanghang 8 | * @date 2019/6/6 9 | */ 10 | public interface OrderService { 11 | 12 | Order findByProductId(Integer productId); 13 | 14 | void save(Integer productId, Integer userId); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/src/main/java/com/zh/springbootatomikosjta/service/StockService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootatomikosjta.service; 2 | 3 | 4 | import com.zh.springbootatomikosjta.model.test2.Stock; 5 | 6 | /** 7 | * @author zhanghang 8 | * @date 2019/6/6 9 | */ 10 | public interface StockService { 11 | 12 | Stock findByProductId(Integer productId); 13 | 14 | void decrementByProductId(Integer productId); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-multidatasource/src/main/java/com/zh/springbootmultidatasource/model/test2/Stock.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmultidatasource.model.test2; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | /** 7 | * @author zhanghang 8 | * @date 2019/6/6 9 | */ 10 | @Data 11 | @ToString 12 | public class Stock { 13 | private Integer id; 14 | 15 | private Integer productId; 16 | 17 | private Integer count; 18 | 19 | } -------------------------------------------------------------------------------- /spring-boot-multidatasource/src/main/java/com/zh/springbootmultidatasource/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmultidatasource.service; 2 | 3 | import com.zh.springbootmultidatasource.model.test1.Order; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/6/6 8 | */ 9 | public interface OrderService { 10 | 11 | Order findByProductId(Integer productId); 12 | 13 | void save(Integer productId, Integer userId); 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-multidatasource/src/main/java/com/zh/springbootmultidatasource/service/StockService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmultidatasource.service; 2 | 3 | import com.zh.springbootmultidatasource.model.test2.Stock; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/6/6 8 | */ 9 | public interface StockService { 10 | 11 | Stock findByProductId(Integer productId); 12 | 13 | void decrementByProductId(Integer productId); 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-aoplog/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-banner/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-jpa/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-mail/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-redis/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-shiro/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-activemq/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-command/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-easypoi/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-exception/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-java8stream/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-java8stream/src/main/java/com/zh/java8stream/Java8streamApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.java8stream; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Java8streamApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Java8streamApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-mongodb/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-mybatis/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-redisson/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-scheduler/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-swagger/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-condition/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | vcs.xml 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-jpa/src/main/java/com/zh/springbootjpa/SpringBootJpaApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjpa; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootJpaApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootJpaApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/zh/springbootjwt/SpringBootJwtApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjwt; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootJwtApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootJwtApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-multidatasource/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-mail/src/main/java/com/zh/springbootmail/SpringBootMailApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmail; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootMailApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootMailApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-async/src/main/java/com/zh/springbootasync/SpringBootAsyncApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootasync; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootAsyncApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootAsyncApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-redis/src/main/java/com/zh/springbootredis/SpringBootRedisApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootredis; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootRedisApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootRedisApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/zh/springbootshiro/SpringBootShiroApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootshiro; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootShiroApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootShiroApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-aoplog/src/main/java/com/zh/springbootaoplog/SpringBootAoplogApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootaoplog; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootAoplogApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootAoplogApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-banner/src/main/java/com/zh/springbootbanner/SpringBootBannerApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootbanner; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootBannerApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootBannerApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-command/src/main/java/com/zh/springbootcommand/SpringBootCommandApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootcommand; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootCommandApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootCommandApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-easypoi/src/main/java/com/zh/springbooteasypoi/SpringBootEasypoiApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbooteasypoi; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootEasypoiApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootEasypoiApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-logback/src/main/java/com/zh/springbootlogback/SpringBootLogbackApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootlogback; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootLogbackApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootLogbackApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/zh/springbootmongodb/SpringBootMongodbApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmongodb; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootMongodbApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootMongodbApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/java/com/zh/springbootswagger/SpringBootSwaggerApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootswagger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootSwaggerApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootSwaggerApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-activemq/src/main/java/com/zh/springbootactivemq/SpringBootActivemqApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootactivemq; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootActivemqApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootActivemqApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-async/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /spring-boot-docker/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /spring-boot-jwt/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/zh/springbootrabbitmq/SpringBootRabbitmqApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootrabbitmq; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootRabbitmqApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootRabbitmqApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-redisson/src/main/java/com/zh/springbootredisson/SpringBootRedissonApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootredisson; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootRedissonApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootRedissonApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-bloomfilter/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /spring-boot-condition/src/main/java/com/zh/springbootcondition/SpringBootConditionApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootcondition; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootConditionApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootConditionApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-exception/src/main/java/com/zh/springbootexception/SpringBootExceptionApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootexception; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootExceptionApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootExceptionApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/test/java/com/zh/springbootjwt/SpringBootJwtApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjwt; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootJwtApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-logback/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/src/main/java/com/zh/springbootthymeleaf/SpringBootThymeleafApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootthymeleaf; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootThymeleafApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootThymeleafApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-websocket/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/java/com/zh/springbootwebsocket/SpringBootWebsocketApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootwebsocket; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootWebsocketApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootWebsocketApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-design-pattern/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /spring-boot-bloomfilter/src/main/java/com/zh/springbootbloomfilter/SpringBootBloomfilterApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootbloomfilter; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootBloomfilterApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootBloomfilterApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-exception/src/test/java/com/zh/springbootexception/ExceptionApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootexception; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ExceptionApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/test/java/com/zh/springbootshiro/SpringBootShiroApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootshiro; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootShiroApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-aoplog/src/test/java/com/zh/springbootaoplog/SpringBootAoplogApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootaoplog; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootAoplogApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-banner/src/test/java/com/zh/springbootbanner/SpringBootBannerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootbanner; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootBannerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-command/src/main/java/com/zh/springbootcommand/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootcommand.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | /** 7 | * @author zhanghang 8 | * @date 2019/5/31 9 | */ 10 | @RestController 11 | public class HelloController { 12 | 13 | @GetMapping("/hello") 14 | public String hello(){ 15 | return "Hello World"; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-docker/src/test/java/com/zh/springbootdocker/SpringBootDockerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootdocker; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootDockerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-redisson/src/test/java/com/zh/springbootredisson/RedissonApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootredisson; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | 9 | @RunWith(SpringRunner.class) 10 | @SpringBootTest 11 | public class RedissonApplicationTests { 12 | 13 | @Test 14 | public void contextLoads() { 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-command/src/test/java/com/zh/springbootcommand/SpringBootCommandApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootcommand; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootCommandApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-logback/src/test/java/com/zh/springbootlogback/SpringBootLogbackApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootlogback; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootLogbackApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-swagger/src/test/java/com/zh/springbootswagger/SpringBootSwaggerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootswagger; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootSwaggerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-design-pattern/src/main/java/com/zh/springbootdesignpattern/SpringBootDesignPatternApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootdesignpattern; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootDesignPatternApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootDesignPatternApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch/src/main/java/com/zh/springbootelasticsearch/SpringBootElasticsearchApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootelasticsearch; 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 | } 14 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/zh/springbootjwt/model/User.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjwt.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import lombok.ToString; 7 | 8 | /** 9 | * @author zhanghang 10 | * @date 2019/6/25 11 | */ 12 | @Data 13 | @ToString 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class User { 17 | 18 | private Integer id; 19 | 20 | private String username; 21 | 22 | private String password; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-scheduler/src/test/java/com/zh/springbootscheduler/SpringBootSchedulerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootscheduler; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootSchedulerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/src/test/java/com/zh/springbootthymeleaf/SpringBootThymeleafApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootthymeleaf; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootThymeleafApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/src/main/java/com/zh/springbootatomikosjta/model/test1/Order.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootatomikosjta.model.test1; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * @author zhanghang 10 | * @date 2019/6/6 11 | */ 12 | @Data 13 | @ToString 14 | public class Order { 15 | private Integer id; 16 | 17 | private Integer userId; 18 | 19 | private Integer productId; 20 | 21 | private Date createTime; 22 | 23 | private String rmk; 24 | 25 | } -------------------------------------------------------------------------------- /spring-boot-multidatasource/src/main/java/com/zh/springbootmultidatasource/SpringBootMultidatasourceApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmultidatasource; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootMultidatasourceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootMultidatasourceApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/zh/springbootmybatis/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmybatis.service; 2 | 3 | import com.zh.springbootmybatis.model.User; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author zhanghang 9 | * @date 2019/5/31 10 | */ 11 | public interface UserService { 12 | 13 | User findById(Integer id); 14 | 15 | List listByAge(Integer age); 16 | 17 | void save(User user); 18 | 19 | void save(List users); 20 | 21 | void deleteById(Integer id); 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-multidatasource/src/main/java/com/zh/springbootmultidatasource/model/test1/Order.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmultidatasource.model.test1; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * @author zhanghang 10 | * @date 2019/6/6 11 | */ 12 | @Data 13 | @ToString 14 | public class Order { 15 | private Integer id; 16 | 17 | private Integer userId; 18 | 19 | private Integer productId; 20 | 21 | private Date createTime; 22 | 23 | private String rmk; 24 | 25 | } -------------------------------------------------------------------------------- /spring-boot-design-pattern/src/main/java/com/zh/springbootdesignpattern/bo/OrderEvent.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootdesignpattern.bo; 2 | 3 | import lombok.Data; 4 | import org.springframework.context.ApplicationEvent; 5 | 6 | /** 7 | * 订单事件类 8 | * @author zhanghang 9 | * @date 2019/7/18 10 | */ 11 | @Data 12 | public class OrderEvent extends ApplicationEvent { 13 | 14 | private String orderNum; 15 | 16 | public OrderEvent(Object source,String orderNum) { 17 | super(source); 18 | this.orderNum = orderNum; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/zh/springbootrabbitmq/model/User.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootrabbitmq.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @author zhanghang 11 | * @date 2019/6/21 12 | */ 13 | @Data 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class User implements Serializable { 17 | 18 | private static final long serialVersionUID = 688414151558441951L; 19 | 20 | private String name; 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/src/main/java/com/zh/springbootthymeleaf/model/User.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootthymeleaf.model; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author zhanghang 7 | * @date 2019/5/29 8 | */ 9 | @Data 10 | public class User { 11 | 12 | private Integer id; 13 | 14 | private String name; 15 | 16 | private Integer age; 17 | 18 | public User() {} 19 | 20 | public User(Integer id, String name, Integer age) { 21 | this.id = id; 22 | this.name = name; 23 | this.age = age; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/zh/springbootmongodb/entity/model/User.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmongodb.entity.model; 2 | 3 | import lombok.Data; 4 | 5 | import javax.validation.constraints.NotBlank; 6 | import javax.validation.constraints.NotNull; 7 | 8 | /** 9 | * @author zhanghang 10 | * @date 2019/5/29 11 | */ 12 | @Data 13 | public class User { 14 | 15 | private Integer id; 16 | 17 | @NotBlank(message = "姓名不能为空") 18 | private String name; 19 | 20 | @NotNull(message = "年龄不能为空") 21 | private Integer age; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/zh/springbootmybatis/SpringBootMybatisApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmybatis; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @MapperScan("com.zh.springbootmybatis.dao") 9 | public class SpringBootMybatisApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringBootMybatisApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-scheduler/src/main/java/com/zh/springbootscheduler/SpringBootSchedulerApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootscheduler; 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 SpringBootSchedulerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringBootSchedulerApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | spring.datasource.test1.jdbc-url=jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf-8&useSSL=false&serverTimezone=UTC 3 | spring.datasource.test1.username=root 4 | spring.datasource.test1.password=123456 5 | mybatis.test1.mapper-locations=classpath:mapper/test1/*.xml 6 | 7 | spring.datasource.test2.jdbc-url=jdbc:mysql://127.0.0.1:3306/test2?characterEncoding=utf-8&useSSL=false&serverTimezone=UTC 8 | spring.datasource.test2.username=root 9 | spring.datasource.test2.password=123456 10 | mybatis.test2.mapper-locations=classpath:mapper/test2/*.xml 11 | -------------------------------------------------------------------------------- /spring-boot-jpa/src/main/java/com/zh/springbootjpa/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjpa.service; 2 | 3 | import com.zh.springbootjpa.model.User; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author zhanghang 9 | * @date 2019/5/31 10 | */ 11 | public interface UserService { 12 | 13 | User findById(Integer id); 14 | 15 | User findByName(String name); 16 | 17 | List listByAge(Integer age); 18 | 19 | void save(User user); 20 | 21 | void save(List users); 22 | 23 | void updateAgeByName(String name,Integer age); 24 | 25 | void deleteById(Integer id); 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/java/com/zh/springbootwebsocket/config/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootwebsocket.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.socket.server.standard.ServerEndpointExporter; 6 | 7 | /** 8 | * WebSocket配置 9 | * @author zhanghang 10 | * @date 2019/1/3 17:53 11 | */ 12 | @Component 13 | public class WebSocketConfig { 14 | 15 | @Bean 16 | public ServerEndpointExporter serverEndpointExporter() { 17 | return new ServerEndpointExporter(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/src/main/java/com/zh/springbootatomikosjta/SpringBootAtomikosJtaApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootatomikosjta; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 6 | 7 | @SpringBootApplication 8 | @EnableConfigurationProperties 9 | public class SpringBootAtomikosJtaApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringBootAtomikosJtaApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/src/main/java/com/zh/springbootthymeleaf/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootthymeleaf.controller; 2 | 3 | import com.zh.springbootthymeleaf.model.User; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.ui.Model; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | 8 | /** 9 | * @author zhanghang 10 | * @date 2019/6/3 11 | */ 12 | @Controller 13 | public class HelloController { 14 | 15 | @GetMapping("/index") 16 | public String index(Model model){ 17 | model.addAttribute("user",new User(1,"张三",27)); 18 | return "index"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/zh/springbootmybatis/model/User.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmybatis.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | /** 7 | * @author zhanghang 8 | * @date 2019/5/29 9 | */ 10 | @Data 11 | @ToString 12 | public class User { 13 | 14 | private Integer id; 15 | 16 | private String name; 17 | 18 | private Integer age; 19 | 20 | public User() { 21 | } 22 | 23 | public User(String name, Integer age) { 24 | this.name = name; 25 | this.age = age; 26 | } 27 | 28 | public User(Integer id, Integer age) { 29 | this.id = id; 30 | this.age = age; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-command/src/main/java/com/zh/springbootcommand/command/SecondLoadResourseCommangRunner.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootcommand.command; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.boot.CommandLineRunner; 5 | import org.springframework.core.annotation.Order; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * @author zhanghang 10 | * @date 2019/5/31 11 | */ 12 | @Slf4j 13 | @Order(2) 14 | @Component 15 | public class SecondLoadResourseCommangRunner implements CommandLineRunner { 16 | @Override 17 | public void run(String... args) { 18 | log.info("===================第2个资源加载啦======================"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-command/src/main/java/com/zh/springbootcommand/command/FirstLoadResourseCommangRunner.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootcommand.command; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.boot.CommandLineRunner; 5 | import org.springframework.core.annotation.Order; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * @author zhanghang 10 | * @date 2019/5/31 11 | */ 12 | @Slf4j 13 | @Order(1) 14 | @Component 15 | public class FirstLoadResourseCommangRunner implements CommandLineRunner { 16 | @Override 17 | public void run(String... args) throws Exception { 18 | log.info("===================第1个资源加载啦======================"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-exception/src/main/java/com/zh/springbootexception/enums/AppResultCode.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootexception.enums; 2 | 3 | 4 | /** 5 | * @author zhanghang 6 | * @date 2019/6/5 7 | */ 8 | public enum AppResultCode { 9 | 10 | SUCCESS(200,"成功"), 11 | 12 | FAIL(-1, "操作失败,请稍候再试!"), 13 | 14 | USER_NOT_EXIST(100, "用户不存在!"); 15 | 16 | private final int code; 17 | 18 | private final String msg; 19 | 20 | AppResultCode(int code, String msg) { 21 | this.code = code; 22 | this.msg = msg; 23 | } 24 | 25 | public int getCode() { 26 | return code; 27 | } 28 | 29 | public String getMsg() { 30 | return msg; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-mail/src/main/java/com/zh/springbootmail/service/MailService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmail.service; 2 | 3 | import org.springframework.core.io.InputStreamSource; 4 | 5 | import javax.mail.MessagingException; 6 | import java.util.Map; 7 | 8 | /** 9 | * @author zhanghang 10 | * @date 2019/6/3 11 | */ 12 | public interface MailService { 13 | 14 | void sendEmail(String to, String subject, String text); 15 | 16 | void sendEmailWithFile(String to, String subject, String text, String path); 17 | 18 | void sendWithHtml(String to, String subject, String html); 19 | 20 | void sendWithImageHtml(String to, String subject, String html, Map map); 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/zh/springbootmongodb/base/enums/AppResultCode.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmongodb.base.enums; 2 | 3 | 4 | /** 5 | * @author zhanghang 6 | * @date 2019/6/5 7 | */ 8 | public enum AppResultCode { 9 | 10 | SUCCESS(200,"成功"), 11 | 12 | FAIL(-1, "操作失败,请稍候再试!"), 13 | 14 | USER_NOT_EXIST(100, "用户不存在!"); 15 | 16 | private final int code; 17 | 18 | private final String msg; 19 | 20 | AppResultCode(int code, String msg) { 21 | this.code = code; 22 | this.msg = msg; 23 | } 24 | 25 | public int getCode() { 26 | return code; 27 | } 28 | 29 | public String getMsg() { 30 | return msg; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /spring-boot-logback/logs/spring-boot-logback/log.log: -------------------------------------------------------------------------------- 1 | 2019-06-21 10:38:56.744 [main] INFO c.z.springbootlogback.SpringBootLogbackApplication - Starting SpringBootLogbackApplication on 2013-20160801DY with PID 6220 (started by Administrator in D:\idea project2\springbootdemos) 2 | 2019-06-21 10:38:56.746 [main] DEBUG c.z.springbootlogback.SpringBootLogbackApplication - Running with Spring Boot v2.1.5.RELEASE, Spring v5.1.7.RELEASE 3 | 2019-06-21 10:38:56.747 [main] INFO c.z.springbootlogback.SpringBootLogbackApplication - The following profiles are active: dev 4 | 2019-06-21 10:38:57.317 [main] INFO c.z.springbootlogback.SpringBootLogbackApplication - Started SpringBootLogbackApplication in 1.128 seconds (JVM running for 1.993) 5 | -------------------------------------------------------------------------------- /spring-boot-redisson/src/main/resources/redisson.yml: -------------------------------------------------------------------------------- 1 | singleServerConfig: 2 | idleConnectionTimeout: 10000 3 | pingTimeout: 1000 4 | connectTimeout: 10000 5 | timeout: 3000 6 | retryAttempts: 3 7 | retryInterval: 1500 8 | reconnectionTimeout: 3000 9 | failedAttempts: 3 10 | password: null 11 | subscriptionsPerConnection: 5 12 | clientName: null 13 | address: "redis://127.0.0.1:6379" 14 | subscriptionConnectionMinimumIdleSize: 1 15 | subscriptionConnectionPoolSize: 50 16 | connectionMinimumIdleSize: 32 17 | connectionPoolSize: 64 18 | database: 0 19 | dnsMonitoringInterval: 5000 20 | threads: 0 21 | nettyThreads: 0 22 | codec: 23 | class: "org.redisson.codec.JsonJacksonCodec" 24 | transportMode: "NIO" -------------------------------------------------------------------------------- /spring-boot-activemq/src/main/java/com/zh/springbootactivemq/model/User.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootactivemq.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @author zhanghang 10 | * @date 2019/5/29 11 | */ 12 | @Data 13 | @ToString 14 | public class User implements Serializable { 15 | 16 | private static final long serialVersionUID = 3466562964054157094L; 17 | 18 | private Integer id; 19 | 20 | private String name; 21 | 22 | private Integer age; 23 | 24 | public User() {} 25 | 26 | public User(Integer id, String name, Integer age) { 27 | this.id = id; 28 | this.name = name; 29 | this.age = age; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot-multidatasource/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | spring.datasource.test1.driver-class-name=com.mysql.jdbc.Driver 3 | spring.datasource.test1.jdbc-url=jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf-8&useSSL=false&serverTimezone=UTC 4 | spring.datasource.test1.username=root 5 | spring.datasource.test1.password=123456 6 | mybatis.test1.mapper-locations=classpath:mapper/test1/*.xml 7 | 8 | spring.datasource.test2.driver-class-name=com.mysql.jdbc.Driver 9 | spring.datasource.test2.jdbc-url=jdbc:mysql://127.0.0.1:3306/test2?characterEncoding=utf-8&useSSL=false&serverTimezone=UTC 10 | spring.datasource.test2.username=root 11 | spring.datasource.test2.password=123456 12 | mybatis.test2.mapper-locations=classpath:mapper/test2/*.xml 13 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/zh/springbootshiro/enums/AppResultCode.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootshiro.enums; 2 | 3 | 4 | /** 5 | * @author zhanghang 6 | * @date 2019/6/5 7 | */ 8 | public enum AppResultCode { 9 | 10 | SUCCESS(200,"成功"), 11 | 12 | FAIL(-1, "操作失败,请稍候再试!"), 13 | 14 | USER_NOT_EXIST(100, "用户不存在!"), 15 | PASSWORD_INCORRECT(101, "密码错误!"), 16 | UNAUTHORIZED(102, "权限不足!"); 17 | 18 | private final int code; 19 | 20 | private final String msg; 21 | 22 | AppResultCode(int code, String msg) { 23 | this.code = code; 24 | this.msg = msg; 25 | } 26 | 27 | public int getCode() { 28 | return code; 29 | } 30 | 31 | public String getMsg() { 32 | return msg; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-docker/src/main/java/com/zh/springbootdocker/SpringBootDockerApplication.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootdocker; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | @SpringBootApplication 10 | public class SpringBootDockerApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(SpringBootDockerApplication.class, args); 14 | } 15 | 16 | @GetMapping("/hello") 17 | public String hello(){ 18 | return "Hello World, This is a docker container"; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-aoplog/src/main/java/com/zh/springbootaoplog/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootaoplog.controller; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.zh.springbootaoplog.model.User; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | /** 10 | * @author zhanghang 11 | * @date 2019/6/3 12 | */ 13 | @RestController 14 | public class HelloController { 15 | 16 | @GetMapping("/hello") 17 | public String hello(String name){ 18 | return "Hello World " + name; 19 | } 20 | 21 | @PostMapping("save") 22 | public String save(User user){ 23 | return JSONObject.toJSONString(user); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/zh/springbootshiro/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootshiro.exception; 2 | 3 | import com.zh.springbootshiro.enums.AppResultCode; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author zhanghang 8 | * @date 2019/6/5 9 | */ 10 | @Data 11 | public class BusinessException extends RuntimeException { 12 | 13 | private int code; 14 | 15 | private String msg; 16 | 17 | private AppResultCode appResultCode; 18 | 19 | public BusinessException() { 20 | super(); 21 | } 22 | 23 | public BusinessException(AppResultCode appResultCode) { 24 | super(appResultCode.getMsg()); 25 | this.code = appResultCode.getCode(); 26 | this.msg = appResultCode.getMsg(); 27 | this.appResultCode = appResultCode; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-exception/src/main/java/com/zh/springbootexception/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootexception.exception; 2 | 3 | import com.zh.springbootexception.enums.AppResultCode; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author zhanghang 8 | * @date 2019/6/5 9 | */ 10 | @Data 11 | public class BusinessException extends RuntimeException { 12 | 13 | private int code; 14 | 15 | private String msg; 16 | 17 | private AppResultCode appResultCode; 18 | 19 | public BusinessException() { 20 | super(); 21 | } 22 | 23 | public BusinessException(AppResultCode appResultCode) { 24 | super(appResultCode.getMsg()); 25 | this.code = appResultCode.getCode(); 26 | this.msg = appResultCode.getMsg(); 27 | this.appResultCode = appResultCode; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/zh/springbootmybatis/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmybatis.dao; 2 | 3 | import com.zh.springbootmybatis.model.User; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.apache.ibatis.annotations.Select; 6 | 7 | import java.util.List; 8 | import java.util.Optional; 9 | 10 | public interface UserMapper { 11 | int deleteByPrimaryKey(Integer id); 12 | 13 | int insert(User record); 14 | 15 | int insertSelective(User record); 16 | 17 | Optional selectByPrimaryKey(Integer id); 18 | 19 | int updateByPrimaryKeySelective(User record); 20 | 21 | int updateByPrimaryKey(User record); 22 | 23 | @Select("SELECT * FROM user WHERE age = #{age}") 24 | List listByAge(@Param("age") Integer age); 25 | 26 | void saveBatch(List users); 27 | } -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/java/com/zh/springbootwebsocket/config/HttpSessionWSHelper.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootwebsocket.config; 2 | 3 | import javax.servlet.http.HttpSession; 4 | import javax.websocket.HandshakeResponse; 5 | import javax.websocket.server.HandshakeRequest; 6 | import javax.websocket.server.ServerEndpointConfig; 7 | 8 | /** 9 | * 协助server获取http session 10 | * @author zhanghang 11 | * @date 2019/1/4 13:58 12 | */ 13 | public class HttpSessionWSHelper extends ServerEndpointConfig.Configurator { 14 | 15 | @Override 16 | public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) { 17 | HttpSession httpSession=(HttpSession) request.getHttpSession(); 18 | sec.getUserProperties().put(HttpSession.class.getName(),httpSession); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/src/main/java/com/zh/springbootatomikosjta/dao/test1/OrderMapper.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootatomikosjta.dao.test1; 2 | 3 | import com.zh.springbootatomikosjta.model.test1.Order; 4 | import org.apache.ibatis.annotations.Select; 5 | 6 | /** 7 | * @author zhanghang 8 | * @date 2019/6/6 9 | */ 10 | public interface OrderMapper { 11 | int deleteByPrimaryKey(Integer id); 12 | 13 | int insert(Order record); 14 | 15 | int insertSelective(Order record); 16 | 17 | Order selectByPrimaryKey(Integer id); 18 | 19 | int updateByPrimaryKeySelective(Order record); 20 | 21 | int updateByPrimaryKey(Order record); 22 | 23 | @Select("SELECT id,user_id userId,product_id productId,create_time createTime,rmk FROM `order` WHERE product_id = #{productId}") 24 | Order findByProductId(Integer productId); 25 | } -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/zh/springbootmongodb/base/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmongodb.base.exception; 2 | 3 | import com.zh.springbootmongodb.base.enums.AppResultCode; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author zhanghang 8 | * @date 2019/6/5 9 | */ 10 | @Data 11 | public class BusinessException extends RuntimeException { 12 | 13 | private int code; 14 | 15 | private String msg; 16 | 17 | private AppResultCode appResultCode; 18 | 19 | public BusinessException() { 20 | super(); 21 | } 22 | 23 | public BusinessException(AppResultCode appResultCode) { 24 | super(appResultCode.getMsg()); 25 | this.code = appResultCode.getCode(); 26 | this.msg = appResultCode.getMsg(); 27 | this.appResultCode = appResultCode; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-async/src/main/java/com/zh/springbootasync/service/impl/MsgServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootasync.service.impl; 2 | 3 | import com.zh.springbootasync.service.MsgService; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.scheduling.annotation.Async; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.concurrent.TimeUnit; 9 | 10 | /** 11 | * @author zhanghang 12 | * @date 2019/6/17 13 | */ 14 | @Slf4j 15 | @Service 16 | public class MsgServiceImpl implements MsgService{ 17 | 18 | @Async 19 | @Override 20 | public void sendMsg() { 21 | try { 22 | TimeUnit.SECONDS.sleep(10); 23 | log.info("============消息发送成功============="); 24 | } catch (InterruptedException e) { 25 | log.error(e.getMessage(),e); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-banner/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ___ ___ _______ ___ ___ ________ ___ __ ________ ________ ___ ________ 2 | |\ \|\ \|\ ___ \ |\ \ |\ \ |\ __ \ |\ \ |\ \|\ __ \|\ __ \|\ \ |\ ___ \ 3 | \ \ \\\ \ \ __/|\ \ \ \ \ \ \ \ \|\ \ \ \ \ \ \ \ \ \|\ \ \ \|\ \ \ \ \ \ \_|\ \ 4 | \ \ __ \ \ \_|/_\ \ \ \ \ \ \ \ \\\ \ \ \ \ __\ \ \ \ \\\ \ \ _ _\ \ \ \ \ \ \\ \ 5 | \ \ \ \ \ \ \_|\ \ \ \____\ \ \____\ \ \\\ \ \ \ \|\__\_\ \ \ \\\ \ \ \\ \\ \ \____\ \ \_\\ \ 6 | \ \__\ \__\ \_______\ \_______\ \_______\ \_______\ \ \____________\ \_______\ \__\\ _\\ \_______\ \_______\ 7 | \|__|\|__|\|_______|\|_______|\|_______|\|_______| \|____________|\|_______|\|__|\|__|\|_______|\|_______| -------------------------------------------------------------------------------- /spring-boot-redisson/src/main/java/com/zh/springbootredisson/config/RedissonConfig.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootredisson.config; 2 | 3 | import org.redisson.Redisson; 4 | import org.redisson.api.RedissonClient; 5 | import org.redisson.config.Config; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import java.io.IOException; 10 | 11 | /** 12 | * @author zhanghang 13 | * @date 2019/6/6 14 | */ 15 | @Configuration 16 | public class RedissonConfig { 17 | 18 | @Bean 19 | public RedissonClient redisson() throws IOException { 20 | // 本例子使用的是yml格式的配置文件,读取使用Config.fromYAML,如果是Json文件,则使用Config.fromJSON 21 | Config config = Config.fromYAML(RedissonConfig.class.getClassLoader().getResource("redisson.yml")); 22 | return Redisson.create(config); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-activemq/src/main/java/com/zh/springbootactivemq/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootactivemq.service; 2 | 3 | import com.zh.springbootactivemq.model.User; 4 | 5 | import javax.jms.JMSException; 6 | 7 | /** 8 | * @author zhanghang 9 | * @date 2019/6/11 10 | */ 11 | public interface ProductService { 12 | 13 | void sendQueueMsg(String msg) throws JMSException; 14 | 15 | void sendQueueMsg(User user) throws JMSException; 16 | 17 | void send2WayQueueMsg(String msg) throws JMSException; 18 | 19 | void sendACKQueueMsg(String msg) throws JMSException; 20 | 21 | void sendTopicMsg(String msg) throws JMSException; 22 | 23 | void sendTopicMsg(User user) throws JMSException; 24 | 25 | void sendDelayTopicMsg(String msg) throws JMSException; 26 | 27 | void sendDelayTopicMsg(String msg,long time) throws JMSException; 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-jpa/src/main/java/com/zh/springbootjpa/dao/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjpa.dao; 2 | 3 | import com.zh.springbootjpa.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Modifying; 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.data.repository.query.Param; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import java.util.List; 11 | 12 | public interface UserRepository extends JpaRepository { 13 | 14 | User findByNameIs(String name); 15 | 16 | List findByAgeIs(Integer age); 17 | 18 | @Modifying 19 | @Transactional(rollbackFor = Exception.class) 20 | @Query("UPDATE User SET age = :age WHERE name = :name") 21 | void updateAgeByName(@Param("name") String name, @Param("age") Integer age); 22 | 23 | } -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/zh/springbootmongodb/service/AppVisitLogService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmongodb.service; 2 | 3 | import com.zh.springbootmongodb.entity.model.AppVisitLog; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @author zhanghang 9 | * @date 2019/6/14 10 | */ 11 | public interface AppVisitLogService { 12 | 13 | void save(String uuid, String ipAddress, String userAgent, String requestUrl, String requestClazz, String requestMethod, String requestParam, Date requestTime); 14 | 15 | void save(String uuid, Integer userId, String ipAddress, String userAgent, String requestUrl, String requestClazz, String requestMethod, String requestParam, Date requestTime,Integer status); 16 | 17 | void save(String uuid, Date responseTime, Long costTime, String responseContent,Integer status); 18 | 19 | AppVisitLog findByUuidAndCreateTime(String uuid,Date createTime); 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-multidatasource/src/main/java/com/zh/springbootmultidatasource/dao/test1/OrderMapper.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmultidatasource.dao.test1; 2 | 3 | import com.zh.springbootmultidatasource.model.test1.Order; 4 | import org.apache.ibatis.annotations.ResultMap; 5 | import org.apache.ibatis.annotations.Select; 6 | 7 | /** 8 | * @author zhanghang 9 | * @date 2019/6/6 10 | */ 11 | public interface OrderMapper { 12 | int deleteByPrimaryKey(Integer id); 13 | 14 | int insert(Order record); 15 | 16 | int insertSelective(Order record); 17 | 18 | Order selectByPrimaryKey(Integer id); 19 | 20 | int updateByPrimaryKeySelective(Order record); 21 | 22 | int updateByPrimaryKey(Order record); 23 | 24 | @Select("SELECT id,user_id userId,product_id productId,create_time createTime,rmk FROM `order` WHERE product_id = #{productId}") 25 | Order findByProductId(Integer productId); 26 | } -------------------------------------------------------------------------------- /spring-boot-redisson/src/main/java/com/zh/springbootredisson/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootredisson.controller; 2 | 3 | import com.zh.springbootredisson.service.OrderService; 4 | import lombok.extern.slf4j.Slf4j; 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 | /** 10 | * @author zhanghang 11 | * @date 2019/6/6 12 | */ 13 | @Slf4j 14 | @RestController 15 | public class OrderController { 16 | 17 | @Autowired 18 | private OrderService orderService; 19 | 20 | @GetMapping("/book") 21 | public String book(){ 22 | return this.orderService.book(); 23 | } 24 | 25 | @GetMapping("/bookWithLock") 26 | public String bookWithLock(){ 27 | return this.orderService.bookWithLock(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-scheduler/src/main/java/com/zh/springbootscheduler/job/HelloJob.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootscheduler.job; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.scheduling.annotation.Scheduled; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.time.LocalDateTime; 8 | import java.time.format.DateTimeFormatter; 9 | 10 | /** 11 | * @author zhanghang 12 | * @date 2019/6/3 13 | */ 14 | @Slf4j 15 | @Component 16 | public class HelloJob { 17 | 18 | @Scheduled(fixedRate = 5000) 19 | public void printHello(){ 20 | log.info("====================Hello World 2019====================="); 21 | } 22 | 23 | @Scheduled(cron = "0 05 16 * * ?") 24 | public void printNow(){ 25 | log.info("====================北京时间:{}=====================", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now())); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/zh/springbootshiro/model/User.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootshiro.model; 2 | 3 | import lombok.*; 4 | 5 | import java.io.Serializable; 6 | import java.util.Set; 7 | 8 | /** 9 | * @author zhanghang 10 | * @date 2019/6/21 11 | */ 12 | @Data 13 | @ToString 14 | @NoArgsConstructor 15 | public class User implements Serializable { 16 | 17 | private static final long serialVersionUID = 1748661428525631994L; 18 | 19 | private Integer id; 20 | 21 | private String username; 22 | 23 | private String password; 24 | 25 | private String salt; 26 | 27 | private Set roles; 28 | 29 | private Set perms; 30 | 31 | public User(Integer id, String username, String password, String salt) { 32 | this.id = id; 33 | this.username = username; 34 | this.password = password; 35 | this.salt = salt; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spring-boot-jpa/src/main/java/com/zh/springbootjpa/model/User.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjpa.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | 11 | /** 12 | * @author zhanghang 13 | * @date 2019/5/29 14 | */ 15 | @Data 16 | @ToString 17 | @Entity 18 | public class User { 19 | 20 | @Id 21 | @GeneratedValue(strategy = GenerationType.IDENTITY) 22 | private Integer id; 23 | 24 | private String name; 25 | 26 | private Integer age; 27 | 28 | public User() { 29 | } 30 | 31 | public User(String name, Integer age) { 32 | this.name = name; 33 | this.age = age; 34 | } 35 | 36 | public User(Integer id, Integer age) { 37 | this.id = id; 38 | this.age = age; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /spring-boot-async/src/main/java/com/zh/springbootasync/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootasync.service; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | import java.util.concurrent.ExecutionException; 5 | import java.util.concurrent.Future; 6 | 7 | /** 8 | * @author zhanghang 9 | * @date 2019/6/17 10 | */ 11 | public interface OrderService { 12 | 13 | void createOrder(); 14 | 15 | void sendEmail(); 16 | 17 | void cancelOrder() throws ExecutionException, InterruptedException; 18 | 19 | Future doCancelTask1(); 20 | 21 | Future doCancelTask2(); 22 | 23 | Future doCancelTask3(); 24 | 25 | void deleteOrder() throws ExecutionException, InterruptedException; 26 | 27 | CompletableFuture doDeleteTask1(); 28 | 29 | CompletableFuture doDeleteTask2(); 30 | 31 | CompletableFuture doDeleteTask3(); 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-exception/src/main/java/com/zh/springbootexception/service/impl/TestServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootexception.service.impl; 2 | 3 | import com.zh.springbootexception.dto.Result; 4 | import com.zh.springbootexception.enums.AppResultCode; 5 | import com.zh.springbootexception.exception.BusinessException; 6 | import com.zh.springbootexception.service.TestService; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author zhanghang 11 | * @date 2019/6/5 12 | */ 13 | @Service 14 | public class TestServiceImpl implements TestService { 15 | 16 | @Override 17 | public Result test(Integer index) { 18 | if (index == 0){ 19 | throw new BusinessException(AppResultCode.USER_NOT_EXIST); 20 | }else if (index == 1){ 21 | throw new RuntimeException("其他异常!"); 22 | }else{ 23 | return Result.genSuccessResult(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-exception/src/main/java/com/zh/springbootexception/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootexception.controller; 2 | 3 | import com.zh.springbootexception.dto.Result; 4 | import com.zh.springbootexception.service.TestService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.validation.annotation.Validated; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | import javax.validation.constraints.NotNull; 11 | 12 | /** 13 | * @author zhanghang 14 | * @date 2019/6/5 15 | */ 16 | @RestController 17 | @Validated 18 | public class TestController { 19 | 20 | @Autowired 21 | private TestService testService; 22 | 23 | @GetMapping("/test") 24 | public Result test(@NotNull(message = "index不能为空") Integer index){ 25 | return this.testService.test(index); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 20 | 21 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/src/main/java/com/zh/springbootatomikosjta/service/impl/StockServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootatomikosjta.service.impl; 2 | 3 | import com.zh.springbootatomikosjta.dao.test2.StockMapper; 4 | import com.zh.springbootatomikosjta.model.test2.Stock; 5 | import com.zh.springbootatomikosjta.service.StockService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author zhanghang 11 | * @date 2019/6/10 12 | */ 13 | @Service 14 | public class StockServiceImpl implements StockService { 15 | 16 | @Autowired 17 | private StockMapper stockMapper; 18 | 19 | @Override 20 | public Stock findByProductId(Integer productId) { 21 | return this.stockMapper.findByProductId(productId); 22 | } 23 | 24 | @Override 25 | public void decrementByProductId(Integer productId) { 26 | this.stockMapper.decrementByProductId(productId); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-async/src/main/java/com/zh/springbootasync/config/AsyncConfig.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootasync.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.scheduling.annotation.EnableAsync; 6 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 7 | 8 | import java.util.concurrent.Executor; 9 | 10 | /** 11 | * @author zhanghang 12 | * @date 2019/6/17 13 | */ 14 | @EnableAsync 15 | @Configuration 16 | public class AsyncConfig { 17 | 18 | @Bean("asyncExecutor") 19 | public Executor asyncExecutor() { 20 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); 21 | executor.setCorePoolSize(8); 22 | executor.setMaxPoolSize(10); 23 | executor.setQueueCapacity(100); 24 | executor.setThreadNamePrefix("asyncExecutor-"); 25 | executor.initialize(); 26 | return executor; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-java8stream/src/main/java/com/zh/java8stream/User.java: -------------------------------------------------------------------------------- 1 | package com.zh.java8stream; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Objects; 7 | 8 | /** 9 | * @author zhanghang 10 | * @date 2019/5/29 11 | */ 12 | @Data 13 | public class User implements Serializable { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | private Integer id; 18 | private String name; 19 | 20 | public User(){} 21 | 22 | public User(Integer id, String name) { 23 | this.id = id; 24 | this.name = name; 25 | } 26 | 27 | @Override 28 | public boolean equals(Object o) { 29 | if (this == o) return true; 30 | if (o == null || getClass() != o.getClass()) return false; 31 | User user = (User) o; 32 | return Objects.equals(getId(), user.getId()); 33 | } 34 | 35 | @Override 36 | public int hashCode() { 37 | return Objects.hash(getId()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-multidatasource/src/main/java/com/zh/springbootmultidatasource/service/impl/StockServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmultidatasource.service.impl; 2 | 3 | import com.zh.springbootmultidatasource.dao.test2.StockMapper; 4 | import com.zh.springbootmultidatasource.model.test2.Stock; 5 | import com.zh.springbootmultidatasource.service.StockService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author zhanghang 11 | * @date 2019/6/10 12 | */ 13 | @Service 14 | public class StockServiceImpl implements StockService { 15 | 16 | @Autowired 17 | private StockMapper stockMapper; 18 | 19 | @Override 20 | public Stock findByProductId(Integer productId) { 21 | return this.stockMapper.findByProductId(productId); 22 | } 23 | 24 | @Override 25 | public void decrementByProductId(Integer productId) { 26 | this.stockMapper.decrementByProductId(productId); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/zh/springbootshiro/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootshiro.service.impl; 2 | 3 | import com.zh.springbootshiro.model.User; 4 | import com.zh.springbootshiro.service.RoleService; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.HashMap; 8 | import java.util.HashSet; 9 | import java.util.Map; 10 | import java.util.Set; 11 | 12 | /** 13 | * @author zhanghang 14 | * @date 2019/6/26 15 | */ 16 | @Service 17 | public class RoleServiceImpl implements RoleService { 18 | 19 | private static Map> roleMap = new HashMap<>(16); 20 | 21 | static { 22 | Set set = new HashSet<>(16); 23 | set.add("超级管理员"); 24 | roleMap.put(1,set); 25 | set = new HashSet<>(16); 26 | set.add("运营经理"); 27 | roleMap.put(2,set); 28 | } 29 | 30 | @Override 31 | public Set findByUserId(Integer userId) { 32 | return roleMap.get(userId); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch/src/main/java/com/zh/springbootelasticsearch/repository/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootelasticsearch.repository; 2 | 3 | import com.zh.springbootelasticsearch.model.Product; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.PageRequest; 6 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author zhanghang 12 | * @date 2019/6/19 13 | */ 14 | public interface ProductRepository extends ElasticsearchRepository { 15 | 16 | List findByBrand(String brand); 17 | 18 | Page findByCategoryOrderByCreateTimeDesc(String category, PageRequest page); 19 | 20 | List findByCreateTimeBetween(String from, String to); 21 | 22 | List findByNameLike(String name); 23 | 24 | List findByNameLikeOrBrandLike(String name,String brand); 25 | 26 | void deleteByIdIn(List ids); 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-redis/src/main/java/com/zh/springbootredis/User.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootredis; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Objects; 7 | 8 | /** 9 | * @author zhanghang 10 | * @date 2019/5/29 11 | */ 12 | @Data 13 | public class User implements Serializable { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | private Integer id; 18 | private String name; 19 | private String sex; 20 | 21 | public User(){} 22 | 23 | public User(Integer id, String name) { 24 | this.id = id; 25 | this.name = name; 26 | } 27 | 28 | @Override 29 | public boolean equals(Object o) { 30 | if (this == o) return true; 31 | if (o == null || getClass() != o.getClass()) return false; 32 | User user = (User) o; 33 | return Objects.equals(getId(), user.getId()); 34 | } 35 | 36 | @Override 37 | public int hashCode() { 38 | return Objects.hash(getId()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/zh/springbootshiro/service/impl/PermServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootshiro.service.impl; 2 | 3 | import com.zh.springbootshiro.service.PermService; 4 | import org.springframework.stereotype.Service; 5 | 6 | import java.util.HashMap; 7 | import java.util.HashSet; 8 | import java.util.Map; 9 | import java.util.Set; 10 | 11 | /** 12 | * @author zhanghang 13 | * @date 2019/6/26 14 | */ 15 | @Service 16 | public class PermServiceImpl implements PermService { 17 | 18 | private static Map> permMap = new HashMap<>(16); 19 | 20 | static { 21 | Set set = new HashSet<>(16); 22 | set.add("增"); 23 | set.add("删"); 24 | set.add("改"); 25 | set.add("查"); 26 | permMap.put(1,set); 27 | set = new HashSet<>(16); 28 | set.add("查"); 29 | permMap.put(2,set); 30 | } 31 | 32 | @Override 33 | public Set findByUserId(Integer userId) { 34 | return permMap.get(userId); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/test/java/com/zh/springbootmongodb/SpringBootMongodbApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmongodb; 2 | 3 | import com.zh.springbootmongodb.entity.model.AppVisitLog; 4 | import com.zh.springbootmongodb.service.AppVisitLogService; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | 12 | import java.util.Date; 13 | 14 | @Slf4j 15 | @RunWith(SpringRunner.class) 16 | @SpringBootTest 17 | public class SpringBootMongodbApplicationTests { 18 | 19 | @Autowired 20 | private AppVisitLogService appVisitLogService; 21 | 22 | @Test 23 | public void contextLoads() { 24 | AppVisitLog appVisitLog = this.appVisitLogService.findByUuidAndCreateTime("d5aeb799f332492d9aafc2d4782e7883",new Date()); 25 | log.info("appVisitLog:{}",appVisitLog); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-design-pattern/src/main/java/com/zh/springbootdesignpattern/service/observer/impl/SmsObserveServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootdesignpattern.service.observer.impl; 2 | 3 | import com.zh.springbootdesignpattern.bo.OrderEvent; 4 | import com.zh.springbootdesignpattern.service.observer.OrderObserverService; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.context.ApplicationListener; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * 短信类观察者 11 | * 使用原生观察和模式只需要实现OrderObserver接口 12 | * 使用spring监听器实现观察者需要实现ApplicationListener接口 13 | * @author zhanghang 14 | * @date 2019/7/18 15 | */ 16 | @Slf4j 17 | @Service("smsObserverService") 18 | public class SmsObserveServiceImpl implements OrderObserverService,ApplicationListener { 19 | 20 | @Override 21 | public void afterCreateOrder() { 22 | log.info("发送短信通知运营专员!"); 23 | } 24 | 25 | @Override 26 | public void onApplicationEvent(OrderEvent orderEvent) { 27 | log.info("发送短信通知运营专员,订单号:{}的订单已创建!",orderEvent.getOrderNum()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-design-pattern/src/test/java/com/zh/springbootdesignpattern/SpringBootDesignPatternApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootdesignpattern; 2 | 3 | import com.zh.springbootdesignpattern.service.observer.OrderSubjectService; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | @RunWith(SpringRunner.class) 11 | @SpringBootTest 12 | public class SpringBootDesignPatternApplicationTests { 13 | 14 | @Autowired 15 | private OrderSubjectService orderSubjectService; 16 | 17 | @Test 18 | public void commonTest() { 19 | this.orderSubjectService.createOrder(); 20 | } 21 | 22 | @Test 23 | public void observerTest() { 24 | this.orderSubjectService.createOrder2(); 25 | } 26 | 27 | @Test 28 | public void observerWithListenerTest() { 29 | this.orderSubjectService.createOrder3(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/zh/springbootmongodb/entity/model/AppVisitLog.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmongodb.entity.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | import org.bson.types.ObjectId; 6 | import org.springframework.data.annotation.Id; 7 | import org.springframework.data.mongodb.core.mapping.Field; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * @author zhanghang 13 | * @date 2019/6/14 14 | */ 15 | @Data 16 | @ToString 17 | public class AppVisitLog { 18 | 19 | @Id 20 | private ObjectId id; 21 | 22 | private String uuid; 23 | 24 | private Integer userId; 25 | 26 | private String ipAddress; 27 | 28 | private String userAgent; 29 | 30 | private String requestUrl; 31 | 32 | private String requestClazz; 33 | 34 | private String requestMethod; 35 | 36 | private String requestParam; 37 | 38 | private Date requestTime; 39 | 40 | private Date responseTime; 41 | 42 | private Long costTime; 43 | 44 | private Integer status; 45 | 46 | private String responseContent; 47 | } 48 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/src/main/java/com/zh/springbootatomikosjta/dao/test2/StockMapper.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootatomikosjta.dao.test2; 2 | 3 | import com.zh.springbootatomikosjta.model.test2.Stock; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.apache.ibatis.annotations.Select; 6 | import org.apache.ibatis.annotations.Update; 7 | 8 | /** 9 | * @author zhanghang 10 | * @date 2019/6/6 11 | */ 12 | public interface StockMapper { 13 | int deleteByPrimaryKey(Integer id); 14 | 15 | int insert(Stock record); 16 | 17 | int insertSelective(Stock record); 18 | 19 | Stock selectByPrimaryKey(Integer id); 20 | 21 | int updateByPrimaryKeySelective(Stock record); 22 | 23 | int updateByPrimaryKey(Stock record); 24 | 25 | @Select("SELECT id,product_id productId,`count` FROM stock WHERE product_id = #{productId}") 26 | Stock findByProductId(@Param("productId") Integer productId); 27 | 28 | @Update("UPDATE stock SET `count` = `count` - 1 WHERE product_id = #{productId}") 29 | void decrementByProductId(@Param("productId") Integer productId); 30 | } -------------------------------------------------------------------------------- /spring-boot-design-pattern/src/main/java/com/zh/springbootdesignpattern/service/observer/impl/WeChatObserveServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootdesignpattern.service.observer.impl; 2 | 3 | import com.zh.springbootdesignpattern.bo.OrderEvent; 4 | import com.zh.springbootdesignpattern.service.observer.OrderObserverService; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.context.ApplicationListener; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * 微信类观察者 11 | * 使用原生观察和模式只需要实现OrderObserver接口 12 | * 使用spring监听器实现观察者需要实现ApplicationListener接口 13 | * @author zhanghang 14 | * @date 2019/7/18 15 | */ 16 | @Slf4j 17 | @Service("weChatObserverService") 18 | public class WeChatObserveServiceImpl implements OrderObserverService, ApplicationListener { 19 | 20 | @Override 21 | public void afterCreateOrder() { 22 | log.info("发送微信通知运营专员!"); 23 | } 24 | 25 | @Override 26 | public void onApplicationEvent(OrderEvent orderEvent) { 27 | log.info("发送微信通知运营专员,订单号:{}的订单已创建!",orderEvent.getOrderNum()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-multidatasource/src/main/java/com/zh/springbootmultidatasource/dao/test2/StockMapper.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmultidatasource.dao.test2; 2 | 3 | import com.zh.springbootmultidatasource.model.test2.Stock; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.apache.ibatis.annotations.Select; 6 | import org.apache.ibatis.annotations.Update; 7 | 8 | /** 9 | * @author zhanghang 10 | * @date 2019/6/6 11 | */ 12 | public interface StockMapper { 13 | int deleteByPrimaryKey(Integer id); 14 | 15 | int insert(Stock record); 16 | 17 | int insertSelective(Stock record); 18 | 19 | Stock selectByPrimaryKey(Integer id); 20 | 21 | int updateByPrimaryKeySelective(Stock record); 22 | 23 | int updateByPrimaryKey(Stock record); 24 | 25 | @Select("SELECT id,product_id productId,`count` FROM stock WHERE product_id = #{productId}") 26 | Stock findByProductId(@Param("productId") Integer productId); 27 | 28 | @Update("UPDATE stock SET `count` = `count` - 1 WHERE product_id = #{productId}") 29 | void decrementByProductId(@Param("productId") Integer productId); 30 | } -------------------------------------------------------------------------------- /spring-boot-easypoi/src/main/java/com/zh/springbooteasypoi/model/User.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbooteasypoi.model; 2 | 3 | import cn.afterturn.easypoi.excel.annotation.Excel; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * @author zhanghang 11 | * @date 2019/5/29 12 | */ 13 | @Data 14 | public class User implements Serializable { 15 | 16 | @Excel(name = "编号", isImportField = "true_st") 17 | private Integer id; 18 | 19 | @Excel(name = "姓名", height = 20, width = 30, isImportField = "true_st") 20 | private String name; 21 | 22 | @Excel(name = "学生性别", replace = { "男_1", "女_2" }, suffix = "生", isImportField = "true_st") 23 | private Integer gender; 24 | 25 | @Excel(name = "出生日期", format = "yyyy-MM-dd", width = 20, isImportField = "true_st") 26 | private Date birthday; 27 | 28 | public User() {} 29 | 30 | public User(Integer id, String name, Integer gender, Date birthday) { 31 | this.id = id; 32 | this.name = name; 33 | this.gender = gender; 34 | this.birthday = birthday; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-multidatasource/src/main/java/com/zh/springbootmultidatasource/service/impl/BookProductServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmultidatasource.service.impl; 2 | 3 | import com.zh.springbootmultidatasource.service.BookProductService; 4 | import com.zh.springbootmultidatasource.service.OrderService; 5 | import com.zh.springbootmultidatasource.service.StockService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | /** 11 | * @author zhanghang 12 | * @date 2019/6/6 13 | */ 14 | @Service 15 | public class BookProductServiceImpl implements BookProductService { 16 | 17 | @Autowired 18 | private StockService stockService; 19 | 20 | @Autowired 21 | private OrderService orderService; 22 | 23 | 24 | @Override 25 | @Transactional(rollbackFor = Exception.class) 26 | public void bookProduct(Integer productId, Integer userId) { 27 | //订单表插入一条数据 28 | this.orderService.save(productId,userId); 29 | //库存表扣减一份商品 30 | this.stockService.decrementByProductId(productId); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/src/main/java/com/zh/springbootatomikosjta/service/impl/BookProductServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootatomikosjta.service.impl; 2 | 3 | import com.zh.springbootatomikosjta.service.BookProductService; 4 | import com.zh.springbootatomikosjta.service.OrderService; 5 | import com.zh.springbootatomikosjta.service.StockService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | /** 11 | * @author zhanghang 12 | * @date 2019/6/6 13 | */ 14 | @Service 15 | public class BookProductServiceImpl implements BookProductService { 16 | 17 | @Autowired 18 | private StockService stockService; 19 | 20 | @Autowired 21 | private OrderService orderService; 22 | 23 | @Override 24 | @Transactional(rollbackFor = Exception.class) 25 | public void bookProduct(Integer productId, Integer userId) { 26 | //订单表插入一条数据 27 | this.orderService.save(productId,userId); 28 | //库存表扣减一份商品 29 | this.stockService.decrementByProductId(productId); 30 | int a = 1/0; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/src/main/java/com/zh/springbootatomikosjta/service/impl/OrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootatomikosjta.service.impl; 2 | 3 | import com.zh.springbootatomikosjta.dao.test1.OrderMapper; 4 | import com.zh.springbootatomikosjta.model.test1.Order; 5 | import com.zh.springbootatomikosjta.service.OrderService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * @author zhanghang 13 | * @date 2019/6/10 14 | */ 15 | @Service 16 | public class OrderServiceImpl implements OrderService { 17 | 18 | @Autowired 19 | private OrderMapper orderMapper; 20 | 21 | @Override 22 | public Order findByProductId(Integer productId) { 23 | return this.orderMapper.findByProductId(productId); 24 | } 25 | 26 | @Override 27 | public void save(Integer productId, Integer userId) { 28 | Order order = new Order(); 29 | order.setUserId(userId); 30 | order.setProductId(productId); 31 | order.setCreateTime(new Date()); 32 | order.setRmk("创建一笔订单"); 33 | this.orderMapper.insertSelective(order); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/zh/springbootjwt/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjwt.controller; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.zh.springbootjwt.config.annotation.CurrentUser; 5 | import com.zh.springbootjwt.config.annotation.Token; 6 | import com.zh.springbootjwt.model.User; 7 | import com.zh.springbootjwt.service.UserService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import javax.validation.constraints.NotBlank; 13 | 14 | /** 15 | * @author zhanghang 16 | * @date 2019/6/3 17 | */ 18 | @RestController 19 | public class UserController { 20 | 21 | @Autowired 22 | private UserService userService; 23 | 24 | @PostMapping("/login") 25 | public JSONObject login(@NotBlank(message = "用户名不能为空") String username, @NotBlank(message = "密码不能为空") String password){ 26 | return this.userService.login(username,password); 27 | } 28 | 29 | @Token 30 | @PostMapping("checkUserInfo") 31 | public User save(@CurrentUser User user){ 32 | return user; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch/src/main/java/com/zh/springbootelasticsearch/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootelasticsearch.service; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.zh.springbootelasticsearch.model.Product; 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author zhanghang 12 | * @date 2019/6/18 13 | */ 14 | public interface ProductService { 15 | 16 | Product getProduct(); 17 | 18 | List listProduct(); 19 | 20 | List findByFieldMatch(String filed, String value); 21 | 22 | Page findByFieldMatch(String filed, String value, Pageable pageable); 23 | 24 | List findByMultiFieldMatch(List fileds, String value); 25 | 26 | Page findByMultiFieldMatch(List fileds, String value, Pageable pageable); 27 | 28 | List findByValue(String value); 29 | 30 | Page findByValue(String value, Pageable pageable); 31 | 32 | Page findByValue(String value,List hightLightField, Pageable pageable); 33 | 34 | List findAllCategorySumPrice(); 35 | } 36 | -------------------------------------------------------------------------------- /spring-boot-multidatasource/src/main/java/com/zh/springbootmultidatasource/service/impl/OrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmultidatasource.service.impl; 2 | 3 | import com.zh.springbootmultidatasource.dao.test1.OrderMapper; 4 | import com.zh.springbootmultidatasource.model.test1.Order; 5 | import com.zh.springbootmultidatasource.service.OrderService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * @author zhanghang 13 | * @date 2019/6/10 14 | */ 15 | @Service 16 | public class OrderServiceImpl implements OrderService { 17 | 18 | @Autowired 19 | private OrderMapper orderMapper; 20 | 21 | @Override 22 | public Order findByProductId(Integer productId) { 23 | return this.orderMapper.findByProductId(productId); 24 | } 25 | 26 | @Override 27 | public void save(Integer productId, Integer userId) { 28 | Order order = new Order(); 29 | order.setUserId(userId); 30 | order.setProductId(productId); 31 | order.setCreateTime(new Date()); 32 | order.setRmk("创建一笔订单"); 33 | this.orderMapper.insertSelective(order); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-boot-bloomfilter/src/test/java/com/zh/springbootbloomfilter/SpringBootBloomfilterApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootbloomfilter; 2 | 3 | import cn.hutool.core.util.RandomUtil; 4 | import com.zh.springbootbloomfilter.service.TestService; 5 | import com.zh.springbootbloomfilter.service.impl.TestServiceImpl; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | 13 | @Slf4j 14 | @RunWith(SpringRunner.class) 15 | @SpringBootTest 16 | public class SpringBootBloomfilterApplicationTests { 17 | 18 | @Autowired 19 | private TestService testService; 20 | 21 | @Test 22 | public void checkExist() { 23 | int num = RandomUtil.randomInt(TestServiceImpl.size); 24 | boolean exist = this.testService.checkExist(num); 25 | if (exist){ 26 | log.info("{}号老铁在名单中!",num); 27 | }else{ 28 | log.info("{}号老铁不在名单中!",num); 29 | } 30 | } 31 | 32 | @Test 33 | public void printAccidentHit() { 34 | this.testService.printAccidentHit(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-command/src/main/java/com/zh/springbootcommand/command/GoogleCommandRunner.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootcommand.command; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * 项目启动浏览器自动访问配置 10 | * @author zhanghang 11 | * @date 2019/5/31 12 | */ 13 | @Slf4j 14 | @Component 15 | public class GoogleCommandRunner implements CommandLineRunner { 16 | @Value("${spring.web.indexUrl}") 17 | private String indexUrl; 18 | 19 | @Value("${spring.web.googleexcute}") 20 | private String googleExcutePath; 21 | 22 | @Value("${spring.auto.openurl}") 23 | private boolean isOpen; 24 | 25 | @Override 26 | public void run(String... args){ 27 | if(isOpen){ 28 | String cmd = googleExcutePath +" "+ indexUrl; 29 | Runtime run = Runtime.getRuntime(); 30 | try{ 31 | run.exec(cmd); 32 | log.info("================启动浏览器打开项目成功==============="); 33 | }catch (Exception e){ 34 | e.printStackTrace(); 35 | log.error(e.getMessage()); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/zh/springbootmongodb/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmongodb.controller; 2 | 3 | import cn.hutool.core.util.RandomUtil; 4 | import com.zh.springbootmongodb.entity.dto.Result; 5 | import com.zh.springbootmongodb.entity.model.User; 6 | import org.springframework.validation.BindException; 7 | import org.springframework.validation.BindingResult; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import javax.validation.Valid; 13 | import javax.validation.constraints.NotBlank; 14 | 15 | /** 16 | * @author zhanghang 17 | * @date 2019/6/3 18 | */ 19 | @RestController 20 | public class HelloController { 21 | 22 | @GetMapping("/hello") 23 | public Result hello(@NotBlank(message = "姓名不能为空") String name){ 24 | return Result.genSuccessResult("Hello World " + name); 25 | } 26 | 27 | @PostMapping("save") 28 | public Result save(@Valid User user, BindingResult br) throws BindException { 29 | if (br.hasErrors()){ 30 | throw new BindException(br); 31 | } 32 | user.setId(RandomUtil.randomInt(100)); 33 | return Result.genSuccessResult(user); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/zh/springbootshiro/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootshiro.service.impl; 2 | 3 | import com.zh.springbootshiro.model.User; 4 | import com.zh.springbootshiro.service.UserService; 5 | import org.apache.shiro.crypto.RandomNumberGenerator; 6 | import org.apache.shiro.crypto.SecureRandomNumberGenerator; 7 | import org.apache.shiro.crypto.hash.Md5Hash; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | /** 14 | * @author zhanghang 15 | * @date 2019/6/25 16 | */ 17 | @Service 18 | public class UserServiceImpl implements UserService { 19 | 20 | private static Map userMap = new HashMap<>(16); 21 | 22 | static { 23 | //明文密码:111111 24 | userMap.put("张三",new User(1,"张三","9787fe0770108f8027140811f31cb180","abcde")); 25 | //明文密码:111111 26 | userMap.put("李四",new User(2,"李四","83cf8ae22c7acc592052498d63d96832","fghjk")); 27 | } 28 | 29 | @Override 30 | public User findByUserName(String userName) { 31 | return userMap.get(userName); 32 | } 33 | 34 | public static void main(String[] args) { 35 | String salt = "abcde"; 36 | String hashedPwd = new Md5Hash("111111", salt, 3).toHex(); 37 | System.out.println(hashedPwd); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-boot-java8stream/src/test/java/com/zh/java8stream/StreamDistinctTest.java: -------------------------------------------------------------------------------- 1 | package com.zh.java8stream; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | import java.util.ArrayList; 10 | import java.util.Arrays; 11 | import java.util.List; 12 | import java.util.Optional; 13 | 14 | @RunWith(SpringRunner.class) 15 | @SpringBootTest 16 | @Slf4j 17 | public class StreamDistinctTest { 18 | 19 | /** 20 | * 去重,元素为引用类型的话需要重写equals和hashcode 21 | */ 22 | @Test 23 | public void distinctTest() { 24 | List strList = Arrays.asList("a","b","c","d",null,"a",null); 25 | List strContainer = new ArrayList<>(); 26 | strList.stream().distinct().forEach(e -> strContainer.add(e)); 27 | log.info("==========================={}================================",strContainer.toString()); 28 | List userList = Arrays.asList(new User(1,"张三"),new User(2,"李四"),new User(1,"王五")); 29 | List userContainer = new ArrayList<>(); 30 | userList.stream().distinct().forEach(e -> userContainer.add(e)); 31 | log.info("==========================={}================================",userContainer.toString()); 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-boot-condition/src/main/java/com/zh/springbootcondition/ConditionConfig.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootcondition; 2 | 3 | import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Conditional; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | /** 10 | * @author zhanghang 11 | * @date 2019/5/29 12 | */ 13 | @Configuration 14 | public class ConditionConfig { 15 | 16 | /** 17 | * @Conditional 18 | * 一般用于配置类,可注解方法也可注解类,只有在指定满足条件下才会生效, 19 | * 如果是多个条件类则需要都满足即数组里的类的match皆返回true 20 | * @return 21 | */ 22 | @Bean 23 | @Conditional(MyCondition.class) 24 | public CatBean catBean(){ 25 | return new CatBean(); 26 | } 27 | 28 | /** 29 | * @ConditionalOnBean 30 | * 容器中存在指定 Bean,则生效。 31 | * @return 32 | */ 33 | @Bean 34 | @ConditionalOnBean(CatBean.class) 35 | public DogBean dogBean(){ 36 | return new DogBean(); 37 | } 38 | 39 | /** 40 | * @ConditionalOnBean 41 | * 容器中不存在指定 Bean,则生效。 42 | * @return 43 | */ 44 | @Bean 45 | @ConditionalOnMissingBean(CatBean.class) 46 | public BirdBean birdBean(){ 47 | return new BirdBean(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/zh/springbootmongodb/base/utils/IpUtil.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmongodb.base.utils; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import java.net.Inet4Address; 5 | import java.net.InetAddress; 6 | import java.net.NetworkInterface; 7 | import java.net.SocketException; 8 | import java.util.Enumeration; 9 | 10 | /** 11 | * @author : zhanghang 12 | * @date 2019/6/14 13 | */ 14 | public class IpUtil { 15 | 16 | public static String getIpAddress(HttpServletRequest request) { 17 | String ip = request.getHeader("x-forwarded-for"); 18 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 19 | ip = request.getHeader("Proxy-Client-IP"); 20 | } 21 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 22 | ip = request.getHeader("WL-Proxy-Client-IP"); 23 | } 24 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 25 | ip = request.getHeader("HTTP_CLIENT_IP"); 26 | } 27 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 28 | ip = request.getHeader("HTTP_X_FORWARDED_FOR"); 29 | } 30 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 31 | ip = request.getRemoteAddr(); 32 | } 33 | return ip; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/zh/springbootjwt/config/web/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjwt.config.web; 2 | 3 | import com.zh.springbootjwt.config.interceptor.AuthenticationInterceptor; 4 | import com.zh.springbootjwt.config.resolver.UserArgumentResolver; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 8 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 9 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @author zhanghang 15 | * @date 2019/6/25 16 | */ 17 | @Configuration 18 | public class WebMvcConfig implements WebMvcConfigurer { 19 | 20 | @Autowired 21 | private AuthenticationInterceptor authenticationInterceptor; 22 | 23 | @Autowired 24 | private UserArgumentResolver userArgumentResolver; 25 | 26 | /** 27 | * 注册自定义拦截器 28 | * @param registry 29 | */ 30 | @Override 31 | public void addInterceptors(InterceptorRegistry registry) { 32 | registry.addInterceptor(this.authenticationInterceptor).addPathPatterns("/**"); 33 | } 34 | 35 | /** 36 | * 注册自定义参数解析器 37 | * @param argumentResolvers 38 | */ 39 | @Override 40 | public void addArgumentResolvers(List argumentResolvers) { 41 | argumentResolvers.add(userArgumentResolver); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/java/com/zh/springbootswagger/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootswagger.controller; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.zh.springbootswagger.model.User; 5 | import io.swagger.annotations.Api; 6 | import io.swagger.annotations.ApiImplicitParam; 7 | import io.swagger.annotations.ApiImplicitParams; 8 | import io.swagger.annotations.ApiOperation; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * @author zhanghang 15 | * @date 2019/5/31 16 | */ 17 | @Api(value = "欢迎", description = "欢迎业务相关API") 18 | @RestController 19 | public class HelloController { 20 | 21 | @ApiOperation("欢迎") 22 | @ApiImplicitParams({ 23 | @ApiImplicitParam(name = "name", paramType = "query", value = "姓名", required = true, dataType = "String") 24 | }) 25 | @GetMapping("/hello") 26 | public String hello(String name){ 27 | return "Hello World " + name; 28 | } 29 | 30 | @ApiOperation("保存") 31 | @ApiImplicitParams({ 32 | @ApiImplicitParam(name = "name", paramType = "query", value = "姓名", required = true, dataType = "String"), 33 | @ApiImplicitParam(name = "age", paramType = "query", value = "年龄", required = true, dataType = "Integer"), 34 | }) 35 | @PostMapping("/save") 36 | public String save(User user){ 37 | return JSONObject.toJSONString(user); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/zh/springbootrabbitmq/config/RabbitMQDelayConfig.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootrabbitmq.config; 2 | 3 | import org.springframework.amqp.core.*; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * rabbitMQ延时队列配置类 12 | * 之前提到了使用TTL+DLX方式实现延时队列 13 | * 但是对于给每一条消息设置生存时间的话很鸡肋, 14 | * 因为先入队生存时间长的消息会阻塞后入队生存时间短的消息变成死信转发 15 | * 所以这里是使用rabbitmq_delayed_message_exchange的方式实现为每一条消息设置生存时间而且不会互相阻塞 16 | * 这是一个官方提供的插件,3.6及以上版本才能使用,可以去官网下载插件: 17 | * http://www.rabbitmq.com/community-plugins.html 18 | * 使用方法:https://blog.csdn.net/eumenides_/article/details/86027185 19 | * @author zhanghang 20 | * @date 2019/7/9 21 | */ 22 | @Configuration 23 | public class RabbitMQDelayConfig { 24 | 25 | private static final String BINDING_KET_AAA = "aaa"; 26 | 27 | @Bean 28 | public CustomExchange delayExchange(){ 29 | Map arg = new HashMap<>(16); 30 | //这里可以指定队列类型,为了方便就制定direct类型 31 | arg.put("x-delayed-type", "direct"); 32 | return new CustomExchange("exchange_delay","x-delayed-message",true,false,arg); 33 | } 34 | 35 | @Bean 36 | public Queue delayQueue(){ 37 | return new Queue("queue_delay"); 38 | } 39 | 40 | @Bean 41 | public Binding delayBinding(Queue delayQueue, CustomExchange delayExchange){ 42 | return BindingBuilder.bind(delayQueue).to(delayExchange).with(BINDING_KET_AAA).noargs(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 |
14 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 36 | -------------------------------------------------------------------------------- /spring-boot-bloomfilter/src/main/java/com/zh/springbootbloomfilter/service/impl/TestServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootbloomfilter.service.impl; 2 | 3 | import com.google.common.hash.BloomFilter; 4 | import com.google.common.hash.Funnels; 5 | import com.zh.springbootbloomfilter.service.TestService; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * 布隆过滤器 11 | * 适用于大批量数据下内存紧张的情况,爬虫url重复抓取判别;垃圾邮件过滤; 12 | * 通过多次hash将元素映射到布隆过滤器对应的位置上,0标识该位置不存在元素,1表示该位置存在元素 13 | * 缺点是有误伤概率和不能删除元素 14 | * 为了降低误伤概率guava的bloomfilter可以通过降低误判概率来实现 15 | * 还可以配合白名单来避免误伤 16 | * @author zhanghang 17 | * @date 2019/7/1 18 | */ 19 | @Slf4j 20 | @Service 21 | public class TestServiceImpl implements TestService { 22 | 23 | public static int size = 1000000; 24 | 25 | private static double fpp = 0.001; 26 | 27 | private static BloomFilter bloomFilter = BloomFilter.create(Funnels.integerFunnel(),size,fpp); 28 | 29 | static { 30 | for (int i = 0;i < size; i++){ 31 | bloomFilter.put(i); 32 | } 33 | } 34 | 35 | @Override 36 | public void printAccidentHit(){ 37 | int sum = 0; 38 | for (int i = size + 10000;i < size + 20000; i++){ 39 | if (bloomFilter.mightContain(i)){ 40 | sum += 1; 41 | log.info("悲催的{}号老铁被误伤~~(>_<)~~",i); 42 | } 43 | } 44 | log.info("{}%的概率下,一共有{}个悲催的老铁被误伤~~(>_<)~~",fpp * 100,sum); 45 | } 46 | 47 | @Override 48 | public boolean checkExist(Integer num){ 49 | return bloomFilter.mightContain(num); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /spring-boot-logback/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.5.RELEASE 9 | 10 | 11 | com.zh 12 | spring-boot-logback 13 | 0.0.1-SNAPSHOT 14 | spring-boot-logback 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-test 29 | test 30 | 31 | 32 | 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-maven-plugin 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /spring-boot-banner/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.5.RELEASE 9 | 10 | 11 | com.zh 12 | spring-boot-banner 13 | 0.0.1-SNAPSHOT 14 | spring-boot-banner 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-test 30 | test 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-maven-plugin 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /spring-boot-docker/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.5.RELEASE 9 | 10 | 11 | com.zh 12 | spring-boot-docker 13 | 0.0.1-SNAPSHOT 14 | spring-boot-docker 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-test 30 | test 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-maven-plugin 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /spring-boot-condition/src/main/java/com/zh/springbootcondition/MyCondition.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootcondition; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; 5 | import org.springframework.beans.factory.support.BeanDefinitionRegistry; 6 | import org.springframework.context.annotation.Condition; 7 | import org.springframework.context.annotation.ConditionContext; 8 | import org.springframework.core.env.Environment; 9 | import org.springframework.core.io.ResourceLoader; 10 | import org.springframework.core.type.AnnotatedTypeMetadata; 11 | 12 | /** 13 | * 此处我们可以根据自己的特定逻辑来返回true/false 14 | * @author zhanghang 15 | * @date 2019/5/29 16 | */ 17 | @Slf4j 18 | public class MyCondition implements Condition { 19 | 20 | @Override 21 | public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) { 22 | //获取bean定义的注册类 23 | BeanDefinitionRegistry registry = conditionContext.getRegistry(); 24 | //获取ioc使用的beanFactory 25 | ConfigurableListableBeanFactory beanFactory = conditionContext.getBeanFactory(); 26 | //获取当前环境信息 27 | Environment environment = conditionContext.getEnvironment(); 28 | //获得当前系统名 29 | String property = environment.getProperty("os.name"); 30 | log.info("------------------------当前系统:{}------------------------------",property); 31 | //获取资源resourceLoader 32 | ResourceLoader resourceLoader = conditionContext.getResourceLoader(); 33 | //获取类加载器 34 | ClassLoader classLoader = conditionContext.getClassLoader(); 35 | 36 | return false; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /spring-boot-jpa/src/main/java/com/zh/springbootjpa/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjpa.service.impl; 2 | 3 | import com.zh.springbootjpa.dao.UserRepository; 4 | import com.zh.springbootjpa.model.User; 5 | import com.zh.springbootjpa.service.UserService; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author zhanghang 14 | * @date 2019/5/31 15 | */ 16 | @Service 17 | @Slf4j 18 | public class UserServiceImpl implements UserService { 19 | 20 | @Autowired 21 | private UserRepository userRepository; 22 | 23 | @Override 24 | public User findById(Integer id) { 25 | return this.userRepository.findById(id).orElse(null); 26 | } 27 | 28 | @Override 29 | public User findByName(String name) { 30 | return this.userRepository.findByNameIs(name); 31 | } 32 | 33 | @Override 34 | public List listByAge(Integer age) { 35 | return this.userRepository.findByAgeIs(age); 36 | } 37 | 38 | @Override 39 | public void save(User user) { 40 | this.userRepository.saveAndFlush(user); 41 | } 42 | 43 | @Override 44 | public void save(List users) { 45 | this.userRepository.saveAll(users); 46 | this.userRepository.flush(); 47 | } 48 | 49 | @Override 50 | public void updateAgeByName(String name, Integer age) { 51 | this.userRepository.updateAgeByName(name,age); 52 | } 53 | 54 | @Override 55 | public void deleteById(Integer id) { 56 | this.userRepository.deleteById(id); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/zh/springbootmybatis/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmybatis.service.impl; 2 | 3 | import com.zh.springbootmybatis.dao.UserMapper; 4 | import com.zh.springbootmybatis.model.User; 5 | import com.zh.springbootmybatis.service.UserService; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.List; 11 | import java.util.Optional; 12 | 13 | /** 14 | * @author zhanghang 15 | * @date 2019/5/31 16 | */ 17 | @Service 18 | @Slf4j 19 | public class UserServiceImpl implements UserService { 20 | 21 | @Autowired 22 | private UserMapper userMapper; 23 | 24 | @Override 25 | public User findById(Integer id) { 26 | return this.userMapper.selectByPrimaryKey(id) 27 | .orElseThrow(() -> new RuntimeException("user未查得")); 28 | } 29 | 30 | @Override 31 | public List listByAge(Integer age) { 32 | return this.userMapper.listByAge(age); 33 | } 34 | 35 | @Override 36 | public void save(User user) { 37 | Optional.ofNullable(user.getId()) 38 | .map(e -> this.userMapper.updateByPrimaryKeySelective(user)) 39 | .orElseGet(() -> this.userMapper.insertSelective(user)); 40 | log.info("=======================编号为:{}的用户被保存啦====================",user.getId()); 41 | } 42 | 43 | @Override 44 | public void save(List users) { 45 | this.userMapper.saveBatch(users); 46 | } 47 | 48 | @Override 49 | public void deleteById(Integer id) { 50 | this.userMapper.deleteByPrimaryKey(id); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/zh/springbootshiro/model/dto/Result.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootshiro.model.dto; 2 | 3 | import com.zh.springbootshiro.enums.AppResultCode; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author zhanghang 8 | * @date 2019/6/5 9 | */ 10 | @Data 11 | public class Result { 12 | 13 | private int code; 14 | 15 | private String msg; 16 | 17 | private Object data; 18 | 19 | public Result() {} 20 | 21 | public Result(int code, String msg) { 22 | this.code = code; 23 | this.msg = msg; 24 | } 25 | 26 | public Result(int code, String msg, Object data) { 27 | this.code = code; 28 | this.msg = msg; 29 | this.data = data; 30 | } 31 | 32 | public Result(AppResultCode appResultCode) { 33 | this.code = appResultCode.getCode(); 34 | this.msg = appResultCode.getMsg(); 35 | } 36 | 37 | public Result(AppResultCode appResultCode, Object data) { 38 | this.code = appResultCode.getCode(); 39 | this.msg = appResultCode.getMsg(); 40 | this.data = data; 41 | } 42 | 43 | public static Result genSuccessResult() { 44 | return new Result(AppResultCode.SUCCESS); 45 | } 46 | 47 | public static Result genSuccessResult(Object data) { 48 | return new Result(AppResultCode.SUCCESS,data); 49 | } 50 | 51 | public static Result genFailResult(AppResultCode appResultCode) { 52 | return new Result(appResultCode); 53 | } 54 | 55 | public static Result genFailResult() { 56 | return new Result(AppResultCode.FAIL); 57 | } 58 | 59 | public static Result genFailResult(Object data) { 60 | return new Result(AppResultCode.FAIL,data); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /spring-boot-exception/src/main/java/com/zh/springbootexception/dto/Result.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootexception.dto; 2 | 3 | import com.zh.springbootexception.enums.AppResultCode; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author zhanghang 8 | * @date 2019/6/5 9 | */ 10 | @Data 11 | public class Result { 12 | 13 | private int code; 14 | 15 | private String msg; 16 | 17 | private Object data; 18 | 19 | public Result() {} 20 | 21 | public Result(int code, String msg) { 22 | this.code = code; 23 | this.msg = msg; 24 | } 25 | 26 | public Result(int code, String msg, Object data) { 27 | this.code = code; 28 | this.msg = msg; 29 | this.data = data; 30 | } 31 | 32 | public Result(AppResultCode appResultCode) { 33 | this.code = appResultCode.getCode(); 34 | this.msg = appResultCode.getMsg(); 35 | } 36 | 37 | public Result(AppResultCode appResultCode, Object data) { 38 | this.code = appResultCode.getCode(); 39 | this.msg = appResultCode.getMsg(); 40 | this.data = data; 41 | } 42 | 43 | public static Result genSuccessResult() { 44 | return new Result(AppResultCode.SUCCESS); 45 | } 46 | 47 | public static Result genSuccessResult(Object data) { 48 | return new Result(AppResultCode.SUCCESS,data); 49 | } 50 | 51 | public static Result genFailResult(AppResultCode appResultCode) { 52 | return new Result(appResultCode); 53 | } 54 | 55 | public static Result genFailResult() { 56 | return new Result(AppResultCode.FAIL); 57 | } 58 | 59 | public static Result genFailResult(Object data) { 60 | return new Result(AppResultCode.FAIL,data); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/java/com/zh/springbootswagger/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootswagger.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.ApiInfoBuilder; 6 | import springfox.documentation.builders.PathSelectors; 7 | import springfox.documentation.builders.RequestHandlerSelectors; 8 | import springfox.documentation.service.ApiInfo; 9 | import springfox.documentation.service.Contact; 10 | import springfox.documentation.spi.DocumentationType; 11 | import springfox.documentation.spring.web.plugins.Docket; 12 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 13 | 14 | /** 15 | * @author zhanghang 16 | * @date 2019/5/31 17 | */ 18 | @Configuration 19 | @EnableSwagger2 20 | public class SwaggerConfig { 21 | 22 | @Bean 23 | public Docket api() { 24 | return new Docket(DocumentationType.SWAGGER_2) 25 | .apiInfo(apiInfo()) 26 | .select() 27 | //controller包路径 28 | .apis(RequestHandlerSelectors.basePackage("com.zh.springbootswagger.controller")) 29 | .paths(PathSelectors.any()) 30 | .build(); 31 | } 32 | 33 | private ApiInfo apiInfo() { 34 | return new ApiInfoBuilder() 35 | .title("xxx系统") 36 | .description("xxx系统 API 在线文档") 37 | //服务条款网址 38 | .termsOfServiceUrl("https://blog.csdn.net/eumenides_") 39 | .version("1.0") 40 | .contact(new Contact("是guava不是瓜娃", "https://blog.csdn.net/eumenides_", "zhanghang9202@163.com")) 41 | .build(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-boot-activemq/src/main/java/com/zh/springbootactivemq/config/Consumer2.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootactivemq.config; 2 | 3 | import com.zh.springbootactivemq.model.User; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.jms.annotation.JmsListener; 6 | import org.springframework.stereotype.Component; 7 | 8 | import javax.jms.JMSException; 9 | import javax.jms.Message; 10 | import javax.jms.ObjectMessage; 11 | import java.time.LocalDateTime; 12 | 13 | /** 14 | * @author zhanghang 15 | * @date 2019/6/11 16 | */ 17 | @Slf4j 18 | @Component 19 | public class Consumer2 { 20 | 21 | @JmsListener(destination = "queue_string_test",containerFactory = "queueListenerFactory") 22 | public void receiveQueue(String text) { 23 | log.info("consumer2收到queue_string信息:{}",text); 24 | } 25 | 26 | @JmsListener(destination = "queue_user_test",containerFactory = "queueListenerFactory") 27 | public void receiveQueue(User user) { 28 | log.info("consumer2收到queue_user信息:{}",user.toString()); 29 | } 30 | 31 | @JmsListener(destination = "topic_string_test",containerFactory = "topicListenerFactory") 32 | public void receiveTopic(String text) { 33 | log.info("consumer2收到topic_string信息:{}",text); 34 | } 35 | 36 | @JmsListener(destination = "topic_user_test",containerFactory = "topicListenerFactory") 37 | public void receiveTopic(User user) { 38 | log.info("consumer2收到topic_user信息:{}",user.toString()); 39 | } 40 | 41 | @JmsListener(destination = "topic_delay_string_test",containerFactory = "topicListenerFactory") 42 | public void receiveDelayTopic(String text) { 43 | log.info("consumer2收到topic_delay_string延时信息:{},接收时间:{}",text, LocalDateTime.now()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/zh/springbootmongodb/entity/dto/Result.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmongodb.entity.dto; 2 | 3 | import com.zh.springbootmongodb.base.enums.AppResultCode; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author zhanghang 8 | * @date 2019/6/5 9 | */ 10 | @Data 11 | public class Result { 12 | 13 | private int code; 14 | 15 | private String msg; 16 | 17 | private Object data; 18 | 19 | public Result() {} 20 | 21 | public Result(int code, String msg) { 22 | this.code = code; 23 | this.msg = msg; 24 | } 25 | 26 | public Result(int code, String msg, Object data) { 27 | this.code = code; 28 | this.msg = msg; 29 | this.data = data; 30 | } 31 | 32 | public Result(AppResultCode appResultCode) { 33 | this.code = appResultCode.getCode(); 34 | this.msg = appResultCode.getMsg(); 35 | } 36 | 37 | public Result(AppResultCode appResultCode, Object data) { 38 | this.code = appResultCode.getCode(); 39 | this.msg = appResultCode.getMsg(); 40 | this.data = data; 41 | } 42 | 43 | public static Result genSuccessResult() { 44 | return new Result(AppResultCode.SUCCESS); 45 | } 46 | 47 | public static Result genSuccessResult(Object data) { 48 | return new Result(AppResultCode.SUCCESS,data); 49 | } 50 | 51 | public static Result genFailResult(AppResultCode appResultCode) { 52 | return new Result(appResultCode); 53 | } 54 | 55 | public static Result genFailResult() { 56 | return new Result(AppResultCode.FAIL); 57 | } 58 | 59 | public static Result genFailResult(Object data) { 60 | return new Result(AppResultCode.FAIL,data); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /spring-boot-async/src/test/java/com/zh/springbootasync/SpringBootAsyncApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootasync; 2 | 3 | import com.zh.springbootasync.service.OrderService; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | import java.util.concurrent.ExecutionException; 11 | import java.util.concurrent.TimeUnit; 12 | 13 | @RunWith(SpringRunner.class) 14 | @SpringBootTest 15 | public class SpringBootAsyncApplicationTests { 16 | 17 | @Autowired 18 | private OrderService orderService; 19 | 20 | /** 21 | * 测试无返回值纯异步方式 22 | * 涉及到本类异步和其他类异步,调用方式不同 23 | * 调用实现了接口的其他类的异步方法,直接调用 24 | * 调用实现了接口的本类异步方法需要获得本类的class对象在调用,否则不成功 25 | * @throws InterruptedException 26 | */ 27 | @Test 28 | public void createOrderTest() throws InterruptedException { 29 | orderService.createOrder(); 30 | TimeUnit.SECONDS.sleep(20); 31 | } 32 | 33 | /** 34 | * 测试有返回值的异步 35 | * 需要用Future接收返回值,然后while(true)轮训结果 36 | * @throws ExecutionException 37 | * @throws InterruptedException 38 | */ 39 | @Test 40 | public void cancelOrderTest() throws ExecutionException, InterruptedException { 41 | orderService.cancelOrder(); 42 | } 43 | 44 | /** 45 | * 测试有返回值的异步 46 | * 需要用CompletableFuture接收返回值 47 | * @throws ExecutionException 48 | * @throws InterruptedException 49 | */ 50 | @Test 51 | public void deleteOrderTest() throws ExecutionException, InterruptedException { 52 | orderService.deleteOrder(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /spring-boot-condition/src/test/java/com/zh/springbootcondition/SpringBootConditionApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootcondition; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | @RunWith(SpringRunner.class) 11 | @SpringBootTest 12 | @Slf4j 13 | public class SpringBootConditionApplicationTests { 14 | 15 | @Autowired(required = false) 16 | private CatBean catBean; 17 | 18 | @Autowired(required = false) 19 | private DogBean dogBean; 20 | 21 | @Autowired(required = false) 22 | private BirdBean birdBean; 23 | 24 | @Test 25 | public void conditionTest() { 26 | if (this.catBean != null){ 27 | log.info("-----------------------容器里存在CatBean----------------------------"); 28 | this.catBean.say(); 29 | }else{ 30 | log.info("-----------------------容器里不存在CatBean----------------------------"); 31 | } 32 | if (this.dogBean != null){ 33 | log.info("-----------------------容器里存在DogBean----------------------------"); 34 | this.dogBean.say(); 35 | }else{ 36 | log.info("-----------------------容器里不存在DogBean----------------------------"); 37 | } 38 | if (this.birdBean != null){ 39 | log.info("-----------------------容器里存在BirdBean----------------------------"); 40 | this.birdBean.say(); 41 | }else{ 42 | log.info("-----------------------容器里不存在BirdBean----------------------------"); 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch/src/main/java/com/zh/springbootelasticsearch/model/Product.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootelasticsearch.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | import lombok.ToString; 6 | import org.springframework.data.annotation.Id; 7 | import org.springframework.data.elasticsearch.annotations.DateFormat; 8 | import org.springframework.data.elasticsearch.annotations.Document; 9 | import org.springframework.data.elasticsearch.annotations.Field; 10 | import org.springframework.data.elasticsearch.annotations.FieldType; 11 | 12 | import java.util.Date; 13 | 14 | /** 15 | * @author zhanghang 16 | * @date 2019/6/18 17 | */ 18 | @Data 19 | @ToString 20 | @Document(indexName = "es_products",type = "product", shards = 1, replicas = 0) 21 | public class Product { 22 | 23 | @Id 24 | private String id; 25 | 26 | @Field(type = FieldType.Text, analyzer = "ik_max_word",searchAnalyzer="ik_max_word",fielddata = true) 27 | private String category; 28 | 29 | @Field(type = FieldType.Text, analyzer = "ik_max_word",searchAnalyzer="ik_max_word",fielddata = true) 30 | private String brand; 31 | 32 | @Field(type = FieldType.Text, analyzer = "ik_max_word",searchAnalyzer="ik_max_word",fielddata = true) 33 | private String name; 34 | 35 | @Field(type = FieldType.Double) 36 | private Double costPrice; 37 | 38 | @Field(type = FieldType.Double) 39 | private Double salePrice; 40 | 41 | @Field(type = FieldType.Integer) 42 | private Integer stockCount; 43 | 44 | @Field(type = FieldType.Date,format = DateFormat.custom,pattern ="yyyy-MM-dd HH:mm:ss") 45 | @JsonFormat(shape =JsonFormat.Shape.STRING,pattern ="yyyy-MM-dd HH:mm:ss",timezone ="GMT+8") 46 | private Date createTime; 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /spring-boot-java8stream/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.5.RELEASE 9 | 10 | 11 | com.zh 12 | java8stream 13 | 0.0.1-SNAPSHOT 14 | java8stream 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | 28 | org.projectlombok 29 | lombok 30 | true 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-test 35 | test 36 | 37 | 38 | 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-maven-plugin 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /spring-boot-async/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.5.RELEASE 9 | 10 | 11 | com.zh 12 | spring-boot-async 13 | 0.0.1-SNAPSHOT 14 | spring-boot-async 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | 28 | org.projectlombok 29 | lombok 30 | true 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-test 35 | test 36 | 37 | 38 | 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-maven-plugin 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/java/com/zh/springbootwebsocket/controller/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootwebsocket.controller; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.zh.springbootwebsocket.config.WebSocket; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.PostMapping; 9 | import org.springframework.web.bind.annotation.ResponseBody; 10 | 11 | import javax.servlet.http.HttpSession; 12 | import java.util.List; 13 | import java.util.stream.Collectors; 14 | 15 | /** 16 | * @author zhanghang 17 | * @date 2019/6/21 18 | */ 19 | @Controller 20 | public class HomeController { 21 | 22 | @Autowired 23 | private WebSocket webSocket; 24 | 25 | @GetMapping("/index") 26 | public String index(){ 27 | return "index"; 28 | } 29 | 30 | @GetMapping("/main") 31 | public String main(){ 32 | return "main"; 33 | } 34 | 35 | @PostMapping("/login") 36 | @ResponseBody 37 | public String login(String userName){ 38 | return userName; 39 | } 40 | 41 | @GetMapping("/listAllUser") 42 | @ResponseBody 43 | public List listAllUser(){ 44 | return this.webSocket.listOnline(); 45 | } 46 | 47 | @PostMapping("/sendSingleMsg") 48 | @ResponseBody 49 | public void sendSingleMsg(String fromUserName,String toUserName, String msg, HttpSession session){ 50 | this.webSocket.sendP2PMsgBy2UserName(fromUserName,toUserName,msg); 51 | } 52 | 53 | @PostMapping("/sendMultiMsg") 54 | @ResponseBody 55 | public void sendMultiMsg(String fromUserName,String msg){ 56 | this.webSocket.sendMsg(fromUserName,msg); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /spring-boot-redisson/src/main/java/com/zh/springbootredisson/service/impl/OrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootredisson.service.impl; 2 | 3 | import com.zh.springbootredisson.service.OrderService; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.redisson.api.RLock; 6 | import org.redisson.api.RedissonClient; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.data.redis.core.StringRedisTemplate; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.concurrent.TimeUnit; 12 | 13 | /** 14 | * @author zhanghang 15 | * @date 2019/6/6 16 | */ 17 | @Slf4j 18 | @Service 19 | public class OrderServiceImpl implements OrderService { 20 | 21 | @Autowired 22 | private RedissonClient redissonClient; 23 | 24 | @Autowired 25 | private StringRedisTemplate stringRedisTemplate; 26 | 27 | @Override 28 | public String book() { 29 | return this.decrementOrder(); 30 | } 31 | 32 | @Override 33 | public String bookWithLock() { 34 | RLock lock = this.redissonClient.getLock("lock"); 35 | try { 36 | lock.lock(10, TimeUnit.SECONDS); 37 | return this.decrementOrder(); 38 | } catch (Exception e) { 39 | log.error(e.getMessage()); 40 | return "预定失败"; 41 | } finally { 42 | lock.unlock(); 43 | } 44 | } 45 | 46 | private String decrementOrder(){ 47 | Long count = Long.valueOf(this.stringRedisTemplate.opsForValue().get("count")); 48 | if (count <= 0){ 49 | return "库存不足"; 50 | }else{ 51 | count = this.stringRedisTemplate.opsForValue().decrement("count"); 52 | } 53 | log.info("==================库存还剩{}个================",count); 54 | return String.valueOf(count); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.5.RELEASE 9 | 10 | 11 | com.zh 12 | spring-boot-thymeleaf 13 | 0.0.1-SNAPSHOT 14 | spring-boot-thymeleaf 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-thymeleaf 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-test 34 | test 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-maven-plugin 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /spring-boot-scheduler/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.5.RELEASE 9 | 10 | 11 | com.zh 12 | spring-boot-scheduler 13 | 0.0.1-SNAPSHOT 14 | spring-boot-scheduler 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | 28 | org.projectlombok 29 | lombok 30 | true 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-test 35 | test 36 | 37 | 38 | 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-maven-plugin 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /spring-boot-command/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.5.RELEASE 9 | 10 | 11 | com.zh 12 | spring-boot-command 13 | 0.0.1-SNAPSHOT 14 | spring-boot-command 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | 28 | org.projectlombok 29 | lombok 30 | true 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-test 36 | test 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-maven-plugin 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.5.RELEASE 9 | 10 | 11 | com.zh 12 | spring-boot-rabbitmq 13 | 0.0.1-SNAPSHOT 14 | spring-boot-rabbitmq 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-amqp 25 | 26 | 27 | 28 | org.projectlombok 29 | lombok 30 | true 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-test 35 | test 36 | 37 | 38 | 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-maven-plugin 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /spring-boot-condition/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.5.RELEASE 9 | 10 | 11 | com.zh 12 | spring-boot-condition 13 | 0.0.1-SNAPSHOT 14 | spring-boot-condition 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | 28 | org.projectlombok 29 | lombok 30 | true 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-test 36 | test 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-maven-plugin 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/zh/springbootrabbitmq/config/RabbitMQAlternateExchangeConfig.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootrabbitmq.config; 2 | 3 | import org.springframework.amqp.core.*; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * rabbitMQ备份交换机配置类 12 | * 当生产者将消息发送到交换机上时, 13 | * 加入交换机通过routingkey无法匹配到绑定了他的队列的bingingkey时 14 | * 为了消息不丢失,指定备份交换机,这样消息可以路由到备份交换机上, 15 | * 在路由到队列里消费,通常备份交换机是fanout类型 16 | * @author zhanghang 17 | * @date 2019/7/9 18 | */ 19 | @Configuration 20 | public class RabbitMQAlternateExchangeConfig { 21 | 22 | private static final String BINDING_KET_AAA = "aaa"; 23 | 24 | @Bean 25 | public DirectExchange altDirectExchange(){ 26 | Map arg = new HashMap<>(16); 27 | arg.put("alternate-exchange","exchange_alt_fanout"); 28 | return new DirectExchange("exchange_alt_direct",true,false,arg); 29 | } 30 | 31 | @Bean 32 | public Queue altDirectQueue(){ 33 | return new Queue("queue_alt_direct"); 34 | } 35 | 36 | 37 | @Bean 38 | public Binding altDirectBinding(Queue altDirectQueue, DirectExchange altDirectExchange){ 39 | return BindingBuilder.bind(altDirectQueue).to(altDirectExchange).with(BINDING_KET_AAA); 40 | } 41 | 42 | @Bean 43 | public FanoutExchange altFanoutExchange(){ 44 | return new FanoutExchange("exchange_alt_fanout"); 45 | } 46 | 47 | @Bean 48 | public Queue altFanoutQueue(){ 49 | return new Queue("queue_alt_fanout"); 50 | } 51 | 52 | @Bean 53 | public Binding altFanoutBinding(Queue altFanoutQueue, FanoutExchange altFanoutExchange){ 54 | return BindingBuilder.bind(altFanoutQueue).to(altFanoutExchange); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/zh/springbootjwt/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjwt.service.impl; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import com.zh.springbootjwt.model.User; 5 | import com.zh.springbootjwt.service.UserService; 6 | import com.zh.springbootjwt.utils.JwtUtil; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | import java.util.Optional; 12 | 13 | /** 14 | * @author zhanghang 15 | * @date 2019/6/25 16 | */ 17 | @Service 18 | public class UserServiceImpl implements UserService { 19 | 20 | private static Map map = new HashMap<>(16); 21 | 22 | static { 23 | map.put(1,new User(1,"张三","111111")); 24 | map.put(2,new User(2,"李四","222222")); 25 | map.put(3,new User(3,"王五","333333")); 26 | map.put(4,new User(4,"赵六","444444")); 27 | map.put(5,new User(5,"田七","555555")); 28 | } 29 | 30 | @Override 31 | public User findByUserId(Integer userId) { 32 | return map.get(userId); 33 | } 34 | 35 | @Override 36 | public JSONObject login(String username,String password) { 37 | JSONObject result = new JSONObject(); 38 | User user = map.entrySet() 39 | .stream() 40 | .filter(e -> e.getValue().getUsername().equals(username)) 41 | .findFirst() 42 | .map(e -> e.getValue()) 43 | .orElse(null); 44 | if (user != null && password.equals(user.getPassword())){ 45 | result.put("result","SUCCESS"); 46 | result.put("token", JwtUtil.createToken(user)); 47 | }else{ 48 | result.put("result","FAIL"); 49 | result.put("msg", "用户名或密码错误"); 50 | } 51 | return result; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /spring-boot-design-pattern/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.5.RELEASE 9 | 10 | 11 | com.zh 12 | spring-boot-design-pattren 13 | 0.0.1-SNAPSHOT 14 | spring-boot-design-pattren 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | 28 | org.projectlombok 29 | lombok 30 | true 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-test 36 | test 37 | 38 | 39 | 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-maven-plugin 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/zh/springbootrabbitmq/config/RabbitMQTTLDLXConfig.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootrabbitmq.config; 2 | 3 | import org.springframework.amqp.core.*; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * rabbitMQ TTL DLX配置类 12 | * TTL:死信,消息在队列里的生存时间,到期即成为死信。 13 | * 可以针对队列设置生存时间也可以针对每一条消息设置生存时间 14 | * 不过这里不建议在生产者里对每一条消息设置生存时间, 15 | * 因为这是一个坑,如果同一个队列里的消息生存时间不一样 16 | * 先入队的消息生存时间长会阻塞后入队生存时间短的消息转发到死信队列 17 | * DLX:死信交换机,通常可以将到期的死信转发到死信交换机, 18 | * 然后死信交换机将消息路由到死信队列消费达到延时队列的目的 19 | * 20 | * @author zhanghang 21 | * @date 2019/7/9 22 | */ 23 | @Configuration 24 | public class RabbitMQTTLDLXConfig { 25 | 26 | @Bean 27 | public FanoutExchange ttlFanoutExchange(){ 28 | return new FanoutExchange("exchange_ttl_fanout"); 29 | } 30 | 31 | @Bean 32 | public Queue ttlFanoutQueue(){ 33 | Map arg = new HashMap<>(16); 34 | arg.put("x-message-ttl", 10000); 35 | arg.put("x-dead-letter-exchange", "exchange_dlx_fanout"); 36 | return new Queue("queue_ttl_fanout",true,false,false,arg); 37 | } 38 | 39 | @Bean 40 | public Binding ttlFanoutBinding(Queue ttlFanoutQueue, FanoutExchange ttlFanoutExchange){ 41 | return BindingBuilder.bind(ttlFanoutQueue).to(ttlFanoutExchange); 42 | } 43 | 44 | @Bean 45 | public FanoutExchange dlxFanoutExchange(){ 46 | return new FanoutExchange("exchange_dlx_fanout"); 47 | } 48 | 49 | @Bean 50 | public Queue dlxFanoutQueue(){ 51 | return new Queue("queue_dlx_fanout"); 52 | } 53 | 54 | @Bean 55 | public Binding dlxFanoutBinding(Queue dlxFanoutQueue, FanoutExchange dlxFanoutExchange){ 56 | return BindingBuilder.bind(dlxFanoutQueue).to(dlxFanoutExchange); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/test/java/com/zh/springbootrabbitmq/SpringBootRabbitmqApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootrabbitmq; 2 | 3 | import com.zh.springbootrabbitmq.config.RabbitMQProduct; 4 | import com.zh.springbootrabbitmq.model.User; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | import java.util.concurrent.TimeUnit; 12 | 13 | @RunWith(SpringRunner.class) 14 | @SpringBootTest 15 | public class SpringBootRabbitmqApplicationTests { 16 | 17 | @Autowired 18 | private RabbitMQProduct rabbitMQProduct; 19 | 20 | @Test 21 | public void fanoutExchangeTest() { 22 | rabbitMQProduct.sendFanoutMsg(new User("张三")); 23 | } 24 | 25 | @Test 26 | public void directExchangeTest() { 27 | rabbitMQProduct.sendDirectMsg(new User("李四"),"bbb"); 28 | } 29 | 30 | @Test 31 | public void topicExchangeTest() { 32 | rabbitMQProduct.sendTopicMsg(new User("王五"),"aaa.bbb"); 33 | rabbitMQProduct.sendTopicMsg(new User("赵六"),"aaa.bbb.ccc"); 34 | } 35 | 36 | @Test 37 | public void alternateExchangeTest() { 38 | rabbitMQProduct.sendAlternateMsg(new User("田七"),"aaa"); 39 | rabbitMQProduct.sendAlternateMsg(new User("庞八"),"bbb"); 40 | } 41 | 42 | @Test 43 | public void delayTTLDLXExchangeTest() throws InterruptedException { 44 | rabbitMQProduct.sendTTLDLXDelayMsg(new User("陈九")); 45 | TimeUnit.SECONDS.sleep(15); 46 | } 47 | 48 | @Test 49 | public void delayExchangeTest() throws InterruptedException { 50 | rabbitMQProduct.sendDelayMsg(new User("周十"),"aaa",10000); 51 | rabbitMQProduct.sendDelayMsg(new User("吴十一"),"aaa",5000); 52 | TimeUnit.SECONDS.sleep(15); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /spring-boot-atomikos-jta/src/test/java/com/zh/springbootatomikosjta/SpringBootAtomikosJtaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootatomikosjta; 2 | 3 | import com.zh.springbootatomikosjta.model.test1.Order; 4 | import com.zh.springbootatomikosjta.model.test2.Stock; 5 | import com.zh.springbootatomikosjta.service.BookProductService; 6 | import com.zh.springbootatomikosjta.service.OrderService; 7 | import com.zh.springbootatomikosjta.service.StockService; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.context.SpringBootTest; 13 | import org.springframework.test.context.junit4.SpringRunner; 14 | 15 | import java.util.Optional; 16 | 17 | @Slf4j 18 | @RunWith(SpringRunner.class) 19 | @SpringBootTest 20 | public class SpringBootAtomikosJtaApplicationTests { 21 | 22 | @Autowired 23 | private BookProductService bookProductService; 24 | 25 | @Autowired 26 | private OrderService orderService; 27 | 28 | @Autowired 29 | private StockService stockService; 30 | 31 | @Test 32 | public void bookProductTest() { 33 | Integer productId = 1; 34 | Integer userId = 1; 35 | Order order = this.orderService.findByProductId(productId); 36 | log.info(Optional.ofNullable(order).map(e -> e.toString()).orElse(null)); 37 | Stock stock = this.stockService.findByProductId(productId); 38 | log.info(Optional.ofNullable(stock).map(e -> e.toString()).orElse(null)); 39 | this.bookProductService.bookProduct(productId,userId); 40 | order = this.orderService.findByProductId(productId); 41 | log.info(Optional.ofNullable(order).map(e -> e.toString()).orElse(null)); 42 | stock = this.stockService.findByProductId(productId); 43 | log.info(Optional.ofNullable(stock).map(e -> e.toString()).orElse(null)); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/zh/springbootrabbitmq/config/RabbitMQProduct.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootrabbitmq.config; 2 | 3 | import com.zh.springbootrabbitmq.model.User; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.amqp.rabbit.core.RabbitTemplate; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Component; 8 | 9 | /** 10 | * @author zhanghang 11 | * @date 2019/7/9 12 | */ 13 | @Slf4j 14 | @Component 15 | public class RabbitMQProduct { 16 | 17 | @Autowired 18 | private RabbitTemplate rabbitTemplate; 19 | 20 | public void sendFanoutMsg(User user){ 21 | this.rabbitTemplate.convertAndSend("exchange_fanout",null,user); 22 | } 23 | 24 | public void sendDirectMsg(User user,String routingKey) { 25 | this.rabbitTemplate.convertAndSend("exchange_direct",routingKey,user); 26 | } 27 | 28 | public void sendTopicMsg(User user,String routingKey) { 29 | this.rabbitTemplate.convertAndSend("exchange_topic",routingKey,user); 30 | } 31 | 32 | public void sendAlternateMsg(User user, String routingKey) { 33 | this.rabbitTemplate.convertAndSend("exchange_alt_direct",routingKey,user); 34 | } 35 | 36 | public void sendTTLDLXDelayMsg(User user) { 37 | log.info("============TTLDLX延时队列发送消息============="); 38 | this.rabbitTemplate.convertAndSend("exchange_ttl_fanout",null,user); 39 | } 40 | 41 | public void sendDelayMsg(User user, String routingKey, long expiration) { 42 | log.info("============delay exchange延时队列发送消息============="); 43 | this.rabbitTemplate.convertAndSend( 44 | "exchange_delay", 45 | routingKey, 46 | user, 47 | message -> { 48 | message.getMessageProperties().setHeader("x-delay",expiration); 49 | return message; 50 | } 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.zh 8 | spring-boot-demos 9 | pom 10 | 1.0-SNAPSHOT 11 | 12 | 13 | spring-boot-condition 14 | spring-boot-redis 15 | spring-boot-java8stream 16 | spring-boot-banner 17 | spring-boot-swagger 18 | spring-boot-command 19 | spring-boot-mybatis 20 | spring-boot-jpa 21 | spring-boot-aoplog 22 | spring-boot-mail 23 | spring-boot-scheduler 24 | spring-boot-thymeleaf 25 | spring-boot-easypoi 26 | spring-boot-exception 27 | spring-boot-redisson 28 | spring-boot-multidatasource 29 | spring-boot-atomikos-jta 30 | spring-boot-activemq 31 | spring-boot-mongodb 32 | spring-boot-async 33 | spring-boot-elasticsearch 34 | spring-boot-logback 35 | spring-boot-websocket 36 | spring-boot-jwt 37 | spring-boot-shiro 38 | spring-boot-bloomfilter 39 | spring-boot-docker 40 | spring-boot-rabbitmq 41 | spring-boot-design-pattern 42 | 43 | -------------------------------------------------------------------------------- /spring-boot-multidatasource/src/test/java/com/zh/springbootmultidatasource/SpringBootMultidatasourceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootmultidatasource; 2 | 3 | import com.zh.springbootmultidatasource.model.test1.Order; 4 | import com.zh.springbootmultidatasource.model.test2.Stock; 5 | import com.zh.springbootmultidatasource.service.BookProductService; 6 | import com.zh.springbootmultidatasource.service.OrderService; 7 | import com.zh.springbootmultidatasource.service.StockService; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.context.SpringBootTest; 13 | import org.springframework.test.context.junit4.SpringRunner; 14 | 15 | import java.util.Optional; 16 | 17 | @Slf4j 18 | @RunWith(SpringRunner.class) 19 | @SpringBootTest 20 | public class SpringBootMultidatasourceApplicationTests { 21 | 22 | @Autowired 23 | private BookProductService bookProductService; 24 | 25 | @Autowired 26 | private OrderService orderService; 27 | 28 | @Autowired 29 | private StockService stockService; 30 | 31 | @Test 32 | public void bookProductTest() { 33 | Integer productId = 1; 34 | Integer userId = 1; 35 | Order order = this.orderService.findByProductId(productId); 36 | log.info(Optional.ofNullable(order).map(e -> e.toString()).orElse(null)); 37 | Stock stock = this.stockService.findByProductId(productId); 38 | log.info(Optional.ofNullable(stock).map(e -> e.toString()).orElse(null)); 39 | this.bookProductService.bookProduct(productId,userId); 40 | order = this.orderService.findByProductId(productId); 41 | log.info(Optional.ofNullable(order).map(e -> e.toString()).orElse(null)); 42 | stock = this.stockService.findByProductId(productId); 43 | log.info(Optional.ofNullable(stock).map(e -> e.toString()).orElse(null)); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-boot-activemq/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.5.RELEASE 9 | 10 | 11 | com.zh 12 | spring-boot-activemq 13 | 0.0.1-SNAPSHOT 14 | spring-boot-activemq 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-activemq 25 | 26 | 27 | org.messaginghub 28 | pooled-jms 29 | 30 | 31 | org.projectlombok 32 | lombok 33 | true 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-maven-plugin 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/zh/springbootjwt/config/resolver/UserArgumentResolver.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjwt.config.resolver; 2 | 3 | import com.zh.springbootjwt.config.annotation.CurrentUser; 4 | import com.zh.springbootjwt.model.User; 5 | import com.zh.springbootjwt.service.UserService; 6 | import com.zh.springbootjwt.utils.JwtUtil; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.core.MethodParameter; 9 | import org.springframework.stereotype.Component; 10 | import org.springframework.web.bind.support.WebDataBinderFactory; 11 | import org.springframework.web.context.request.NativeWebRequest; 12 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 13 | import org.springframework.web.method.support.ModelAndViewContainer; 14 | 15 | 16 | /** 17 | * 参数解析器 18 | * 将当前登陆用户的信息注入到参数里 19 | * @author zhanghang 20 | * @date 2019/6/25 21 | */ 22 | @Component 23 | public class UserArgumentResolver implements HandlerMethodArgumentResolver { 24 | 25 | @Autowired 26 | private UserService userService; 27 | 28 | @Override 29 | public boolean supportsParameter(MethodParameter methodParameter) { 30 | return methodParameter.getParameterType().isAssignableFrom(User.class) && methodParameter.hasParameterAnnotation(CurrentUser.class); 31 | } 32 | 33 | @Override 34 | public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer modelAndViewContainer, NativeWebRequest nativeWebRequest, WebDataBinderFactory webDataBinderFactory) throws Exception { 35 | String token = nativeWebRequest.getHeader("token"); 36 | if (token != null){ 37 | Integer userId = JwtUtil.getUserId(token); 38 | if (userId != null){ 39 | User user = this.userService.findByUserId(userId); 40 | if (user != null){ 41 | return user; 42 | } 43 | } 44 | } 45 | return null; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-boot-jwt/src/main/java/com/zh/springbootjwt/utils/JwtUtil.java: -------------------------------------------------------------------------------- 1 | package com.zh.springbootjwt.utils; 2 | 3 | import cn.hutool.core.date.DateUtil; 4 | import com.auth0.jwt.JWT; 5 | import com.auth0.jwt.JWTVerifier; 6 | import com.auth0.jwt.algorithms.Algorithm; 7 | import com.auth0.jwt.exceptions.JWTDecodeException; 8 | import com.auth0.jwt.exceptions.JWTVerificationException; 9 | import com.zh.springbootjwt.model.User; 10 | import lombok.extern.slf4j.Slf4j; 11 | import org.springframework.util.StringUtils; 12 | 13 | import java.util.Date; 14 | import java.util.Optional; 15 | 16 | /** 17 | * @author zhanghang 18 | * @date 2019/6/25 19 | */ 20 | @Slf4j 21 | public class JwtUtil { 22 | 23 | public static String createToken(User user){ 24 | Date now = new Date(); 25 | return JWT.create() 26 | //设置载荷payload 27 | .withClaim("userId",user.getId()) 28 | //生成签名的时间 29 | .withIssuedAt(now) 30 | //签名过期的时间 31 | .withExpiresAt(DateUtil.offsetHour(now,1).toJdkDate()) 32 | .sign(Algorithm.HMAC256(user.getPassword())); 33 | } 34 | 35 | public static boolean verifyToken(String token,String secret){ 36 | if (StringUtils.isEmpty(token) || StringUtils.isEmpty(secret)){ 37 | return false; 38 | } 39 | JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(secret)).build(); 40 | try { 41 | jwtVerifier.verify(token); 42 | return true; 43 | } catch (Exception e) { 44 | log.error(e.getMessage(),e); 45 | return false; 46 | } 47 | } 48 | 49 | public static Integer getUserId(String token){ 50 | try { 51 | return Optional.ofNullable(JWT.decode(token).getClaim("userId")).map(e -> e.asInt()).orElse(null); 52 | } catch (Exception e) { 53 | log.error(e.getMessage(),e); 54 | return null; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /spring-boot-mail/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.5.RELEASE 9 | 10 | 11 | com.zh 12 | spring-boot-mail 13 | 0.0.1-SNAPSHOT 14 | spring-boot-mail 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-mail 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | 32 | org.projectlombok 33 | lombok 34 | true 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-test 39 | test 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-maven-plugin 48 | 49 | 50 | 51 | 52 | 53 | --------------------------------------------------------------------------------