├── .gitignore ├── LICENSE ├── README.md ├── doc └── webflux │ ├── Spring Boot 2 快速教程:WebFlux Restful CRUD 实践(三).md │ ├── Spring Boot 2 快速教程:WebFlux 快速入门(二).md │ ├── Spring Boot 2 快速教程:WebFlux 集成 Mongodb(四).md │ ├── Spring Boot 2 快速教程:WebFlux 集成 Thymeleaf 、 Mongodb 实践(六).md │ ├── Spring Boot 2 快速教程:WebFlux 集成 Thymeleaf(五).md │ └── image │ ├── 2.png │ └── noshow.png ├── pom.xml ├── spring-boot-2.x-annotation-filter ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootExamplesApplication.java │ │ │ ├── config │ │ │ └── WebApplicationConfig.java │ │ │ └── filter │ │ │ └── URLFilter.java │ └── resources │ │ ├── application.properties │ │ └── static │ │ └── hello.html │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootExamplesApplicationTests.java ├── spring-boot-2.x-custom-start-dependency ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ ├── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ ├── httpclient │ │ │ │ ├── autoconfig │ │ │ │ │ ├── HttpClientAutoConfiguration.java │ │ │ │ │ └── HttpClientProperties.java │ │ │ │ └── enable │ │ │ │ │ └── EnableHttpClient.java │ │ │ └── robot │ │ │ │ ├── TencentAIOpenPlatformProperties.java │ │ │ │ ├── controller │ │ │ │ └── ReBotChatController.java │ │ │ │ └── util │ │ │ │ ├── MD5Util.java │ │ │ │ └── TencentAIHelper.java │ │ │ └── lijunkui2 │ │ │ └── autoconfig │ │ │ ├── HttpClientAutoConfigurationOut.java │ │ │ └── HttpClientPropertiesOut.java │ └── resources │ │ ├── META-INF │ │ └── spring.factories │ │ ├── application.properties │ │ └── static │ │ ├── hello.html │ │ └── rebot.html │ └── test │ └── java │ └── cn │ └── lijunkui │ ├── SpringbootexamplesApplicationTests.java │ └── autoconfig │ └── HttpClientAutoConfigurationTest.java ├── spring-boot-2.x-freemarker ├── EnableHttpClient.java ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── demo │ │ │ └── HelloWorldController.java │ └── resources │ │ ├── application.properties │ │ ├── static │ │ └── hello.html │ │ └── templates │ │ └── test │ │ └── helloworld.ftl │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-interceptor ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ ├── controller │ │ │ └── IndexController.java │ │ │ └── interceptor │ │ │ ├── InterceptorConfigByExtendsWebMvcConfigurerAdapter.java │ │ │ ├── InterceptorConfigByImplWebMvcConfigurer.java │ │ │ └── LoginInterceptor.java │ └── resources │ │ ├── application.properties │ │ ├── static │ │ └── hello.html │ │ └── templates │ │ └── index.ftl │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-jsp ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── jsp │ │ │ └── JspController.java │ ├── resources │ │ ├── application.properties │ │ ├── static │ │ │ ├── 1.png │ │ │ ├── 2.png │ │ │ └── hello.html │ │ └── templates │ │ │ └── test │ │ │ └── freemarkerDemo.ftl │ └── webapp │ │ └── WEB-INF │ │ └── jsp │ │ └── welcome.jsp │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-jwt ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ ├── controller │ │ │ ├── IndexController.java │ │ │ └── LoginController.java │ │ │ ├── exception │ │ │ ├── ExceptionHandle.java │ │ │ ├── customexception │ │ │ │ └── JKException.java │ │ │ └── message │ │ │ │ ├── CodeEnum.java │ │ │ │ ├── ReturnMessage.java │ │ │ │ └── ReturnMessageUtil.java │ │ │ ├── interceptor │ │ │ ├── InterceptorConfig.java │ │ │ └── LoginInterceptor.java │ │ │ ├── jwt │ │ │ └── Payload.java │ │ │ └── utils │ │ │ └── JWTService.java │ ├── resources │ │ ├── application.properties │ │ ├── static │ │ │ ├── 1.png │ │ │ ├── 2.png │ │ │ ├── 3.png │ │ │ ├── 4.png │ │ │ ├── 5.png │ │ │ ├── 6.png │ │ │ ├── 7.png │ │ │ └── hello.html │ │ └── templates │ │ │ ├── footer.html │ │ │ ├── productList.html │ │ │ └── test │ │ │ └── freemarkerDemo.ftl │ └── webapp │ │ ├── WEB-INF │ │ └── jsp │ │ │ └── welcome.jsp │ │ ├── css │ │ └── gtvg.css │ │ └── images │ │ └── gtvglogo.png │ └── test │ └── java │ └── cn │ └── lijunkui │ ├── JWTDemo.java │ ├── JWTServiceTest.java │ ├── SpringbootexamplesApplicationTests.java │ └── User.java ├── spring-boot-2.x-listener ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootExamplesApplication.java │ │ │ ├── config │ │ │ └── WebApplicationConfig.java │ │ │ └── listener │ │ │ └── ApplicationListener.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootExamplesApplicationTests.java ├── spring-boot-2.x-mybaties-multipleDataSource ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ ├── config │ │ │ ├── DataSourceAop.java │ │ │ ├── DataSourceConfig.java │ │ │ ├── DynamicDataSourceRouting.java │ │ │ ├── DynamicDataSourceRoutingKeyState.java │ │ │ ├── TargetDataSource.java │ │ │ └── TransactionConfiguration.java │ │ │ ├── controller │ │ │ ├── HotelController.java │ │ │ └── ProductController.java │ │ │ ├── dao │ │ │ ├── HotelMapper.java │ │ │ └── ProductMapper.java │ │ │ ├── domain │ │ │ ├── Hotel.java │ │ │ └── Product.java │ │ │ ├── enums │ │ │ └── DataSourceKeyEnum.java │ │ │ └── service │ │ │ ├── HotelService.java │ │ │ └── ProductService.java │ └── resources │ │ ├── application.yml │ │ ├── mapper │ │ ├── HotelMapper.xml │ │ └── ProductMapper.xml │ │ └── mybatis-config.xml │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-mybaties ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ ├── config │ │ │ └── DruidConfig.java │ │ │ ├── controller │ │ │ └── ProductController.java │ │ │ └── mybaties │ │ │ ├── annotation │ │ │ ├── ProductMapper.java │ │ │ ├── ProductProvider.java │ │ │ └── domain │ │ │ │ └── Product.java │ │ │ └── xml │ │ │ ├── domain │ │ │ └── Hotel.java │ │ │ ├── mapper │ │ │ └── HotelMapper.java │ │ │ ├── page │ │ │ ├── Page.java │ │ │ └── PageInfo.java │ │ │ └── param │ │ │ └── HotalParam.java │ └── resources │ │ ├── application.properties │ │ ├── mybatis-config.xml │ │ ├── simple │ │ └── mapper │ │ │ └── HotelMapper.xml │ │ └── static │ │ └── hello.html │ └── test │ └── java │ └── cn │ └── lijunkui │ ├── SpringbootexamplesApplicationTests.java │ └── mybaties │ ├── annotation │ └── mapper │ │ └── ProductMapperTest.java │ └── xml │ └── mapper │ └── HotelMapperTest.java ├── spring-boot-2.x-rabbit-mq ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── rabbitmq │ │ │ ├── direct │ │ │ ├── RabbitMQConfig.java │ │ │ ├── RabbitMQSend.java │ │ │ ├── RabbitReceiver.java │ │ │ └── controller │ │ │ │ └── RabbitMQDemoController.java │ │ │ ├── fanout │ │ │ ├── RabbitMQFanoutConfig.java │ │ │ ├── RabbitMQFanoutReceiver.java │ │ │ ├── RabbitMQFanoutSend.java │ │ │ └── controller │ │ │ │ └── RabbitMQFanoutDemoController.java │ │ │ ├── header │ │ │ ├── RabbitHeadReceiver.java │ │ │ ├── RabbitMQHeadSend.java │ │ │ ├── RabbitMQHeaderConfig.java │ │ │ └── controller │ │ │ │ └── RabbitMQHeadDemoController.java │ │ │ └── topic │ │ │ ├── RabbitMQTopicConfig.java │ │ │ ├── RabbitMQTopicReceiver.java │ │ │ ├── RabbitMQTopicSend.java │ │ │ └── controller │ │ │ └── RabbitMQTopicDemoController.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-redis-jedis-objectcache ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ ├── cache │ │ │ ├── JedisCacheService.java │ │ │ ├── JedisCacheServiceSupport.java │ │ │ └── JedisJsonCacheService.java │ │ │ ├── config │ │ │ └── JedisConfig.java │ │ │ ├── model │ │ │ └── User.java │ │ │ └── util │ │ │ └── IOUtil.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── cn │ └── lijunkui │ ├── JedisTest.java │ ├── SpringbootexamplesApplicationTests.java │ └── cache │ ├── JedisCacheServiceTest.java │ └── JedisJsonCacheServiceTest.java ├── spring-boot-2.x-redis-jedis ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── config │ │ │ └── JedisConfig.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── cn │ └── lijunkui │ ├── JedisTest.java │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-redis-redistemplate ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ └── SpringbootexamplesApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── cn │ └── lijunkui │ ├── RedisTemplateTest.java │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-redis ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── jedis │ │ │ ├── JedisAutoConfiguration.java │ │ │ ├── JedisProperties.java │ │ │ └── Pool.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── cn │ └── lijunkui │ └── jedis │ ├── JedisTest.java │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-rest-template ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── resttemplate │ │ │ ├── config │ │ │ └── RestTemplateConfig.java │ │ │ ├── model │ │ │ └── User.java │ │ │ └── support │ │ │ └── CustomConnectionKeepAliveStrategy.java │ └── resources │ │ ├── application.properties │ │ └── static │ │ └── hello.html │ └── test │ └── java │ └── cn │ └── lijunkui │ ├── RestTemplateDemoController.java │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-restful-api ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── restful │ │ │ ├── basic │ │ │ ├── controller │ │ │ │ └── UserController.java │ │ │ └── model │ │ │ │ └── User.java │ │ │ ├── coutomvalidator │ │ │ ├── UserController.java │ │ │ ├── custominterface │ │ │ │ ├── Addr.java │ │ │ │ ├── AddrWithEnum.java │ │ │ │ ├── AddrWithParam.java │ │ │ │ └── MyAddrValidator.java │ │ │ └── model │ │ │ │ └── User.java │ │ │ ├── filter │ │ │ └── PutFilter.java │ │ │ └── hibernatevalidator │ │ │ ├── UserController.java │ │ │ └── model │ │ │ └── User.java │ └── resources │ │ ├── application.properties │ │ └── static │ │ └── hello.html │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-sentinel ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── test │ │ │ └── TestController.java │ └── resources │ │ ├── application.properties │ │ └── static │ │ └── hello.html │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-servlet ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ ├── config │ │ │ └── WebApplicationConfig.java │ │ │ ├── model │ │ │ └── User.java │ │ │ ├── servlet │ │ │ └── UserServlet.java │ │ │ └── utils │ │ │ └── JsonUtil.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-spring-data-jpa ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── jpa │ │ │ ├── model │ │ │ ├── ResultDTO.java │ │ │ ├── User.java │ │ │ └── UserParam.java │ │ │ └── repository │ │ │ ├── UserCrudRepository.java │ │ │ ├── UserJpaRepository.java │ │ │ ├── UserJpaSpecificationExecutor.java │ │ │ ├── UserMethodNameQueryRepositroy.java │ │ │ ├── UserPagingAndSortingRepository.java │ │ │ └── UserQueryAnnotationRepository.java │ └── resources │ │ ├── application.properties │ │ └── static │ │ ├── application.yml │ │ └── hello.html │ └── test │ └── java │ └── cn │ └── lijunkui │ ├── SpringbootexamplesApplicationTests.java │ └── jpa │ └── repository │ ├── UserCrudRepositoryTest.java │ ├── UserJpaRepositoryTest.java │ ├── UserJpaSpecificationExecutorTest.java │ ├── UserMethodNameQueryRepositroyTest.java │ ├── UserPagingAndSortingRepositoryTest.java │ └── UserQueryAnnotationRepositoryTest.java ├── spring-boot-2.x-spring-session-1 ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── controller │ │ │ └── SpringSessionTestController.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-spring-session-2 ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── controller │ │ │ └── SpringSessionTestController.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-spring-webflux ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── helloworld │ │ │ ├── springmvc │ │ │ └── HelloWordMvcController.java │ │ │ └── springwebflux │ │ │ └── HelloWordWebFluxController.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-start ├── README.md └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ └── SpringbootexamplesApplication.java │ └── resources │ │ ├── application.properties │ │ └── static │ │ └── hello.html │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-swagger-starter ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── swagger │ │ │ ├── SwaggerConfig.java │ │ │ ├── User.java │ │ │ └── UserController.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-swagger ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── swagger │ │ │ ├── SwaggerConfig.java │ │ │ ├── User.java │ │ │ └── UserController.java │ ├── resources │ │ ├── application.properties │ │ └── static │ │ │ ├── 1.png │ │ │ ├── 10.png │ │ │ ├── 11.png │ │ │ ├── 2.png │ │ │ ├── 3.png │ │ │ ├── 4.png │ │ │ ├── 5.png │ │ │ ├── 6.png │ │ │ ├── 7.png │ │ │ ├── 8.png │ │ │ ├── 9.png │ │ │ └── hello.html │ └── webapp │ │ ├── WEB-INF │ │ └── jsp │ │ │ └── welcome.jsp │ │ ├── css │ │ └── gtvg.css │ │ └── images │ │ └── gtvglogo.png │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-thymeleaf ├── README.md ├── pom.xml ├── src │ ├── main │ │ ├── java │ │ │ └── cn │ │ │ │ └── lijunkui │ │ │ │ ├── SpringbootexamplesApplication.java │ │ │ │ ├── course │ │ │ │ ├── CourseController.java │ │ │ │ └── pojo │ │ │ │ │ └── User.java │ │ │ │ ├── helloword │ │ │ │ └── controller │ │ │ │ │ └── ThymeleafHelloWrodController.java │ │ │ │ ├── layout │ │ │ │ └── LayoutController.java │ │ │ │ └── thymeleaf │ │ │ │ ├── officialexamples │ │ │ │ └── product │ │ │ │ │ ├── LocaleResolverConfig.java │ │ │ │ │ ├── ProductController.java │ │ │ │ │ ├── model │ │ │ │ │ ├── Comment.java │ │ │ │ │ ├── Product.java │ │ │ │ │ └── User.java │ │ │ │ │ ├── repositories │ │ │ │ │ └── ProductRepository.java │ │ │ │ │ ├── service │ │ │ │ │ └── ProductService.java │ │ │ │ │ └── util │ │ │ │ │ └── CalendarUtil.java │ │ │ │ └── upload │ │ │ │ └── FileUploadController.java │ │ ├── resources │ │ │ ├── application.properties │ │ │ ├── message.properties │ │ │ ├── message_en_US.properties │ │ │ ├── message_zh_CN.properties │ │ │ ├── static │ │ │ │ ├── 0.png │ │ │ │ ├── hello.html │ │ │ │ ├── huploadify │ │ │ │ │ ├── Huploadify.css │ │ │ │ │ ├── demo.html │ │ │ │ │ ├── jquery.Huploadify.js │ │ │ │ │ ├── jquery.js │ │ │ │ │ ├── readme.txt │ │ │ │ │ └── upload.php │ │ │ │ ├── index.html │ │ │ │ └── upload │ │ │ │ │ └── QQ图片20181017130208 - 副本.jpg │ │ │ └── templates │ │ │ │ ├── course │ │ │ │ ├── aggregates.html │ │ │ │ ├── arrays.html │ │ │ │ ├── bools.html │ │ │ │ ├── dates.html │ │ │ │ ├── elvis.html │ │ │ │ ├── ids.html │ │ │ │ ├── lists.html │ │ │ │ ├── maps.html │ │ │ │ ├── noOperation.html │ │ │ │ ├── numbers.html │ │ │ │ ├── objects.html │ │ │ │ ├── sets.html │ │ │ │ ├── strings.html │ │ │ │ ├── th.html │ │ │ │ ├── thaction.html │ │ │ │ ├── thattr.html │ │ │ │ ├── thclass.html │ │ │ │ ├── theach.html │ │ │ │ ├── thhref.html │ │ │ │ ├── thid.html │ │ │ │ ├── thif.html │ │ │ │ ├── thinline.html │ │ │ │ ├── thonclick.html │ │ │ │ ├── threeElementOperation.html │ │ │ │ ├── thselected.html │ │ │ │ ├── thsrc.html │ │ │ │ ├── thstyle.html │ │ │ │ ├── thswitch.html │ │ │ │ ├── thvalue.html │ │ │ │ └── thwith.html │ │ │ │ ├── footer.html │ │ │ │ ├── footer2.html │ │ │ │ ├── hello │ │ │ │ └── index.html │ │ │ │ ├── layout │ │ │ │ ├── header.html │ │ │ │ ├── index.html │ │ │ │ ├── index2.html │ │ │ │ └── remove.html │ │ │ │ ├── productList.html │ │ │ │ └── test │ │ │ │ └── freemarkerDemo.ftl │ │ └── webapp │ │ │ ├── WEB-INF │ │ │ └── jsp │ │ │ │ └── welcome.jsp │ │ │ ├── css │ │ │ └── gtvg.css │ │ │ └── images │ │ │ └── gtvglogo.png │ └── test │ │ └── java │ │ └── cn │ │ └── lijunkui │ │ └── SpringbootexamplesApplicationTests.java └── target │ ├── lesson5_thymeleaf-0.0.1-SNAPSHOT.jar.original │ └── maven-status │ └── maven-compiler-plugin │ ├── compile │ └── default-compile │ │ └── createdFiles.lst │ └── testCompile │ └── default-testCompile │ └── createdFiles.lst ├── spring-boot-2.x-unified_anomaly ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── unifiedException │ │ │ ├── ExceptionHandle.java │ │ │ ├── controller │ │ │ └── DemoException.java │ │ │ ├── customexception │ │ │ └── SbException.java │ │ │ └── message │ │ │ ├── ReturnMessage.java │ │ │ └── ReturnMessageUtil.java │ ├── resources │ │ ├── application.properties │ │ ├── message.properties │ │ ├── message_en_US.properties │ │ ├── message_zh_CN.properties │ │ ├── static │ │ │ ├── 4.png │ │ │ └── hello.html │ │ └── templates │ │ │ ├── footer.html │ │ │ ├── productList.html │ │ │ └── test │ │ │ └── freemarkerDemo.ftl │ └── webapp │ │ ├── WEB-INF │ │ └── jsp │ │ │ └── welcome.jsp │ │ ├── css │ │ └── gtvg.css │ │ └── images │ │ └── gtvglogo.png │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-weixin ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ ├── WeiXinService.java │ │ │ ├── config │ │ │ └── WeiXinConfig.java │ │ │ ├── controller │ │ │ └── WeiXinDemoController.java │ │ │ └── resttemplate │ │ │ ├── config │ │ │ └── RestTemplateConfig.java │ │ │ ├── model │ │ │ └── User.java │ │ │ └── support │ │ │ └── CustomConnectionKeepAliveStrategy.java │ └── resources │ │ ├── application.properties │ │ └── static │ │ ├── hello.html │ │ ├── jquery-1.8.3.min.js │ │ ├── weixinshare.html │ │ └── wxShare.js │ └── test │ └── java │ └── cn │ └── lijunkui │ ├── RestTemplateDemoController.java │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x-wxpay ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ ├── resttemplate │ │ │ ├── config │ │ │ │ └── RestTemplateConfig.java │ │ │ ├── model │ │ │ │ └── User.java │ │ │ └── support │ │ │ │ └── CustomConnectionKeepAliveStrategy.java │ │ │ └── wx │ │ │ ├── official │ │ │ ├── WeiXinPaySupportUtil.java │ │ │ ├── WxPayOfficialDemoController.java │ │ │ └── config │ │ │ │ └── WeiXinOfficPayProperties.java │ │ │ ├── test │ │ │ ├── WeiXinPayTestController.java │ │ │ └── config │ │ │ │ └── WeiXinPayProperties.java │ │ │ └── utils │ │ │ └── WeiXinUtil.java │ └── resources │ │ ├── application.properties │ │ └── static │ │ ├── gotoNativePage.html │ │ ├── gotoNativePage2.html │ │ ├── jquery-1.8.3.min.js │ │ ├── jquery.qrcode.js │ │ ├── jquery.qrcode.min.js │ │ └── qrcode.js │ └── test │ └── java │ └── cn │ └── lijunkui │ ├── RestTemplateDemoController.java │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x_filter ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── filter │ │ │ ├── FilterConfig.java │ │ │ └── URLFilter.java │ └── resources │ │ ├── application.properties │ │ └── static │ │ ├── 1.png │ │ └── hello.html │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x_mail ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── mail │ │ │ ├── InlineResource.java │ │ │ └── MailService.java │ └── resources │ │ ├── application.properties │ │ ├── image.jpg │ │ └── static │ │ └── hello.html │ └── test │ └── java │ └── cn │ └── lijunkui │ ├── SpringbootexamplesApplicationTests.java │ └── mail │ └── MailServiceTest.java ├── spring-boot-2.x_task ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── task │ │ │ ├── jdk │ │ │ ├── scheduledExecutorService │ │ │ │ ├── ScheduledExecutorTask.java │ │ │ │ └── ScheduledExecutorTest.java │ │ │ └── timer │ │ │ │ ├── DemoTask.java │ │ │ │ ├── TimerManger.java │ │ │ │ └── TimerMangerRunner.java │ │ │ ├── own │ │ │ ├── SchedulerTask.java │ │ │ └── SchedulerTaskForCron.java │ │ │ └── quartz │ │ │ ├── cron │ │ │ ├── CronJob.java │ │ │ ├── CronJob2.java │ │ │ ├── CronSchedulerJobManger.java │ │ │ ├── CronSchedulerRunner.java │ │ │ └── service │ │ │ │ └── LiveReminderService.java │ │ │ └── simple │ │ │ ├── SimpleJob.java │ │ │ ├── SimpleJobConfig.java │ │ │ └── service │ │ │ └── OrderService.java │ └── resources │ │ ├── application.properties │ │ └── static │ │ └── hello.html │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-2.x_websocket ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── lijunkui │ │ │ ├── SpringbootexamplesApplication.java │ │ │ └── socket │ │ │ ├── Socket.java │ │ │ ├── SocketTestController.java │ │ │ └── config │ │ │ └── WebSocketConfig.java │ ├── resources │ │ ├── application.properties │ │ └── static │ │ │ ├── controllerTest.html │ │ │ ├── hello.html │ │ │ └── socket.html │ └── webapp │ │ ├── WEB-INF │ │ └── jsp │ │ │ └── welcome.jsp │ │ ├── css │ │ └── gtvg.css │ │ └── images │ │ └── gtvglogo.png │ └── test │ └── java │ └── cn │ └── lijunkui │ └── SpringbootexamplesApplicationTests.java ├── spring-boot-start-httpclient ├── pom.xml └── src │ └── main │ └── java │ └── cn │ └── lijunkui │ └── autoconfig │ ├── EnableHttpClient.java │ ├── HttpClientAutoConfiguration.java │ └── HttpClientProperties.java ├── springboot-2.x-httpclient-custom-starter ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── zhuoqianmingyue │ │ │ ├── HttpClientConfig.java │ │ │ └── SpringBootExamplesApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── cn │ └── zhuoqianmingyue │ ├── HttpClientAutoConfigurationTest.java │ └── SpringBootExamplesApplicationTests.java └── src ├── main └── java │ └── springbootexamples │ └── Demo.java └── test └── java └── springbootexamples └── DemoTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | /.classpath 25 | /.project 26 | /.springBeans 27 | /target/ 28 | -------------------------------------------------------------------------------- /doc/webflux/image/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/doc/webflux/image/2.png -------------------------------------------------------------------------------- /doc/webflux/image/noshow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/doc/webflux/image/noshow.png -------------------------------------------------------------------------------- /spring-boot-2.x-annotation-filter/src/main/java/cn/lijunkui/SpringbootExamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.web.servlet.ServletComponentScan; 6 | 7 | @SpringBootApplication 8 | //@ServletComponentScan 9 | public class SpringbootExamplesApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringbootExamplesApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-2.x-annotation-filter/src/main/java/cn/lijunkui/config/WebApplicationConfig.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.config; 2 | 3 | import org.springframework.boot.web.servlet.FilterRegistrationBean; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import cn.lijunkui.listener.AnnotationFilter; 8 | 9 | @Configuration 10 | public class WebApplicationConfig { 11 | @Bean 12 | public FilterRegistrationBean userServlet(){ 13 | return new FilterRegistrationBean(new AnnotationFilter()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-2.x-annotation-filter/src/main/java/cn/lijunkui/filter/URLFilter.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.filter; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.Filter; 6 | import javax.servlet.FilterChain; 7 | import javax.servlet.ServletException; 8 | import javax.servlet.ServletRequest; 9 | import javax.servlet.ServletResponse; 10 | import javax.servlet.annotation.WebFilter; 11 | import javax.servlet.http.HttpServletRequest; 12 | 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | 16 | @WebFilter(urlPatterns="/*") 17 | public class URLFilter implements Filter{ 18 | 19 | private Logger log = LoggerFactory.getLogger(URLFilter.class); 20 | 21 | @Override 22 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 23 | throws IOException, ServletException { 24 | HttpServletRequest httpServeltRequest = (HttpServletRequest)request; 25 | String requestURI = httpServeltRequest.getRequestURI(); 26 | log.info("访问地址:"+requestURI); 27 | chain.doFilter(request, response); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-2.x-annotation-filter/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe -------------------------------------------------------------------------------- /spring-boot-2.x-annotation-filter/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-annotation-filter/src/test/java/cn/lijunkui/SpringbootExamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootExamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-custom-start-dependency/README.md: -------------------------------------------------------------------------------- 1 | # springbootexamples 2 | this is spirngboot2.0 examples 3 | -------------------------------------------------------------------------------- /spring-boot-2.x-custom-start-dependency/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import cn.lijunkui.httpclient.enable.EnableHttpClient; 6 | 7 | 8 | @SpringBootApplication 9 | @EnableHttpClient() 10 | public class SpringbootexamplesApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(SpringbootexamplesApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-2.x-custom-start-dependency/src/main/java/cn/lijunkui/httpclient/enable/EnableHttpClient.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.httpclient.enable; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | import org.springframework.context.annotation.Import; 8 | import cn.lijunkui2.autoconfig.HttpClientAutoConfigurationOut; 9 | 10 | 11 | @Target(value = { ElementType.TYPE }) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @Import(HttpClientAutoConfigurationOut.class) 14 | public @interface EnableHttpClient { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-custom-start-dependency/src/main/java/cn/lijunkui/robot/TencentAIOpenPlatformProperties.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.robot; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | @ConfigurationProperties("tencent.ai") 8 | public class TencentAIOpenPlatformProperties { 9 | private String appID; 10 | private String appKey; 11 | private String createChatUrl = "https://api.ai.qq.com/fcgi-bin/nlp/nlp_textchat"; 12 | 13 | public String getCreateChatUrl() { 14 | return createChatUrl; 15 | } 16 | public void setCreateChatUrl(String createChatUrl) { 17 | this.createChatUrl = createChatUrl; 18 | } 19 | public String getAppID() { 20 | return appID; 21 | } 22 | public void setAppID(String appID) { 23 | this.appID = appID; 24 | } 25 | public String getAppKey() { 26 | return appKey; 27 | } 28 | public void setAppKey(String appKey) { 29 | this.appKey = appKey; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-2.x-custom-start-dependency/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | cn.lijunkui2.autoconfig.HttpClientAutoConfigurationOut -------------------------------------------------------------------------------- /spring-boot-2.x-custom-start-dependency/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe 3 | 4 | tencent.ai.appID=your tencent ai open platform appid 5 | tencent.ai.appKey=your tencent ai open platform appid appKey -------------------------------------------------------------------------------- /spring-boot-2.x-custom-start-dependency/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-custom-start-dependency/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-custom-start-dependency/src/test/java/cn/lijunkui/autoconfig/HttpClientAutoConfigurationTest.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.autoconfig; 2 | 3 | import java.io.IOException; 4 | 5 | import org.apache.http.HttpEntity; 6 | import org.apache.http.client.ClientProtocolException; 7 | import org.apache.http.client.HttpClient; 8 | import org.apache.http.client.methods.HttpGet; 9 | import org.apache.http.util.EntityUtils; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.test.context.junit4.SpringRunner; 15 | 16 | @SpringBootTest 17 | @RunWith(SpringRunner.class) 18 | public class HttpClientAutoConfigurationTest { 19 | @Autowired 20 | private HttpClient httpClient; 21 | @Test 22 | public void test() throws ClientProtocolException, IOException { 23 | HttpEntity httpEntity = httpClient.execute(new HttpGet("http://www.baidu.com")).getEntity(); 24 | String content = EntityUtils.toString(httpEntity, "utf-8"); 25 | System.out.println(content); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-2.x-freemarker/EnableHttpClient.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui2.httpclient.enable; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | import org.springframework.context.annotation.Import; 8 | import cn.lijunkui2.httpclient.autoconfig.HttpClientAutoConfigurationOut; 9 | 10 | 11 | @Target(value = { ElementType.TYPE }) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @Import(HttpClientAutoConfigurationOut.class) 14 | public @interface EnableHttpClient { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-freemarker/README.md: -------------------------------------------------------------------------------- 1 | # springbootexamples 2 | this is spirngboot2.0 examples 3 | -------------------------------------------------------------------------------- /spring-boot-2.x-freemarker/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-freemarker/src/main/java/cn/lijunkui/demo/HelloWorldController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.demo; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | @Controller 8 | @RequestMapping("/hello") 9 | public class HelloWorldController { 10 | @RequestMapping("/test") 11 | public String test(Model model){ 12 | model.addAttribute("msg", "SpringBoot With Freemark hello world!"); 13 | return "test/helloworld"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-2.x-freemarker/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe -------------------------------------------------------------------------------- /spring-boot-2.x-freemarker/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-freemarker/src/main/resources/templates/test/helloworld.ftl: -------------------------------------------------------------------------------- 1 |

${msg}

-------------------------------------------------------------------------------- /spring-boot-2.x-freemarker/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-interceptor/README.md: -------------------------------------------------------------------------------- 1 | # 快速搭建我们的SpringBoot 2.0 2 | 这个分支并没有多少代码,基本都是SpringBoot框架的代码。我这里仅仅是创建了一个html文件,用于SpringBoot 项目启动后的测试使用。关于快速创建我们的SpringBoot项目请参考wiki [快速搭建我们的SpringBoot 2.0 ](https://github.com/zhuoqianmingyue/springbootexamples/wiki/%E5%BF%AB%E9%80%9F%E6%90%AD%E5%BB%BA%E6%88%91%E4%BB%AC%E7%9A%84SpringBoot-2.0) 3 | 4 | 快速搭建主要涉及2个配置在/src/main/resources/ 目录下的**application.properties**中: 5 | 6 | ``` 7 | server.port=8080 8 | server.servlet.context-path=/sbe 9 | 10 | ``` 11 | server.port 配置我们项目访问的端口号,server.servlet.context-path 配置访问的项目名称 12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-2.x-interceptor/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-interceptor/src/main/java/cn/lijunkui/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | @Controller 8 | public class IndexController { 9 | 10 | @GetMapping("/index") 11 | public String index(ModelAndView modelAndView){ 12 | 13 | return "index"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-2.x-interceptor/src/main/java/cn/lijunkui/interceptor/InterceptorConfigByExtendsWebMvcConfigurerAdapter.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.interceptor; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 7 | //@Configuration 8 | public class InterceptorConfigByExtendsWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter{ 9 | 10 | //@Bean 11 | public LoginInterceptor loginInterceptor(){ 12 | return new LoginInterceptor(); 13 | } 14 | 15 | public void addInterceptors(InterceptorRegistry registry) { 16 | registry.addInterceptor(loginInterceptor()).addPathPatterns("/**"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-2.x-interceptor/src/main/java/cn/lijunkui/interceptor/InterceptorConfigByImplWebMvcConfigurer.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.interceptor; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | 9 | @Configuration 10 | public class InterceptorConfigByImplWebMvcConfigurer implements WebMvcConfigurer{ 11 | 12 | @Bean 13 | public LoginInterceptor loginInterceptor(){ 14 | return new LoginInterceptor(); 15 | } 16 | @Override 17 | public void addInterceptors(InterceptorRegistry registry) { 18 | registry.addInterceptor(loginInterceptor()).addPathPatterns("/**").excludePathPatterns("/*.html"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-2.x-interceptor/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe -------------------------------------------------------------------------------- /spring-boot-2.x-interceptor/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-interceptor/src/main/resources/templates/index.ftl: -------------------------------------------------------------------------------- 1 |

${msg}

-------------------------------------------------------------------------------- /spring-boot-2.x-interceptor/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-jsp/README.md: -------------------------------------------------------------------------------- 1 | # springbootexamples 2 | this is spirngboot2.0 examples 3 | -------------------------------------------------------------------------------- /spring-boot-2.x-jsp/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-jsp/src/main/java/cn/lijunkui/jsp/JspController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.jsp; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | @Controller 8 | @RequestMapping() 9 | public class JspController { 10 | @RequestMapping("/jsp") 11 | public String toJps(Model model) { 12 | model.addAttribute("welcome", "不建议使用jsp"); 13 | return "welcome"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-2.x-jsp/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe 3 | 4 | spring.mvc.view.prefix=/WEB-INF/jsp/ 5 | spring.mvc.view.suffix=.jsp 6 | -------------------------------------------------------------------------------- /spring-boot-2.x-jsp/src/main/resources/static/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-jsp/src/main/resources/static/1.png -------------------------------------------------------------------------------- /spring-boot-2.x-jsp/src/main/resources/static/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-jsp/src/main/resources/static/2.png -------------------------------------------------------------------------------- /spring-boot-2.x-jsp/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-jsp/src/main/resources/templates/test/freemarkerDemo.ftl: -------------------------------------------------------------------------------- 1 |

springBoot freemark hello world!

-------------------------------------------------------------------------------- /spring-boot-2.x-jsp/src/main/webapp/WEB-INF/jsp/welcome.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Insert title here 8 | 9 | 10 | ${welcome} 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-2.x-jsp/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/README.md: -------------------------------------------------------------------------------- 1 | # springbootexamples 2 | this is spirngboot2.0 examples 3 | -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/java/cn/lijunkui/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | import cn.lijunkui.exception.message.ReturnMessage; 7 | import cn.lijunkui.exception.message.ReturnMessageUtil; 8 | 9 | @RestController 10 | public class IndexController { 11 | 12 | @GetMapping("index") 13 | public ReturnMessage index() { 14 | return ReturnMessageUtil.sucess(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/java/cn/lijunkui/exception/customexception/JKException.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.exception.customexception; 2 | 3 | import cn.lijunkui.exception.message.CodeEnum; 4 | 5 | public class JKException extends RuntimeException{ 6 | private static final long serialVersionUID = -8201518085425482189L; 7 | 8 | public Integer getCode() { 9 | return code; 10 | } 11 | public void setCode(Integer code) { 12 | this.code = code; 13 | } 14 | private Integer code; 15 | 16 | public JKException(Integer code,String message) { 17 | super(message); 18 | this.code = code; 19 | } 20 | public JKException(CodeEnum codeEnum) { 21 | super(codeEnum.getMsg()); 22 | this.code = codeEnum.getCode(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/java/cn/lijunkui/exception/message/CodeEnum.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.exception.message; 2 | 3 | public enum CodeEnum { 4 | 5 | LOGINNAMEANDPWDERROR(100000,"用户名或者密码错误!"), 6 | LOGINAGAIN(100001,"需要重新登录!"), 7 | ILLEGALTOKEN(110000,"非法token!"), 8 | EXPIRETOKEN(110001,"token已经过期!"), 9 | TOKENISEMPTY(110002,"Token 不能为空"); 10 | 11 | 12 | private CodeEnum(Integer code,String msg){ 13 | this.code = code; 14 | this.msg = msg; 15 | } 16 | private Integer code; 17 | private String msg; 18 | 19 | public Integer getCode() { 20 | return code; 21 | } 22 | public void setCode(Integer code) { 23 | this.code = code; 24 | } 25 | public String getMsg() { 26 | return msg; 27 | } 28 | public void setMsg(String msg) { 29 | this.msg = msg; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/java/cn/lijunkui/exception/message/ReturnMessage.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.exception.message; 2 | 3 | public class ReturnMessage { 4 | private Integer code;//错误码 5 | private String message;//提示信息 6 | private T date;//返回具体内容 7 | 8 | public Integer getCode() { 9 | return code; 10 | } 11 | public void setCode(Integer code) { 12 | this.code = code; 13 | } 14 | public ReturnMessage(Integer code, String message, T date) { 15 | super(); 16 | this.code = code; 17 | this.message = message; 18 | this.date = date; 19 | } 20 | public String getMessage() { 21 | return message; 22 | } 23 | public void setMessage(String message) { 24 | this.message = message; 25 | } 26 | public T getDate() { 27 | return date; 28 | } 29 | public void setDate(T date) { 30 | this.date = date; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/java/cn/lijunkui/exception/message/ReturnMessageUtil.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.exception.message; 2 | 3 | 4 | public class ReturnMessageUtil { 5 | /** 6 | * 无异常 请求成功并有具体内容返回 7 | * @param object 8 | * @return 9 | */ 10 | public static ReturnMessage sucess(Object object) { 11 | ReturnMessage message = new ReturnMessage(0,"sucess",object); 12 | return message; 13 | } 14 | /** 15 | * 无异常 请求成功并无具体内容返回 16 | * @return 17 | */ 18 | public static ReturnMessage sucess() { 19 | ReturnMessage message = new ReturnMessage(0,"sucess",null); 20 | return message; 21 | } 22 | /** 23 | * 有自定义错误异常信息 24 | * @param code 25 | * @param msg 26 | * @return 27 | */ 28 | public static ReturnMessage error(Integer code,String msg) { 29 | ReturnMessage message = new ReturnMessage(code,msg,null); 30 | return message; 31 | } 32 | public static ReturnMessage error(CodeEnum codeEnum) { 33 | ReturnMessage message = new ReturnMessage(codeEnum.getCode(),codeEnum.getMsg(),null); 34 | return message; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/java/cn/lijunkui/interceptor/InterceptorConfig.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.interceptor; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 8 | 9 | import cn.lijunkui.utils.JWTService; 10 | 11 | @Configuration 12 | public class InterceptorConfig implements WebMvcConfigurer{ 13 | 14 | @Autowired 15 | private JWTService jwtService; 16 | @Bean 17 | public LoginInterceptor loginInterceptor(){ 18 | return new LoginInterceptor(jwtService); 19 | } 20 | @Override 21 | public void addInterceptors(InterceptorRegistry registry) { 22 | registry.addInterceptor(loginInterceptor()).addPathPatterns("/**").excludePathPatterns("/login").excludePathPatterns("/logout").excludePathPatterns("/loginSys").excludePathPatterns("/static/**"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe 3 | -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/resources/static/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-jwt/src/main/resources/static/1.png -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/resources/static/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-jwt/src/main/resources/static/2.png -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/resources/static/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-jwt/src/main/resources/static/3.png -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/resources/static/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-jwt/src/main/resources/static/4.png -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/resources/static/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-jwt/src/main/resources/static/5.png -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/resources/static/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-jwt/src/main/resources/static/6.png -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/resources/static/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-jwt/src/main/resources/static/7.png -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/resources/templates/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |
9 | © 2011 The Good Thymes Virtual Grocery 10 |
11 | 12 | -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/resources/templates/test/freemarkerDemo.ftl: -------------------------------------------------------------------------------- 1 |

springBoot freemark hello world!

-------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/webapp/WEB-INF/jsp/welcome.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Insert title here 8 | 9 | 10 | ${welcome} 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/main/webapp/images/gtvglogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-jwt/src/main/webapp/images/gtvglogo.png -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/test/java/cn/lijunkui/JWTServiceTest.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import java.util.Date; 4 | import java.util.Map; 5 | 6 | import org.junit.Assert; 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 | import com.auth0.jwt.algorithms.Algorithm; 14 | 15 | import cn.lijunkui.jwt.Payload; 16 | import cn.lijunkui.utils.JWTService; 17 | 18 | @SpringBootTest 19 | @RunWith(SpringRunner.class) 20 | public class JWTServiceTest { 21 | 22 | @Autowired 23 | private JWTService jWTService; 24 | 25 | @Test 26 | public void verifyToken() { 27 | Payload payload = jWTService.createPayload("USERSERVICE","userLoginToken","APP",new Date(),1); 28 | String token = jWTService.createToken(payload, Algorithm.HMAC256("secret")); 29 | Payload verifyToken = jWTService.verifyToken(token); 30 | Assert.assertNotNull(verifyToken); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-jwt/src/test/java/cn/lijunkui/User.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | public class User { 4 | 5 | private String userNaem; 6 | private String deptName; 7 | 8 | public String getUserNaem() { 9 | return userNaem; 10 | } 11 | public void setUserNaem(String userNaem) { 12 | this.userNaem = userNaem; 13 | } 14 | public String getDeptName() { 15 | return deptName; 16 | } 17 | public void setDeptName(String deptName) { 18 | this.deptName = deptName; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-2.x-listener/src/main/java/cn/lijunkui/SpringbootExamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.web.servlet.ServletComponentScan; 6 | 7 | @SpringBootApplication 8 | //@ServletComponentScan 9 | public class SpringbootExamplesApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringbootExamplesApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-2.x-listener/src/main/java/cn/lijunkui/config/WebApplicationConfig.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.config; 2 | 3 | import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import cn.lijunkui.listener.ApplicationListener; 8 | 9 | @Configuration 10 | public class WebApplicationConfig { 11 | @Bean 12 | public ServletListenerRegistrationBean userServlet(){ 13 | return new ServletListenerRegistrationBean (new ApplicationListener()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-2.x-listener/src/main/java/cn/lijunkui/listener/ApplicationListener.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.listener; 2 | 3 | import javax.servlet.ServletContextEvent; 4 | import javax.servlet.ServletContextListener; 5 | import javax.servlet.annotation.WebListener; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | @WebListener 11 | public class ApplicationListener implements ServletContextListener{ 12 | private Logger log = LoggerFactory.getLogger(ApplicationListener.class); 13 | 14 | @Override 15 | public void contextInitialized(ServletContextEvent sce) { 16 | log.info("ApplicationListener 监听器启动..."); 17 | } 18 | @Override 19 | public void contextDestroyed(ServletContextEvent sce) { 20 | log.info("ApplicationListener 监听器销毁..."); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-2.x-listener/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe -------------------------------------------------------------------------------- /spring-boot-2.x-listener/src/test/java/cn/lijunkui/SpringbootExamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootExamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/main/java/cn/lijunkui/config/DynamicDataSourceRouting.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.config; 2 | 3 | import cn.lijunkui.enums.DataSourceKeyEnum; 4 | import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; 5 | 6 | /** 7 | * @Author jkli 8 | * @Date 2020/6/14 2:57 下午 9 | **/ 10 | public class DynamicDataSourceRouting extends AbstractRoutingDataSource { 11 | @Override 12 | protected Object determineCurrentLookupKey() { 13 | DataSourceKeyEnum dataSourceKey = DynamicDataSourceRoutingKeyState.getDataSourceKey(); 14 | return dataSourceKey; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/main/java/cn/lijunkui/config/TargetDataSource.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.config; 2 | 3 | import cn.lijunkui.enums.DataSourceKeyEnum; 4 | 5 | import java.lang.annotation.*; 6 | 7 | /** 8 | * @Author jkli 9 | * @Date 2020/6/14 2:57 下午 10 | **/ 11 | @Target({ElementType.METHOD, ElementType.TYPE}) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @Documented 14 | public @interface TargetDataSource { 15 | DataSourceKeyEnum value() default DataSourceKeyEnum.PRODUCT; 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/main/java/cn/lijunkui/controller/HotelController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.controller; 2 | 3 | import cn.lijunkui.domain.Hotel; 4 | import cn.lijunkui.service.HotelService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import java.util.List; 10 | /** 11 | * 旅馆 Controller 12 | * @Author jkli 13 | * @Date 2020/6/14 2:57 下午 14 | **/ 15 | @RestController 16 | public class HotelController { 17 | 18 | @Autowired 19 | private HotelService hotelService; 20 | 21 | /** 22 | * 查询所有的旅馆信息 23 | * @return 24 | */ 25 | @GetMapping("/hotel") 26 | public List findAll(){ 27 | List hotelList = hotelService.findAll(); 28 | return hotelList; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/main/java/cn/lijunkui/controller/ProductController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.controller; 2 | 3 | import cn.lijunkui.domain.Product; 4 | import cn.lijunkui.service.ProductService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import java.util.List; 10 | /** 11 | * @Author jkli 12 | * @Date 2020/6/14 2:57 下午 13 | **/ 14 | @RestController 15 | public class ProductController { 16 | 17 | @Autowired 18 | private ProductService productService; 19 | 20 | /** 21 | * 查询所有的商品信息 22 | * @return 23 | */ 24 | @GetMapping("/product") 25 | public List findAll() { 26 | List productList = productService.findAll(); 27 | return productList; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/main/java/cn/lijunkui/dao/HotelMapper.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.dao; 2 | 3 | import java.util.List; 4 | 5 | import cn.lijunkui.config.TargetDataSource; 6 | import cn.lijunkui.enums.DataSourceKeyEnum; 7 | import org.apache.ibatis.annotations.Mapper; 8 | import cn.lijunkui.domain.Hotel; 9 | /** 10 | * @Author jkli 11 | * @Date 2020/6/14 2:57 下午 12 | **/ 13 | @Mapper 14 | @TargetDataSource(value = DataSourceKeyEnum.HOTEL ) 15 | public interface HotelMapper { 16 | 17 | 18 | /** 19 | * 查询所有 20 | * @return List 21 | */ 22 | List selectList(); 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/main/java/cn/lijunkui/dao/ProductMapper.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.dao; 2 | 3 | import cn.lijunkui.config.TargetDataSource; 4 | import cn.lijunkui.domain.Product; 5 | import cn.lijunkui.enums.DataSourceKeyEnum; 6 | import org.apache.ibatis.annotations.Mapper; 7 | 8 | import java.util.List; 9 | /** 10 | * @Author jkli 11 | * @Date 2020/6/14 2:57 下午 12 | **/ 13 | @Mapper 14 | @TargetDataSource(value = DataSourceKeyEnum.PRODUCT ) 15 | public interface ProductMapper { 16 | 17 | /** 18 | * 查询所有 19 | * @param 20 | * @return List 21 | */ 22 | List selectList(); 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/main/java/cn/lijunkui/domain/Hotel.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.domain; 2 | /** 3 | * 旅馆Model 类 4 | * @Author jkli 5 | * @Date 2020/6/14 2:57 下午 6 | **/ 7 | public class Hotel { 8 | 9 | private Long id; 10 | private String city; 11 | private String name; 12 | private String address; 13 | 14 | public Long getId() { 15 | return id; 16 | } 17 | 18 | public void setId(Long id) { 19 | this.id = id; 20 | } 21 | 22 | public String getCity() { 23 | return city; 24 | } 25 | 26 | public void setCity(String city) { 27 | this.city = city; 28 | } 29 | 30 | public String getName() { 31 | return name; 32 | } 33 | 34 | public void setName(String name) { 35 | this.name = name; 36 | } 37 | 38 | public String getAddress() { 39 | return address; 40 | } 41 | 42 | public void setAddress(String address) { 43 | this.address = address; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/main/java/cn/lijunkui/domain/Product.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.domain; 2 | /** 3 | * 商品Model类 4 | * @Author jkli 5 | * @Date 2020/6/14 2:57 下午 6 | **/ 7 | public class Product { 8 | 9 | private Long id; 10 | /**商品名称*/ 11 | private String productName; 12 | /**商品价格*/ 13 | private Double price; 14 | /**商品简介*/ 15 | private String productBrief; 16 | 17 | public Long getId() { 18 | return id; 19 | } 20 | 21 | public void setId(Long id) { 22 | this.id = id; 23 | } 24 | 25 | public String getProductName() { 26 | return productName; 27 | } 28 | 29 | public void setProductName(String productName) { 30 | this.productName = productName; 31 | } 32 | 33 | public Double getPrice() { 34 | return price; 35 | } 36 | 37 | public void setPrice(Double price) { 38 | this.price = price; 39 | } 40 | 41 | public String getProductBrief() { 42 | return productBrief; 43 | } 44 | 45 | public void setProductBrief(String productBrief) { 46 | this.productBrief = productBrief; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/main/java/cn/lijunkui/enums/DataSourceKeyEnum.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.enums; 2 | /** 3 | * 4 | * @Author jkli 5 | * @Date 2020/6/14 2:57 下午 6 | **/ 7 | public enum DataSourceKeyEnum { 8 | HOTEL, PRODUCT 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/main/java/cn/lijunkui/service/HotelService.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.service; 2 | 3 | import cn.lijunkui.dao.HotelMapper; 4 | import cn.lijunkui.domain.Hotel; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | /** 10 | * @Author jkli 11 | * @Date 2020/6/14 2:57 下午 12 | **/ 13 | @Service 14 | public class HotelService { 15 | 16 | @Autowired 17 | private HotelMapper hotelMapper; 18 | 19 | public List findAll(){ 20 | List hotels = hotelMapper.selectList(); 21 | return hotels; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/main/java/cn/lijunkui/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.service; 2 | 3 | import cn.lijunkui.dao.ProductMapper; 4 | import cn.lijunkui.domain.Product; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | /** 10 | * @Author jkli 11 | * @Date 2020/6/14 2:57 下午 12 | **/ 13 | @Service 14 | public class ProductService { 15 | 16 | @Autowired 17 | private ProductMapper productMapper; 18 | 19 | public List findAll(){ 20 | return productMapper.selectList(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/main/resources/mapper/HotelMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | select id, city, name, address from hotel 12 | 13 | 14 | 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/main/resources/mapper/ProductMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/main/resources/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties-multipleDataSource/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties/README.md: -------------------------------------------------------------------------------- 1 | # springbootexamples 2 | this is spirngboot2.0 examples 3 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties/src/main/java/cn/lijunkui/controller/ProductController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import cn.lijunkui.mybaties.annotation.ProductMapper; 9 | import cn.lijunkui.mybaties.annotation.domain.Product; 10 | 11 | @RestController 12 | public class ProductController { 13 | @Autowired 14 | private ProductMapper productMapper; 15 | @GetMapping("/productList/{id}") 16 | public Product findById(@PathVariable(name="id") Long id) { 17 | Product findById = productMapper.findById(id); 18 | return findById; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties/src/main/java/cn/lijunkui/mybaties/annotation/domain/Product.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.mybaties.annotation.domain; 2 | 3 | public class Product { 4 | private Long id; 5 | private String productName; 6 | private Double price; 7 | private String productBrief; 8 | public Long getId() { 9 | return id; 10 | } 11 | public void setId(Long id) { 12 | this.id = id; 13 | } 14 | public String getProductName() { 15 | return productName; 16 | } 17 | public void setProductName(String productName) { 18 | this.productName = productName; 19 | } 20 | public Double getPrice() { 21 | return price; 22 | } 23 | public void setPrice(Double price) { 24 | this.price = price; 25 | } 26 | public String getProductBrief() { 27 | return productBrief; 28 | } 29 | public void setProductBrief(String productBrief) { 30 | this.productBrief = productBrief; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties/src/main/java/cn/lijunkui/mybaties/xml/domain/Hotel.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.mybaties.xml.domain; 2 | 3 | public class Hotel { 4 | private Long id; 5 | private String city; 6 | private String name; 7 | private String address; 8 | public Long getId() { 9 | return id; 10 | } 11 | public void setId(Long id) { 12 | this.id = id; 13 | } 14 | 15 | public String getCity() { 16 | return city; 17 | } 18 | public void setCity(String city) { 19 | this.city = city; 20 | } 21 | public String getName() { 22 | return name; 23 | } 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | public String getAddress() { 28 | return address; 29 | } 30 | public void setAddress(String address) { 31 | this.address = address; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties/src/main/java/cn/lijunkui/mybaties/xml/mapper/HotelMapper.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.mybaties.xml.mapper; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | import cn.lijunkui.mybaties.xml.domain.Hotel; 8 | import cn.lijunkui.mybaties.xml.param.HotalParam; 9 | 10 | @Mapper 11 | public interface HotelMapper { 12 | Hotel selectByCityId(long id); 13 | 14 | List selectHotelList(Hotel hotel); 15 | 16 | List selectHotelListByPage(HotalParam hotalParam); 17 | 18 | void deleteById(long id); 19 | 20 | void deleteByIds(Long[] ids); 21 | 22 | void update(Hotel hotel); 23 | 24 | void insert(Hotel hotel); 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties/src/main/java/cn/lijunkui/mybaties/xml/page/Page.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.mybaties.xml.page; 2 | 3 | import java.util.List; 4 | 5 | public class Page extends PageInfo { 6 | 7 | private Integer totalCount; 8 | private List items; 9 | 10 | public Integer getTotalCount() { 11 | return totalCount; 12 | } 13 | public void setTotalCount(Integer totalCount) { 14 | this.totalCount = totalCount; 15 | } 16 | public List getItems() { 17 | return items; 18 | } 19 | public void setItems(List items) { 20 | this.items = items; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties/src/main/java/cn/lijunkui/mybaties/xml/page/PageInfo.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.mybaties.xml.page; 2 | 3 | public class PageInfo { 4 | private Integer pageSize = 10; 5 | private Integer currentPage= 1; 6 | private Integer startIndex; 7 | 8 | public Integer getStartIndex() { 9 | this.startIndex = (currentPage-1) * pageSize; 10 | return startIndex; 11 | } 12 | public void setStartIndex(Integer startIndex) { 13 | this.startIndex = startIndex; 14 | } 15 | public Integer getPageSize() { 16 | return pageSize; 17 | } 18 | public void setPageSize(Integer pageSize) { 19 | this.pageSize = pageSize; 20 | } 21 | public Integer getCurrentPage() { 22 | return currentPage; 23 | } 24 | public void setCurrentPage(Integer currentPage) { 25 | this.currentPage = currentPage; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties/src/main/java/cn/lijunkui/mybaties/xml/param/HotalParam.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.mybaties.xml.param; 2 | 3 | import cn.lijunkui.mybaties.xml.page.PageInfo; 4 | 5 | public class HotalParam extends PageInfo{ 6 | 7 | private Long id; 8 | private String city; 9 | private String name; 10 | private String address; 11 | public Long getId() { 12 | return id; 13 | } 14 | public void setId(Long id) { 15 | this.id = id; 16 | } 17 | 18 | public String getCity() { 19 | return city; 20 | } 21 | public void setCity(String city) { 22 | this.city = city; 23 | } 24 | public String getName() { 25 | return name; 26 | } 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | public String getAddress() { 31 | return address; 32 | } 33 | public void setAddress(String address) { 34 | this.address = address; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-mybaties/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-rabbit-mq/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-rabbit-mq/src/main/java/cn/lijunkui/rabbitmq/direct/RabbitMQConfig.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.rabbitmq.direct; 2 | 3 | import org.springframework.amqp.core.Queue; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | 8 | @Configuration 9 | public class RabbitMQConfig { 10 | public static final String QUEUE = "queue"; 11 | 12 | @Bean 13 | public Queue queue() { 14 | return new Queue(QUEUE,true); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-rabbit-mq/src/main/java/cn/lijunkui/rabbitmq/direct/RabbitMQSend.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.rabbitmq.direct; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.amqp.core.AmqpTemplate; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class RabbitMQSend { 11 | private static Logger log = LoggerFactory.getLogger(RabbitMQSend.class); 12 | 13 | @Autowired 14 | private AmqpTemplate amqpTemplate ; 15 | 16 | public void send(Object message) { 17 | amqpTemplate.convertAndSend(RabbitMQConfig.QUEUE, message); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-2.x-rabbit-mq/src/main/java/cn/lijunkui/rabbitmq/direct/RabbitReceiver.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.rabbitmq.direct; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class RabbitReceiver { 10 | private static Logger log = LoggerFactory.getLogger(RabbitReceiver.class); 11 | 12 | /** 13 | * Direct 模式 交换机模式 14 | * @param message 15 | */ 16 | @RabbitListener(queues=RabbitMQConfig.QUEUE) 17 | public void receive(String message) { 18 | log.info("receive message:"+message); 19 | } 20 | 21 | /** 22 | * Direct 模式 交换机模式 23 | * @param message 24 | */ 25 | @RabbitListener(queues=RabbitMQConfig.QUEUE) 26 | public void receive2(String message) { 27 | log.info("receive2 message:"+message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-2.x-rabbit-mq/src/main/java/cn/lijunkui/rabbitmq/direct/controller/RabbitMQDemoController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.rabbitmq.direct.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestParam; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import cn.lijunkui.rabbitmq.direct.RabbitMQSend; 9 | 10 | @RestController 11 | @RequestMapping("/rabbitMQDemo") 12 | public class RabbitMQDemoController { 13 | 14 | @Autowired 15 | private RabbitMQSend send; 16 | 17 | @RequestMapping("/helloworld") 18 | public String helloword(@RequestParam("msg") String msg) { 19 | send.send(msg); 20 | return "发送成功!"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-2.x-rabbit-mq/src/main/java/cn/lijunkui/rabbitmq/fanout/RabbitMQFanoutReceiver.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.rabbitmq.fanout; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class RabbitMQFanoutReceiver { 10 | private static Logger log = LoggerFactory.getLogger(RabbitMQFanoutReceiver.class); 11 | 12 | @RabbitListener(queues=RabbitMQFanoutConfig.FANOUT_QUEUE) 13 | public void receiveFanout(String message) { 14 | log.info(" rabbitMQ Fanout receive "+RabbitMQFanoutConfig.FANOUT_QUEUE+" message:"+message); 15 | } 16 | @RabbitListener(queues=RabbitMQFanoutConfig.FANOUT_QUEUE2) 17 | public void receiveFanout2(String message) { 18 | log.info(" rabbitMQ Fanout receive "+RabbitMQFanoutConfig.FANOUT_QUEUE2+" message:"+message); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-2.x-rabbit-mq/src/main/java/cn/lijunkui/rabbitmq/fanout/RabbitMQFanoutSend.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.rabbitmq.fanout; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.amqp.core.AmqpTemplate; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class RabbitMQFanoutSend { 11 | private static Logger log = LoggerFactory.getLogger(RabbitMQFanoutSend.class); 12 | 13 | @Autowired 14 | private AmqpTemplate amqpTemplate ; 15 | 16 | public void sendFanout(Object message) { 17 | log.info("send topic message:"+message); 18 | amqpTemplate.convertAndSend(RabbitMQFanoutConfig.FANOUT_EXCHANGE, "", message); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-2.x-rabbit-mq/src/main/java/cn/lijunkui/rabbitmq/fanout/controller/RabbitMQFanoutDemoController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.rabbitmq.fanout.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestParam; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import cn.lijunkui.rabbitmq.direct.RabbitMQSend; 9 | import cn.lijunkui.rabbitmq.fanout.RabbitMQFanoutSend; 10 | import cn.lijunkui.rabbitmq.topic.RabbitMQTopicSend; 11 | 12 | @RestController 13 | @RequestMapping("/rabbitMQ/fanout") 14 | public class RabbitMQFanoutDemoController { 15 | 16 | @Autowired 17 | private RabbitMQFanoutSend send; 18 | 19 | @RequestMapping("/send") 20 | public String send(@RequestParam("msg") String message) { 21 | send.sendFanout(message); 22 | return "发送成功!"; 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-2.x-rabbit-mq/src/main/java/cn/lijunkui/rabbitmq/header/RabbitHeadReceiver.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.rabbitmq.header; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class RabbitHeadReceiver { 10 | private static Logger log = LoggerFactory.getLogger(RabbitHeadReceiver.class); 11 | 12 | /** 13 | * 14 | * @param message 15 | */ 16 | @RabbitListener(queues=RabbitMQHeaderConfig.HEAD_QUEUE) 17 | public void receive(byte[] message) { 18 | log.info("receive head message:"+new String(message)); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-2.x-rabbit-mq/src/main/java/cn/lijunkui/rabbitmq/header/RabbitMQHeadSend.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.rabbitmq.header; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.amqp.core.AmqpTemplate; 6 | import org.springframework.amqp.core.Message; 7 | import org.springframework.amqp.core.MessageProperties; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | @Service 12 | public class RabbitMQHeadSend { 13 | private static Logger log = LoggerFactory.getLogger(RabbitMQHeadSend.class); 14 | 15 | @Autowired 16 | private AmqpTemplate amqpTemplate ; 17 | 18 | public void send(String message) { 19 | MessageProperties properties = new MessageProperties(); 20 | properties.setHeader("token", "abc123"); 21 | Message amqpMessage = new Message(message.getBytes(), properties); 22 | amqpTemplate.convertAndSend(RabbitMQHeaderConfig.HEAD_EXCHAGE, "", amqpMessage); 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-2.x-rabbit-mq/src/main/java/cn/lijunkui/rabbitmq/header/controller/RabbitMQHeadDemoController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.rabbitmq.header.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestParam; 6 | import org.springframework.web.bind.annotation.RestController; 7 | import cn.lijunkui.rabbitmq.header.RabbitMQHeadSend; 8 | 9 | @RestController 10 | @RequestMapping("/rabbitMQ/head") 11 | public class RabbitMQHeadDemoController { 12 | 13 | @Autowired 14 | private RabbitMQHeadSend send; 15 | 16 | @RequestMapping("/send") 17 | public String send(@RequestParam("msg") String message) { 18 | send.send(message); 19 | return "发送成功!"; 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-2.x-rabbit-mq/src/main/java/cn/lijunkui/rabbitmq/topic/RabbitMQTopicReceiver.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.rabbitmq.topic; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class RabbitMQTopicReceiver { 10 | private static Logger log = LoggerFactory.getLogger(RabbitMQTopicReceiver.class); 11 | 12 | @RabbitListener(queues=RabbitMQTopicConfig.TOPIC_QUEUE) 13 | public void receiveTopic(String message) { 14 | log.info(" rabbitMQ topic receive "+RabbitMQTopicConfig.TOPIC_QUEUE+" message:"+message); 15 | } 16 | 17 | @RabbitListener(queues=RabbitMQTopicConfig.TOPIC_QUEUE_ANOTHER) 18 | public void receiveTopicAnother(String message) { 19 | log.info(" rabbitMQ topic another receive "+RabbitMQTopicConfig.TOPIC_QUEUE_ANOTHER+" message:"+message); 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-2.x-rabbit-mq/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe 3 | 4 | #rabbitmq 5 | spring.rabbitmq.host=127.0.0.1 6 | spring.rabbitmq.port=5672 7 | spring.rabbitmq.username=guest 8 | spring.rabbitmq.password=guest -------------------------------------------------------------------------------- /spring-boot-2.x-rabbit-mq/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis-jedis-objectcache/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis-jedis-objectcache/src/main/java/cn/lijunkui/cache/JedisCacheServiceSupport.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.cache; 2 | 3 | import redis.clients.jedis.Jedis; 4 | 5 | public abstract class JedisCacheServiceSupport { 6 | public static final long EXPIRE_MILLISECONDS_DEFAULT_LONG = 3*60*60*1000; 7 | 8 | public Long getExpireTime(Long expireTime) { 9 | expireTime = (expireTime == null || expireTime.longValue() <= 0) ? EXPIRE_MILLISECONDS_DEFAULT_LONG : expireTime; 10 | return expireTime; 11 | } 12 | 13 | public void close(Jedis jedis){ 14 | if(jedis != null){ 15 | jedis.close(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis-jedis-objectcache/src/main/java/cn/lijunkui/config/JedisConfig.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.config; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import redis.clients.jedis.JedisPool; 8 | import redis.clients.jedis.JedisPoolConfig; 9 | 10 | @Configuration 11 | public class JedisConfig { 12 | 13 | @Value("${redis.host}") 14 | String host; 15 | @Value("${redis.port}") 16 | int port; 17 | @Value("${redis.timeout}") 18 | int timeout; 19 | 20 | @Bean 21 | @ConfigurationProperties("redis") 22 | public JedisPoolConfig jedisPoolConfig() { 23 | return new JedisPoolConfig(); 24 | } 25 | 26 | @Bean(destroyMethod = "close") 27 | public JedisPool jedisPool() { 28 | JedisPool jedisPool = new JedisPool(jedisPoolConfig(), host, port, timeout*1000); 29 | return jedisPool; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis-jedis-objectcache/src/main/java/cn/lijunkui/model/User.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class User implements Serializable { 6 | 7 | private String name; 8 | private Integer age; 9 | 10 | public User(String name,Integer age){ 11 | this.name = name; 12 | this.age = age; 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | public Integer getAge() { 24 | return age; 25 | } 26 | 27 | public void setAge(Integer age) { 28 | this.age = age; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis-jedis-objectcache/src/main/java/cn/lijunkui/util/IOUtil.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.util; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.io.OutputStream; 6 | 7 | public class IOUtil { 8 | public static void closeStream(InputStream inputStream) { 9 | if (inputStream != null) { 10 | try { 11 | inputStream.close(); 12 | } catch (IOException e) { 13 | e.printStackTrace(); 14 | } 15 | 16 | } 17 | } 18 | 19 | public static void closeStream(OutputStream outputStream) { 20 | if (outputStream != null) { 21 | try { 22 | outputStream.close(); 23 | } catch (IOException e) { 24 | e.printStackTrace(); 25 | } 26 | 27 | } 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis-jedis-objectcache/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe 3 | 4 | redis.host=localhost 5 | redis.port=6379 6 | redis.timeout=2000 7 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis-jedis-objectcache/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis-jedis/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis-jedis/src/main/java/cn/lijunkui/config/JedisConfig.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.config; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import redis.clients.jedis.JedisPool; 8 | import redis.clients.jedis.JedisPoolConfig; 9 | 10 | @Configuration 11 | public class JedisConfig { 12 | 13 | @Value("${redis.host}") 14 | String host; 15 | @Value("${redis.port}") 16 | int port; 17 | @Value("${redis.timeout}") 18 | int timeout; 19 | 20 | @Bean 21 | @ConfigurationProperties("redis") 22 | public JedisPoolConfig jedisPoolConfig() { 23 | return new JedisPoolConfig(); 24 | } 25 | 26 | @Bean(destroyMethod = "close") 27 | public JedisPool jedisPool() { 28 | JedisPool jedisPool = new JedisPool(jedisPoolConfig(), host, port, timeout*1000); 29 | return jedisPool; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis-jedis/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe 3 | 4 | redis.host=192.168.31.150 5 | redis.port=6379 6 | redis.timeout=2000 7 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis-jedis/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis-redistemplate/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis-redistemplate/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe 3 | 4 | spring.redis.port=6379 5 | spring.redis.host=localhost 6 | spring.redis.lettuce.pool.maxActive=5 7 | spring.redis.lettuce.pool.maxIdle=5 8 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis-redistemplate/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis/src/main/java/cn/lijunkui/jedis/Pool.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.jedis; 2 | 3 | public class Pool { 4 | /**最大连接数, 默认8个*/ 5 | private int maxTotal = 8; 6 | /**最大空闲连接数, 默认8个*/ 7 | private int maxIdle = 8; 8 | /**最小空闲连接数, 默认0*/ 9 | private int minIdle = 0; 10 | /**获取连接时的最大等待毫秒数(如果设置为阻塞时BlockWhenExhausted),如果超时就抛异常, 小于零:阻塞不确定的时间, 默认-1*/ 11 | private long maxWaitMillis; 12 | 13 | public long getMaxWaitMillis() { 14 | return maxWaitMillis; 15 | } 16 | public void setMaxWaitMillis(long maxWaitMillis) { 17 | this.maxWaitMillis = maxWaitMillis; 18 | } 19 | public int getMaxTotal() { 20 | return maxTotal; 21 | } 22 | public void setMaxTotal(int maxTotal) { 23 | this.maxTotal = maxTotal; 24 | } 25 | public int getMaxIdle() { 26 | return maxIdle; 27 | } 28 | public void setMaxIdle(int maxIdle) { 29 | this.maxIdle = maxIdle; 30 | } 31 | public int getMinIdle() { 32 | return minIdle; 33 | } 34 | public void setMinIdle(int minIdle) { 35 | this.minIdle = minIdle; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # \u5FC5\u9009\u914D\u7F6E 2 | #spring.jedis.host= Redis\u670D\u52A1\u5668\u4E3B\u673Aip 3 | #spring.jedis.port=Redis\u670D\u52A1\u5668\u7AEF\u53E3 4 | 5 | # \u5982\u679C\u4F60redis\u670D\u52A1\u914D\u7F6E\u4E86\u5BC6\u7801\u8FD9\u4E2A\u5C31\u5FC5\u987B\u8981\u8FDB\u884C\u914D\u7F6E\u3002 6 | #spring.jedis.password=Redis\u670D\u52A1\u5668\u767B\u5F55\u5BC6\u7801 7 | 8 | # \u975E\u5FC5\u9009\u914D\u7F6E 9 | #spring.jedis.timeout=\u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4 10 | #spring.jedis.pool.max-total=\u6700\u5927\u8FDE\u63A5\u6570, \u9ED8\u8BA48\u4E2A 11 | #spring.jedis.pool.max-idle=\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5\u6570, \u9ED8\u8BA48\u4E2A 12 | #spring.jedis.pool.min-idle=\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5\u6570, \u9ED8\u8BA40 13 | #spring.jedis.pool.max-wait-millis=\u83B7\u53D6\u8FDE\u63A5\u65F6\u7684\u6700\u5927\u7B49\u5F85\u6BEB\u79D2\u6570 14 | 15 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis/src/test/java/cn/lijunkui/jedis/JedisTest.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.jedis; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | import redis.clients.jedis.Jedis; 10 | import redis.clients.jedis.JedisPool; 11 | @RunWith(SpringRunner.class) 12 | @SpringBootTest 13 | public class JedisTest { 14 | 15 | @Autowired 16 | private JedisPool jedisPool; 17 | @Test 18 | public void set() { 19 | Jedis jedis = jedisPool.getResource(); 20 | jedis.set("abc", "123"); 21 | } 22 | 23 | @Test 24 | public void get() { 25 | Jedis jedis = jedisPool.getResource(); 26 | String value = jedis.get("abc"); 27 | System.out.println(value); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-2.x-redis/src/test/java/cn/lijunkui/jedis/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.jedis; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-rest-template/README.md: -------------------------------------------------------------------------------- 1 | # 快速搭建我们的SpringBoot 2.0 2 | 这个分支并没有多少代码,基本都是SpringBoot框架的代码。我这里仅仅是创建了一个html文件,用于SpringBoot 项目启动后的测试使用。关于快速创建我们的SpringBoot项目请参考wiki [快速搭建我们的SpringBoot 2.0 ](https://github.com/zhuoqianmingyue/springbootexamples/wiki/%E5%BF%AB%E9%80%9F%E6%90%AD%E5%BB%BA%E6%88%91%E4%BB%AC%E7%9A%84SpringBoot-2.0) 3 | 4 | 快速搭建主要涉及2个配置在/src/main/resources/ 目录下的**application.properties**中: 5 | 6 | ``` 7 | server.port=8080 8 | server.servlet.context-path=/sbe 9 | 10 | ``` 11 | server.port 配置我们项目访问的端口号,server.servlet.context-path 配置访问的项目名称 12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-2.x-rest-template/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-rest-template/src/main/java/cn/lijunkui/resttemplate/model/User.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.resttemplate.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class User implements Serializable{ 6 | 7 | private String name; 8 | private Integer age; 9 | private String addr; 10 | 11 | public String getAddr() { 12 | return addr; 13 | } 14 | 15 | public void setAddr(String addr) { 16 | this.addr = addr; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public Integer getAge() { 28 | return age; 29 | } 30 | 31 | public void setAge(Integer age) { 32 | this.age = age; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-2.x-rest-template/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8090 2 | server.servlet.context-path=/sbe2 -------------------------------------------------------------------------------- /spring-boot-2.x-rest-template/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-rest-template/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-restful-api/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-restful-api/src/main/java/cn/lijunkui/restful/basic/model/User.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.restful.basic.model; 2 | 3 | public class User { 4 | private String name; 5 | private Integer age; 6 | public User(){}; 7 | public User(String name,Integer age){ 8 | this.name = name; 9 | this.age = age; 10 | } 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | public void setName(String name) { 16 | this.name = name; 17 | } 18 | public Integer getAge() { 19 | return age; 20 | } 21 | public void setAge(Integer age) { 22 | this.age = age; 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-2.x-restful-api/src/main/java/cn/lijunkui/restful/coutomvalidator/custominterface/Addr.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.restful.coutomvalidator.custominterface; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.Target; 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import javax.validation.Constraint; 9 | import javax.validation.Payload; 10 | 11 | @Target({ ElementType.FIELD})//修饰的范围是成员变量 12 | @Retention(RetentionPolicy.RUNTIME)//该注解被保留的时间长短 RUNTIME:在运行时有效 13 | @Constraint(validatedBy = MyAddrValidator.class)//指定校验逻辑处理的Class 14 | public @interface Addr { 15 | String message() default "不支持该地区!"; 16 | Class[] groups() default { }; 17 | Class[] payload() default { }; 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-2.x-restful-api/src/main/java/cn/lijunkui/restful/coutomvalidator/custominterface/MyAddrValidator.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.restful.coutomvalidator.custominterface; 2 | 3 | import javax.validation.ConstraintValidator; 4 | import javax.validation.ConstraintValidatorContext; 5 | 6 | public class MyAddrValidator implements ConstraintValidator{ 7 | String[] addrArray = new String[]{"北京","河北","天津"}; 8 | @Override 9 | public void initialize(Addr addr) { 10 | //启动时执行 11 | } 12 | @Override 13 | public boolean isValid(String value, ConstraintValidatorContext context) { 14 | for (String addrStr : addrArray) { 15 | if(addrStr.equals(value)) { 16 | return true; 17 | } 18 | } 19 | return false; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-2.x-restful-api/src/main/java/cn/lijunkui/restful/coutomvalidator/model/User.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.restful.coutomvalidator.model; 2 | 3 | import javax.validation.constraints.Max; 4 | import javax.validation.constraints.Min; 5 | import javax.validation.constraints.NotEmpty; 6 | 7 | 8 | public class User { 9 | @NotEmpty(message="请输入您的名称!") 10 | private String name; 11 | @Max(value = 100, message = "年龄必须在20-100之间!") 12 | @Min(value= 20 ,message= "年龄必须在20-100之间!" ) 13 | private Integer age; 14 | //@Addr(message="我们仅支持北京河北天津的用户!") 15 | //@AddrWithParam(value = { "北京","河北","天津" }) 16 | //@AddrWithEnum(addr = AddrEnum.BEIJING) 17 | private String addr; 18 | 19 | public String getAddr() { 20 | return addr; 21 | } 22 | 23 | public void setAddr(String addr) { 24 | this.addr = addr; 25 | } 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | 35 | public Integer getAge() { 36 | return age; 37 | } 38 | 39 | public void setAge(Integer age) { 40 | this.age = age; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-boot-2.x-restful-api/src/main/java/cn/lijunkui/restful/filter/PutFilter.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.restful.filter; 2 | 3 | import org.springframework.stereotype.Component; 4 | import org.springframework.web.filter.HttpPutFormContentFilter; 5 | 6 | /** 7 | * 解决restFul put 参数无法接收的问题 8 | */ 9 | @Component 10 | public class PutFilter extends HttpPutFormContentFilter { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-restful-api/src/main/java/cn/lijunkui/restful/hibernatevalidator/UserController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.restful.hibernatevalidator; 2 | 3 | import javax.validation.Valid; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.web.bind.annotation.PostMapping; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | import cn.lijunkui.restful.hibernatevalidator.model.User; 12 | 13 | /** 14 | * User restful api 15 | */ 16 | @RestController() 17 | @RequestMapping("/user") 18 | public class UserController { 19 | 20 | Logger log = LoggerFactory.getLogger(UserController.class); 21 | 22 | /** 23 | * 添加用户 24 | */ 25 | @PostMapping("/") 26 | public ResponseEntity add(@Valid User user){ 27 | log.info("添加用户成功:"+"name:{},age:{}",user.getName(),user.getAge()); 28 | return ResponseEntity.status(HttpStatus.CREATED).body(user); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot-2.x-restful-api/src/main/java/cn/lijunkui/restful/hibernatevalidator/model/User.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.restful.hibernatevalidator.model; 2 | 3 | import javax.validation.constraints.Max; 4 | import javax.validation.constraints.Min; 5 | import javax.validation.constraints.NotEmpty; 6 | 7 | public class User { 8 | 9 | @NotEmpty(message="请输入您的名称!") 10 | private String name; 11 | @Max(value = 100, message = "年龄必须在20-100之间!") 12 | @Min(value= 20 ,message= "年龄必须在20-100之间!" ) 13 | private Integer age; 14 | public User(){}; 15 | public User(String name,Integer age){ 16 | this.name = name; 17 | this.age = age; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | public Integer getAge() { 27 | return age; 28 | } 29 | public void setAge(Integer age) { 30 | this.age = age; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-2.x-restful-api/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe -------------------------------------------------------------------------------- /spring-boot-2.x-restful-api/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-restful-api/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-sentinel/README.md: -------------------------------------------------------------------------------- 1 | # 快速搭建我们的SpringBoot 2.0 2 | 这个分支并没有多少代码,基本都是SpringBoot框架的代码。我这里仅仅是创建了一个html文件,用于SpringBoot 项目启动后的测试使用。关于快速创建我们的SpringBoot项目请参考wiki [快速搭建我们的SpringBoot 2.0 ](https://github.com/zhuoqianmingyue/springbootexamples/wiki/%E5%BF%AB%E9%80%9F%E6%90%AD%E5%BB%BA%E6%88%91%E4%BB%AC%E7%9A%84SpringBoot-2.0) 3 | 4 | 快速搭建主要涉及2个配置在/src/main/resources/ 目录下的**application.properties**中: 5 | 6 | ``` 7 | server.port=8080 8 | server.servlet.context-path=/sbe 9 | 10 | ``` 11 | server.port 配置我们项目访问的端口号,server.servlet.context-path 配置访问的项目名称 12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-2.x-sentinel/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-sentinel/src/main/java/cn/lijunkui/test/TestController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.test; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | import com.alibaba.csp.sentinel.annotation.SentinelResource; 6 | 7 | @RestController 8 | public class TestController { 9 | @GetMapping(value = "/hello") 10 | @SentinelResource("hello") 11 | public String hello() { 12 | return "Hello Sentinel"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-2.x-sentinel/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe 3 | spring.application.name=sentine 4 | # java -Dserver.port=8089 -jar -Dcsp.sentinel.dashboard.server=localhost:8089 -Dproject.name=sentinel-dashboard sentinel-dashboard-1.6.1.jar \u9ED8\u8BA48080\u7AEF\u53E3 5 | spring.cloud.sentinel.transport.dashboard=localhost:8089 6 | #\u53D6\u6D88Sentinel\u63A7\u5236\u53F0\u61D2\u52A0\u8F7D 7 | spring.cloud.sentinel.eager=true -------------------------------------------------------------------------------- /spring-boot-2.x-sentinel/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-sentinel/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-servlet/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.web.servlet.ServletComponentScan; 6 | 7 | @SpringBootApplication 8 | //@ServletComponentScan 9 | public class SpringbootexamplesApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringbootexamplesApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-2.x-servlet/src/main/java/cn/lijunkui/config/WebApplicationConfig.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.config; 2 | 3 | import org.springframework.boot.web.servlet.ServletRegistrationBean; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import cn.lijunkui.servlet.UserServlet; 8 | 9 | @Configuration 10 | public class WebApplicationConfig { 11 | 12 | @Bean 13 | public ServletRegistrationBean userServlet(){ 14 | return new ServletRegistrationBean(new UserServlet()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-servlet/src/main/java/cn/lijunkui/model/User.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.model; 2 | 3 | public class User { 4 | private String name; 5 | private Integer age; 6 | 7 | public User(String name, Integer age) { 8 | super(); 9 | this.name = name; 10 | this.age = age; 11 | } 12 | public String getName() { 13 | return name; 14 | } 15 | public void setName(String name) { 16 | this.name = name; 17 | } 18 | public Integer getAge() { 19 | return age; 20 | } 21 | public void setAge(Integer age) { 22 | this.age = age; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-2.x-servlet/src/main/java/cn/lijunkui/utils/JsonUtil.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.utils; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | 6 | public class JsonUtil { 7 | 8 | private static Gson gson = null; 9 | static { 10 | if (gson == null) { 11 | gson= new GsonBuilder().create(); 12 | } 13 | } 14 | 15 | public static String toJson(Object object){ 16 | return gson.toJson(object); 17 | } 18 | 19 | public static T GsonToBean(String json,Class clazz){ 20 | return gson.fromJson(json, clazz); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-2.x-servlet/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe -------------------------------------------------------------------------------- /spring-boot-2.x-servlet/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-data-jpa/README.md: -------------------------------------------------------------------------------- 1 | # springbootexamples 2 | this is spirngboot2.0 examples 3 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-data-jpa/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-data-jpa/src/main/java/cn/lijunkui/jpa/model/ResultDTO.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.jpa.model; 2 | 3 | public class ResultDTO { 4 | private String address; 5 | private Long count; 6 | public String getAddress() { 7 | return address; 8 | } 9 | public void setAddress(String address) { 10 | this.address = address; 11 | } 12 | public Long getCount() { 13 | return count; 14 | } 15 | public void setCount(Long count) { 16 | this.count = count; 17 | } 18 | public ResultDTO(String address, Long count) { 19 | super(); 20 | this.address = address; 21 | this.count = count; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-data-jpa/src/main/java/cn/lijunkui/jpa/model/UserParam.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.jpa.model; 2 | 3 | public class UserParam { 4 | 5 | private String name; 6 | private String address; 7 | private Integer age; 8 | private Integer maxage; 9 | private Integer minage; 10 | 11 | public Integer getAge() { 12 | return age; 13 | } 14 | public void setAge(Integer age) { 15 | this.age = age; 16 | } 17 | public String getName() { 18 | return name; 19 | } 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | public String getAddress() { 24 | return address; 25 | } 26 | public void setAddress(String address) { 27 | this.address = address; 28 | } 29 | public Integer getMaxage() { 30 | return maxage; 31 | } 32 | public void setMaxage(Integer maxage) { 33 | this.maxage = maxage; 34 | } 35 | public Integer getMinage() { 36 | return minage; 37 | } 38 | public void setMinage(Integer minage) { 39 | this.minage = minage; 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-data-jpa/src/main/java/cn/lijunkui/jpa/repository/UserCrudRepository.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.jpa.repository; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.repository.CrudRepository; 6 | import org.springframework.transaction.annotation.Transactional; 7 | 8 | import cn.lijunkui.jpa.model.User; 9 | 10 | public interface UserCrudRepository extends CrudRepository{ 11 | long countByName(String name); 12 | @Transactional 13 | List reomveByName(String name); 14 | @Transactional 15 | List deleteByName(String name); 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-data-jpa/src/main/java/cn/lijunkui/jpa/repository/UserJpaRepository.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.jpa.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import cn.lijunkui.jpa.model.User; 5 | 6 | public interface UserJpaRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-data-jpa/src/main/java/cn/lijunkui/jpa/repository/UserJpaSpecificationExecutor.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.jpa.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 5 | 6 | import cn.lijunkui.jpa.model.User; 7 | 8 | public interface UserJpaSpecificationExecutor extends JpaRepository,JpaSpecificationExecutor{ 9 | 10 | } 11 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-data-jpa/src/main/java/cn/lijunkui/jpa/repository/UserMethodNameQueryRepositroy.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.jpa.repository; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | import cn.lijunkui.jpa.model.User; 8 | 9 | public interface UserMethodNameQueryRepositroy extends JpaRepository{ 10 | /** 11 | * where name=?1 and age=?2 12 | * @param name 13 | * @param age 14 | * @return 15 | */ 16 | public List findByNameAndAge(String name,Integer age); 17 | /** 18 | * where name=?1 or age=?2 19 | * @param name 20 | * @param age 21 | * @return 22 | */ 23 | public List findByNameOrAge(String name,Integer age); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-data-jpa/src/main/java/cn/lijunkui/jpa/repository/UserPagingAndSortingRepository.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.jpa.repository; 2 | 3 | import org.springframework.data.repository.PagingAndSortingRepository; 4 | 5 | import cn.lijunkui.jpa.model.User; 6 | 7 | public interface UserPagingAndSortingRepository extends PagingAndSortingRepository{ 8 | 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-data-jpa/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe 3 | 4 | spring.datasource.url=jdbc:mysql://localhost:3306/learn?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true 5 | spring.datasource.username=root 6 | spring.datasource.password=root 7 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 8 | 9 | spring.jpa.hibernate.ddl-auto=update 10 | #SQL 输出 11 | spring.jpa.show-sql=true 12 | #format 一下 SQL 进行输出 13 | spring.jpa.properties.hibernate.format_sql=true 14 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect -------------------------------------------------------------------------------- /spring-boot-2.x-spring-data-jpa/src/main/resources/static/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | url: jdbc:mysql://127.0.0.1:3306/learn?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true 4 | driver-class-name: com.mysql.jdbc.Driver 5 | username: root 6 | password: root 7 | # Ddl-auto : Create: 自动创建表 Update:自动修改表 Create-drop:应用停下来会把表删除掉 None:什么都不做 Validate:类和表明是否一致 8 | jpa: 9 | show-sql: true # 在日志中输出sql 10 | hibernate: 11 | ddl-auto: update 12 | properties: 13 | hibernate: 14 | format_sql: true #格式化sql语句 15 | dialect: org.hibernate.dialect.MySQL5InnoDBDialect #设置生成表的存储引擎为 InnoDB -------------------------------------------------------------------------------- /spring-boot-2.x-spring-data-jpa/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-data-jpa/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-session-1/README.md: -------------------------------------------------------------------------------- 1 | # 快速搭建我们的SpringBoot 2.0 2 | 这个分支并没有多少代码,基本都是SpringBoot框架的代码。我这里仅仅是创建了一个html文件,用于SpringBoot 项目启动后的测试使用。关于快速创建我们的SpringBoot项目请参考wiki [快速搭建我们的SpringBoot 2.0 ](https://github.com/zhuoqianmingyue/springbootexamples/wiki/%E5%BF%AB%E9%80%9F%E6%90%AD%E5%BB%BA%E6%88%91%E4%BB%AC%E7%9A%84SpringBoot-2.0) 3 | 4 | 快速搭建主要涉及2个配置在/src/main/resources/ 目录下的**application.properties**中: 5 | 6 | ``` 7 | server.port=8080 8 | server.servlet.context-path=/sbe 9 | 10 | ``` 11 | server.port 配置我们项目访问的端口号,server.servlet.context-path 配置访问的项目名称 12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-session-1/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.session.data.redis.RedisFlushMode; 6 | import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; 7 | 8 | @SpringBootApplication 9 | //@EnableRedisHttpSession(redisFlushMode = RedisFlushMode.ON_SAVE) 10 | public class SpringbootexamplesApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(SpringbootexamplesApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-session-1/src/main/java/cn/lijunkui/controller/SpringSessionTestController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.controller; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpSession; 5 | 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | @RestController 11 | @RequestMapping("/session") 12 | public class SpringSessionTestController { 13 | 14 | @RequestMapping("/get/{name}") 15 | public String getSesseion(HttpServletRequest request,@PathVariable("name") String name){ 16 | HttpSession session = request.getSession(); 17 | String value = (String)session.getAttribute(name); 18 | return "sessionId:"+session.getId()+" value:"+value; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-session-1/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8090 2 | server.servlet.context-path=/sbe 3 | spring.redis.host=localhost 4 | 5 | #spring.session.store-type=redis 6 | #spring.session.timeout=5 7 | #spring.session.redis.flush-mode= 8 | #spring.session.redis.namespace= 9 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-session-1/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-session-2/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; 6 | 7 | @SpringBootApplication 8 | //@EnableRedisHttpSession 9 | public class SpringbootexamplesApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringbootexamplesApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-session-2/src/main/java/cn/lijunkui/controller/SpringSessionTestController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.controller; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpSession; 5 | 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | @RestController 11 | @RequestMapping("/session") 12 | public class SpringSessionTestController { 13 | @RequestMapping("/add/{name}/{value}") 14 | public String addSession(HttpServletRequest request,@PathVariable("name") String name,@PathVariable("value") String value){ 15 | HttpSession session = request.getSession(); 16 | session.setAttribute(name,value); 17 | return "sessionId:"+session.getId()+" name:"+name; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-session-2/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe 3 | spring.redis.host=localhost -------------------------------------------------------------------------------- /spring-boot-2.x-spring-session-2/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-webflux/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-webflux/src/main/java/cn/lijunkui/helloworld/springmvc/HelloWordMvcController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.helloworld.springmvc; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | @RestController 6 | @RequestMapping("/mvc") 7 | public class HelloWordMvcController { 8 | 9 | @RequestMapping("/helloworld") 10 | public String helloWord(){ 11 | return "hello mvc!"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-webflux/src/main/java/cn/lijunkui/helloworld/springwebflux/HelloWordWebFluxController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.helloworld.springwebflux; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | import reactor.core.publisher.Mono; 7 | 8 | @RestController 9 | @RequestMapping("/webflux") 10 | public class HelloWordWebFluxController { 11 | 12 | @RequestMapping("/helloworld") 13 | public Mono helloWord(){ 14 | return Mono.just("hello WebFlux!"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-spring-webflux/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe -------------------------------------------------------------------------------- /spring-boot-2.x-spring-webflux/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-start/README.md: -------------------------------------------------------------------------------- 1 | # 快速搭建我们的SpringBoot 2.0 2 | 这个分支并没有多少代码,基本都是SpringBoot框架的代码。我这里仅仅是创建了一个html文件,用于SpringBoot 项目启动后的测试使用。关于快速创建我们的SpringBoot项目请参考wiki [快速搭建我们的SpringBoot 2.0 ](https://github.com/zhuoqianmingyue/springbootexamples/wiki/%E5%BF%AB%E9%80%9F%E6%90%AD%E5%BB%BA%E6%88%91%E4%BB%AC%E7%9A%84SpringBoot-2.0) 3 | 4 | 快速搭建主要涉及2个配置在/src/main/resources/ 目录下的**application.properties**中: 5 | 6 | ``` 7 | server.port=8080 8 | server.servlet.context-path=/sbe 9 | 10 | ``` 11 | server.port 配置我们项目访问的端口号,server.servlet.context-path 配置访问的项目名称 12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-2.x-start/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-start/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe -------------------------------------------------------------------------------- /spring-boot-2.x-start/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-start/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-swagger-starter/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-swagger-starter/README.md -------------------------------------------------------------------------------- /spring-boot-2.x-swagger-starter/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-swagger-starter/src/main/java/cn/lijunkui/swagger/User.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.swagger; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | @ApiModel(value="user对象",description="用户对象user") 7 | public class User { 8 | @ApiModelProperty(value="用户名",name="name",example="xingguo") 9 | private String name; 10 | @ApiModelProperty(value="年龄1",name="age",required=true,example="23") 11 | private Integer age; 12 | public String getName() { 13 | return name; 14 | } 15 | public void setName(String name) { 16 | this.name = name; 17 | } 18 | public Integer getAge() { 19 | return age; 20 | } 21 | public void setAge(Integer age) { 22 | this.age = age; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-2.x-swagger-starter/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe 3 | 4 | swagger.enable = true -------------------------------------------------------------------------------- /spring-boot-2.x-swagger-starter/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/README.md: -------------------------------------------------------------------------------- 1 | # springbootexamples 2 | this is spirngboot2.0 examples 3 | -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/java/cn/lijunkui/swagger/User.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.swagger; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | @ApiModel(value="user对象",description="用户对象user") 7 | public class User { 8 | @ApiModelProperty(value="用户名",name="name",example="xingguo") 9 | private String name; 10 | @ApiModelProperty(value="年龄1",name="age",required=true) 11 | private Integer age; 12 | public String getName() { 13 | return name; 14 | } 15 | public void setName(String name) { 16 | this.name = name; 17 | } 18 | public Integer getAge() { 19 | return age; 20 | } 21 | public void setAge(Integer age) { 22 | this.age = age; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe 3 | 4 | swagger.enable = true 5 | -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/resources/static/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-swagger/src/main/resources/static/1.png -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/resources/static/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-swagger/src/main/resources/static/10.png -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/resources/static/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-swagger/src/main/resources/static/11.png -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/resources/static/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-swagger/src/main/resources/static/2.png -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/resources/static/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-swagger/src/main/resources/static/3.png -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/resources/static/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-swagger/src/main/resources/static/4.png -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/resources/static/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-swagger/src/main/resources/static/5.png -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/resources/static/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-swagger/src/main/resources/static/6.png -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/resources/static/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-swagger/src/main/resources/static/7.png -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/resources/static/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-swagger/src/main/resources/static/8.png -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/resources/static/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-swagger/src/main/resources/static/9.png -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/webapp/WEB-INF/jsp/welcome.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Insert title here 8 | 9 | 10 | ${welcome} 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/main/webapp/images/gtvglogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-swagger/src/main/webapp/images/gtvglogo.png -------------------------------------------------------------------------------- /spring-boot-2.x-swagger/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/README.md: -------------------------------------------------------------------------------- 1 | # springbootexamples 2 | this is spirngboot2.0 examples 3 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/java/cn/lijunkui/course/pojo/User.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.course.pojo; 2 | 3 | public class User { 4 | private String name; 5 | private Integer age; 6 | public User(String name,Integer age){ 7 | this.name = name; 8 | this.age = age; 9 | } 10 | public String getName() { 11 | return name; 12 | } 13 | public void setName(String name) { 14 | this.name = name; 15 | } 16 | public Integer getAge() { 17 | return age; 18 | } 19 | public void setAge(Integer age) { 20 | this.age = age; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/java/cn/lijunkui/helloword/controller/ThymeleafHelloWrodController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.helloword.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | @Controller 8 | @RequestMapping("/hello") 9 | public class ThymeleafHelloWrodController { 10 | 11 | @RequestMapping("/thymeleaf") 12 | public String helloThymeleaf(Model model){ 13 | model.addAttribute("hello","hello Thymeleaf!"); 14 | return "hello/index"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/java/cn/lijunkui/layout/LayoutController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.layout; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | @Controller 8 | @RequestMapping("/layout") 9 | public class LayoutController { 10 | @RequestMapping("/index") 11 | public String index(Model model) { 12 | return "/layout/index"; 13 | } 14 | 15 | @RequestMapping("/index2") 16 | public String index2(Model model) { 17 | return "/layout/index2"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/java/cn/lijunkui/thymeleaf/officialexamples/product/LocaleResolverConfig.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.thymeleaf.officialexamples.product; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.LocaleResolver; 6 | import org.springframework.web.servlet.i18n.SessionLocaleResolver; 7 | 8 | @Configuration 9 | public class LocaleResolverConfig { 10 | @Bean(name="localeResolver") 11 | public LocaleResolver localeResolverBean() { 12 | return new SessionLocaleResolver(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/java/cn/lijunkui/thymeleaf/officialexamples/product/model/Comment.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.thymeleaf.officialexamples.product.model; 2 | 3 | public class Comment { 4 | 5 | private Integer id = null;//评论id 6 | private String text = null;//评论内容 7 | 8 | 9 | public Comment() { 10 | super(); 11 | } 12 | 13 | public Comment(final Integer id, final String text) { 14 | this.id = id; 15 | this.text = text; 16 | } 17 | 18 | public Integer getId() { 19 | return this.id; 20 | } 21 | public void setId(final Integer id) { 22 | this.id = id; 23 | } 24 | 25 | 26 | public String getText() { 27 | return this.text; 28 | } 29 | public void setText(final String text) { 30 | this.text = text; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/java/cn/lijunkui/thymeleaf/officialexamples/product/model/User.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.thymeleaf.officialexamples.product.model; 2 | 3 | public class User { 4 | private String firstName = null; 5 | private String lastName = null; 6 | private String nationality = null; 7 | private Integer age = null; 8 | 9 | public User(final String firstName, final String lastName, final String nationality, final Integer age) { 10 | super(); 11 | this.firstName = firstName; 12 | this.lastName = lastName; 13 | this.nationality = nationality; 14 | this.age = age; 15 | } 16 | 17 | public String getFirstName() { 18 | return this.firstName; 19 | } 20 | 21 | public String getLastName() { 22 | return this.lastName; 23 | } 24 | 25 | public String getName() { 26 | return this.firstName + " " + this.lastName; 27 | } 28 | 29 | public String getNationality() { 30 | return this.nationality; 31 | } 32 | 33 | public Integer getAge() { 34 | return this.age; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/java/cn/lijunkui/thymeleaf/officialexamples/product/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.thymeleaf.officialexamples.product.service; 2 | 3 | import java.util.List; 4 | 5 | import cn.lijunkui.thymeleaf.officialexamples.product.model.Product; 6 | import cn.lijunkui.thymeleaf.officialexamples.product.repositories.ProductRepository; 7 | 8 | public class ProductService { 9 | public ProductService() { 10 | super(); 11 | } 12 | 13 | public List findAll() { 14 | return ProductRepository.getInstance().findAll(); 15 | } 16 | 17 | public Product findById(final Integer id) { 18 | return ProductRepository.getInstance().findById(id); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/java/cn/lijunkui/thymeleaf/officialexamples/product/util/CalendarUtil.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.thymeleaf.officialexamples.product.util; 2 | 3 | import java.util.Calendar; 4 | 5 | public class CalendarUtil { 6 | public static Calendar calendarFor( 7 | final int year, final int month, final int day, final int hour, final int minute) { 8 | 9 | final Calendar cal = Calendar.getInstance(); 10 | cal.set(Calendar.YEAR, year); 11 | cal.set(Calendar.MONTH, month - 1); 12 | cal.set(Calendar.DAY_OF_MONTH, day); 13 | cal.set(Calendar.HOUR_OF_DAY, hour); 14 | cal.set(Calendar.MINUTE, minute); 15 | cal.set(Calendar.SECOND, 0); 16 | cal.set(Calendar.MILLISECOND, 0); 17 | return cal; 18 | 19 | } 20 | 21 | private CalendarUtil() { 22 | super(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8090 2 | server.servlet.context-path=/sbe 3 | 4 | ##spring.mvc.view.prefix=/WEB-INF/jsp/ 5 | ##spring.mvc.view.suffix=.jsp 6 | 7 | spring.thymeleaf.cache = false 8 | #thymeleaf\u7684\u7F16\u7801\u914D\u7F6E 9 | spring.thymeleaf.encoding=UTF-8 10 | #thymeleaf\u7684\u7F13\u5B58\u8BBE\u7F6E false\u662F\u7981\u7528\u7F13\u5B58 11 | #\u6A21\u677F\u6A21\u5F0F 12 | spring.thymeleaf.mode=HTML5 13 | #\u6A21\u677F\u540E\u7F00\u540D\u79F0 14 | spring.thymeleaf.suffix=.html 15 | #\u6A21\u677F\u8DEF\u5F84 16 | spring.thymeleaf.prefix=classpath:/templates/ 17 | #\u56FD\u9645\u5316\u914D\u7F6E\u6587\u4EF6\u540D\u79F0 \u9ED8\u8BA4\u4E3Amessages 18 | spring.messages.basename=message 19 | #\u56FD\u9645\u5316\u914D\u7F6E\u7684\u7F16\u7801 20 | spring.messages.encoding=UTF-8 21 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/message.properties: -------------------------------------------------------------------------------- 1 | true=yes 2 | false=no 3 | date.format=MMMM dd'','' yyyy 4 | home.welcome=Welcome to our grocery store,{0}!(default message) -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/message_en_US.properties: -------------------------------------------------------------------------------- 1 | true=yes 2 | false=no 3 | date.format=MMMM dd'','' yyyy 4 | home.welcome=Welcome to our grocery store,{0}! -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/message_zh_CN.properties: -------------------------------------------------------------------------------- 1 | home.welcome=\u6B22\u8FCE\u6765\u5230\u6211\u4EEC\u7684\u6742\u8D27\u5E97, {0}! 2 | true=\u662F 3 | false=\u5426 4 | date.format=MMMM dd'','' yyyy -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/static/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-thymeleaf/src/main/resources/static/0.png -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/static/huploadify/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-thymeleaf/src/main/resources/static/huploadify/readme.txt -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/static/huploadify/upload.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/static/upload/QQ图片20181017130208 - 副本.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-thymeleaf/src/main/resources/static/upload/QQ图片20181017130208 - 副本.jpg -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/aggregates.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 18 |

19 |

20 |

21 |

22 | 23 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/arrays.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 28 |

29 |

30 |

31 |

32 |

33 | 34 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/elvis.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |

Age:

9 |

Age2:

10 | 11 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/ids.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/lists.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 24 |

25 |

26 |

27 | 28 |

29 |

30 | 31 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/maps.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 20 |

21 |

22 |

23 | 24 |

25 |

26 | 27 |

28 | 29 | 30 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/noOperation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | no user authenticated 10 | 11 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/objects.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 17 |

18 |

19 |

20 |

21 | 22 | 23 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/sets.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 21 |

22 |

23 |

24 |

25 | 26 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/th.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |

9 |

10 |

11 | ----------------------------------------------- 12 |

13 |

14 |

15 |

16 | ----------------------------------------------- 17 |

18 |

19 | ----------------------------------------------- 20 |
21 |

22 |

23 |
24 | ----------------------------------------------- 25 |

26 |

27 | 28 | 29 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/thaction.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |
9 | 10 |
11 | 12 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/thattr.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/thclass.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |

9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/theach.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
用户名称用户年龄
Onions2.41
22 | ------------------------------------------------------------------------------ 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
用户名称
Onions
35 | 36 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/thhref.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 返回首页 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/thid.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |

9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/thif.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |

if判断

9 |

unless 判断

10 | 11 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/thinline.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/thonclick.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 11 | 12 | 13 |

点我

14 | 15 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/threeElementOperation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |

9 |

10 | 11 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/thselected.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/thsrc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/thstyle.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 |

10 | 11 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/thswitch.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |
9 |

User is ljk

10 |

User is ljk1

11 |
12 | 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/thvalue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/course/thwith.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |

9 | Today is: 13 February 2011 10 |

11 | 12 |
13 |

14 | 第一个用户的名称是: . 15 |

16 |
17 | 18 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |
9 | © 2011 The Good Thymes Virtual Grocery 10 |
11 | 12 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/footer2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 |
10 | © 2011 The Good Thymes Virtual Grocery 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/hello/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |

hello

9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/layout/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |
9 | © 2011 The Good Thymes Virtual Grocery 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/layout/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |
9 |
10 | 11 |
12 |
13 | 14 | 15 |
16 |
...
17 |
18 | 19 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/layout/index2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |
9 |
10 |
11 | 12 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/layout/remove.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/resources/templates/test/freemarkerDemo.ftl: -------------------------------------------------------------------------------- 1 |

springBoot freemark hello world!

-------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/webapp/WEB-INF/jsp/welcome.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Insert title here 8 | 9 | 10 | ${welcome} 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/main/webapp/images/gtvglogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-thymeleaf/src/main/webapp/images/gtvglogo.png -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/target/lesson5_thymeleaf-0.0.1-SNAPSHOT.jar.original: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-thymeleaf/target/lesson5_thymeleaf-0.0.1-SNAPSHOT.jar.original -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-thymeleaf/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst -------------------------------------------------------------------------------- /spring-boot-2.x-thymeleaf/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-thymeleaf/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/README.md: -------------------------------------------------------------------------------- 1 | # springbootexamples 2 | this is spirngboot2.0 examples 3 | -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/main/java/cn/lijunkui/unifiedException/controller/DemoException.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.unifiedException.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | import cn.lijunkui.unifiedException.customexception.SbException; 8 | @RestController 9 | @RequestMapping("/error") 10 | public class DemoException { 11 | @GetMapping(value = "custome") 12 | public void customException() { 13 | SbException sbe = new SbException(100, "这个是自定义异常!"); 14 | throw sbe; 15 | } 16 | @GetMapping(value = "unknown") 17 | public void unknownException() { 18 | int i = 0; 19 | int b = 1/i; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/main/java/cn/lijunkui/unifiedException/customexception/SbException.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.unifiedException.customexception; 2 | 3 | public class SbException extends RuntimeException{ 4 | private static final long serialVersionUID = -8201518085425482189L; 5 | 6 | public Integer getCode() { 7 | return code; 8 | } 9 | public void setCode(Integer code) { 10 | this.code = code; 11 | } 12 | private Integer code; 13 | 14 | public SbException(Integer code,String message) { 15 | super(message); 16 | this.code = code; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/main/java/cn/lijunkui/unifiedException/message/ReturnMessage.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.unifiedException.message; 2 | 3 | public class ReturnMessage { 4 | private Integer code;//错误码 5 | private String message;//提示信息 6 | private T date;//返回具体内容 7 | 8 | public Integer getCode() { 9 | return code; 10 | } 11 | public void setCode(Integer code) { 12 | this.code = code; 13 | } 14 | public ReturnMessage(Integer code, String message, T date) { 15 | super(); 16 | this.code = code; 17 | this.message = message; 18 | this.date = date; 19 | } 20 | public String getMessage() { 21 | return message; 22 | } 23 | public void setMessage(String message) { 24 | this.message = message; 25 | } 26 | public T getDate() { 27 | return date; 28 | } 29 | public void setDate(T date) { 30 | this.date = date; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/main/java/cn/lijunkui/unifiedException/message/ReturnMessageUtil.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.unifiedException.message; 2 | 3 | public class ReturnMessageUtil { 4 | /** 5 | * 无异常 请求成功并有具体内容返回 6 | * @param object 7 | * @return 8 | */ 9 | public static ReturnMessage sucess(Object object) { 10 | ReturnMessage message = new ReturnMessage(0,"sucess",object); 11 | return message; 12 | } 13 | /** 14 | * 无异常 请求成功并无具体内容返回 15 | * @return 16 | */ 17 | public static ReturnMessage sucess() { 18 | ReturnMessage message = new ReturnMessage(0,"sucess",null); 19 | return message; 20 | } 21 | /** 22 | * 有自定义错误异常信息 23 | * @param code 24 | * @param msg 25 | * @return 26 | */ 27 | public static ReturnMessage error(Integer code,String msg) { 28 | ReturnMessage message = new ReturnMessage(code,msg,null); 29 | return message; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe 3 | -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/main/resources/message.properties: -------------------------------------------------------------------------------- 1 | true=yes 2 | false=no 3 | date.format=MMMM dd'','' yyyy 4 | home.welcome=Welcome to our grocery store,{0}!(default message) -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/main/resources/message_en_US.properties: -------------------------------------------------------------------------------- 1 | true=yes 2 | false=no 3 | date.format=MMMM dd'','' yyyy 4 | home.welcome=Welcome to our grocery store,{0}! -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/main/resources/message_zh_CN.properties: -------------------------------------------------------------------------------- 1 | home.welcome=\u6B22\u8FCE\u6765\u5230\u6211\u4EEC\u7684\u6742\u8D27\u5E97, {0}! 2 | true=\u662F 3 | false=\u5426 4 | date.format=MMMM dd'','' yyyy -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/main/resources/static/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-unified_anomaly/src/main/resources/static/4.png -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/main/resources/templates/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 |
9 | © 2011 The Good Thymes Virtual Grocery 10 |
11 | 12 | -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/main/resources/templates/test/freemarkerDemo.ftl: -------------------------------------------------------------------------------- 1 |

springBoot freemark hello world!

-------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/main/webapp/WEB-INF/jsp/welcome.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Insert title here 8 | 9 | 10 | ${welcome} 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/main/webapp/images/gtvglogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x-unified_anomaly/src/main/webapp/images/gtvglogo.png -------------------------------------------------------------------------------- /spring-boot-2.x-unified_anomaly/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-weixin/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-weixin/src/main/java/cn/lijunkui/config/WeiXinConfig.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix="wx") 8 | public class WeiXinConfig { 9 | 10 | private String appID; 11 | private String mchID; 12 | private String appsecret; 13 | private String key; 14 | 15 | public String getAppID() { 16 | return appID; 17 | } 18 | public void setAppID(String appID) { 19 | this.appID = appID; 20 | } 21 | public String getMchID() { 22 | return mchID; 23 | } 24 | public void setMchID(String mchID) { 25 | this.mchID = mchID; 26 | } 27 | public String getKey() { 28 | return key; 29 | } 30 | public void setKey(String key) { 31 | this.key = key; 32 | } 33 | public String getAppsecret() { 34 | return appsecret; 35 | } 36 | public void setAppsecret(String appsecret) { 37 | this.appsecret = appsecret; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-boot-2.x-weixin/src/main/java/cn/lijunkui/resttemplate/model/User.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.resttemplate.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class User implements Serializable{ 6 | 7 | private String name; 8 | private Integer age; 9 | private String addr; 10 | 11 | public String getAddr() { 12 | return addr; 13 | } 14 | 15 | public void setAddr(String addr) { 16 | this.addr = addr; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public Integer getAge() { 28 | return age; 29 | } 30 | 31 | public void setAge(Integer age) { 32 | this.age = age; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-2.x-weixin/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8090 2 | server.servlet.context-path=/sbe2 3 | 4 | wx.appId=wx06e5a34a25031175 5 | wx.appsecret=c0fc269a2ce31ddd22f8efd5d7b643fd 6 | -------------------------------------------------------------------------------- /spring-boot-2.x-weixin/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x-weixin/src/main/resources/static/weixinshare.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | 9 | 10 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /spring-boot-2.x-weixin/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x-wxpay/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /spring-boot-2.x-wxpay/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x-wxpay/src/main/java/cn/lijunkui/resttemplate/model/User.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.resttemplate.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class User implements Serializable{ 6 | 7 | private String name; 8 | private Integer age; 9 | private String addr; 10 | 11 | public String getAddr() { 12 | return addr; 13 | } 14 | 15 | public void setAddr(String addr) { 16 | this.addr = addr; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public Integer getAge() { 28 | return age; 29 | } 30 | 31 | public void setAge(Integer age) { 32 | this.age = age; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-2.x-wxpay/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8090 2 | server.servlet.context-path=/sbe2 3 | 4 | wx.pay.appid=wxab8acb865bb1637e 5 | wx.pay.mchId=11473623 6 | wx.pay.appsecret= 7 | wx.pay.key=2ab9071b06b9f739b950ddb41db2690d 8 | wx.pay.sandboxKey=eb3f6a988431f913921e38a546d48fdf 9 | wx.pay.notifyUrl: http://65ta5j.natappfree.cc/wxpay/refund/notify 10 | wx.pay.useSandbox:true 11 | 12 | wxpay.AppID=wxab8acb865bb1637e 13 | wxpay.mchID=11473623 14 | wxpay.key=2ab9071b06b9f739b950ddb41db2690d -------------------------------------------------------------------------------- /spring-boot-2.x-wxpay/src/main/resources/static/gotoNativePage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 9 |

购买商品:苹果

10 |

价格:20

11 |

数量:10个

12 |
13 | 14 | 15 | 16 | 17 | 18 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /spring-boot-2.x-wxpay/src/main/resources/static/gotoNativePage2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 9 |

购买商品:香蕉

10 |

价格:20

11 |

数量:10个

12 |
13 | 14 | 15 | 16 | 17 | 18 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /spring-boot-2.x-wxpay/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x_filter/README.md: -------------------------------------------------------------------------------- 1 | # springbootexamples 2 | this is spirngboot2.0 examples 3 | -------------------------------------------------------------------------------- /spring-boot-2.x_filter/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x_filter/src/main/java/cn/lijunkui/filter/FilterConfig.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.filter; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import javax.servlet.Filter; 7 | 8 | import org.springframework.boot.web.servlet.FilterRegistrationBean; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | @Configuration 13 | public class FilterConfig { 14 | @Bean 15 | public FilterRegistrationBean filterRegistration(){ 16 | FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(); 17 | filterRegistrationBean.setFilter(new URLFilter()); 18 | List urlList = new ArrayList(); 19 | urlList.add("/*"); 20 | filterRegistrationBean.setUrlPatterns(urlList); 21 | filterRegistrationBean.setName("URLFilter"); 22 | filterRegistrationBean.setOrder(1); 23 | return filterRegistrationBean; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-2.x_filter/src/main/java/cn/lijunkui/filter/URLFilter.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.filter; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.Filter; 6 | import javax.servlet.FilterChain; 7 | import javax.servlet.ServletException; 8 | import javax.servlet.ServletRequest; 9 | import javax.servlet.ServletResponse; 10 | import javax.servlet.http.HttpServletRequest; 11 | 12 | public class URLFilter implements Filter{ 13 | 14 | @Override 15 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 16 | throws IOException, ServletException { 17 | HttpServletRequest httpServeltRequest = (HttpServletRequest)request; 18 | String requestURI = httpServeltRequest.getRequestURI(); 19 | StringBuffer requestURL = httpServeltRequest.getRequestURL(); 20 | System.out.println("requestURI:"+requestURI +" requestURL:"+requestURL); 21 | chain.doFilter(request, response); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-2.x_filter/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe -------------------------------------------------------------------------------- /spring-boot-2.x_filter/src/main/resources/static/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x_filter/src/main/resources/static/1.png -------------------------------------------------------------------------------- /spring-boot-2.x_filter/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x_filter/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x_mail/README.md: -------------------------------------------------------------------------------- 1 | # springbootexamples 2 | this is spirngboot2.0 examples 3 | -------------------------------------------------------------------------------- /spring-boot-2.x_mail/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x_mail/src/main/java/cn/lijunkui/mail/InlineResource.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.mail; 2 | 3 | public class InlineResource { 4 | private String cid; 5 | private String path; 6 | 7 | public InlineResource(String cid,String path) { 8 | this.cid = cid; 9 | this.path = path; 10 | } 11 | public String getCid() { 12 | return cid; 13 | } 14 | public void setCid(String cid) { 15 | this.cid = cid; 16 | } 17 | public String getPath() { 18 | return path; 19 | } 20 | public void setPath(String path) { 21 | this.path = path; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-2.x_mail/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe 3 | spring.mail.host=smtp.126.com 4 | spring.mail.username=your email loginName 5 | spring.mail.password=your email password 6 | spring.mail.properties.mail.smtp.auth=true 7 | spring.mail.properties.mail.starttls.enable=true 8 | spring.mail.properties.mail.starttls.required=true -------------------------------------------------------------------------------- /spring-boot-2.x_mail/src/main/resources/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x_mail/src/main/resources/image.jpg -------------------------------------------------------------------------------- /spring-boot-2.x_mail/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x_mail/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x_task/README.md: -------------------------------------------------------------------------------- 1 | # springbootexamples 2 | this is spirngboot2.0 examples 3 | -------------------------------------------------------------------------------- /spring-boot-2.x_task/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | import org.springframework.scheduling.annotation.EnableScheduling; 11 | 12 | @SpringBootApplication 13 | //@EnableScheduling 14 | public class SpringbootexamplesApplication { 15 | 16 | private static final Logger log = LoggerFactory.getLogger(SpringbootexamplesApplication.class); 17 | private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); 18 | public static void main(String[] args) { 19 | SpringApplication.run(SpringbootexamplesApplication.class, args); 20 | log.info("reportCurrentTimeInitialDelay fixedRate The time is start {}", dateFormat.format(new Date())); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-2.x_task/src/main/java/cn/lijunkui/task/jdk/scheduledExecutorService/ScheduledExecutorTask.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.task.jdk.scheduledExecutorService; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | public class ScheduledExecutorTask implements Runnable{ 9 | private static final Logger log = LoggerFactory.getLogger(ScheduledExecutorTask.class); 10 | private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); 11 | @Override 12 | public void run() { 13 | try { 14 | Thread.sleep(4*1000); 15 | } catch (InterruptedException e) { 16 | e.printStackTrace(); 17 | } 18 | log.info("scheduledExecutorTask The time is now {}", dateFormat.format(new Date())); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-2.x_task/src/main/java/cn/lijunkui/task/jdk/scheduledExecutorService/ScheduledExecutorTest.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.task.jdk.scheduledExecutorService; 2 | 3 | import java.util.concurrent.Executors; 4 | import java.util.concurrent.ScheduledExecutorService; 5 | import java.util.concurrent.TimeUnit; 6 | 7 | public class ScheduledExecutorTest { 8 | 9 | private ScheduledExecutorTask task; 10 | public ScheduledExecutorTest(ScheduledExecutorTask task) { 11 | this.task = task; 12 | } 13 | public void run() { 14 | ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(); 15 | 16 | //当任务时间小于设置时间间隔则以设置的时间间隔为准 17 | //当任务执行时间大于设置的间隔时间时,真正间隔的时间由任务执行时间为准! 18 | // service.scheduleAtFixedRate(task, 0, 3, TimeUnit.SECONDS);//不延迟立即执行每3执行一次 19 | service.scheduleWithFixedDelay(task,0, 3, TimeUnit.SECONDS); //时间间隔是设置的间隔时间+执行任务的时间 20 | // service.schedule(task, 3, TimeUnit.SECONDS);//只执行一次时间间隔是设置的间隔时间+执行任务的时间 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-2.x_task/src/main/java/cn/lijunkui/task/jdk/timer/DemoTask.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.task.jdk.timer; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import java.util.TimerTask; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import cn.lijunkui.task.own.SchedulerTask; 10 | 11 | public class DemoTask extends TimerTask{ 12 | private static final Logger log = LoggerFactory.getLogger(SchedulerTask.class); 13 | private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); 14 | @Override 15 | public void run() { 16 | try { 17 | Thread.sleep(4*1000); 18 | } catch (InterruptedException e) { 19 | e.printStackTrace(); 20 | } 21 | log.info("DemoTask The time is now {}", dateFormat.format(new Date())); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-2.x_task/src/main/java/cn/lijunkui/task/jdk/timer/TimerManger.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.task.jdk.timer; 2 | 3 | import java.text.ParseException; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 6 | import java.util.Timer; 7 | 8 | public class TimerManger { 9 | private DemoTask demoTask; 10 | public TimerManger(DemoTask demoTask) { 11 | this.demoTask = demoTask; 12 | } 13 | public void run() throws ParseException { 14 | Timer timer = new Timer(); 15 | 16 | long intevalPeriod = 3 * 1000; 17 | long delay = 0; 18 | timer.scheduleAtFixedRate(demoTask, delay, intevalPeriod);//每每intevalPeriod毫秒执行一次 19 | //timer.scheduleAtFixedRate(demoTask, 1000, intevalPeriod);//延迟一秒后每intevalPeriod毫秒执行一次 20 | String datetimeStr = "2018-10-16 15:00:00"; 21 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 22 | Date firstTime = sdf.parse(datetimeStr); 23 | //timer.schedule(demoTask, firstTime, intevalPeriod);//3点后开始执行 每intevalPeriod毫秒执行一次 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-2.x_task/src/main/java/cn/lijunkui/task/jdk/timer/TimerMangerRunner.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.task.jdk.timer; 2 | 3 | import org.springframework.boot.ApplicationArguments; 4 | import org.springframework.boot.ApplicationRunner; 5 | import org.springframework.core.annotation.Order; 6 | import org.springframework.stereotype.Component; 7 | 8 | import cn.lijunkui.task.jdk.scheduledExecutorService.ScheduledExecutorTask; 9 | import cn.lijunkui.task.jdk.scheduledExecutorService.ScheduledExecutorTest; 10 | /** 11 | * TimerManger 的启动类 12 | * @author lijunkui 13 | */ 14 | //@Component 15 | @Order(value = 1) 16 | public class TimerMangerRunner implements ApplicationRunner{ 17 | 18 | @Override 19 | public void run(ApplicationArguments args) throws Exception { 20 | //TimerManger manger = new TimerManger(new DemoTask()); 21 | //manger.run(); 22 | ScheduledExecutorTest test = new ScheduledExecutorTest(new ScheduledExecutorTask()); 23 | test.run(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-2.x_task/src/main/java/cn/lijunkui/task/own/SchedulerTaskForCron.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.task.own; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.scheduling.annotation.Scheduled; 9 | import org.springframework.stereotype.Component; 10 | 11 | //@Component 12 | public class SchedulerTaskForCron { 13 | private static final Logger log = LoggerFactory.getLogger(SchedulerTask.class); 14 | private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); 15 | /** 16 | * 每天的14:00 执行一次 17 | */ 18 | @Scheduled(cron="0 0 14 * * ?") 19 | private void cron() { 20 | log.info("cron The time is now {}", dateFormat.format(new Date())); 21 | } 22 | 23 | /** 24 | * 每5秒执行一次 25 | */ 26 | @Scheduled(cron="0/5 * * * * ?") 27 | private void cron2() { 28 | try { 29 | Thread.sleep(6*1000); 30 | } catch (InterruptedException e) { 31 | e.printStackTrace(); 32 | } 33 | log.info("cron2 The time is now {}", dateFormat.format(new Date())); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-boot-2.x_task/src/main/java/cn/lijunkui/task/quartz/cron/CronJob2.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.task.quartz.cron; 2 | 3 | import org.quartz.Job; 4 | import org.quartz.JobExecutionContext; 5 | import org.quartz.JobExecutionException; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | import cn.lijunkui.task.quartz.cron.service.LiveReminderService; 9 | 10 | public class CronJob2 implements Job{ 11 | @Autowired 12 | private LiveReminderService liveReminderService;//直播课提醒 13 | private String serviceCode;//业务code Live lesson reminder 14 | 15 | public String getServiceCode() { 16 | return serviceCode; 17 | } 18 | public void setServiceCode(String serviceCode) { 19 | this.serviceCode = serviceCode; 20 | } 21 | @Override 22 | public void execute(JobExecutionContext context) throws JobExecutionException { 23 | System.out.println("CronJob2"+serviceCode); 24 | liveReminderService.sendmessage(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-2.x_task/src/main/java/cn/lijunkui/task/quartz/cron/CronSchedulerRunner.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.task.quartz.cron; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.CommandLineRunner; 5 | import org.springframework.stereotype.Component; 6 | @Component 7 | public class CronSchedulerRunner implements CommandLineRunner { 8 | @Autowired 9 | public CronSchedulerJobManger manger; 10 | @Override 11 | public void run(String... args) throws Exception { 12 | manger.scheduleJobs(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-2.x_task/src/main/java/cn/lijunkui/task/quartz/cron/service/LiveReminderService.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.task.quartz.cron.service; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | @Service 6 | public class LiveReminderService { 7 | public void sendmessage() { 8 | try { 9 | Thread.sleep(10*1000); 10 | } catch (InterruptedException e) { 11 | e.printStackTrace(); 12 | } 13 | System.out.println("xiaoming xiaoliu xiaoli has 3:00 Live broadcast lesson"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-2.x_task/src/main/java/cn/lijunkui/task/quartz/simple/SimpleJobConfig.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.task.quartz.simple; 2 | 3 | import org.quartz.JobBuilder; 4 | import org.quartz.JobDetail; 5 | import org.quartz.SimpleScheduleBuilder; 6 | import org.quartz.Trigger; 7 | import org.quartz.TriggerBuilder; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | //@Configuration 12 | public class SimpleJobConfig { 13 | @Bean 14 | public JobDetail simpleJobDetail() { 15 | 16 | return JobBuilder.newJob(SimpleJob.class).withIdentity("myJob").storeDurably() 17 | .usingJobData("serviceCode","delete overdue orders") 18 | .build(); 19 | } 20 | @Bean 21 | public Trigger simpleJobTrigger() { 22 | //定义每三秒执行一次 23 | SimpleScheduleBuilder simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(3).repeatForever(); 24 | //定义触发器 25 | return TriggerBuilder.newTrigger().forJob(simpleJobDetail()).withIdentity("myJobTrigger").withSchedule(simpleScheduleBuilder).build(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-2.x_task/src/main/java/cn/lijunkui/task/quartz/simple/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.task.quartz.simple.service; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | @Service 6 | public class OrderService { 7 | public void delete() { 8 | try { 9 | Thread.sleep(6*1000); 10 | } catch (InterruptedException e) { 11 | e.printStackTrace(); 12 | } 13 | System.out.println("delete data sucess...."); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-2.x_task/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe -------------------------------------------------------------------------------- /spring-boot-2.x_task/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x_task/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-2.x_websocket/README.md: -------------------------------------------------------------------------------- 1 | # springbootexamples 2 | this is spirngboot2.0 examples 3 | -------------------------------------------------------------------------------- /spring-boot-2.x_websocket/src/main/java/cn/lijunkui/SpringbootexamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringbootexamplesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringbootexamplesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-2.x_websocket/src/main/java/cn/lijunkui/socket/SocketTestController.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.socket; 2 | 3 | import java.io.IOException; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @RestController 12 | @RequestMapping("socket") 13 | public class SocketTestController { 14 | 15 | @Autowired 16 | private Socket socket; 17 | @GetMapping("/{message}") 18 | public void sendMessage(@PathVariable("message") String message) throws IOException { 19 | socket.sendMessage("直接向服务端发送消息:"+message); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-2.x_websocket/src/main/java/cn/lijunkui/socket/config/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.socket.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.socket.server.standard.ServerEndpointExporter; 6 | 7 | @Configuration 8 | public class WebSocketConfig { 9 | @Bean 10 | public ServerEndpointExporter serverEndpointExporter(){ 11 | return new ServerEndpointExporter(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-2.x_websocket/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | server.servlet.context-path=/sbe 3 | -------------------------------------------------------------------------------- /spring-boot-2.x_websocket/src/main/resources/static/controllerTest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 |

直接向服务端发送消息

9 | 10 | 11 | 33 | -------------------------------------------------------------------------------- /spring-boot-2.x_websocket/src/main/resources/static/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Insert title here 6 | 7 | 8 | Hello spring boot! 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-2.x_websocket/src/main/webapp/WEB-INF/jsp/welcome.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Insert title here 8 | 9 | 10 | ${welcome} 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-2.x_websocket/src/main/webapp/images/gtvglogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cxyxiaokui/spring-boot-examples/c98b4ccbb25897a68d96ef3c444c00ec54d465da/spring-boot-2.x_websocket/src/main/webapp/images/gtvglogo.png -------------------------------------------------------------------------------- /spring-boot-2.x_websocket/src/test/java/cn/lijunkui/SpringbootexamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui; 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 SpringbootexamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-start-httpclient/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | cn.lijunkui 4 | spring-boot-start-httpclient 5 | 0.0.1-SNAPSHOT 6 | 7 | 8 | org.apache.httpcomponents 9 | httpclient 10 | 4.5.6 11 | 12 | 13 | org.springframework.boot 14 | spring-boot-autoconfigure 15 | 2.1.0.RELEASE 16 | 17 | 18 | -------------------------------------------------------------------------------- /spring-boot-start-httpclient/src/main/java/cn/lijunkui/autoconfig/EnableHttpClient.java: -------------------------------------------------------------------------------- 1 | package cn.lijunkui.autoconfig; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | import org.springframework.context.annotation.Import; 8 | 9 | 10 | @Target(value = { ElementType.TYPE }) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Import(HttpClientAutoConfiguration.class) 13 | public @interface EnableHttpClient { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /springboot-2.x-httpclient-custom-starter/src/main/java/cn/zhuoqianmingyue/HttpClientConfig.java: -------------------------------------------------------------------------------- 1 | package cn.zhuoqianmingyue; 2 | 3 | import org.apache.http.client.HttpClient; 4 | import org.apache.http.client.config.RequestConfig; 5 | import org.apache.http.impl.NoConnectionReuseStrategy; 6 | import org.apache.http.impl.client.HttpClientBuilder; 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import cn.lijunkui.autoconfig.EnableHttpClient; 11 | 12 | @Configuration 13 | public class HttpClientConfig { 14 | //@Bean 15 | public HttpClient httpClient() { 16 | RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(1500) 17 | .setSocketTimeout(15000).build(); 18 | 19 | HttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(requestConfig) 20 | .setUserAgent("agent").setMaxConnPerRoute(10) 21 | .setConnectionReuseStrategy(new NoConnectionReuseStrategy()).build(); 22 | return httpClient; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /springboot-2.x-httpclient-custom-starter/src/main/java/cn/zhuoqianmingyue/SpringBootExamplesApplication.java: -------------------------------------------------------------------------------- 1 | package cn.zhuoqianmingyue; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | import cn.lijunkui.autoconfig.EnableHttpClient; 7 | 8 | @SpringBootApplication 9 | @EnableHttpClient 10 | public class SpringBootExamplesApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(SpringBootExamplesApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /springboot-2.x-httpclient-custom-starter/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.httpclient.connectTimeout=2000 2 | -------------------------------------------------------------------------------- /springboot-2.x-httpclient-custom-starter/src/test/java/cn/zhuoqianmingyue/HttpClientAutoConfigurationTest.java: -------------------------------------------------------------------------------- 1 | package cn.zhuoqianmingyue; 2 | 3 | import java.io.IOException; 4 | 5 | import org.apache.http.HttpEntity; 6 | import org.apache.http.client.ClientProtocolException; 7 | import org.apache.http.client.HttpClient; 8 | import org.apache.http.client.methods.HttpGet; 9 | import org.apache.http.util.EntityUtils; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.test.context.junit4.SpringRunner; 15 | 16 | @SpringBootTest 17 | @RunWith(SpringRunner.class) 18 | public class HttpClientAutoConfigurationTest { 19 | @Autowired 20 | private HttpClient httpClient; 21 | @Test 22 | public void test() throws ClientProtocolException, IOException { 23 | HttpEntity httpEntity = httpClient.execute(new HttpGet("http://www.baidu.com")).getEntity(); 24 | String content = EntityUtils.toString(httpEntity, "utf-8"); 25 | System.out.println(content); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /springboot-2.x-httpclient-custom-starter/src/test/java/cn/zhuoqianmingyue/SpringBootExamplesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.zhuoqianmingyue; 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 SpringBootExamplesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/springbootexamples/Demo.java: -------------------------------------------------------------------------------- 1 | package springbootexamples; 2 | 3 | public class Demo { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/test/java/springbootexamples/DemoTest.java: -------------------------------------------------------------------------------- 1 | 2 | package springbootexamples; 3 | 4 | public class DemoTest { 5 | 6 | } 7 | --------------------------------------------------------------------------------