├── .gitattributes ├── .gitignore ├── E:\test\logback.log ├── README.md ├── SnowFlake ├── README.md └── SnowFlake.java ├── data ├── dubbo │ └── cache │ │ ├── dubbo-consumer │ │ ├── dubbo-consumer.lock │ │ ├── dubbo-provider │ │ └── dubbo-provider.lock └── logs │ └── spring-boot-logback │ ├── all_spring-boot-logback.log │ ├── err_spring-boot-logback.log │ └── info_spring-boot-logback.log ├── logs ├── app-heks │ └── config-cache │ │ ├── app-heks+default+infra.heks.config.properties │ │ └── app-heks+default+infra.push.starter.properties └── infra-heks │ └── config-cache │ └── infra-heks+default+application.properties ├── spring-boot-apollo ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── heks │ │ │ └── springbootapollo │ │ │ ├── SpringBootApolloApplication.java │ │ │ └── controller │ │ │ └── ApolloController.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── heks │ └── springbootapollo │ └── SpringBootApolloApplicationTests.java ├── spring-boot-assembly ├── .gitattributes ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── img │ ├── mvn-clean-package-dev.png │ └── mvn-clean-package-local.png ├── package.bat ├── package.sh ├── pom.xml └── src │ ├── bin │ ├── restart.sh │ ├── shutdown.sh │ ├── startup.bat │ └── startup.sh │ ├── logs │ └── startup.log │ ├── main │ ├── assembly │ │ └── assembly.xml │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── assembly │ │ │ ├── Application.java │ │ │ ├── controller │ │ │ ├── HelloController.java │ │ │ └── SysUserController.java │ │ │ ├── entity │ │ │ └── SysUser.java │ │ │ ├── mapper │ │ │ └── SysUserMapper.java │ │ │ ├── service │ │ │ ├── SysUserService.java │ │ │ └── impl │ │ │ │ └── SysUserServiceImpl.java │ │ │ ├── util │ │ │ └── ClassPathFileUtil.java │ │ │ └── vo │ │ │ └── ApiResult.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-local.yml │ │ ├── application-prod.yml │ │ ├── application-test.yml │ │ ├── application-uat.yml │ │ ├── application.yml │ │ ├── db │ │ ├── data.sql │ │ └── schema.sql │ │ ├── hello │ │ └── hello.txt │ │ ├── mapper │ │ └── SysUserMapper.xml │ │ ├── static │ │ ├── css │ │ │ └── index.css │ │ ├── index.html │ │ └── js │ │ │ └── index.js │ │ ├── templates │ │ └── test.txt │ │ └── test.txt │ └── test │ └── java │ └── com │ └── hks │ └── assembly │ └── ApplicationTests.java ├── spring-boot-dubbo ├── dubbo-api │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── hks │ │ └── dubbo │ │ └── api │ │ └── DemoService.java ├── dubbo-consumer │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── hks │ │ │ │ └── dubbo │ │ │ │ └── consumer │ │ │ │ ├── config │ │ │ │ └── PropertiesConfig.java │ │ │ │ ├── run │ │ │ │ └── DubboConsumerApplication.java │ │ │ │ ├── service │ │ │ │ └── ConsumerDemoService.java │ │ │ │ └── web │ │ │ │ └── DemoConsumerController.java │ │ └── resources │ │ │ ├── application.properties │ │ │ ├── dubbo.properties │ │ │ ├── dubbo │ │ │ ├── dubbo-consumer.xml │ │ │ └── dubbo.xml │ │ │ └── log4j.properties │ │ └── test │ │ └── java │ │ └── io │ │ └── ymq │ │ └── dubbo │ │ └── test │ │ └── ConsumerTest.java ├── dubbo-provider │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── dubbo │ │ │ └── provider │ │ │ ├── config │ │ │ └── PropertiesConfig.java │ │ │ ├── run │ │ │ └── DubboProviderApplication.java │ │ │ └── service │ │ │ └── DemoServiceImpl.java │ │ └── resources │ │ ├── application.properties │ │ ├── dubbo.properties │ │ ├── dubbo │ │ ├── dubbo-provider.xml │ │ └── dubbo.xml │ │ └── log4j.properties └── pom.xml ├── spring-boot-elasticsearch-demo ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── example │ │ │ └── elasticsearch │ │ │ ├── config │ │ │ └── ElasticsearchConfig.java │ │ │ ├── run │ │ │ └── ElasticsearchDemoApplication.java │ │ │ ├── service │ │ │ └── AboutService.java │ │ │ └── utils │ │ │ ├── ElasticsearchUtils.java │ │ │ └── EsPage.java │ └── resources │ │ ├── application.properties │ │ └── logback-spring.xml │ └── test │ └── java │ └── com │ └── hks │ └── example │ └── elasticsearch │ ├── ElasticsearchUtilsTest.java │ └── searchListDataTest.java ├── spring-boot-elasticsearch ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── elasticsearch │ │ │ ├── config │ │ │ └── ElasticsearchConfig.java │ │ │ ├── model │ │ │ └── Book.java │ │ │ ├── repository │ │ │ └── BookRepository.java │ │ │ ├── run │ │ │ └── ElasticsearchApplication.java │ │ │ └── service │ │ │ ├── BookService.java │ │ │ └── BookServiceImpl.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── hks │ └── elasticsearch │ └── BaseTests.java ├── spring-boot-gracefulShutdown ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── graceful │ │ │ └── GracefulShutdownApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── hks │ └── graceful │ └── GracefulShutdownApplicationTests.java ├── spring-boot-hbase ├── .gitignore ├── pom.xml ├── readme.md └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── hbase │ │ │ ├── HbaseApplication.java │ │ │ ├── config │ │ │ └── HBaseZookeeperConfig.java │ │ │ ├── controller │ │ │ └── HbaseDemoController.java │ │ │ ├── model │ │ │ ├── HBaseCell.java │ │ │ ├── HBaseCellData.java │ │ │ ├── HBasePageModel.java │ │ │ ├── HBaseTable.java │ │ │ └── KeyValue.java │ │ │ ├── pojo │ │ │ ├── CFIdCell.java │ │ │ ├── CFIdInfoTable.java │ │ │ ├── CFResultCell.java │ │ │ ├── CFResultTable.java │ │ │ ├── CFResultTypeEnum.java │ │ │ ├── InformationCell.java │ │ │ ├── InformationTable.java │ │ │ ├── UserDeviceCell.java │ │ │ └── UserDeviceTable.java │ │ │ ├── regionhelper │ │ │ ├── HashChoreWoker.java │ │ │ ├── HashRowKeyGenerator.java │ │ │ ├── RowKeyGenerator.java │ │ │ └── SplitKeysCalculator.java │ │ │ ├── service │ │ │ ├── HBaseServiceImpl.java │ │ │ └── IHBaseService.java │ │ │ └── util │ │ │ ├── CheckUtil.java │ │ │ ├── HBaseUtil.java │ │ │ ├── StringUtil.java │ │ │ └── ThreadPoolUtil.java │ └── resources │ │ └── zookeeper.properties │ └── test │ └── java │ └── com │ └── hks │ └── hbase │ └── HbaseApplicationTests.java ├── spring-boot-hive ├── .gitignore ├── pom.xml ├── readme.md └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── hive │ │ │ └── SpringBootHiveApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── hks │ └── hive │ └── SpringBootHiveApplicationTests.java ├── spring-boot-http ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── heks │ │ │ └── http │ │ │ ├── HttpApplication.java │ │ │ └── config │ │ │ ├── AsyncRestTemplateConfig.java │ │ │ ├── HttpAsyncClientConfig.java │ │ │ ├── HttpClientConfig.java │ │ │ ├── HttpClientProperties.java │ │ │ └── RestTemplateConfig.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── heks │ └── http │ └── HttpApplicationTests.java ├── spring-boot-kafka ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── kafka │ │ │ ├── MsgConsumer.java │ │ │ ├── MsgProducer.java │ │ │ ├── config │ │ │ └── KafkaConfiguration.java │ │ │ ├── controller │ │ │ └── MsgController.java │ │ │ └── run │ │ │ └── KafkaApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── hks │ └── kafka │ └── test │ ├── BaseTest.java │ └── KafkaUnitTest.java ├── spring-boot-lettuce ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── lettuce │ │ │ ├── LettuceApplication.java │ │ │ ├── dao │ │ │ ├── EmployeeDAO.java │ │ │ ├── FamilyDAO.java │ │ │ ├── FriendDAO.java │ │ │ └── UserDAO.java │ │ │ ├── entity │ │ │ └── Person.java │ │ │ └── service │ │ │ ├── AsyncTaskService.java │ │ │ └── TaskExecutorConfig.java │ └── resources │ │ ├── application.yml │ │ └── logging-config.xml │ └── test │ └── java │ └── com │ └── hks │ └── lettuce │ └── LettuceApplicationTests.java ├── spring-boot-limit ├── HELP.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── example │ │ │ ├── Constants.java │ │ │ ├── RateLimitClient.java │ │ │ ├── SpringBootLimitApplication.java │ │ │ ├── Token.java │ │ │ ├── annotation │ │ │ └── RateLimit.java │ │ │ ├── config │ │ │ ├── Commons.java │ │ │ ├── LimitAspect.java │ │ │ ├── RedisConfig.java │ │ │ ├── RestTemplateConfig.java │ │ │ └── ThreadPoolConfig.java │ │ │ └── controller │ │ │ └── LimiterController.java │ └── resources │ │ ├── application.properties │ │ ├── limit │ │ ├── ratelimit.lua │ │ └── ratelimitInit.lua │ │ └── rateLimit.lua │ └── test │ └── java │ └── com │ └── hks │ └── example │ └── limit │ └── SpringBootLimitApplicationTests.java ├── spring-boot-logback ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── hks │ │ └── logback │ │ ├── config │ │ ├── annotation │ │ │ └── Log.java │ │ └── commons │ │ │ ├── ControllerInterceptor.java │ │ │ ├── LogAspect.java │ │ │ └── MyWebMvcConfigurer.java │ │ ├── controller │ │ └── IndexController.java │ │ └── run │ │ └── LogbackApplication.java │ └── resources │ ├── application.properties │ └── logback-spring.xml ├── spring-boot-lucene-demo ├── indexDir │ ├── _5.cfe │ ├── _5.cfs │ ├── _5.si │ ├── segments_8 │ └── write.lock ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── lucene │ │ │ ├── LuceneApplication.java │ │ │ └── service │ │ │ ├── IKanalyzerService.java │ │ │ └── impl │ │ │ └── IKanalyzerServiceImpl.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── hks │ └── lucene │ ├── BaseTest.java │ └── IKAnalyzerTest.java ├── spring-boot-mongodb ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── example │ │ │ └── mongodb │ │ │ ├── SpringBootMongodbApplication.java │ │ │ ├── controller │ │ │ └── DemoController.java │ │ │ ├── dao │ │ │ ├── DemoDao.java │ │ │ └── impl │ │ │ │ └── DemoDaoImpl.java │ │ │ └── pojo │ │ │ └── DemoEntity.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── hks │ └── example │ └── mongodb │ └── SpringBootMongodbApplicationTests.java ├── spring-boot-mybatis ├── pom.xml └── src │ ├── doc │ ├── ymq_one.sql │ └── ymq_two.sql │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── mybatis │ │ │ ├── config │ │ │ ├── DBOneConfiguration.java │ │ │ ├── DBTwoConfiguration.java │ │ │ └── druid │ │ │ │ ├── AbstractDruidDBConfig.java │ │ │ │ ├── DruidDbProperties.java │ │ │ │ └── DruidMonitConfig.java │ │ │ ├── dao │ │ │ ├── YmqOneBaseDao.java │ │ │ ├── YmqTwoBaseDao.java │ │ │ └── base │ │ │ │ ├── BaseDao.java │ │ │ │ ├── BaseUtils.java │ │ │ │ ├── IBaseDao.java │ │ │ │ └── QueryResult.java │ │ │ ├── po │ │ │ ├── TestOnePo.java │ │ │ └── TestTwoPo.java │ │ │ ├── run │ │ │ └── MybatisApplication.java │ │ │ ├── service │ │ │ └── MybatisService.java │ │ │ └── web │ │ │ └── IndexController.java │ └── resources │ │ ├── application.yml │ │ └── mybatis │ │ ├── TestOneMapper.xml │ │ └── TestTwoMapper.xml │ └── test │ └── java │ └── com │ └── hks │ └── mybatis │ └── test │ └── BaseTest.java ├── spring-boot-netty ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── Info.txt ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── netty │ │ │ ├── NettyApplication.java │ │ │ ├── config │ │ │ ├── NettyConfig.java │ │ │ └── NettyProperties.java │ │ │ └── server │ │ │ ├── ChannelRepository.java │ │ │ ├── TCPServer.java │ │ │ └── handler │ │ │ ├── SomethingChannelInitializer.java │ │ │ └── SomethingServerHandler.java │ └── resources │ │ ├── application.yml │ │ └── logback.xml │ └── test │ └── java │ └── com │ └── hks │ └── netty │ ├── ICallback.java │ ├── NettyApplicationTests.java │ ├── NettyTest.java │ ├── NettyTest1.java │ ├── SomethingServerHandlerTest.java │ └── SomethingServerHandlerTest2.java ├── spring-boot-participle ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── hks │ │ └── participle │ │ ├── cfg │ │ ├── Configuration.java │ │ └── DefaultConfig.java │ │ ├── core │ │ ├── AnalyzeContext.java │ │ ├── CJKSegmenter.java │ │ ├── CN_QuantifierSegmenter.java │ │ ├── CharacterUtil.java │ │ ├── IKArbitrator.java │ │ ├── IKSegmenter.java │ │ ├── ISegmenter.java │ │ ├── LetterSegmenter.java │ │ ├── Lexeme.java │ │ ├── LexemePath.java │ │ └── QuickSortSet.java │ │ ├── dic │ │ ├── DictSegment.java │ │ ├── Dictionary.java │ │ ├── Hit.java │ │ └── Monitor.java │ │ ├── lucene │ │ ├── IKAnalyzer.java │ │ └── IKTokenizer.java │ │ ├── query │ │ ├── IKQueryExpressionParser.java │ │ └── SWMCQueryBuilder.java │ │ ├── sample │ │ └── IKAnalyzerDemo.java │ │ └── solr │ │ └── IKTokenizerFactory.java │ └── resources │ ├── IKAnalyzer.cfg.xml │ ├── dic │ ├── main2012.dic │ └── quantifier.dic │ ├── ext.dic │ └── stopword.dic ├── spring-boot-prometheus-exporter ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── exporter │ │ │ ├── ExporterApplication.java │ │ │ └── controller │ │ │ └── HelloController.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── hks │ └── exporter │ └── ExporterApplicationTests.java ├── spring-boot-prometheus ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── prometheus │ │ │ ├── PrometheusApplication.java │ │ │ └── controller │ │ │ └── DemoController.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── hks │ └── prometheus │ └── PrometheusApplicationTests.java ├── spring-boot-push ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── heks │ │ │ └── push │ │ │ └── PushApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── heks │ └── push │ ├── PushApplicationTests.java │ └── XiaomiSDKTest.java ├── spring-boot-rabbitmq-ack ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── example │ │ │ └── springboot │ │ │ └── rabbitmq │ │ │ └── ack │ │ │ ├── SpringBootRabbitmqAckApplication.java │ │ │ ├── config │ │ │ └── RabbitConfig.java │ │ │ ├── producer │ │ │ └── HelloSender.java │ │ │ ├── receiver │ │ │ └── HelloReceiver.java │ │ │ └── web │ │ │ └── IndexController.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── hks │ └── example │ └── springboot │ └── rabbitmq │ └── ack │ └── SpringBootRabbitmqAckApplicationTests.java ├── spring-boot-rabbitmq ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── rabbitmq │ │ │ ├── config │ │ │ ├── RabbitDirectConfig.java │ │ │ ├── RabbitFanoutConfig.java │ │ │ └── RabbitTopicConfig.java │ │ │ ├── direct │ │ │ ├── DirectReceiver.java │ │ │ └── helloReceiver.java │ │ │ ├── fanout │ │ │ ├── FanoutReceiver1.java │ │ │ └── FanoutReceiver2.java │ │ │ ├── run │ │ │ └── RabbitApplication.java │ │ │ └── topic │ │ │ ├── TopicReceiver1.java │ │ │ ├── TopicReceiver2.java │ │ │ └── TopicReceiver3.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── hks │ └── rabbitmq │ └── test │ ├── RabbitDirectTest.java │ ├── RabbitFanoutTest.java │ └── RabbitTopicTest.java ├── spring-boot-redis-test ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ ├── DemoRedisApplication.java │ │ │ └── pubsub │ │ │ ├── MessagePublisher.java │ │ │ ├── RedisMessagePublisher.java │ │ │ ├── RedisMessageSubscriber.java │ │ │ └── RedisPubSubConfig.java │ └── resources │ │ ├── application.properties │ │ └── logback.xml │ └── test │ └── java │ └── com │ └── hks │ ├── DemoRedisApplicationTests.java │ ├── LettuceOperation.java │ ├── bitmap │ └── BitmapTest.java │ ├── pipelining │ └── RedisPipeliningTests.java │ ├── pubsub │ └── RedisPubSub.java │ └── scankeys │ └── RedisScanKeyTests.java ├── spring-boot-redis ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── redis │ │ │ ├── config │ │ │ ├── RedisAutoConfiguration.java │ │ │ └── RedisConfig.java │ │ │ ├── controller │ │ │ └── RedisController.java │ │ │ ├── run │ │ │ └── RedisApplication.java │ │ │ └── utils │ │ │ └── CacheUtils.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── hks │ └── redis │ └── test │ └── BaseTest.java ├── spring-boot-renren-generator ├── .gitignore ├── LICENSE ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ ├── RenrenApplication.java │ │ │ ├── controller │ │ │ └── SysGeneratorController.java │ │ │ ├── dao │ │ │ └── SysGeneratorDao.java │ │ │ ├── entity │ │ │ ├── ColumnEntity.java │ │ │ └── TableEntity.java │ │ │ ├── service │ │ │ └── SysGeneratorService.java │ │ │ └── utils │ │ │ ├── Constant.java │ │ │ ├── DateUtils.java │ │ │ ├── GenUtils.java │ │ │ ├── PageUtils.java │ │ │ ├── Query.java │ │ │ ├── R.java │ │ │ ├── RRException.java │ │ │ └── RRExceptionHandler.java │ └── resources │ │ ├── application.yml │ │ ├── generator.properties │ │ ├── mapper │ │ └── SysGeneratorDao.xml │ │ ├── static │ │ ├── css │ │ │ ├── AdminLTE.min.css │ │ │ ├── all-skins.min.css │ │ │ ├── bootstrap.min.css │ │ │ ├── font-awesome.min.css │ │ │ └── main.css │ │ ├── favicon.ico │ │ ├── fonts │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ ├── fontawesome-webfont.woff │ │ │ ├── fontawesome-webfont.woff2 │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ └── glyphicons-halflings-regular.woff2 │ │ ├── js │ │ │ ├── common.js │ │ │ ├── generator.js │ │ │ └── index.js │ │ ├── libs │ │ │ ├── app.js │ │ │ ├── app.min.js │ │ │ ├── bootstrap.min.js │ │ │ ├── fastclick.min.js │ │ │ ├── jquery.min.js │ │ │ ├── jquery.slimscroll.min.js │ │ │ ├── router.js │ │ │ └── vue.min.js │ │ └── plugins │ │ │ ├── jqgrid │ │ │ ├── grid.locale-cn.js │ │ │ ├── jquery.jqGrid.min.js │ │ │ ├── ui.jqgrid-bootstrap-ui.css │ │ │ ├── ui.jqgrid-bootstrap.css │ │ │ └── ui.jqgrid.css │ │ │ └── layer │ │ │ ├── layer.js │ │ │ ├── mobile │ │ │ ├── layer.js │ │ │ └── need │ │ │ │ └── layer.css │ │ │ └── skin │ │ │ ├── default │ │ │ ├── icon-ext.png │ │ │ ├── icon.png │ │ │ ├── layer.css │ │ │ ├── loading-0.gif │ │ │ ├── loading-1.gif │ │ │ └── loading-2.gif │ │ │ └── moon │ │ │ ├── default.png │ │ │ └── style.css │ │ ├── template │ │ ├── Controller.java.vm │ │ ├── Dao.java.vm │ │ ├── Dao.xml.vm │ │ ├── Entity.java.vm │ │ ├── Service.java.vm │ │ ├── ServiceImpl.java.vm │ │ ├── list.html.vm │ │ ├── list.js.vm │ │ └── menu.sql.vm │ │ └── views │ │ ├── generator.html │ │ ├── index.html │ │ └── main.html │ └── test │ └── java │ └── com │ └── hks │ └── RenrenApplicationTests.java ├── spring-boot-rocketmq ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── example │ │ │ └── rocketmq │ │ │ ├── Consumer.java │ │ │ ├── Producer.java │ │ │ └── SpringBootRocketmqApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── hks │ └── example │ └── rocketmq │ ├── SpringBootRocketmqApplicationTests.java │ └── test.java ├── spring-boot-shutdown ├── .gitignore ├── pom.xml ├── prometheus.md └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── heks │ │ │ └── shutdown │ │ │ └── ShutdownApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── heks │ └── shutdown │ ├── ShutdownApplicationTests.java │ └── ShutdownGracefulTest.java ├── spring-boot-solr-cloud ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── solr │ │ │ ├── YmqRepository.java │ │ │ ├── config │ │ │ └── SolrConfig.java │ │ │ ├── pagehelper │ │ │ ├── ISelect.java │ │ │ ├── Page.java │ │ │ ├── PageInfo.java │ │ │ ├── PageInfoFacet.java │ │ │ └── RowBounds.java │ │ │ ├── po │ │ │ └── Ymq.java │ │ │ ├── run │ │ │ └── SolrApplication.java │ │ │ └── utils │ │ │ ├── BaseSolr.java │ │ │ └── BaseSolrImpl.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── hks │ └── solr │ └── test │ └── BaseTest.java ├── spring-boot-spark ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hks │ │ │ └── spark │ │ │ └── SparkApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── hks │ └── spark │ └── SparkApplicationTests.java ├── spring-boot-starter-simple-use ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── use │ │ │ ├── UseApplication.java │ │ │ └── controller │ │ │ └── HelloController.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── example │ └── use │ └── UseApplicationTests.java ├── spring-boot-starter-simple ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── hks │ │ ├── config │ │ └── ExampleAutoConfigure.java │ │ └── service │ │ ├── ExampleService.java │ │ └── ExampleServiceProperties.java │ └── resources │ └── META-INF │ └── spring.factories ├── spring-boot-swagger ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── hks │ │ └── swagger │ │ ├── config │ │ └── SwaggerConfig.java │ │ ├── controller │ │ └── YmqController.java │ │ ├── model │ │ └── User.java │ │ └── run │ │ └── SwaggerApplication.java │ └── resources │ ├── application.properties │ └── static │ └── swagger │ ├── css │ ├── print.css │ ├── reset.css │ ├── screen.css │ ├── style.css │ └── typography.css │ ├── fonts │ ├── DroidSans-Bold.ttf │ └── DroidSans.ttf │ ├── images │ ├── collapse.gif │ ├── expand.gif │ ├── explorer_icons.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── favicon.ico │ ├── logo.png │ ├── logo_small.png │ ├── pet_store_api.png │ ├── throbber.gif │ └── wordnik_api.png │ ├── index.html │ ├── lang │ ├── en.js │ ├── translator.js │ └── zh-cn.js │ ├── lib │ ├── backbone-min.js │ ├── es5-shim.js │ ├── handlebars-4.0.5.js │ ├── highlight.9.1.0.pack.js │ ├── highlight.9.1.0.pack_extended.js │ ├── jquery-1.8.0.min.js │ ├── jquery.ba-bbq.min.js │ ├── jquery.slideto.min.js │ ├── jquery.wiggle.min.js │ ├── js-yaml.min.js │ ├── jsoneditor.min.js │ ├── lodash.min.js │ ├── marked.js │ ├── object-assign-pollyfill.js │ ├── sanitize-html.min.js │ └── swagger-oauth.js │ ├── o2c.html │ ├── swagger-ui.js │ └── swagger.yaml └── spring-boot-zookeeper ├── .gitignore ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── heks │ │ └── demo │ │ ├── ZookeeperApplication.java │ │ ├── config │ │ └── ZkConfiguration.java │ │ ├── controller │ │ └── ZkController.java │ │ └── model │ │ └── ZkClient.java └── resources │ └── application.yml └── test └── java └── com └── heks └── demo ├── StateExecutorTest.java ├── TestingCluster_Sample.java └── ZookeeperApplicationTests.java /.gitattributes: -------------------------------------------------------------------------------- 1 | *.js linguist-language=java 2 | *.css linguist-language=java 3 | *.html linguist-language=java 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | *.iml 3 | .idea 4 | logs 5 | .mvn -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # springBoot的application.properties默认配置 2 | https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html 3 | 4 | # Spring Boot 示例代码 5 | 6 | [Spring Boot 中使用 分布式应用限流实践] 7 | 8 | [Spring Boot 中使用 MongoDB 增删改查] 9 | 10 | [Spring Boot 中使用 RocketMQ] 11 | 12 | [Spring Boot 中使用 Redis] 13 | 14 | [Spring Boot 中使用 RabbitMQ] 15 | 16 | [Spring Boot 中使用 kafka] 17 | 18 | [Spring Boot 中使用 SolrCloud] 19 | 20 | [Spring Boot 中使用 MyBatis 整合 Druid 多数据源] 21 | 22 | [Spring Boot 中使用 Dubbo 详解] 23 | 24 | [Spring Boot 中使用 swagger] 25 | 26 | [Spring Boot 中使用 logback  配置 ] 27 | 28 | [Spring Boot 中使用 elasticsearch] 29 | 30 | [Spring Boot 中使用 Java API 调用 Elasticsearch] 31 | 32 | [Spring Boot 中使用 Java API 调用 lucene] 33 | 34 | [Spring Boot 中使用 Application 实现 Shut down embedded servlet container gracefully] 35 | 36 | #### [CSDN的blog记录](https://blog.csdn.net/singgel/article/category/7574271) 37 | 38 | 39 | - Spring源码深度解析 | https://download.csdn.net/download/singgel/10623766 40 | 41 | 42 | - 深入解析Spring架构与设计原理 | https://download.csdn.net/download/singgel/10637765 43 | 44 | - CSDN的spring全家桶讲解 | https://blog.csdn.net/singgel/article/category/7574271 45 | -------------------------------------------------------------------------------- /data/dubbo/cache/dubbo-consumer.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/data/dubbo/cache/dubbo-consumer.lock -------------------------------------------------------------------------------- /data/dubbo/cache/dubbo-provider: -------------------------------------------------------------------------------- 1 | #Dubbo Registry Cache 2 | #Fri Nov 16 10:50:03 CST 2018 3 | com.hks.dubbo.api.DemoService\:1.0=empty\://172.20.53.115\:20880/com.hks.dubbo.api.DemoService?anyhost\=true&application\=dubbo-provider&category\=configurators&check\=false&default.connections\=5&default.retries\=0&default.timeout\=10000&default.version\=1.0&dubbo\=2.5.6&generic\=false&interface\=com.hks.dubbo.api.DemoService&methods\=sayHello&pid\=9860&side\=provider&threadpool\=fixed&threads\=500×tamp\=1542336532974 4 | DemoService\:1.0=empty\://172.20.53.121\:20880/DemoService?anyhost\=true&application\=dubbo-provider&category\=configurators&check\=false&default.connections\=5&default.retries\=0&default.timeout\=10000&default.version\=1.0&dubbo\=2.5.6&generic\=false&interface\=DemoService&methods\=sayHello&pid\=6676&side\=provider&threadpool\=fixed&threads\=500×tamp\=1542187787726 5 | com.alibaba.dubbo.monitor.MonitorService=empty\://172.20.53.115/com.alibaba.dubbo.monitor.MonitorService?category\=configurators&dubbo\=2.5.6&interface\=com.alibaba.dubbo.monitor.MonitorService&pid\=9860×tamp\=1542336533092 empty\://172.20.53.115/com.alibaba.dubbo.monitor.MonitorService?category\=routers&dubbo\=2.5.6&interface\=com.alibaba.dubbo.monitor.MonitorService&pid\=9860×tamp\=1542336533092 empty\://172.20.53.115/com.alibaba.dubbo.monitor.MonitorService?category\=providers&dubbo\=2.5.6&interface\=com.alibaba.dubbo.monitor.MonitorService&pid\=9860×tamp\=1542336533092 6 | -------------------------------------------------------------------------------- /data/dubbo/cache/dubbo-provider.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/data/dubbo/cache/dubbo-provider.lock -------------------------------------------------------------------------------- /logs/app-heks/config-cache/app-heks+default+infra.heks.config.properties: -------------------------------------------------------------------------------- 1 | #Persisted by DefaultConfig 2 | #Tue Sep 29 10:26:13 CST 2020 3 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 4 | spring.datasource.username=root 5 | spring.datasource.password=root 6 | spring.datasource.url=jdbc\:mysql\://127.0.0.1\:3306/redis_manager?useUnicode\=true&characterEncoding\=utf-8 7 | spring.datasource.name=serverbase 8 | apollo\:json={\n "data"\: {\n "\u6B63\u5E38"\: true\n },\n "result_code"\: 0,\n "message"\: null,\n "detail"\: null\n} 9 | -------------------------------------------------------------------------------- /logs/app-heks/config-cache/app-heks+default+infra.push.starter.properties: -------------------------------------------------------------------------------- 1 | #Persisted by DefaultConfig 2 | #Tue Sep 29 10:14:32 CST 2020 3 | common.white.uids=1729603335,5200718097,1888524028,1967972244,4011570319,6221776139,1363327360,7569407041,5305581349,2683655998,6965750545,5156959196,2694475483,4844691680,1601021124,8539256372,1789076572,2755079479,6198380402,1346360470,8397502649,5009911900,8761205836,3913053806,6308148833,1166733806,9730041146,3757846280,1166369227,5005206716,6080747411,4970303295,9042441341,6275139345,9801989132,7565972852,1881012969,1521447808,5189402057,3029025214,7084762991,1970552355,9854404659,7219879257,8882720256,1939085163,3837879084,6433056760,1940398672,2698758418,6528126146,2108992981,6711978840,8709333227,7056987198,6793155776,7960838915,1275008306,5189402057,7724403617,4831371100,9973960427,6076249823,6837218408,4834350725,4617208189,2868574210,2953841174,5218684010,1398008548,9821924764,1559243343,8259531188,7089675771,3723737746,7249035532,4134256683,4388149251,8398079166,9253855716,1157659863,5784024476,8334891041,7212746274,6009868790,5404668875,5472371957 4 | push.message.id.url=http\://10.10.212.95\:8080/ms/getMid.json 5 | push.message.default.ttl=86400000 6 | push.kafka.producer.bootstrapServers=10.10.106.3\:9092,10.10.106.4\:9092 7 | push.kafka.response.topic=push-status 8 | push.message.batch.size=1000 9 | push.kafka.producer.topic=xueqiu-push-req 10 | -------------------------------------------------------------------------------- /logs/infra-heks/config-cache/infra-heks+default+application.properties: -------------------------------------------------------------------------------- 1 | #Persisted by DefaultConfig 2 | #Tue Sep 29 10:47:30 CST 2020 3 | apollo.str={\n "data"\: {\n "\u6B63\u5E38"\: true\n },\n "result_code"\: 2001,\n "message"\: null,\n "detail"\: null\n} 4 | apollo\:string={\n "data"\: {\n "\u6B63\u5E38"\: true\n },\n "result_code"\: 0,\n "message"\: null,\n "detail"\: null\n} 5 | apollo\:json={\n "data"\: {\n "\u6B63\u5E38"\: true\n },\n "result_code"\: 2001,\n "message"\: null,\n "detail"\: null\n} 6 | -------------------------------------------------------------------------------- /spring-boot-apollo/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot-apollo/src/main/java/com/heks/springbootapollo/SpringBootApolloApplication.java: -------------------------------------------------------------------------------- 1 | package com.heks.springbootapollo; 2 | 3 | import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 8 | 9 | @SpringBootApplication 10 | @EnableAspectJAutoProxy(proxyTargetClass = true) 11 | @EnableApolloConfig 12 | public class SpringBootApolloApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(SpringBootApolloApplication.class, args); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-apollo/src/main/java/com/heks/springbootapollo/controller/ApolloController.java: -------------------------------------------------------------------------------- 1 | package com.heks.springbootapollo.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | /** 8 | * @author heks 9 | * @description: TODO 10 | * @date 2020/9/29 11 | */ 12 | @RestController 13 | public class ApolloController { 14 | // apollo的spring里面使用的话key不要用:符号 15 | @Value("${apollo:json}") 16 | private String json; 17 | @Value("${apollo.str}") 18 | private String str; 19 | 20 | @RequestMapping("/json") 21 | public String testJson() { 22 | return json; 23 | } 24 | 25 | @RequestMapping("/str") 26 | public String testStr() { 27 | return str; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-apollo/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | 2 | app: 3 | id: infra-heks 4 | apollo: 5 | bootstrap: 6 | enabled: true 7 | meta: http://sep.apollo.inter.xueqiu.com 8 | cacheDir: logs -------------------------------------------------------------------------------- /spring-boot-apollo/src/test/java/com/heks/springbootapollo/SpringBootApolloApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.heks.springbootapollo; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringBootApolloApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-assembly/.gitattributes: -------------------------------------------------------------------------------- 1 | *.java linguist-language=java 2 | *.xml linguist-language=java 3 | *.sh linguist-language=java 4 | *.bat linguist-language=java -------------------------------------------------------------------------------- /spring-boot-assembly/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /spring-boot-assembly/img/mvn-clean-package-dev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-assembly/img/mvn-clean-package-dev.png -------------------------------------------------------------------------------- /spring-boot-assembly/img/mvn-clean-package-local.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-assembly/img/mvn-clean-package-local.png -------------------------------------------------------------------------------- /spring-boot-assembly/package.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem ====================================================================== 4 | rem mvn package script 5 | rem default local profile 6 | rem 7 | rem ====================================================================== 8 | 9 | set PROFILE=%1 10 | if "%PROFILE%" == "" ( 11 | echo profile:local 12 | mvn clean package -Plocal -DskipTests 13 | echo profile:local 14 | pause 15 | ) else ( 16 | echo profile:%PROFILE% 17 | mvn clean package -P%PROFILE% -DskipTests 18 | echo profile:%PROFILE% 19 | pause 20 | ) -------------------------------------------------------------------------------- /spring-boot-assembly/package.sh: -------------------------------------------------------------------------------- 1 | #! /bin/shell 2 | 3 | #====================================================================== 4 | # mvn package script 5 | # default local profile 6 | # 7 | #====================================================================== 8 | 9 | PROFILE=$1 10 | if [[ -z "$PROFILE" ]]; then 11 | PROFILE=local 12 | fi 13 | echo "profile:${PROFILE}" 14 | mvn clean package -P${PROFILE} -DskipTests 15 | echo "profile:${PROFILE}" -------------------------------------------------------------------------------- /spring-boot-assembly/src/bin/restart.sh: -------------------------------------------------------------------------------- 1 | #! /bin/shell 2 | 3 | #====================================================================== 4 | # 项目重启shell脚本 5 | # 先调用shutdown.sh停服 6 | # 然后调用startup.sh启动服务 7 | # 8 | #====================================================================== 9 | 10 | # 项目名称 11 | APPLICATION="@project.name@" 12 | 13 | # 项目启动jar包名称 14 | APPLICATION_JAR="@build.finalName@.jar" 15 | 16 | # 停服 17 | echo stop ${APPLICATION} Application... 18 | sh shutdown.sh 19 | 20 | # 启动服务 21 | echo start ${APPLICATION} Application... 22 | sh startup.sh -------------------------------------------------------------------------------- /spring-boot-assembly/src/bin/shutdown.sh: -------------------------------------------------------------------------------- 1 | #! /bin/shell 2 | 3 | #====================================================================== 4 | # 项目停服shell脚本 5 | # 通过项目名称查找到PID 6 | # 然后kill -9 pid 7 | # 8 | #====================================================================== 9 | 10 | # 项目名称 11 | APPLICATION="@project.name@" 12 | 13 | # 项目启动jar包名称 14 | APPLICATION_JAR="@build.finalName@.jar" 15 | 16 | PID=$(ps -ef | grep "${APPLICATION_JAR}" | grep -v grep | awk '{ print $2 }') 17 | if [[ -z "$PID" ]] 18 | then 19 | echo ${APPLICATION} is already stopped 20 | else 21 | echo kill ${PID} 22 | kill -9 ${PID} 23 | echo ${APPLICATION} stopped successfully 24 | fi -------------------------------------------------------------------------------- /spring-boot-assembly/src/bin/startup.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem ====================================================================== 3 | rem windows startup script 4 | rem 5 | rem ====================================================================== 6 | 7 | rem Open in a browser 8 | start "" "http://localhost:8080/example/hello?name=123" 9 | 10 | rem startup jar 11 | java -jar ../boot/@project.build.finalName@.jar --spring.config.location=../config/ 12 | 13 | pause 14 | -------------------------------------------------------------------------------- /spring-boot-assembly/src/logs/startup.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-assembly/src/logs/startup.log -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/java/com/hks/assembly/entity/SysUser.java: -------------------------------------------------------------------------------- 1 | package com.hks.assembly.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | *

11 | * 系统用户实体类 12 | *

13 | * 14 | * @author liujixiang 15 | * @since 2018/12/28 16 | */ 17 | @Data 18 | public class SysUser implements Serializable { 19 | private static final long serialVersionUID = -6310626094486022728L; 20 | /** 21 | * 主键 22 | */ 23 | private Long id; 24 | /** 25 | * 名称 26 | */ 27 | private String name; 28 | /** 29 | * 账号 30 | */ 31 | private String account; 32 | /** 33 | * pwd 34 | */ 35 | private String pwd; 36 | /** 37 | * 备注 38 | */ 39 | private String remark; 40 | /** 41 | * 创建时间 42 | */ 43 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") 44 | private Date createTime; 45 | /** 46 | * 修改时间 47 | */ 48 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") 49 | private Date updateTime; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/java/com/hks/assembly/mapper/SysUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.hks.assembly.mapper; 2 | 3 | import com.hks.assembly.entity.SysUser; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | *

10 | * 系统用户Mapper 11 | *

12 | * 13 | * @author liujixiang 14 | * @since 2018/12/28 15 | */ 16 | @Repository 17 | public interface SysUserMapper { 18 | 19 | /** 20 | * 添加 21 | * @param sysUser 22 | * @return 23 | */ 24 | Integer addSysUser(SysUser sysUser); 25 | 26 | /** 27 | * 修改 28 | * @param sysUser 29 | * @return 30 | */ 31 | Integer updateSysUser(SysUser sysUser); 32 | 33 | /** 34 | * 删除 35 | * @param id 36 | * @return 37 | */ 38 | Integer deleteSysUser(Long id); 39 | 40 | /** 41 | * 根据ID获取用户 42 | * @param id 43 | * @return 44 | */ 45 | SysUser getSysUser(Long id); 46 | 47 | /** 48 | * 获取所有用户 49 | * @return 50 | */ 51 | List getSysUserList(); 52 | 53 | } 54 | -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/java/com/hks/assembly/service/SysUserService.java: -------------------------------------------------------------------------------- 1 | package com.hks.assembly.service; 2 | 3 | import com.hks.assembly.entity.SysUser; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | *

9 | * 系统用户服务接口 10 | *

11 | * 12 | * @author liujixiang 13 | * @since 2018/12/28 14 | */ 15 | public interface SysUserService { 16 | 17 | /** 18 | * 添加 19 | * @param sysUser 20 | * @return 21 | */ 22 | Boolean addSysUser(SysUser sysUser); 23 | 24 | /** 25 | * 修改 26 | * @param sysUser 27 | * @return 28 | */ 29 | Boolean updateSysUser(SysUser sysUser); 30 | 31 | /** 32 | * 删除 33 | * @param id 34 | * @return 35 | */ 36 | Boolean deleteSysUser(Long id); 37 | 38 | /** 39 | * 根据ID获取用户 40 | * @param id 41 | * @return 42 | */ 43 | SysUser getSysUser(Long id); 44 | 45 | /** 46 | * 获取所有用户 47 | * @return 48 | */ 49 | List getSysUserList(); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/java/com/hks/assembly/service/impl/SysUserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.hks.assembly.service.impl; 2 | 3 | import com.hks.assembly.entity.SysUser; 4 | import com.hks.assembly.mapper.SysUserMapper; 5 | import com.hks.assembly.service.SysUserService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | *

13 | * 系统用户服务实现 14 | *

15 | * 16 | * @author liujixiang 17 | * @since 2018/12/28 18 | */ 19 | @Service 20 | public class SysUserServiceImpl implements SysUserService { 21 | 22 | @Autowired 23 | private SysUserMapper sysUserMapper; 24 | 25 | @Override 26 | public Boolean addSysUser(SysUser sysUser) { 27 | return sysUserMapper.addSysUser(sysUser) == 1; 28 | } 29 | 30 | @Override 31 | public Boolean updateSysUser(SysUser sysUser) { 32 | return sysUserMapper.updateSysUser(sysUser) == 1; 33 | } 34 | 35 | @Override 36 | public Boolean deleteSysUser(Long id) { 37 | return sysUserMapper.deleteSysUser(id) == 1; 38 | } 39 | 40 | @Override 41 | public SysUser getSysUser(Long id) { 42 | return sysUserMapper.getSysUser(id); 43 | } 44 | 45 | @Override 46 | public List getSysUserList() { 47 | return sysUserMapper.getSysUserList(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | server: 2 | servlet: 3 | context-path: /example 4 | port: 8080 5 | 6 | spring: 7 | application: 8 | name: spring-boot-assembly 9 | -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/resources/application-local.yml: -------------------------------------------------------------------------------- 1 | server: 2 | servlet: 3 | context-path: /example 4 | port: 8080 5 | 6 | spring: 7 | application: 8 | name: spring-boot-assembly 9 | 10 | # local环境jdbc配置 11 | datasource: 12 | platform: h2 13 | url: jdbc:h2:mem:spring-boot-assembly 14 | username: root 15 | password: root 16 | driver-class-name: org.h2.Driver 17 | # 每次启动程序,都会执行该SQL脚本 18 | schema: classpath:db/schema.sql 19 | # 每次启动程序,都会执行该SQL脚本 20 | data: classpath:db/data.sql 21 | sql-script-encoding: utf-8 22 | 23 | h2: 24 | console: 25 | enabled: true 26 | path: /h2 27 | 28 | hello: Hello Local -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-assembly/src/main/resources/application-prod.yml -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/resources/application-test.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-assembly/src/main/resources/application-test.yml -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/resources/application-uat.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-assembly/src/main/resources/application-uat.yml -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | servlet: 3 | context-path: /example 4 | tomcat: 5 | uri-encoding: UTF-8 6 | 7 | spring: 8 | application: 9 | name: spring-boot-assembly 10 | 11 | # 当前maven打包的profile 12 | profiles: 13 | active: @profileActive@ 14 | 15 | # UTF-8编码 16 | http: 17 | encoding: 18 | enabled: true 19 | force: true 20 | charset: UTF-8 21 | 22 | hello: Hello spring-boot-assembly 23 | 24 | 25 | # mybatis公共配置 26 | mybatis: 27 | mapper-locations: classpath:mapper/*.xml 28 | configuration: 29 | map-underscore-to-camel-case: true 30 | -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/resources/db/data.sql: -------------------------------------------------------------------------------- 1 | -- ---------------------------- 2 | -- Records of sys_user 3 | -- ---------------------------- 4 | INSERT INTO `sys_user` VALUES ('1', '管理员', 'admin', '123456', '管理员账号', '2018-12-29 00:33:25', null); 5 | INSERT INTO `sys_user` VALUES ('2', '测试人员', 'test', '123456', '测试人员账号', '2018-12-29 00:33:42', null); 6 | -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/resources/db/schema.sql: -------------------------------------------------------------------------------- 1 | -- ---------------------------- 2 | -- Table structure for sys_user 3 | -- ---------------------------- 4 | DROP TABLE IF EXISTS `sys_user`; 5 | CREATE TABLE `sys_user` ( 6 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', 7 | `name` varchar(50) DEFAULT NULL COMMENT '名称', 8 | `account` varchar(20) DEFAULT NULL COMMENT '账号', 9 | `pwd` varchar(100) DEFAULT NULL COMMENT '密码', 10 | `remark` varchar(200) DEFAULT NULL COMMENT '备注', 11 | `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 12 | `update_time` datetime DEFAULT NULL COMMENT '修改时间', 13 | PRIMARY KEY (`id`) 14 | ); -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/resources/hello/hello.txt: -------------------------------------------------------------------------------- 1 | sfsf -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/resources/mapper/SysUserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | id, name, account, pwd, remark, create_time, update_time 8 | 9 | 10 | 11 | insert into sys_user values(#{id}, #{name}, #{pwd}, #{remark}, #{createTime}, #{updateTime}) 12 | 13 | 14 | 15 | update sys_user set remark = #{remark} where id = #{id} 16 | 17 | 18 | 19 | delete from sys_user where id = #{id} 20 | 21 | 22 | 25 | 26 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/resources/static/css/index.css: -------------------------------------------------------------------------------- 1 | p{ 2 | font-size: 26px; 3 | } -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Index 6 | 7 | 8 | 9 | 10 |

Hello spring-boot-assembly

11 | 12 | -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/resources/static/js/index.js: -------------------------------------------------------------------------------- 1 | console.log("hello spring-boot-assembly"); -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/resources/templates/test.txt: -------------------------------------------------------------------------------- 1 | test -------------------------------------------------------------------------------- /spring-boot-assembly/src/main/resources/test.txt: -------------------------------------------------------------------------------- 1 | Hello World... 2 | Test File... -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | spring-boot-dubbo 7 | com.hks.example 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | dubbo-api 12 | 1.0-SNAPSHOT 13 | jar 14 | 15 | -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-api/src/main/java/com/hks/dubbo/api/DemoService.java: -------------------------------------------------------------------------------- 1 | package com.hks.dubbo.api; 2 | 3 | /** 4 | * 描述: 定义服务接口 5 | * 6 | * @author hekuangsheng 7 | * @create 2017-10-27 13:20 8 | **/ 9 | public interface DemoService { 10 | 11 | String sayHello(String name); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-consumer/src/main/java/com/hks/dubbo/consumer/config/PropertiesConfig.java: -------------------------------------------------------------------------------- 1 | package com.hks.dubbo.consumer.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.context.annotation.ImportResource; 5 | import org.springframework.context.annotation.PropertySource; 6 | 7 | /** 8 | * 描述: 加载配置 9 | * 10 | * @author hekuangsheng 11 | * @create 2017-10-27 13:26 12 | **/ 13 | @Configuration 14 | @PropertySource("classpath:dubbo.properties") 15 | @ImportResource({"classpath:dubbo/*.xml"}) 16 | public class PropertiesConfig { 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-consumer/src/main/java/com/hks/dubbo/consumer/run/DubboConsumerApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.dubbo.consumer.run; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | /** 8 | * 描述: 启动服务 9 | * 10 | * @author hekuangsheng 11 | * @create 2017-10-27 11:49 12 | **/ 13 | @SpringBootApplication 14 | @ComponentScan(value = {"com.hks.dubbo"}) 15 | public class DubboConsumerApplication { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(DubboConsumerApplication.class, args); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-consumer/src/main/java/com/hks/dubbo/consumer/service/ConsumerDemoService.java: -------------------------------------------------------------------------------- 1 | package com.hks.dubbo.consumer.service; 2 | 3 | import com.hks.dubbo.api.DemoService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Service; 6 | 7 | /** 8 | * 描述: 消费远程方法 9 | * 10 | * @author hekuangsheng 11 | * @create 2017-10-27 13:22 12 | **/ 13 | @Service("consumerDemoService") 14 | public class ConsumerDemoService { 15 | 16 | @Autowired 17 | private DemoService demoService; 18 | 19 | public void sayHello(String name) { 20 | String hello = demoService.sayHello(name); // 执行消费远程方法 21 | System.out.println(hello); // 显示调用结果 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-consumer/src/main/java/com/hks/dubbo/consumer/web/DemoConsumerController.java: -------------------------------------------------------------------------------- 1 | package com.hks.dubbo.consumer.web; 2 | 3 | /** 4 | * 描述: 5 | * 6 | * @author hekuangsheng 7 | * @create 2018-07-25 17:25 8 | **/ 9 | 10 | import com.hks.dubbo.api.DemoService; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | import org.springframework.web.bind.annotation.RequestParam; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import javax.annotation.Resource; 17 | 18 | @RestController 19 | public class DemoConsumerController { 20 | 21 | @Resource 22 | private DemoService demoService; 23 | 24 | @RequestMapping("/sayHello") 25 | public String sayHello(@RequestParam String name) { 26 | return demoService.sayHello(name); 27 | } 28 | 29 | @RequestMapping(value = "hello", method = RequestMethod.GET) 30 | public String hello(){ 31 | return "hello"; 32 | } 33 | } -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-consumer/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=dubbo-consumer 2 | server.port=8085 3 | server.tomcat.max-threads=1000 4 | server.tomcat.max-connections=2000 -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-consumer/src/main/resources/dubbo.properties: -------------------------------------------------------------------------------- 1 | ######################################################### 2 | # dubbo config 3 | #��¶����˿� 4 | dubbo.protocol.port=20880 5 | #�ṩ����ʱʱ�� 6 | dubbo.provider.timeout=10000 7 | #�ṩ���汾 8 | dubbo.provider.version=1.0 9 | #��ʾ�÷���ʹ�ö������������� 10 | dubbo.provider.connections=5 11 | # �̶���С�̳߳أ�����ʱ�����̣߳����رգ�һֱ���С�(ȱʡ) 12 | dubbo.protocol.threadpool=fixed 13 | # �߳����� 14 | dubbo.protocol.threads=500 15 | #�������Դ��������ֻ���ڶ������ԣ�д�������ܻ�������д�� Ĭ��retries="0" 16 | dubbo.provider.retries=0 17 | # dubbo�����ļ� 18 | dubbo.cache=./data/dubbo/cache/dubbo-consumer 19 | ######################################################### 20 | 21 | # zookeeper config 22 | zookeeper.connect=127.0.0.1:2181 -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-consumer/src/main/resources/dubbo/dubbo-consumer.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-consumer/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | ###set log levels### 2 | log4j.rootLogger=debug, stdout 3 | ###输出到控制台### 4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 5 | log4j.appender.stdout.Target=System.out 6 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 7 | log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-consumer/src/test/java/io/ymq/dubbo/test/ConsumerTest.java: -------------------------------------------------------------------------------- 1 | package com.hks.dubbo.test; 2 | 3 | import com.hks.dubbo.consumer.run.DubboConsumerApplication; 4 | import com.hks.dubbo.consumer.service.ConsumerDemoService; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | /** 12 | * 描述: 测试消费远程服务 13 | * 14 | * @author hekuangsheng 15 | * @create 2017-10-27 14:15 16 | **/ 17 | @RunWith(SpringRunner.class) 18 | @SpringBootTest(classes = DubboConsumerApplication.class) 19 | public class ConsumerTest { 20 | 21 | @Autowired 22 | private ConsumerDemoService consumerDemoService; 23 | 24 | @Test 25 | public void sayHello(){ 26 | consumerDemoService.sayHello("Peng Lei"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-provider/src/main/java/com/hks/dubbo/provider/config/PropertiesConfig.java: -------------------------------------------------------------------------------- 1 | package com.hks.dubbo.provider.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.context.annotation.ImportResource; 5 | import org.springframework.context.annotation.PropertySource; 6 | 7 | /** 8 | * 描述: 加载配置 9 | * 10 | * @author hekuangsheng 11 | * @create 2017-10-27 13:26 12 | **/ 13 | @Configuration 14 | @PropertySource("classpath:dubbo.properties") 15 | @ImportResource({"classpath:dubbo/*.xml"}) 16 | public class PropertiesConfig { 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-provider/src/main/java/com/hks/dubbo/provider/run/DubboProviderApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.dubbo.provider.run; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | /** 8 | * 描述:启动提供方服务 9 | * 10 | * @author hekuangsheng 11 | * @create 2017-10-27 11:49 12 | **/ 13 | @SpringBootApplication 14 | @ComponentScan(value = {"com.hks.dubbo"}) 15 | public class DubboProviderApplication { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(DubboProviderApplication.class, args); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-provider/src/main/java/com/hks/dubbo/provider/service/DemoServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.hks.dubbo.provider.service; 2 | 3 | import com.alibaba.dubbo.rpc.RpcContext; 4 | import com.hks.dubbo.api.DemoService; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | 10 | /** 11 | * 描述: 提供方实现 12 | * 13 | * @author hekuangsheng 14 | * @create 2017-10-27 13:22 15 | **/ 16 | @Service("demoService") 17 | public class DemoServiceImpl implements DemoService { 18 | 19 | @Override 20 | public String sayHello(String name) { 21 | System.out.println("[" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "] Hello " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress()); 22 | return "Hello " + name + ", response form provider: " + RpcContext.getContext().getLocalAddress(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-provider/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=dubbo-provider 2 | server.port=8084 3 | server.tomcat.max-threads=1000 4 | server.tomcat.max-connections=2000 -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-provider/src/main/resources/dubbo.properties: -------------------------------------------------------------------------------- 1 | ######################################################### 2 | # dubbo config 3 | #��¶����˿� 4 | dubbo.protocol.port=20880 5 | #�ṩ����ʱʱ�� 6 | dubbo.provider.timeout=10000 7 | #�ṩ���汾 8 | dubbo.provider.version=1.0 9 | #��ʾ�÷���ʹ�ö������������� 10 | dubbo.provider.connections=5 11 | # �̶���С�̳߳أ�����ʱ�����̣߳����رգ�һֱ���С�(ȱʡ) 12 | dubbo.protocol.threadpool=fixed 13 | # �߳����� 14 | dubbo.protocol.threads=500 15 | #�������Դ��������ֻ���ڶ������ԣ�д�������ܻ�������д�� Ĭ��retries="0" 16 | dubbo.provider.retries=0 17 | # dubbo�����ļ� 18 | dubbo.cache=./data/dubbo/cache/dubbo-provider 19 | ######################################################### 20 | # zookeeper config 21 | zookeeper.connect=127.0.0.1:2181 -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-provider/src/main/resources/dubbo/dubbo-provider.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-dubbo/dubbo-provider/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | ###set log levels### 2 | log4j.rootLogger=debug, stdout 3 | ###输出到控制台### 4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 5 | log4j.appender.stdout.Target=System.out 6 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 7 | log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n -------------------------------------------------------------------------------- /spring-boot-elasticsearch-demo/src/main/java/com/hks/example/elasticsearch/run/ElasticsearchDemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.example.elasticsearch.run; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | /** 8 | * 9 | */ 10 | @SpringBootApplication 11 | @ComponentScan(value = {"com.hks.example.elasticsearch"}) 12 | public class ElasticsearchDemoApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(ElasticsearchDemoApplication.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch-demo/src/main/java/com/hks/example/elasticsearch/service/AboutService.java: -------------------------------------------------------------------------------- 1 | package com.hks.example.elasticsearch.service; 2 | 3 | /** 4 | * 描述: 5 | * 6 | * @author hekuangsheng 7 | * @create 2017-11-04 11:17 8 | **/ 9 | public interface AboutService { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch-demo/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Elasticsearch 2 | elasticsearch.cluster.name=xiaoming 3 | elasticsearch.ip=127.0.0.1 4 | elasticsearch.port=9300 5 | elasticsearch.pool=5 6 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch/src/main/java/com/hks/elasticsearch/repository/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.hks.elasticsearch.repository; 2 | 3 | import com.hks.elasticsearch.model.Book; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.Pageable; 6 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 描述: 12 | * 13 | * @author hekuangsheng 14 | * @create 2017-11-02 14:47 15 | **/ 16 | public interface BookRepository extends ElasticsearchRepository { 17 | 18 | Page findByAuthor(String author, Pageable pageable); 19 | 20 | List findByTitle(String title); 21 | 22 | Book save(Book book); 23 | } -------------------------------------------------------------------------------- /spring-boot-elasticsearch/src/main/java/com/hks/elasticsearch/service/BookService.java: -------------------------------------------------------------------------------- 1 | package com.hks.elasticsearch.service; 2 | 3 | import com.hks.elasticsearch.model.Book; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.PageRequest; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * 描述: 11 | * 12 | * @author hekuangsheng 13 | * @create 2017-11-02 14:48 14 | **/ 15 | public interface BookService { 16 | 17 | Book save(Book book); 18 | 19 | void delete(Book book); 20 | 21 | Book findOne(String id); 22 | 23 | Iterable findAll(); 24 | 25 | Page findByAuthor(String author, PageRequest pageRequest); 26 | 27 | List findByTitle(String title); 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch/src/main/java/com/hks/elasticsearch/service/BookServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.hks.elasticsearch.service; 2 | 3 | import com.hks.elasticsearch.model.Book; 4 | import com.hks.elasticsearch.repository.BookRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.data.domain.Page; 7 | import org.springframework.data.domain.PageRequest; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * 描述: 14 | * 15 | * @author hekuangsheng 16 | * @create 2017-11-02 14:49 17 | **/ 18 | @Service 19 | public class BookServiceImpl implements BookService { 20 | 21 | @Autowired 22 | private BookRepository bookRepository; 23 | 24 | 25 | @Override 26 | public Book save(Book book) { 27 | return bookRepository.save(book); 28 | } 29 | 30 | @Override 31 | public void delete(Book book) { 32 | bookRepository.delete(book); 33 | } 34 | 35 | @Override 36 | public Book findOne(String id) { 37 | return bookRepository.findOne(id); 38 | } 39 | 40 | @Override 41 | public Iterable findAll() { 42 | return bookRepository.findAll(); 43 | } 44 | 45 | @Override 46 | public Page findByAuthor(String author, PageRequest pageRequest) { 47 | return bookRepository.findByAuthor(author, pageRequest); 48 | } 49 | 50 | @Override 51 | public List findByTitle(String title) { 52 | return bookRepository.findByTitle(title); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # elasticsearch 2 | elasticsearch.cluster.name=xiaoming 3 | elasticsearch.ip=127.0.0.1 4 | elasticsearch.port=9300 5 | elasticsearch.pool=5 6 | -------------------------------------------------------------------------------- /spring-boot-gracefulShutdown/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /nbbuild/ 22 | /dist/ 23 | /nbdist/ 24 | /.nb-gradle/ 25 | /build/ 26 | 27 | ### VS Code ### 28 | .vscode/ 29 | -------------------------------------------------------------------------------- /spring-boot-gracefulShutdown/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-gracefulShutdown/src/test/java/com/hks/graceful/GracefulShutdownApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hks.graceful; 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 GracefulShutdownApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-hbase/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /spring-boot-hbase/readme.md: -------------------------------------------------------------------------------- 1 | 请移步:https://github.com/singgel/BigData-skillTree -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/hks/hbase/HbaseApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | import java.util.ArrayList; 7 | import java.util.Collections; 8 | import java.util.Comparator; 9 | 10 | @SpringBootApplication 11 | public class HbaseApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(HbaseApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/hks/hbase/controller/HbaseDemoController.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase.controller; 2 | 3 | import com.hks.hbase.model.HBaseTable; 4 | import com.hks.hbase.pojo.UserDeviceTable; 5 | import com.hks.hbase.service.IHBaseService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestMethod; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | /** 12 | * @Author: hekuangsheng 13 | * @Date: 2018/11/30 14 | */ 15 | @RestController 16 | @RequestMapping("/hbase") 17 | public class HbaseDemoController { 18 | 19 | @Autowired 20 | IHBaseService ihBaseService; 21 | 22 | @RequestMapping(value = "create",method = RequestMethod.GET) 23 | public String create(){ 24 | UserDeviceTable table = new UserDeviceTable(); 25 | ihBaseService.createTable(table); 26 | return "success"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/hks/hbase/model/HBaseTable.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import static com.hks.hbase.util.CheckUtil.checkIsEmpty; 7 | 8 | public abstract class HBaseTable { 9 | private String tableName; 10 | protected List columnFamily = new ArrayList<>(); 11 | 12 | public HBaseTable(String tableName){ 13 | checkIsEmpty(tableName,"表名不能为空"); 14 | this.tableName = tableName; 15 | setColumnFamily(); 16 | } 17 | 18 | /** 19 | * 20 | * @return 获取表名 21 | */ 22 | public String getTableName(){ 23 | return this.tableName; 24 | } 25 | 26 | /** 27 | * 28 | * @return 获取表所有列簇List 29 | */ 30 | public List getColumnFamily(){ 31 | return this.columnFamily; 32 | } 33 | protected abstract void setColumnFamily(); 34 | 35 | /** 36 | * 37 | * @return 获取默认的列簇名(即列簇List第一个元素) 38 | */ 39 | public String getDefaultColumnName(){ 40 | return this.columnFamily.get(0); 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/hks/hbase/model/KeyValue.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase.model; 2 | 3 | public class KeyValue { 4 | private K k; 5 | private V v; 6 | public KeyValue(K key,V value){ 7 | this.k = key; 8 | this.v = value; 9 | } 10 | 11 | public K getK() { 12 | return k; 13 | } 14 | 15 | public V getV() { 16 | return v; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/hks/hbase/pojo/CFIdInfoTable.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase.pojo; 2 | 3 | import com.hks.hbase.model.HBaseTable; 4 | 5 | import java.util.Collections; 6 | 7 | /** 8 | * 资讯信息表,rowkey为聚合id,column为objId、objType 9 | */ 10 | public class CFIdInfoTable extends HBaseTable { 11 | 12 | public CFIdInfoTable() { 13 | super("cf_id_info"); 14 | } 15 | 16 | @Override 17 | protected void setColumnFamily() { 18 | this.columnFamily = Collections.singletonList("c"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/hks/hbase/pojo/CFResultCell.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase.pojo; 2 | 3 | import com.hks.hbase.model.HBaseCell; 4 | import org.apache.hadoop.hbase.util.Bytes; 5 | 6 | import java.text.SimpleDateFormat; 7 | import java.util.Date; 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | public class CFResultCell extends HBaseCell { 12 | 13 | /** 14 | * 用fastjson序列化的ArrayList对象 15 | */ 16 | private String resultJson; 17 | private static final SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 18 | public CFResultCell(String rowKey,String resultJson) { 19 | super("c"); 20 | this.resultJson = resultJson; 21 | setRowKey(rowKey); 22 | } 23 | 24 | @Override 25 | public Map getCellMap() { 26 | Map map = new HashMap<>(); 27 | map.put("r", Bytes.toBytes(resultJson)); 28 | map.put("rowkey",Bytes.toBytes(getRowKey())); 29 | map.put("time",Bytes.toBytes(dateformat.format(new Date()))); 30 | return map; 31 | } 32 | 33 | public String getDefaultCellName(){ 34 | return "r"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/hks/hbase/pojo/CFResultTable.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase.pojo; 2 | 3 | import com.hks.hbase.model.HBaseTable; 4 | 5 | import java.util.Collections; 6 | 7 | public class CFResultTable extends HBaseTable { 8 | 9 | public CFResultTable(CFResultTypeEnum cfResultType){ 10 | super(cfResultType.getName()); 11 | } 12 | 13 | public CFResultTable(String tableName){ 14 | super(tableName); 15 | } 16 | 17 | @Override 18 | protected void setColumnFamily() { 19 | this.columnFamily = Collections.singletonList("c"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/hks/hbase/pojo/InformationTable.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase.pojo; 2 | 3 | import com.hks.hbase.model.HBaseTable; 4 | 5 | import java.util.Collections; 6 | 7 | public class InformationTable extends HBaseTable { 8 | 9 | public InformationTable() { 10 | super("information_id"); 11 | } 12 | 13 | @Override 14 | protected void setColumnFamily() { 15 | this.columnFamily = Collections.singletonList("c"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/hks/hbase/pojo/UserDeviceCell.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase.pojo; 2 | 3 | import com.hks.hbase.model.HBaseCell; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | public class UserDeviceCell extends HBaseCell { 9 | 10 | public Integer getId() { 11 | return id; 12 | } 13 | 14 | public void setId(Integer id) { 15 | this.id = id; 16 | } 17 | 18 | /** 19 | * cell ID值 20 | */ 21 | private Integer id; 22 | public UserDeviceCell(String rowKey,Integer id) { 23 | super("c"); 24 | setRowKey(rowKey); 25 | setId(id); 26 | } 27 | 28 | @Override 29 | public Map getCellMap() { 30 | Map cellMap = new HashMap<>(); 31 | cellMap.put(getIdCellName(), getBytes(getId())); 32 | cellMap.put("uidordevid",getBytes(getRowKey())); 33 | return cellMap; 34 | } 35 | 36 | public String getIdCellName(){ 37 | return "id"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/hks/hbase/pojo/UserDeviceTable.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase.pojo; 2 | 3 | import com.hks.hbase.model.HBaseTable; 4 | 5 | import java.util.Collections; 6 | 7 | public class UserDeviceTable extends HBaseTable { 8 | 9 | public UserDeviceTable() { 10 | super("user_device_id"); 11 | } 12 | 13 | @Override 14 | protected void setColumnFamily() { 15 | this.columnFamily = Collections.singletonList("c"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/hks/hbase/regionhelper/HashRowKeyGenerator.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase.regionhelper; 2 | 3 | import org.apache.hadoop.hbase.util.Bytes; 4 | import org.apache.hadoop.hbase.util.MD5Hash; 5 | 6 | import java.util.Random; 7 | 8 | public class HashRowKeyGenerator implements RowKeyGenerator { 9 | private long currentId = 1; 10 | private long currentTime = System.currentTimeMillis(); 11 | 12 | private Random random = new Random(); 13 | 14 | @Override 15 | public byte[] nextId() { 16 | try { 17 | currentTime += random.nextInt(1000); 18 | 19 | byte[] lowT = Bytes.copy(Bytes.toBytes(currentTime), 4, 4); 20 | byte[] lowU = Bytes.copy(Bytes.toBytes(currentId), 4, 4); 21 | 22 | return Bytes.add(MD5Hash.getMD5AsHex(Bytes.add(lowU, lowT)).substring(0, 8).getBytes(), 23 | Bytes.toBytes(currentId)); 24 | } finally { 25 | currentId++; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/hks/hbase/regionhelper/RowKeyGenerator.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase.regionhelper; 2 | 3 | public interface RowKeyGenerator { 4 | byte [] nextId(); 5 | } 6 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/hks/hbase/regionhelper/SplitKeysCalculator.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase.regionhelper; 2 | 3 | public interface SplitKeysCalculator { 4 | public byte[][] calcSplitKeys(); 5 | } 6 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/hks/hbase/util/CheckUtil.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase.util; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import static com.hks.hbase.util.StringUtil.isEmptyOrWhiteSpace; 7 | 8 | public class CheckUtil { 9 | public static void checkIsEmpty(String val,String msg){ 10 | if(isEmptyOrWhiteSpace(val)){ 11 | throw new IllegalArgumentException(msg); 12 | } 13 | } 14 | public static void checkIsEmpty(List val, String msg){ 15 | if(val == null || val.isEmpty()){ 16 | throw new IllegalArgumentException(msg); 17 | } 18 | } 19 | public static void checkIsEmpty(Map val, String msg){ 20 | if(val == null || val.isEmpty()){ 21 | throw new IllegalArgumentException(msg); 22 | } 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/hks/hbase/util/StringUtil.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase.util; 2 | 3 | public class StringUtil { 4 | public static boolean isEmpty(String str){ 5 | if(str == null || str.length() == 0){ 6 | return true; 7 | } 8 | return false; 9 | } 10 | 11 | public static boolean isEmptyOrWhiteSpace(String str){ 12 | if(str == null || str.length() == 0 || str.trim().length() == 0){ 13 | return true; 14 | } 15 | return false; 16 | } 17 | } -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/resources/zookeeper.properties: -------------------------------------------------------------------------------- 1 | hbase.zookeeper.quorum = 192.168.70.3:2181,192.168.70.4:2181,192.168.87.234:2181 2 | hbase.zookeeper.property.clientPort = 2181 3 | zookeeper.znode.parent = /hbase 4 | hbase.client.pause = 50 5 | hbase.client.retries.number = 3 6 | hbase.rpc.timeout = 10000 7 | hbase.client.operation.timeout = 6000 8 | hbase.client.scanner.timeout.period = 10000 -------------------------------------------------------------------------------- /spring-boot-hbase/src/test/java/com/hks/hbase/HbaseApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hks.hbase; 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 HbaseApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-hive/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /spring-boot-hive/readme.md: -------------------------------------------------------------------------------- 1 | 请移步:https://github.com/singgel/BigData-skillTree -------------------------------------------------------------------------------- /spring-boot-hive/src/main/java/com/hks/hive/SpringBootHiveApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.hive; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootHiveApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootHiveApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-hive/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-hive/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-hive/src/test/java/com/hks/hive/SpringBootHiveApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hks.hive; 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 SpringBootHiveApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-http/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /spring-boot-http/src/main/java/com/heks/http/HttpApplication.java: -------------------------------------------------------------------------------- 1 | package com.heks.http; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class HttpApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(HttpApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-http/src/main/java/com/heks/http/config/AsyncRestTemplateConfig.java: -------------------------------------------------------------------------------- 1 | package com.heks.http.config; 2 | 3 | import org.apache.http.impl.nio.client.CloseableHttpAsyncClient; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 8 | import org.springframework.http.client.AsyncClientHttpRequestFactory; 9 | import org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory; 10 | import org.springframework.web.client.AsyncRestTemplate; 11 | 12 | /** 13 | * AsyncRestTemplate客户端连接池配置 14 | * 15 | * 这个AsyncRestTemplate从没用过而且 16 | */ 17 | @Configuration 18 | @EnableAspectJAutoProxy(proxyTargetClass = true) 19 | public class AsyncRestTemplateConfig { 20 | 21 | @Autowired 22 | CloseableHttpAsyncClient asyncClient; 23 | 24 | @Bean 25 | public AsyncRestTemplate asyncRestTemplate() { 26 | return new AsyncRestTemplate(asyncHttpRequestFactory()); 27 | } 28 | 29 | private AsyncClientHttpRequestFactory asyncHttpRequestFactory() { 30 | return new HttpComponentsAsyncClientHttpRequestFactory(asyncClient); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-http/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | httpclient: 2 | connectTimeout: 500 3 | requestTimeout: 500 4 | socketTimeout: 500 5 | defaultMaxPerRoute: 20 6 | maxTotalConnections: 200 7 | defaultKeepAliveTimeMillis: 20000 8 | closeIdleConnectionWaitTimeSecs: 30 -------------------------------------------------------------------------------- /spring-boot-http/src/test/java/com/heks/http/HttpApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.heks.http; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class HttpApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/java/com/hks/kafka/MsgConsumer.java: -------------------------------------------------------------------------------- 1 | package com.hks.kafka; 2 | 3 | import org.springframework.kafka.annotation.KafkaListener; 4 | import org.springframework.stereotype.Component; 5 | 6 | /** 7 | * 描述:消息消费者 8 | * 9 | * @author hekuangsheng 10 | * @create 2017-10-16 18:33 11 | **/ 12 | @Component 13 | public class MsgConsumer { 14 | 15 | @KafkaListener(topics = {"topic-1","topic-2"}) 16 | public void processMessage(String content) { 17 | 18 | System.out.println("消息被消费"+content); 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/java/com/hks/kafka/config/KafkaConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.hks.kafka.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.kafka.annotation.EnableKafka; 5 | 6 | 7 | /** 8 | * 描述: 启用 kafka 9 | * 10 | * @author hekuangsheng 11 | * @create 2017-10-16 18:25 12 | **/ 13 | @Configuration 14 | @EnableKafka 15 | public class KafkaConfiguration { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/java/com/hks/kafka/controller/MsgController.java: -------------------------------------------------------------------------------- 1 | package com.hks.kafka.controller; 2 | 3 | import com.hks.kafka.MsgProducer; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestMethod; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | /** 10 | * @Author: hekuangsheng 11 | * @Date: 2018/11/16 12 | */ 13 | @RestController 14 | @RequestMapping("/kafka") 15 | public class MsgController { 16 | 17 | @Autowired 18 | MsgProducer msgProducer; 19 | 20 | @RequestMapping("/add") 21 | public String add(String name){ 22 | try{ 23 | msgProducer.sendMessage("topic-1",name); 24 | } 25 | catch (Exception ex){ 26 | return ex.getMessage(); 27 | } 28 | return "success"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/java/com/hks/kafka/run/KafkaApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.kafka.run; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | /** 8 | * 描述:启动服务 9 | * 10 | * @author hekuangsheng 11 | * @create 2017-10-16 18:51 12 | **/ 13 | @SpringBootApplication 14 | @ComponentScan(value = {"com.hks.kafka"}) 15 | public class KafkaApplication { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(KafkaApplication.class, args); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spring-boot-kafka 2 | server.port=8070 3 | #kafka 4 | # 指定kafka 代理地址,可以多个 5 | spring.kafka.bootstrap-servers=127.0.0.1:9092 6 | # 指定listener 容器中的线程数,用于提高并发量 7 | spring.kafka.listener.concurrency=3 8 | # 每次批量发送消息的数量 9 | spring.kafka.producer.batch-size=1000 10 | # 指定默认消费者group id 11 | spring.kafka.consumer.group-id=myGroup 12 | # 指定默认topic id 13 | spring.kafka.template.default-topic=topic-1 14 | 15 | logging.level.root=info -------------------------------------------------------------------------------- /spring-boot-kafka/src/test/java/com/hks/kafka/test/BaseTest.java: -------------------------------------------------------------------------------- 1 | package com.hks.kafka.test; 2 | 3 | import com.hks.kafka.MsgProducer; 4 | import com.hks.kafka.run.KafkaApplication; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | 12 | /** 13 | * 描述: 测试 kafka 14 | * 15 | * @author hekuangsheng 16 | * @create 2017-10-16 18:45 17 | **/ 18 | @RunWith(SpringRunner.class) 19 | @SpringBootTest(classes = KafkaApplication.class) 20 | public class BaseTest { 21 | 22 | @Autowired 23 | private MsgProducer msgProducer; 24 | 25 | @Test 26 | public void test() throws Exception { 27 | 28 | msgProducer.sendMessage("topic-1", "topic--------1"); 29 | msgProducer.sendMessage("topic-2", "topic--------2"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/test/java/com/hks/kafka/test/KafkaUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.hks.kafka.test; 2 | 3 | import com.github.charithe.kafka.EphemeralKafkaBroker; 4 | import com.github.charithe.kafka.KafkaJunitRule; 5 | import org.apache.kafka.clients.consumer.KafkaConsumer; 6 | import org.apache.kafka.clients.producer.KafkaProducer; 7 | import org.junit.Rule; 8 | import org.junit.Test; 9 | 10 | import java.util.List; 11 | import java.util.concurrent.ExecutionException; 12 | 13 | public class KafkaUnitTest { 14 | @Rule 15 | public KafkaJunitRule kafkaRule = new KafkaJunitRule(EphemeralKafkaBroker.create()); 16 | 17 | @Test 18 | public void testSomething() throws ExecutionException, InterruptedException { 19 | // Convenience methods to produce and consume messages 20 | kafkaRule.helper().produceStrings("my-test-topic", "a", "b", "c", "d", "e"); 21 | List result = kafkaRule.helper().consumeStrings("my-test-topic", 5).get(); 22 | 23 | // or use the built-in producers and consumers 24 | KafkaProducer producer = kafkaRule.helper().createStringProducer(); 25 | 26 | KafkaConsumer consumer = kafkaRule.helper().createStringConsumer(); 27 | 28 | // Alternatively, the Zookeeper connection String and the broker port can be retrieved to generate your own config 29 | String zkConnStr = kafkaRule.helper().zookeeperConnectionString(); 30 | int brokerPort = kafkaRule.helper().kafkaPort(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-lettuce/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-lettuce/src/main/java/com/hks/lettuce/LettuceApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.lettuce; 2 | 3 | import com.hks.lettuce.dao.EmployeeDAO; 4 | import com.hks.lettuce.dao.FamilyDAO; 5 | import com.hks.lettuce.dao.FriendDAO; 6 | import com.hks.lettuce.dao.UserDAO; 7 | import com.hks.lettuce.entity.Person; 8 | import com.hks.lettuce.service.AsyncTaskService; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.CommandLineRunner; 11 | import org.springframework.boot.SpringApplication; 12 | import org.springframework.boot.autoconfigure.SpringBootApplication; 13 | 14 | @SpringBootApplication 15 | public class LettuceApplication implements CommandLineRunner{ 16 | 17 | @Autowired 18 | AsyncTaskService asyncTaskService; 19 | 20 | public static void main(String[] args) { 21 | SpringApplication.run(LettuceApplication.class, args); 22 | } 23 | 24 | @Override 25 | public void run(String... args) throws Exception { 26 | for (int i = 0; i < 10; i++) { 27 | asyncTaskService.executeAsyncTask(i); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-lettuce/src/main/java/com/hks/lettuce/dao/EmployeeDAO.java: -------------------------------------------------------------------------------- 1 | package com.hks.lettuce.dao; 2 | 3 | import com.hks.lettuce.entity.Person; 4 | import org.springframework.data.redis.core.HashOperations; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import javax.annotation.Resource; 8 | import java.util.Map; 9 | 10 | @Repository 11 | public class EmployeeDAO { 12 | private static final String KEY = "employeesKey"; 13 | 14 | // inject the redisTemplate as HashOperations 15 | @Resource(name="redisTemplate") 16 | private HashOperations hashOps; 17 | 18 | public void addEmployee(Person person) { 19 | hashOps.putIfAbsent(KEY, person.getId(), person); 20 | } 21 | public void updateEmployee(Person person) { 22 | hashOps.put(KEY, person.getId(), person); 23 | } 24 | public Person getEmployee(Integer id) { 25 | return hashOps.get(KEY, id); 26 | } 27 | public long getNumberOfEmployees() { 28 | return hashOps.size(KEY); 29 | } 30 | public Map getAllEmployees() { 31 | return hashOps.entries(KEY); 32 | } 33 | public long deleteEmployees(Integer... ids) { 34 | return hashOps.delete(KEY, (Object)ids); 35 | } 36 | } -------------------------------------------------------------------------------- /spring-boot-lettuce/src/main/java/com/hks/lettuce/dao/FamilyDAO.java: -------------------------------------------------------------------------------- 1 | package com.hks.lettuce.dao; 2 | 3 | import com.hks.lettuce.entity.Person; 4 | import org.springframework.data.redis.core.SetOperations; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import javax.annotation.Resource; 8 | import java.util.Set; 9 | 10 | @Repository 11 | public class FamilyDAO { 12 | private static final String KEY = "myFamilyKey"; 13 | 14 | // inject the redisTemplate as SetOperations 15 | @Resource(name="redisTemplate") 16 | private SetOperations setOps; 17 | 18 | public void addFamilyMembers(Person... persons) { 19 | setOps.add(KEY, persons); 20 | } 21 | public Set getFamilyMembers() { 22 | return setOps.members(KEY); 23 | } 24 | public long getNumberOfFamilyMembers() { 25 | return setOps.size(KEY); 26 | } 27 | public long removeFamilyMembers(Person... persons) { 28 | return setOps.remove(KEY, (Object[])persons); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-lettuce/src/main/java/com/hks/lettuce/dao/FriendDAO.java: -------------------------------------------------------------------------------- 1 | package com.hks.lettuce.dao; 2 | 3 | import com.hks.lettuce.entity.Person; 4 | import org.springframework.data.redis.core.ListOperations; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import javax.annotation.Resource; 8 | 9 | @Repository 10 | public class FriendDAO { 11 | private static final String KEY = "friendsKey"; 12 | 13 | // inject the redisTemplate as ListOperations 14 | @Resource(name="redisTemplate") 15 | private ListOperations opsForList; 16 | 17 | public void addFriend(Person person) { 18 | opsForList.leftPush(KEY, person); 19 | } 20 | public long getNumberOfFriends() { 21 | return opsForList.size(KEY); 22 | } 23 | public Person getFriendAtIndex(Integer index) { 24 | return opsForList.index(KEY, index); 25 | } 26 | public void removeFriend(Person p) { 27 | opsForList.remove(KEY, 1, p); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-lettuce/src/main/java/com/hks/lettuce/dao/UserDAO.java: -------------------------------------------------------------------------------- 1 | package com.hks.lettuce.dao; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.data.redis.core.StringRedisTemplate; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public class UserDAO { 9 | private static final String KEY = "userKey"; 10 | 11 | @Autowired 12 | private StringRedisTemplate stringRedisTemplate; 13 | 14 | public void addUserName(String uname) { 15 | stringRedisTemplate.opsForValue().setIfAbsent(KEY, uname); 16 | } 17 | public void updateUserName(String uname) { 18 | stringRedisTemplate.opsForValue().set(KEY, uname); 19 | } 20 | public String getUserName() { 21 | return stringRedisTemplate.opsForValue().get(KEY); 22 | } 23 | public void deleteUser() { 24 | stringRedisTemplate.delete(KEY); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-lettuce/src/main/java/com/hks/lettuce/entity/Person.java: -------------------------------------------------------------------------------- 1 | package com.hks.lettuce.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Person implements Serializable { 6 | private static final long serialVersionUID = 1L; 7 | private int id; 8 | private String name; 9 | private int age; 10 | public Person() { } 11 | public Person(int id, String name, int age) { 12 | this.id = id; 13 | this.name = name; 14 | this.age = age; 15 | } 16 | public int getId() { 17 | return id; 18 | } 19 | public void setId(int id) { 20 | this.id = id; 21 | } 22 | public String getName() { 23 | return name; 24 | } 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | public int getAge() { 29 | return age; 30 | } 31 | public void setAge(int age) { 32 | this.age = age; 33 | } 34 | @Override 35 | public String toString() { 36 | return id +" - " + name + " - " + age; 37 | } 38 | @Override 39 | public boolean equals(final Object obj) { 40 | if (obj == null) { 41 | return false; 42 | } 43 | final Person person = (Person) obj; 44 | if (this == person) { 45 | return true; 46 | } else { 47 | return (this.name.equals(person.name) && this.age == person.age); 48 | } 49 | } 50 | @Override 51 | public int hashCode() { 52 | int hashno = 7; 53 | hashno = 13 * hashno + (name == null ? 0 : name.hashCode()); 54 | return hashno; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /spring-boot-lettuce/src/main/java/com/hks/lettuce/service/TaskExecutorConfig.java: -------------------------------------------------------------------------------- 1 | package com.hks.lettuce.service; 2 | 3 | import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; 4 | import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.scheduling.annotation.AsyncConfigurer; 8 | import org.springframework.scheduling.annotation.EnableAsync; 9 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 10 | 11 | import java.util.concurrent.Executor; 12 | 13 | /** 14 | * ①利用@EnableAsync 注解开启异步任务支持。 15 | * ②配置类实现AsyncConfigurer 接口并重写getAsyncExecutor 方法,并返回一个 16 | * ThreadPoolTaskExecutor ,这样我们就获得了一个基于线程池TaskExecutor。 17 | */ 18 | @Configuration 19 | @ComponentScan("com.hks.lettuce.service") 20 | @EnableAsync 21 | public class TaskExecutorConfig implements AsyncConfigurer { // 1 22 | @Override 23 | public Executor getAsyncExecutor() { // 2 24 | ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); 25 | taskExecutor.setCorePoolSize(5); 26 | taskExecutor.setMaxPoolSize(10); 27 | taskExecutor.setQueueCapacity(25); 28 | taskExecutor.initialize(); 29 | return taskExecutor; 30 | } 31 | 32 | @Override 33 | public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { 34 | return new SimpleAsyncUncaughtExceptionHandler(); 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /spring-boot-lettuce/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | redis: 3 | cluster: 4 | #nodes: 10.10.53.13:20020,10.10.53.13:20021,10.10.53.13:20030,10.10.53.13:20031,10.10.53.13:20010,10.10.53.13:20011,10.10.53.13:20040,10.10.53.13:20041 5 | nodes: 192.168.64.169:11111,192.168.64.169:11222,192.168.64.169:11333,192.168.64.169:11444,192.168.64.169:11555,192.168.64.169:11666,192.168.64.169:11777,192.168.64.169:11888 6 | lettuce: 7 | pool: 8 | max-active: 7 9 | max-idle: 7 10 | max-wait: -1ms 11 | min-idle: 2 12 | shutdown-timeout: 200ms 13 | 14 | server: 15 | port: 18080 16 | 17 | logging: 18 | config: classpath:logging-config.xml 19 | 20 | -------------------------------------------------------------------------------- /spring-boot-lettuce/src/main/resources/logging-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | logback 4 | 5 | 6 | 9 | 10 | %d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n 11 | 12 | 13 | 14 | 15 | 16 | ${log.path} 17 | 18 | logback.%d{yyyy-MM-dd}.log 19 | 20 | 21 | %d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /spring-boot-lettuce/src/test/java/com/hks/lettuce/LettuceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hks.lettuce; 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 LettuceApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-limit/src/main/java/com/hks/example/Constants.java: -------------------------------------------------------------------------------- 1 | package com.hks.example; 2 | 3 | public class Constants { 4 | public static final String RATE_LIMIT_KEY = "ratelimit:"; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /spring-boot-limit/src/main/java/com/hks/example/SpringBootLimitApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.example; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootLimitApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootLimitApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-limit/src/main/java/com/hks/example/Token.java: -------------------------------------------------------------------------------- 1 | package com.hks.example; 2 | 3 | public enum Token { 4 | SUCCESS, 5 | FAILED; 6 | 7 | public boolean isSuccess() { 8 | return this.equals(SUCCESS); 9 | } 10 | 11 | public boolean isFailed() { 12 | return this.equals(FAILED); 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /spring-boot-limit/src/main/java/com/hks/example/annotation/RateLimit.java: -------------------------------------------------------------------------------- 1 | package com.hks.example.annotation; 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 | 8 | /** 9 | * 描述: 限流注解 10 | * 11 | * @author hekuangsheng 12 | * @create 2018-08-16 15:24 13 | **/ 14 | @Target({ElementType.TYPE, ElementType.METHOD}) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | public @interface RateLimit { 17 | 18 | /** 19 | * 限流唯一标示 20 | * 21 | * @return 22 | */ 23 | String key() default ""; 24 | 25 | /** 26 | * 限流时间 27 | * 28 | * @return 29 | */ 30 | int time(); 31 | 32 | /** 33 | * 限流次数 34 | * 35 | * @return 36 | */ 37 | int count(); 38 | } 39 | -------------------------------------------------------------------------------- /spring-boot-limit/src/main/java/com/hks/example/controller/LimiterController.java: -------------------------------------------------------------------------------- 1 | package com.hks.example.controller; 2 | 3 | import com.hks.example.annotation.RateLimit; 4 | import org.apache.commons.lang3.time.DateFormatUtils; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.data.redis.core.RedisTemplate; 7 | import org.springframework.data.redis.support.atomic.RedisAtomicInteger; 8 | import org.springframework.data.redis.support.atomic.RedisAtomicLong; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import java.util.Date; 13 | 14 | /** 15 | * 描述: 测试页 16 | * 17 | * @author hekuangsheng 18 | * @create 2018-08-16 15:42 19 | **/ 20 | @RestController 21 | public class LimiterController { 22 | 23 | @Autowired 24 | private RedisTemplate redisTemplate; 25 | 26 | // 10 秒中,可以访问10次 27 | @RateLimit(key = "test", time = 10, count = 10) 28 | @GetMapping("/test") 29 | public String luaLimiter() { 30 | RedisAtomicInteger entityIdCounter = new RedisAtomicInteger("entityIdCounter", redisTemplate.getConnectionFactory()); 31 | 32 | String date = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"); 33 | 34 | return date + " 累计访问次数:" + entityIdCounter.getAndIncrement(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-limit/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spring-boot-limit 2 | server.port=8090 3 | 4 | # Redis���ݿ����� 5 | spring.redis.database=0 6 | # Redis��������ַ 7 | spring.redis.host=127.0.0.1 8 | # Redis���������Ӷ˿� 9 | spring.redis.port=6379 10 | # Redis�������������루Ĭ��Ϊ�գ� 11 | spring.redis.password= 12 | # ���ӳ������������ʹ�ø�ֵ��ʾû�����ƣ� 13 | spring.redis.jedis.pool.max-active=8 14 | # ���ӳ���������ȴ�ʱ�䣨ʹ�ø�ֵ��ʾû�����ƣ� 15 | spring.redis.jedis.pool.max-wait=-1ms 16 | # ���ӳ��е����������� 17 | spring.redis.jedis.pool.max-idle=8 18 | # ���ӳ��е���С�������� 19 | spring.redis.jedis.pool.min-idle=0 20 | # ���ӳ�ʱʱ�䣨���룩 21 | spring.redis.timeout=10000ms 22 | -------------------------------------------------------------------------------- /spring-boot-limit/src/main/resources/limit/ratelimit.lua : -------------------------------------------------------------------------------- 1 | -- curr_timestamp: redis current timestamp(Unit of second) 2 | redis.replicate_commands() 3 | local time = redis.call('time') 4 | local curr_timestamp = tonumber(time[1]) 5 | local curr_microseconds = tonumber(time[2]) 6 | local require_permits = tonumber(ARGV[1]) 7 | local result = {} 8 | -- result[1]: minimum time from next refresh(Unit of microsecond) 9 | result[1] = (1000000 - curr_microseconds) / 1000 10 | 11 | local ratelimit_info = redis.call("HMGET", KEYS[1], "last_second", "curr_permits", "max_burst") 12 | local last_second = tonumber(ratelimit_info[1]) 13 | local curr_permits = tonumber(ratelimit_info[2]) 14 | local max_burst = tonumber(ratelimit_info[3]) 15 | 16 | -- If the last time has passed, update the token bucket 17 | if (curr_timestamp > last_second) then 18 | curr_permits = max_burst 19 | redis.call("HMSET", KEYS[1], "last_second", curr_timestamp) 20 | end 21 | 22 | -- Update the last permit amount, base on the curr_permits change 23 | if (curr_permits > require_permits) then 24 | redis.call("HMSET", KEYS[1], "curr_permits", curr_permits - require_permits) 25 | result[2] = require_permits 26 | return result 27 | end 28 | 29 | if (curr_permits > 0) then 30 | redis.call("HMSET", KEYS[1], "curr_permits", 0) 31 | end 32 | result[2] = curr_permits 33 | return result 34 | -------------------------------------------------------------------------------- /spring-boot-limit/src/main/resources/limit/ratelimitInit.lua: -------------------------------------------------------------------------------- 1 | -- curr_timestamp: redis current timestamp(Unit of second) 2 | redis.replicate_commands() 3 | local curr_timestamp = tonumber(redis.call('TIME')[1]) 4 | 5 | --[[ 6 | last_second: token bucket last update timestamp(Unit of second) 7 | curr_permits: token bucket last permit amount 8 | max_burst: token bucket max amount 9 | --]] 10 | local result = 1 11 | redis.call("HMSET", KEYS[1], 12 | "last_second", curr_timestamp, 13 | "curr_permits", ARGV[1], 14 | "max_burst", ARGV[2]) 15 | return result 16 | -------------------------------------------------------------------------------- /spring-boot-limit/src/main/resources/rateLimit.lua: -------------------------------------------------------------------------------- 1 | local key = "rate.limit:" .. KEYS[1] --限流KEY 2 | local limit = tonumber(ARGV[1]) --限流大小 3 | local current = tonumber(redis.call('get', key) or "0") 4 | if current + 1 > limit then --如果超出限流大小 5 | return 0 6 | else --请求数+1,并设置2秒过期 7 | redis.call("INCRBY", key,"1") 8 | redis.call("expire", key,"2") 9 | return current + 1 10 | end -------------------------------------------------------------------------------- /spring-boot-logback/src/main/java/com/hks/logback/config/annotation/Log.java: -------------------------------------------------------------------------------- 1 | package com.hks.logback.config.annotation; 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 | 8 | /** 9 | * Created by hekuangsheng on 2017/5/12. 10 | */ 11 | @Target({ElementType.TYPE, ElementType.METHOD}) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface Log { 14 | 15 | /** 16 | * 说明信息 17 | * 18 | * @return 19 | */ 20 | String value() default ""; 21 | 22 | /** 23 | * 是否忽略 24 | * 25 | * @return 26 | */ 27 | boolean ignore() default false; 28 | } -------------------------------------------------------------------------------- /spring-boot-logback/src/main/java/com/hks/logback/config/commons/MyWebMvcConfigurer.java: -------------------------------------------------------------------------------- 1 | package com.hks.logback.config.commons; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 6 | 7 | /** 8 | * 描述:拦截器配置 9 | * 10 | * @author hekuangsheng 11 | * @create 2017-10-30 16:54 12 | **/ 13 | @Configuration 14 | public class MyWebMvcConfigurer extends WebMvcConfigurerAdapter { 15 | 16 | @Override 17 | public void addInterceptors(InterceptorRegistry registry) { 18 | 19 | /** 20 | * 多个拦截器组成一个拦截器链 21 | * addPathPatterns 用于添加拦截规则 22 | * excludePathPatterns 用于排除拦截 23 | */ 24 | registry.addInterceptor(new ControllerInterceptor()).addPathPatterns("/**"); 25 | super.addInterceptors(registry); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-logback/src/main/java/com/hks/logback/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.hks.logback.controller; 2 | 3 | import com.hks.logback.config.annotation.Log; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.web.bind.annotation.*; 7 | 8 | import java.time.LocalDateTime; 9 | 10 | /** 11 | * 描述: 12 | * 13 | * @author hekuangsheng 14 | * @create 2017-10-30 14:20 15 | **/ 16 | @RestController 17 | @RequestMapping(value = "/index") 18 | public class IndexController { 19 | 20 | private final Logger LOGGER = LoggerFactory.getLogger(this.getClass()); 21 | 22 | /** 23 | * http://127.0.0.1:8090/index/?content="我是测试内容" 24 | * 25 | * @param content 26 | * @return 27 | */ 28 | @Log("首页IndexController") 29 | @RequestMapping(value="", method= RequestMethod.GET) 30 | public String index(@RequestParam String content) { 31 | LocalDateTime localDateTime = LocalDateTime.now(); 32 | 33 | LOGGER.trace("请求参数:content:{}", content); 34 | LOGGER.debug("请求参数:content:{}", content); 35 | LOGGER.info("请求参数:content:{}", content); 36 | LOGGER.warn("请求参数:content:{}", content); 37 | LOGGER.error("请求参数:content:{}", content); 38 | 39 | return localDateTime + ",content:" + content; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-logback/src/main/java/com/hks/logback/run/LogbackApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.logback.run; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | /** 8 | * 描述: 9 | * 10 | * @author hekuangsheng 11 | * @create 2017-10-30 14:15 12 | **/ 13 | @SpringBootApplication 14 | @ComponentScan(value = {"com.hks.logback"}) 15 | public class LogbackApplication { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(LogbackApplication.class, args); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-logback/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | spring.application.name=spring-boot-logback 3 | 4 | server.port=8090 5 | 6 | #日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 7 | logging.level.root=warn 8 | 9 | logging.path=./data/logs/spring-boot-logback 10 | -------------------------------------------------------------------------------- /spring-boot-lucene-demo/indexDir/_5.cfe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-lucene-demo/indexDir/_5.cfe -------------------------------------------------------------------------------- /spring-boot-lucene-demo/indexDir/_5.cfs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-lucene-demo/indexDir/_5.cfs -------------------------------------------------------------------------------- /spring-boot-lucene-demo/indexDir/_5.si: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-lucene-demo/indexDir/_5.si -------------------------------------------------------------------------------- /spring-boot-lucene-demo/indexDir/segments_8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-lucene-demo/indexDir/segments_8 -------------------------------------------------------------------------------- /spring-boot-lucene-demo/indexDir/write.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-lucene-demo/indexDir/write.lock -------------------------------------------------------------------------------- /spring-boot-lucene-demo/src/main/java/com/hks/lucene/LuceneApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.lucene; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | /** 8 | * 描述: 9 | * 10 | * @author: hekuangsheng 11 | * @create: 2017/11/7 17:02 12 | */ 13 | @SpringBootApplication 14 | public class LuceneApplication { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(LuceneApplication.class, args); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-lucene-demo/src/main/java/com/hks/lucene/service/IKanalyzerService.java: -------------------------------------------------------------------------------- 1 | package com.hks.lucene.service; 2 | 3 | import java.util.Map; 4 | 5 | public interface IKanalyzerService { 6 | 7 | /** 8 | * 传入content获取分词 9 | * @param content 文本内容 10 | * @return 返回 map 词,出现次数 11 | */ 12 | Map getParticipleByStr(String content); 13 | 14 | /** 15 | * 16 | * @param content 17 | * @param useSmart 自动智能匹配 18 | * @return 19 | */ 20 | Map getParticipleByStr(String content, boolean useSmart); 21 | 22 | } -------------------------------------------------------------------------------- /spring-boot-lucene-demo/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-lucene-demo/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-mongodb/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/hks/example/mongodb/SpringBootMongodbApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.example.mongodb; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * 描述: 启动服务 8 | * 9 | * @author: hekuangsheng 10 | * @create: 2018/2/5 13:52 11 | */ 12 | @SpringBootApplication 13 | public class SpringBootMongodbApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(SpringBootMongodbApplication.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/hks/example/mongodb/controller/DemoController.java: -------------------------------------------------------------------------------- 1 | package com.hks.example.mongodb.controller; 2 | 3 | import com.hks.example.mongodb.dao.DemoDao; 4 | import com.hks.example.mongodb.pojo.DemoEntity; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | /** 10 | * @Author: hekuangsheng 11 | * @Date: 2018/11/16 12 | */ 13 | @RestController 14 | @RequestMapping("/mongo") 15 | public class DemoController { 16 | 17 | @Autowired 18 | DemoDao demoDao; 19 | 20 | @RequestMapping("/add") 21 | public String add(String name){ 22 | try{ 23 | DemoEntity demoEntity = new DemoEntity(); 24 | demoEntity.setId(1000000L); 25 | demoEntity.setTitle(name); 26 | demoEntity.setDescription(name); 27 | demoEntity.setUrl("www.baidu.com"); 28 | demoEntity.setBy(name); 29 | demoDao.saveDemo(demoEntity); 30 | } 31 | catch (Exception ex){ 32 | return ex.getMessage(); 33 | } 34 | return "success"; 35 | } 36 | 37 | @RequestMapping("get") 38 | public DemoEntity get(Long id){ 39 | return demoDao.findDemoById(id); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/hks/example/mongodb/dao/DemoDao.java: -------------------------------------------------------------------------------- 1 | package com.hks.example.mongodb.dao; 2 | 3 | import com.hks.example.mongodb.pojo.DemoEntity; 4 | 5 | /** 6 | * 描述: 提供增删改查 MongoDB 接口 7 | * 8 | * @author hekuangsheng 9 | * @create 2018-02-03 16:56 10 | **/ 11 | public interface DemoDao { 12 | 13 | void saveDemo(DemoEntity demoEntity); 14 | 15 | void removeDemo(Long id); 16 | 17 | void updateDemo(DemoEntity demoEntity); 18 | 19 | DemoEntity findDemoById(Long id); 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spring-boot-mongodb 2 | server.port=8060 3 | # mongodb 4 | spring.data.mongodb.uri=mongodb://127.0.0.1:27017/demo 5 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/doc/ymq_one.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Version : 50519 6 | Source Host : localhost:3306 7 | Source Database : ymq_one 8 | 9 | Target Server Type : MYSQL 10 | Target Server Version : 50519 11 | File Encoding : 65001 12 | 13 | Date: 2017-10-20 12:51:07 14 | */ 15 | 16 | SET FOREIGN_KEY_CHECKS=0; 17 | 18 | -- ---------------------------- 19 | -- Table structure for test_one 20 | -- ---------------------------- 21 | DROP TABLE IF EXISTS `test_one`; 22 | CREATE TABLE `test_one` ( 23 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', 24 | `name` varchar(50) DEFAULT NULL COMMENT '名称', 25 | `remark` varchar(500) DEFAULT NULL COMMENT '备注', 26 | PRIMARY KEY (`id`) 27 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='测试'; 28 | 29 | -- ---------------------------- 30 | -- Records of test_one 31 | -- ---------------------------- 32 | INSERT INTO `test_one` VALUES ('1', '测试', '这是测试 ymq_one 数据库'); 33 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/doc/ymq_two.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Version : 50519 6 | Source Host : localhost:3306 7 | Source Database : ymq_two 8 | 9 | Target Server Type : MYSQL 10 | Target Server Version : 50519 11 | File Encoding : 65001 12 | 13 | Date: 2017-10-20 12:51:15 14 | */ 15 | 16 | SET FOREIGN_KEY_CHECKS=0; 17 | 18 | -- ---------------------------- 19 | -- Table structure for test_two 20 | -- ---------------------------- 21 | DROP TABLE IF EXISTS `test_two`; 22 | CREATE TABLE `test_two` ( 23 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', 24 | `name` varchar(50) DEFAULT NULL COMMENT '名称', 25 | `remark` varchar(500) DEFAULT NULL COMMENT '备注', 26 | PRIMARY KEY (`id`) 27 | ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='测试'; 28 | 29 | -- ---------------------------- 30 | -- Records of test_two 31 | -- ---------------------------- 32 | INSERT INTO `test_two` VALUES ('1', '测试', '这是测试 ymq_two 数据库'); 33 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/hks/mybatis/dao/YmqOneBaseDao.java: -------------------------------------------------------------------------------- 1 | package com.hks.mybatis.dao; 2 | 3 | import com.hks.mybatis.dao.base.BaseDao; 4 | import org.apache.ibatis.session.SqlSessionFactory; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import javax.annotation.Resource; 8 | 9 | /** 10 | * 描述:数据源 one 11 | * 12 | * @author hekuangsheng 13 | * @create 2017-10-20 11:27 14 | **/ 15 | @Repository 16 | public class YmqOneBaseDao extends BaseDao { 17 | 18 | @Resource 19 | public void setSqlSessionFactorYmqOne(SqlSessionFactory sqlSessionFactory) { 20 | super.setSqlSessionFactory(sqlSessionFactory); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/hks/mybatis/dao/YmqTwoBaseDao.java: -------------------------------------------------------------------------------- 1 | package com.hks.mybatis.dao; 2 | 3 | import com.hks.mybatis.dao.base.BaseDao; 4 | import org.apache.ibatis.session.SqlSessionFactory; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import javax.annotation.Resource; 8 | 9 | /** 10 | * 描述:数据源 two 11 | * 12 | * @author hekuangsheng 13 | * @create 2017-10-20 11:27 14 | **/ 15 | @Repository 16 | public class YmqTwoBaseDao extends BaseDao { 17 | 18 | @Resource 19 | public void setSqlSessionFactorYmqTwo(SqlSessionFactory sqlSessionFactory) { 20 | super.setSqlSessionFactory(sqlSessionFactory); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/hks/mybatis/dao/base/BaseUtils.java: -------------------------------------------------------------------------------- 1 | package com.hks.mybatis.dao.base; 2 | 3 | /** 4 | * 描述: 基础工具方法 5 | * author: hekuangsheng 6 | * Date: 2017/9/8 21:13 7 | */ 8 | public class BaseUtils { 9 | 10 | /** 11 | * 生成sql方法调用路径 12 | * 13 | * @param 14 | * 15 | * @param object 全限定类名 16 | * @param methodName 调用方法名称 17 | * @return 18 | */ 19 | public static String makeClazzPath(T object, String methodName) { 20 | 21 | if (object == null) { 22 | return ""; 23 | } 24 | StringBuffer buffer = new StringBuffer(); 25 | buffer.append(object.getClass().getName()); 26 | buffer.append("."); 27 | buffer.append(methodName); 28 | return buffer.toString(); 29 | 30 | } 31 | 32 | public static String makeClazzPath(Class clazz, String methodName) { 33 | 34 | StringBuffer buffer = new StringBuffer(); 35 | buffer.append(clazz.getName()); 36 | buffer.append("."); 37 | buffer.append(methodName); 38 | return buffer.toString(); 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/hks/mybatis/dao/base/QueryResult.java: -------------------------------------------------------------------------------- 1 | package com.hks.mybatis.dao.base; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 描述: 分页返回实体 7 | * author: hekuangsheng 8 | * Date: 2017/9/8 15:05 9 | */ 10 | public class QueryResult implements java.io.Serializable { 11 | private static final long serialVersionUID = 461900815434592315L; 12 | 13 | private List list; 14 | private long total; 15 | 16 | public QueryResult() { 17 | 18 | } 19 | 20 | public QueryResult(List list, long total) { 21 | super(); 22 | this.list = list; 23 | this.total = total; 24 | } 25 | 26 | public List getlist() { 27 | return list; 28 | } 29 | 30 | public void setlist(List list) { 31 | this.list = list; 32 | } 33 | 34 | public long getTotal() { 35 | return total; 36 | } 37 | 38 | public void setTotal(long total) { 39 | this.total = total; 40 | } 41 | } 42 | 43 | 44 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/hks/mybatis/po/TestOnePo.java: -------------------------------------------------------------------------------- 1 | 2 | package com.hks.mybatis.po; 3 | 4 | import java.io.Serializable; 5 | 6 | public class TestOnePo implements Serializable{ 7 | private static final long serialVersionUID = 1L; 8 | //alias 9 | public static final String TABLE_ALIAS = "TestOne"; 10 | 11 | 12 | //columns START 13 | /** 14 | * id db_column: id 15 | */ 16 | private Long id; 17 | /** 18 | * 名称 db_column: name 19 | */ 20 | private String name; 21 | /** 22 | * 备注 db_column: remark 23 | */ 24 | private String remark; 25 | //columns END 26 | 27 | 28 | 29 | 30 | public Long getId() { 31 | return this.id; 32 | } 33 | 34 | public void setId(Long value) { 35 | this.id = value; 36 | } 37 | 38 | 39 | public String getName() { 40 | return this.name; 41 | } 42 | 43 | public void setName(String value) { 44 | this.name = value; 45 | } 46 | 47 | 48 | public String getRemark() { 49 | return this.remark; 50 | } 51 | 52 | public void setRemark(String value) { 53 | this.remark = value; 54 | } 55 | 56 | 57 | 58 | 59 | } 60 | 61 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/hks/mybatis/po/TestTwoPo.java: -------------------------------------------------------------------------------- 1 | 2 | package com.hks.mybatis.po; 3 | 4 | import java.io.Serializable; 5 | 6 | 7 | public class TestTwoPo implements Serializable { 8 | private static final long serialVersionUID = 1L; 9 | //alias 10 | public static final String TABLE_ALIAS = "TestTwo"; 11 | 12 | 13 | //columns START 14 | /** 15 | * id db_column: id 16 | */ 17 | private Long id; 18 | /** 19 | * 名称 db_column: name 20 | */ 21 | private String name; 22 | /** 23 | * 备注 db_column: remark 24 | */ 25 | private String remark; 26 | //columns END 27 | 28 | 29 | public Long getId() { 30 | return this.id; 31 | } 32 | 33 | public void setId(Long value) { 34 | this.id = value; 35 | } 36 | 37 | 38 | public String getName() { 39 | return this.name; 40 | } 41 | 42 | public void setName(String value) { 43 | this.name = value; 44 | } 45 | 46 | 47 | public String getRemark() { 48 | return this.remark; 49 | } 50 | 51 | public void setRemark(String value) { 52 | this.remark = value; 53 | } 54 | 55 | 56 | } 57 | 58 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/hks/mybatis/run/MybatisApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.mybatis.run; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.transaction.annotation.EnableTransactionManagement; 8 | 9 | /** 10 | * 描述: 启动服务 11 | * 12 | * @author hekuangsheng 13 | * @create 2017-10-19 18:23 14 | **/ 15 | @SpringBootApplication 16 | //@EnableDiscoveryClient 17 | //@EnableTransactionManagement 18 | @ComponentScan(value = {"com.hks.mybatis"}) 19 | public class MybatisApplication { 20 | 21 | public static void main(String[] args) { 22 | SpringApplication.run(MybatisApplication.class, args); 23 | } 24 | } -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/java/com/hks/mybatis/service/MybatisService.java: -------------------------------------------------------------------------------- 1 | package com.hks.mybatis.service; 2 | 3 | import com.hks.mybatis.dao.YmqOneBaseDao; 4 | import com.hks.mybatis.po.TestOnePo; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.transaction.annotation.Transactional; 8 | 9 | @Service 10 | public class MybatisService{ 11 | 12 | @Autowired 13 | YmqOneBaseDao ymqOneBaseDao; 14 | 15 | @Transactional(value = "txManager1", rollbackFor = Exception.class) 16 | public boolean Insert(TestOnePo testOnePo) { 17 | ymqOneBaseDao.insert(testOnePo); 18 | 19 | insert(); 20 | return true; 21 | } 22 | 23 | public boolean insert() { 24 | 25 | TestOnePo testOnePoo = new TestOnePo(); 26 | testOnePoo.setId(1111111L); 27 | testOnePoo.setName("aaaaaaaaaa"); 28 | testOnePoo.setRemark("bbbbbbbbbb"); 29 | 30 | ymqOneBaseDao.insert(testOnePoo); 31 | return true; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-boot-mybatis/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 5555 3 | tomcat: 4 | max-connections: 2000 5 | max-threads: 1000 6 | spring: 7 | application: 8 | name: spring-boot-mybatis 9 | ymq: 10 | one: 11 | datasource: 12 | password: root 13 | url: jdbc:mysql://localhost:3306/ymq_one?useUnicode=true&characterEncoding=UTF-8 14 | username: root 15 | two: 16 | datasource: 17 | password: root 18 | url: jdbc:mysql://localhost:3306/ymq_two?useUnicode=true&characterEncoding=UTF-8 19 | username: root 20 | eureka: 21 | client: 22 | serviceUrl: 23 | defaultZone: ${DISCOVERY_URL:http://localhost:8761}/eureka/ 24 | instance: 25 | leaseRenewalIntervalInSeconds: 1 26 | leaseExpirationDurationInSeconds: 2 27 | 28 | ribbon: 29 | eureka: 30 | enabled: true -------------------------------------------------------------------------------- /spring-boot-netty/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-netty/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-netty/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-boot-netty/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-boot-netty/Info.txt: -------------------------------------------------------------------------------- 1 | 2 | https://github.com/zbum/netty-spring-example 3 | 4 | 1)mvn clean install 5 | 6 | 2)mvn spring-boot:run 7 | 8 | 3)open 2 command prompts and type the following 9 | 10 | telnet localhost 8090 11 | 12 | 4)client1 can send the message to client2 by using his channel key 13 | 14 | /0:0:0:0:0:0:0:1:57220::How are you ? 15 | 16 | 5)client2 can send the message to client1 by using his channel key 17 | 18 | /0:0:0:0:0:0:0:1:57221::fine, thanks. How are you ? -------------------------------------------------------------------------------- /spring-boot-netty/src/main/java/com/hks/netty/config/NettyConfig.java: -------------------------------------------------------------------------------- 1 | package com.hks.netty.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | 5 | @Configuration 6 | public class NettyConfig { 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-netty/src/main/java/com/hks/netty/config/NettyProperties.java: -------------------------------------------------------------------------------- 1 | package com.hks.netty.config; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | 7 | @Getter 8 | @Setter 9 | @ConfigurationProperties(prefix = "netty") 10 | public class NettyProperties { 11 | private int tcpPort; 12 | 13 | private int bossCount; 14 | 15 | private int workerCount; 16 | 17 | private boolean keepAlive; 18 | 19 | private int backlog; 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-netty/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | netty: 2 | tcp-port: 8090 3 | boss-count: 1 4 | worker-count: 10 5 | keep-alive: true 6 | backlog: 100 7 | -------------------------------------------------------------------------------- /spring-boot-netty/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-netty/src/test/java/com/hks/netty/ICallback.java: -------------------------------------------------------------------------------- 1 | package com.hks.netty; 2 | 3 | import java.util.Map; 4 | 5 | public interface ICallback { 6 | 7 | public void callback(Map params); 8 | } 9 | -------------------------------------------------------------------------------- /spring-boot-netty/src/test/java/com/hks/netty/NettyApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hks.netty; 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 NettyApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-netty/src/test/java/com/hks/netty/SomethingServerHandlerTest2.java: -------------------------------------------------------------------------------- 1 | package com.hks.netty; 2 | 3 | import com.hks.netty.server.handler.SomethingServerHandler; 4 | import io.netty.channel.embedded.EmbeddedChannel; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | import java.net.InetSocketAddress; 12 | 13 | import static org.hamcrest.core.Is.is; 14 | import static org.junit.Assert.assertThat; 15 | 16 | /** 17 | * @author heks 18 | * @since 19 | */ 20 | @RunWith(SpringRunner.class) 21 | @SpringBootTest 22 | public class SomethingServerHandlerTest2 { 23 | @Autowired 24 | private SomethingServerHandler somethingServerHandler; 25 | 26 | @Test 27 | public void channelRead() { 28 | EmbeddedChannel channel = new EmbeddedChannel(somethingServerHandler); 29 | channel.connect(new InetSocketAddress("127.0.0.1", 10) ); 30 | 31 | String res1 = channel.readOutbound(); 32 | assertThat(res1, is("Your channel key is embedded\r\n")); 33 | 34 | channel.writeInbound("embedded::test"); 35 | 36 | String res2 = channel.readOutbound(); 37 | assertThat(res2, is("test\n\r")); 38 | } 39 | } -------------------------------------------------------------------------------- /spring-boot-participle/src/main/java/com/hks/participle/core/ISegmenter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * IK 中文分词 版本 5.0 3 | * IK Analyzer release 5.0 4 | * 5 | * Licensed to the Apache Software Foundation (ASF) under one or more 6 | * contributor license agreements. See the NOTICE file distributed with 7 | * this work for additional information regarding copyright ownership. 8 | * The ASF licenses this file to You under the Apache License, Version 2.0 9 | * (the "License"); you may not use this file except in compliance with 10 | * the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | * 源代码由林良益(linliangyi2005@gmail.com)提供 21 | * 版权声明 2012,乌龙茶工作室 22 | * provided by Linliangyi and copyright 2012 by Oolong studio 23 | * 24 | */ 25 | package com.hks.participle.core; 26 | 27 | 28 | /** 29 | * 30 | * 子分词器接口 31 | */ 32 | interface ISegmenter { 33 | 34 | /** 35 | * 从分析器读取下一个可能分解的词元对象 36 | * 37 | * @param context 分词算法上下文 38 | */ 39 | void analyze(AnalyzeContext context); 40 | 41 | 42 | /** 43 | * 重置子分析器状态 44 | */ 45 | void reset(); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /spring-boot-participle/src/main/resources/IKAnalyzer.cfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | IK Analyzer 扩展配置 5 | 6 | ext.dic 7 | 8 | stopword.dic 9 | 10 | http://192.168.70.33:8080/tag.dic 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-participle/src/main/resources/dic/main2012.dic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-participle/src/main/resources/dic/main2012.dic -------------------------------------------------------------------------------- /spring-boot-participle/src/main/resources/dic/quantifier.dic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-participle/src/main/resources/dic/quantifier.dic -------------------------------------------------------------------------------- /spring-boot-participle/src/main/resources/ext.dic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-participle/src/main/resources/ext.dic -------------------------------------------------------------------------------- /spring-boot-participle/src/main/resources/stopword.dic: -------------------------------------------------------------------------------- 1 | a 2 | an 3 | and 4 | are 5 | as 6 | at 7 | be 8 | but 9 | by 10 | for 11 | if 12 | in 13 | into 14 | is 15 | it 16 | no 17 | not 18 | of 19 | on 20 | or 21 | such 22 | that 23 | the 24 | their 25 | then 26 | there 27 | these 28 | they 29 | this 30 | to 31 | was 32 | will 33 | with -------------------------------------------------------------------------------- /spring-boot-prometheus-exporter/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-prometheus-exporter/src/main/java/com/hks/exporter/ExporterApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.exporter; 2 | 3 | import io.prometheus.client.hotspot.DefaultExports; 4 | import io.prometheus.client.spring.boot.EnablePrometheusEndpoint; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | 9 | @SpringBootApplication 10 | @EnablePrometheusEndpoint 11 | public class ExporterApplication implements CommandLineRunner { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(ExporterApplication.class, args); 15 | } 16 | 17 | @Override 18 | public void run(String... args) throws Exception { 19 | DefaultExports.initialize(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-prometheus-exporter/src/main/java/com/hks/exporter/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.hks.exporter.controller; 2 | 3 | import org.springframework.web.bind.annotation.Mapping; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | public class HelloController { 10 | 11 | @RequestMapping(value = "hello",method = RequestMethod.GET) 12 | public String hello(){ 13 | return "hello"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-prometheus-exporter/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | endpoints: 2 | prometheus: 3 | id: metrics 4 | metrics: 5 | id: springmetrics 6 | sensitive: false 7 | enabled: true 8 | 9 | server: 10 | port: 8090 -------------------------------------------------------------------------------- /spring-boot-prometheus-exporter/src/test/java/com/hks/exporter/ExporterApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hks.exporter; 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 ExporterApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-prometheus/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /spring-boot-prometheus/src/main/java/com/hks/prometheus/PrometheusApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.prometheus; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class PrometheusApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(PrometheusApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-prometheus/src/main/java/com/hks/prometheus/controller/DemoController.java: -------------------------------------------------------------------------------- 1 | package com.hks.prometheus.controller; 2 | 3 | import io.prometheus.client.Counter; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import java.util.Random; 9 | 10 | @RestController 11 | public class DemoController { 12 | private static Random random = new Random(); 13 | 14 | private static final Counter requestTotal = Counter.build() 15 | .name("my_sample_counter") 16 | .labelNames("status") 17 | .help("A simple Counter to illustrate custom Counters in Spring Boot and Prometheus").register(); 18 | 19 | @RequestMapping("/endpoint") 20 | public void endpoint() { 21 | if (random.nextInt(2) > 0) { 22 | requestTotal.labels("success").inc(); 23 | } else { 24 | requestTotal.labels("error").inc(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-prometheus/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | ##prometheusj 2 | management: 3 | metrics: 4 | export: 5 | prometheus: 6 | enabled: true 7 | step: 1m 8 | descriptions: true 9 | web: 10 | server: 11 | auto-time-requests: true 12 | endpoints: 13 | prometheus: 14 | id: springmetrics 15 | web: 16 | exposure: 17 | include: health,info,env,prometheus,metrics,httptrace,threaddump,heapdump,springmetrics 18 | -------------------------------------------------------------------------------- /spring-boot-prometheus/src/test/java/com/hks/prometheus/PrometheusApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hks.prometheus; 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 PrometheusApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-push/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot-push/src/main/java/com/heks/push/PushApplication.java: -------------------------------------------------------------------------------- 1 | package com.heks.push; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class PushApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(PushApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-push/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-push/src/test/java/com/heks/push/PushApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.heks.push; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class PushApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq-ack/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /spring-boot-rabbitmq-ack/src/main/java/com/hks/example/springboot/rabbitmq/ack/SpringBootRabbitmqAckApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.example.springboot.rabbitmq.ack; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootRabbitmqAckApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootRabbitmqAckApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq-ack/src/main/java/com/hks/example/springboot/rabbitmq/ack/config/RabbitConfig.java: -------------------------------------------------------------------------------- 1 | package com.hks.example.springboot.rabbitmq.ack.config; 2 | 3 | import org.springframework.amqp.core.Queue; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class RabbitConfig { 9 | 10 | @Bean 11 | public Queue QueueA() { 12 | // boolean durable = true 持久化 13 | return new Queue("hello", true); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq-ack/src/main/java/com/hks/example/springboot/rabbitmq/ack/web/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.hks.example.springboot.rabbitmq.ack.web; 2 | 3 | import com.hks.example.springboot.rabbitmq.ack.producer.HelloSender; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | public class IndexController { 10 | 11 | @Autowired 12 | private HelloSender helloSender; 13 | 14 | /** 15 | * 单生产者-单个消费者 16 | */ 17 | @RequestMapping("/send") 18 | public void sendMessageTest(String context) throws Exception { 19 | helloSender.sendMessage(context); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq-ack/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | #服务器配置 3 | spring.application.name=rabbitmq-hello 4 | #rabbitmq连接参数 5 | spring.rabbitmq.host=10.4.98.15 6 | spring.rabbitmq.port=5672 7 | spring.rabbitmq.username=admin 8 | spring.rabbitmq.password=admin 9 | 10 | 11 | # 开启发送确认 12 | spring.rabbitmq.publisher-confirms=true 13 | # 开启发送失败退回 14 | spring.rabbitmq.publisher-returns=true 15 | # 开启ACK 16 | spring.rabbitmq.listener.direct.acknowledge-mode=manual 17 | spring.rabbitmq.listener.simple.acknowledge-mode=manual -------------------------------------------------------------------------------- /spring-boot-rabbitmq-ack/src/test/java/com/hks/example/springboot/rabbitmq/ack/SpringBootRabbitmqAckApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hks.example.springboot.rabbitmq.ack; 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 SpringBootRabbitmqAckApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/hks/rabbitmq/config/RabbitDirectConfig.java: -------------------------------------------------------------------------------- 1 | package com.hks.rabbitmq.config; 2 | 3 | 4 | import org.springframework.amqp.core.*; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * 描述: 配置默认的交换机模式 10 | * 11 | * Direct Exchange是RabbitMQ默认的交换机模式,也是最简单的模式,根据key全文匹配去寻找队列。 12 | * 13 | * @author hekuangsheng 14 | * @create 2017-10-25 0:09 15 | **/ 16 | @Configuration 17 | public class RabbitDirectConfig { 18 | 19 | @Bean 20 | public Queue helloQueue() { 21 | return new Queue("hello"); 22 | } 23 | 24 | @Bean 25 | public Queue directQueue() { 26 | return new Queue("direct"); 27 | } 28 | 29 | //-------------------配置默认的交换机模式,可以不需要配置以下----------------------------------- 30 | @Bean 31 | DirectExchange directExchange() { 32 | return new DirectExchange("directExchange"); 33 | } 34 | 35 | //绑定一个key "direct",当消息匹配到就会放到这个队列中 36 | @Bean 37 | Binding bindingExchangeDirectQueue(Queue directQueue, DirectExchange directExchange) { 38 | return BindingBuilder.bind(directQueue).to(directExchange).with("direct"); 39 | } 40 | // 推荐使用 helloQueue() 方法写法,这种方式在 Direct Exchange 模式 多此一举,没必要这样写 41 | //--------------------------------------------------------------------------------------------- 42 | } 43 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/hks/rabbitmq/config/RabbitFanoutConfig.java: -------------------------------------------------------------------------------- 1 | package com.hks.rabbitmq.config; 2 | 3 | import org.springframework.amqp.core.*; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * 描述:配置广播模式或者订阅模式队列 9 | *

10 | * Fanout 就是我们熟悉的广播模式或者订阅模式,给Fanout交换机发送消息,绑定了这个交换机的所有队列都收到这个消息。 11 | * 12 | * @author hekuangsheng 13 | * @create 2017-10-16 16:47 14 | **/ 15 | @Configuration 16 | public class RabbitFanoutConfig { 17 | 18 | final static String PENGLEI = "fanout.penglei.net"; 19 | 20 | final static String SOUYUNKU = "fanout.souyunku.com"; 21 | @Bean 22 | public Queue queuePenglei() { 23 | return new Queue(RabbitFanoutConfig.PENGLEI); 24 | } 25 | 26 | @Bean 27 | public Queue queueSouyunku() { 28 | return new Queue(RabbitFanoutConfig.SOUYUNKU); 29 | } 30 | 31 | /** 32 | * 任何发送到Fanout Exchange的消息都会被转发到与该Exchange绑定(Binding)的所有队列上。 33 | */ 34 | @Bean 35 | FanoutExchange fanoutExchange() { 36 | return new FanoutExchange("fanoutExchange"); 37 | } 38 | 39 | @Bean 40 | Binding bindingExchangeQueuePenglei(Queue queuePenglei, FanoutExchange fanoutExchange) { 41 | return BindingBuilder.bind(queuePenglei).to(fanoutExchange); 42 | } 43 | 44 | @Bean 45 | Binding bindingExchangeQueueSouyunku(Queue queueSouyunku, FanoutExchange fanoutExchange) { 46 | return BindingBuilder.bind(queueSouyunku).to(fanoutExchange); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/hks/rabbitmq/direct/DirectReceiver.java: -------------------------------------------------------------------------------- 1 | package com.hks.rabbitmq.direct; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 4 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * 描述: 接收者 9 | * @author: hekuangsheng 10 | * @create: 2017/10/25 0:49 11 | */ 12 | @Component 13 | @RabbitListener(queues = "direct") 14 | public class DirectReceiver { 15 | 16 | @RabbitHandler 17 | public void process(String message) { 18 | System.out.println("接收者 DirectReceiver," + message); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/hks/rabbitmq/direct/helloReceiver.java: -------------------------------------------------------------------------------- 1 | package com.hks.rabbitmq.direct; 2 | 3 | import org.springframework.amqp.rabbit.annotation.Queue; 4 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 5 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * 描述: 10 | * 11 | * @author hekuangsheng 12 | * @create 2017-10-25 0:47 13 | **/ 14 | @Component 15 | @RabbitListener(queues = "hello") 16 | public class helloReceiver { 17 | 18 | @RabbitHandler 19 | public void process(String message) { 20 | System.out.println("接收者 helloReceiver," + message); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/hks/rabbitmq/fanout/FanoutReceiver1.java: -------------------------------------------------------------------------------- 1 | package com.hks.rabbitmq.fanout; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 4 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * 描述:接收者 9 | * 10 | * @author hekuangsheng 11 | * @create 2017-10-23 15:38 12 | **/ 13 | @Component 14 | @RabbitListener(queues = "fanout.penglei.net") 15 | public class FanoutReceiver1 { 16 | 17 | @RabbitHandler 18 | public void process(String message) { 19 | System.out.println("接收者 FanoutReceiver1," + message); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/hks/rabbitmq/fanout/FanoutReceiver2.java: -------------------------------------------------------------------------------- 1 | package com.hks.rabbitmq.fanout; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 4 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * 描述:接收者 9 | * 10 | * @author hekuangsheng 11 | * @create 2017-10-23 15:38 12 | **/ 13 | @Component 14 | @RabbitListener(queues = "fanout.hekuangsheng.com") 15 | public class FanoutReceiver2 { 16 | 17 | @RabbitHandler 18 | public void process(String message) { 19 | System.out.println("接收者 FanoutReceiver2," + message); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/hks/rabbitmq/run/RabbitApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.rabbitmq.run; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | /** 8 | * 描述: 启动服务 9 | * 10 | * @author: hekuangsheng 11 | * @create: 2017/10/23 14:14 12 | */ 13 | @SpringBootApplication 14 | @ComponentScan(value = {"com.hks.rabbitmq"}) 15 | public class RabbitApplication { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(RabbitApplication.class, args); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/hks/rabbitmq/topic/TopicReceiver1.java: -------------------------------------------------------------------------------- 1 | package com.hks.rabbitmq.topic; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 4 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * 描述: 接收者 9 | * 10 | * @author: hekuangsheng 11 | * @create: 2017/10/23 14:15 12 | */ 13 | @Component 14 | @RabbitListener(queues = "topic.message") 15 | public class TopicReceiver1 { 16 | 17 | @RabbitHandler 18 | public void process(String message) { 19 | System.out.println("接收者 TopicReceiver1," + message); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/hks/rabbitmq/topic/TopicReceiver2.java: -------------------------------------------------------------------------------- 1 | package com.hks.rabbitmq.topic; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 4 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * 描述: 接收者 9 | * 10 | * @author: hekuangsheng 11 | * @create: 2017/10/23 14:15 12 | */ 13 | @Component 14 | @RabbitListener(queues = "topic.message.s") 15 | public class TopicReceiver2 { 16 | 17 | @RabbitHandler 18 | public void process(String message) { 19 | System.out.println("接收者 TopicReceiver2," + message); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/hks/rabbitmq/topic/TopicReceiver3.java: -------------------------------------------------------------------------------- 1 | package com.hks.rabbitmq.topic; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 4 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * 描述: 接收者 9 | * 10 | * @author: hekuangsheng 11 | * @create: 2017/10/23 14:15 12 | */ 13 | @Component 14 | @RabbitListener(queues = "topic.ymq") 15 | public class TopicReceiver3 { 16 | 17 | @RabbitHandler 18 | public void process(String message) { 19 | System.out.println("接收者 TopicReceiver3," + message); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spring-boot-rabbitmq 2 | server.port=8020 3 | 4 | spring.rabbitmq.host=127.0.0.1 5 | spring.rabbitmq.port=5672 6 | spring.rabbitmq.username=admin 7 | spring.rabbitmq.password=admin 8 | -------------------------------------------------------------------------------- /spring-boot-redis-test/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-redis-test/src/main/java/com/hks/DemoRedisApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DemoRedisApplication { 8 | 9 | public static void main(String[] args) { 10 | 11 | SpringApplication.run(DemoRedisApplication.class, args); 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-redis-test/src/main/java/com/hks/pubsub/MessagePublisher.java: -------------------------------------------------------------------------------- 1 | package com.hks.pubsub; 2 | 3 | /** 4 | * Message Publisher 5 | * 6 | * @author hekuangsheng@gmail.com 7 | * @create 2019-05-01 19:35 8 | **/ 9 | public interface MessagePublisher { 10 | /** 11 | * publish message 12 | * @param message 13 | */ 14 | void publish(String message); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-redis-test/src/main/java/com/hks/pubsub/RedisMessagePublisher.java: -------------------------------------------------------------------------------- 1 | package com.hks.pubsub; 2 | 3 | import lombok.Setter; 4 | import org.springframework.data.redis.core.RedisTemplate; 5 | import org.springframework.data.redis.listener.ChannelTopic; 6 | 7 | /** 8 | * Redis message publisher 9 | * 10 | * @author hekuangsheng@gmail.com 11 | * @create 2019-05-01 19:36 12 | **/ 13 | @Setter 14 | public class RedisMessagePublisher implements MessagePublisher { 15 | 16 | private RedisTemplate redisTemplate; 17 | 18 | private ChannelTopic topic; 19 | 20 | private RedisMessagePublisher() { 21 | } 22 | 23 | public RedisMessagePublisher(RedisTemplate redisTemplate, ChannelTopic topic) { 24 | this.redisTemplate = redisTemplate; 25 | this.topic = topic; 26 | } 27 | 28 | @Override 29 | public void publish(String message) { 30 | redisTemplate.convertAndSend(topic.getTopic(), message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-redis-test/src/main/java/com/hks/pubsub/RedisMessageSubscriber.java: -------------------------------------------------------------------------------- 1 | package com.hks.pubsub; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.springframework.data.redis.connection.Message; 8 | import org.springframework.data.redis.connection.MessageListener; 9 | import org.springframework.stereotype.Component; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * Redis Message Subscriber 15 | *

16 | * RedisMessageSubscriber implements the Spring Data Redis-provided MessageListener interface 17 | * 18 | * @author hekuangsheng@gmail.com 19 | * @create 2019-05-01 19:39 20 | **/ 21 | @AllArgsConstructor 22 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 23 | @Data 24 | @Component 25 | public class RedisMessageSubscriber implements MessageListener { 26 | 27 | private List messageList; 28 | 29 | @Override 30 | public void onMessage(Message message, byte[] pattern) { 31 | messageList.add("[pattern:" + new String(pattern) + ",message:" + message.toString() + "]"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-boot-redis-test/src/test/java/com/hks/DemoRedisApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hks; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | import org.springframework.test.context.junit4.SpringRunner; 6 | 7 | @RunWith(SpringRunner.class) 8 | @SpringBootTest 9 | public class DemoRedisApplicationTests { 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-redis/src/main/java/com/hks/redis/config/RedisAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.hks.redis.config; 2 | 3 | import com.hks.redis.utils.CacheUtils; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.Import; 6 | 7 | /** 8 | * 描述: 注册配置类到容器 9 | * 10 | * @author hekuangsheng 11 | * @create 2017-10-16 14:50 12 | **/ 13 | 14 | @Configuration 15 | @Import({RedisConfig.class, CacheUtils.class}) 16 | public class RedisAutoConfiguration { 17 | 18 | } -------------------------------------------------------------------------------- /spring-boot-redis/src/main/java/com/hks/redis/config/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package com.hks.redis.config; 2 | 3 | 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; 9 | import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; 10 | import org.springframework.data.redis.core.RedisTemplate; 11 | import org.springframework.data.redis.serializer.StringRedisSerializer; 12 | 13 | /** 14 | * 描述: 配置 RedisTemplate 实例 15 | * 16 | * @author hekuangsheng 17 | * @create 2017-10-16 12:27 18 | **/ 19 | @Configuration 20 | public class RedisConfig { 21 | 22 | private Logger logger = LoggerFactory.getLogger(RedisConfig.class); 23 | 24 | @Bean 25 | LettuceConnectionFactory jedisConnectionFactory() { 26 | return new LettuceConnectionFactory(); 27 | } 28 | 29 | @Bean 30 | public RedisTemplate redisTemplate() { 31 | RedisTemplate template = new RedisTemplate(); 32 | template.setConnectionFactory(jedisConnectionFactory()); 33 | template.setKeySerializer(new StringRedisSerializer()); 34 | logger.info("create RedisTemplate success"); 35 | return template; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spring-boot-redis/src/main/java/com/hks/redis/controller/RedisController.java: -------------------------------------------------------------------------------- 1 | package com.hks.redis.controller; 2 | 3 | import com.hks.redis.utils.CacheUtils; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.data.redis.core.RedisTemplate; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author heks 14 | * @description: TODO 15 | * @date 2020/7/14 16 | */ 17 | @RestController 18 | @RequestMapping("/redis") 19 | public class RedisController { 20 | @Autowired 21 | RedisTemplate redisTemplate; 22 | 23 | @RequestMapping(value={"set"}, method= RequestMethod.GET) 24 | public String setUserList() { 25 | redisTemplate.opsForValue().set("heks","hh"); 26 | return "OK"; 27 | } 28 | 29 | @RequestMapping(value={"get"}, method= RequestMethod.GET) 30 | public String getUserList() { 31 | String heks = (String) redisTemplate.opsForValue().get("heks"); 32 | return heks; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-redis/src/main/java/com/hks/redis/run/RedisApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.redis.run; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | import java.io.IOException; 8 | import java.net.ServerSocket; 9 | 10 | /** 11 | * 描述: 启动服务 12 | * 13 | * @author hekuangsheng 14 | * @create 2017-10-16 13:19 15 | **/ 16 | @SpringBootApplication 17 | @ComponentScan(value = {"com.hks.redis"}) 18 | public class RedisApplication { 19 | 20 | public static void main(String[] args) throws IOException { 21 | SpringApplication.run(RedisApplication.class, args); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-redis/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spring-boot-redis 2 | server.port=8010 3 | 4 | #redis 5 | # Redis服务器地址 6 | spring.redis.host=127.0.0.1 7 | # Redis服务器连接端口 8 | spring.redis.port=6379 9 | # Redis数据库索引(默认为0) 10 | spring.redis.database=0 11 | # Redis服务器连接密码(默认为空) 12 | spring.redis.password= 13 | # 连接超时时间(毫秒) 14 | spring.redis.timeout=10000 15 | 16 | # 以下连接池已在SpringBoot2.0不推荐使用 17 | #spring.redis.pool.max-active=8 18 | #spring.redis.pool.max-wait=-1 19 | #spring.redis.pool.max-idle=8 20 | #spring.redis.pool.min-idle=0 21 | 22 | # Jedis 23 | #spring.redis.jredis.max-active=8 24 | #spring.redis.jredis.max-wait=10000 25 | #spring.redis.jredis.max-idle=8 26 | #spring.redis.jredis.min-idle=0 27 | 28 | # Lettuce 29 | # 连接池最大连接数(使用负值表示没有限制) 30 | spring.redis.lettuce.pool.max-active=8 31 | # 连接池最大阻塞等待时间(使用负值表示没有限制) 32 | spring.redis.lettuce.pool.max-wait=10000 33 | # 连接池中的最大空闲连接 34 | spring.redis.lettuce.pool.max-idle=8 35 | # 连接池中的最小空闲连接 36 | spring.redis.lettuce.pool.min-idle=0 37 | # 关闭超时时间 38 | spring.redis.lettuce.shutdown-timeout=100 -------------------------------------------------------------------------------- /spring-boot-redis/src/test/java/com/hks/redis/test/BaseTest.java: -------------------------------------------------------------------------------- 1 | package com.hks.redis.test; 2 | 3 | 4 | import com.hks.redis.utils.CacheUtils; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import com.hks.redis.run.RedisApplication; 10 | import org.springframework.data.redis.core.RedisTemplate; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | 13 | /** 14 | * 描述:测试类 15 | * 16 | * @author hekuangsheng 17 | * @create 2017-10-16 13:18 18 | **/ 19 | @RunWith(SpringRunner.class) 20 | @SpringBootTest(classes = RedisApplication.class) 21 | public class BaseTest { 22 | 23 | @Autowired 24 | RedisTemplate redisTemplate; 25 | 26 | @Test 27 | public void test() throws Exception { 28 | 29 | CacheUtils.hashSet("test", "ymq", "www.ymq.io"); 30 | 31 | System.out.println(CacheUtils.hashGet("test", "ymq")); 32 | } 33 | 34 | @Test 35 | public void test2(){ 36 | redisTemplate.opsForValue().set("heks","09012321"); 37 | String result = redisTemplate.opsForValue().get("heks").toString(); 38 | System.out.println(result); 39 | } 40 | 41 | @Test 42 | public void test3(){ 43 | String result = redisTemplate.opsForValue().get("heks1").toString(); 44 | System.out.println(result); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .classpath 3 | .project 4 | .settings 5 | *.log 6 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/README.md: -------------------------------------------------------------------------------- 1 | **项目说明** 2 | - renren-generator是人人开源项目的代码生成器,可在线生成entity、xml、dao、service、html、js、sql代码,减少70%以上的开发任务 3 |
4 | 5 | 6 | **如何交流、反馈、参与贡献?** 7 | - Git仓库:http://git.oschina.net/babaio/renren-generator 8 | - 其他项目:http://www.renren.io/open/ 9 | - [编程入门教程](http://www.renren.io):http://www.renren.io 10 | - 官方QQ群:324780204、145799952 11 | - 如需关注项目最新动态,请Watch、Star项目,同时也是对项目最好的支持 12 |
13 | 14 | 15 | **本地部署** 16 | - 通过git下载源码 17 | - 修改application.yml,更新MySQL账号和密码、数据库名称 18 | - Eclipse、IDEA运行RenrenApplication.java,则可启动项目 19 | - 项目访问路径:http://localhost 20 | 21 | **演示效果图:** 22 | ![输入图片说明](http://cdn.renren.io/img/82b99a1f0f884454ac3fff5e7f658ac8 "在这里输入图片标题") 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/java/com/hks/RenrenApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @MapperScan("com.hks.dao") 9 | public class RenrenApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(RenrenApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/java/com/hks/dao/SysGeneratorDao.java: -------------------------------------------------------------------------------- 1 | package com.hks.dao; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | /** 7 | * 代码生成器 8 | * 9 | * @author hekuangsheng 10 | * @email hekuangsheng@gmail.com 11 | * @date 2016年12月19日 下午3:32:04 12 | */ 13 | public interface SysGeneratorDao { 14 | 15 | List> queryList(Map map); 16 | 17 | int queryTotal(Map map); 18 | 19 | Map queryTable(String tableName); 20 | 21 | List> queryColumns(String tableName); 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/java/com/hks/utils/Constant.java: -------------------------------------------------------------------------------- 1 | package com.hks.utils; 2 | 3 | /** 4 | * 常量 5 | * 6 | * @author hekuangsheng 7 | * @email hekuangsheng@gmail.com 8 | * @date 2016年11月15日 下午1:23:52 9 | */ 10 | public class Constant { 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/java/com/hks/utils/DateUtils.java: -------------------------------------------------------------------------------- 1 | package com.hks.utils; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | /** 7 | * 日期处理 8 | * 9 | * @author hekuangsheng 10 | * @email hekuangsheng@gmail.com 11 | * @date 2016年12月21日 下午12:53:33 12 | */ 13 | public class DateUtils { 14 | /** 时间格式(yyyy-MM-dd) */ 15 | public final static String DATE_PATTERN = "yyyy-MM-dd"; 16 | /** 时间格式(yyyy-MM-dd HH:mm:ss) */ 17 | public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; 18 | 19 | public static String format(Date date) { 20 | return format(date, DATE_PATTERN); 21 | } 22 | 23 | public static String format(Date date, String pattern) { 24 | if(date != null){ 25 | SimpleDateFormat df = new SimpleDateFormat(pattern); 26 | return df.format(date); 27 | } 28 | return null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/java/com/hks/utils/Query.java: -------------------------------------------------------------------------------- 1 | package com.hks.utils; 2 | 3 | 4 | import java.util.LinkedHashMap; 5 | import java.util.Map; 6 | 7 | /** 8 | * 查询参数 9 | * 10 | * @author hekuangsheng 11 | * @email hekuangsheng@gmail.com 12 | * @date 2017-03-14 23:15 13 | */ 14 | public class Query extends LinkedHashMap { 15 | private static final long serialVersionUID = 1L; 16 | //当前页码 17 | private int page; 18 | //每页条数 19 | private int limit; 20 | 21 | public Query(Map params){ 22 | this.putAll(params); 23 | 24 | //分页参数 25 | this.page = Integer.parseInt(params.get("page").toString()); 26 | this.limit = Integer.parseInt(params.get("limit").toString()); 27 | this.put("offset", (page - 1) * limit); 28 | this.put("page", page); 29 | this.put("limit", limit); 30 | } 31 | 32 | 33 | public int getPage() { 34 | return page; 35 | } 36 | 37 | public void setPage(int page) { 38 | this.page = page; 39 | } 40 | 41 | public int getLimit() { 42 | return limit; 43 | } 44 | 45 | public void setLimit(int limit) { 46 | this.limit = limit; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/java/com/hks/utils/R.java: -------------------------------------------------------------------------------- 1 | package com.hks.utils; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * 返回数据 8 | * 9 | * @author hekuangsheng 10 | * @email hekuangsheng@gmail.com 11 | * @date 2016年10月27日 下午9:59:27 12 | */ 13 | public class R extends HashMap { 14 | private static final long serialVersionUID = 1L; 15 | 16 | public R() { 17 | put("code", 0); 18 | } 19 | 20 | public static R error() { 21 | return error(500, "未知异常,请联系管理员"); 22 | } 23 | 24 | public static R error(String msg) { 25 | return error(500, msg); 26 | } 27 | 28 | public static R error(int code, String msg) { 29 | R r = new R(); 30 | r.put("code", code); 31 | r.put("msg", msg); 32 | return r; 33 | } 34 | 35 | public static R ok(String msg) { 36 | R r = new R(); 37 | r.put("msg", msg); 38 | return r; 39 | } 40 | 41 | public static R ok(Map map) { 42 | R r = new R(); 43 | r.putAll(map); 44 | return r; 45 | } 46 | 47 | public static R ok() { 48 | return new R(); 49 | } 50 | 51 | public R put(String key, Object value) { 52 | super.put(key, value); 53 | return this; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/java/com/hks/utils/RRException.java: -------------------------------------------------------------------------------- 1 | package com.hks.utils; 2 | 3 | /** 4 | * 自定义异常 5 | * 6 | * @author hekuangsheng 7 | * @email hekuangsheng@gmail.com 8 | * @date 2016年10月27日 下午10:11:27 9 | */ 10 | public class RRException extends RuntimeException { 11 | private static final long serialVersionUID = 1L; 12 | 13 | private String msg; 14 | private int code = 500; 15 | 16 | public RRException(String msg) { 17 | super(msg); 18 | this.msg = msg; 19 | } 20 | 21 | public RRException(String msg, Throwable e) { 22 | super(msg, e); 23 | this.msg = msg; 24 | } 25 | 26 | public RRException(String msg, int code) { 27 | super(msg); 28 | this.msg = msg; 29 | this.code = code; 30 | } 31 | 32 | public RRException(String msg, int code, Throwable e) { 33 | super(msg, e); 34 | this.msg = msg; 35 | this.code = code; 36 | } 37 | 38 | public String getMsg() { 39 | return msg; 40 | } 41 | 42 | public void setMsg(String msg) { 43 | this.msg = msg; 44 | } 45 | 46 | public int getCode() { 47 | return code; 48 | } 49 | 50 | public void setCode(int code) { 51 | this.code = code; 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # Tomcat 2 | server: 3 | tomcat: 4 | max-threads: 10 5 | min-spare-threads: 10 6 | port: 80 7 | 8 | # mysql 9 | spring: 10 | datasource: 11 | type: com.alibaba.druid.pool.DruidDataSource 12 | driverClassName: com.mysql.cj.jdbc.Driver 13 | url: jdbc:mysql://127.0.0.1:3306/redis_manager?useUnicode=true&characterEncoding=utf-8 14 | username: root 15 | password: root 16 | jackson: 17 | time-zone: GMT+8 18 | date-format: yyyy-MM-dd HH:mm:ss 19 | resources: 20 | static-locations: classpath:/static/,classpath:/views/ 21 | 22 | # Mybatis配置 23 | mybatis: 24 | mapperLocations: classpath:mapper/**/*.xml 25 | 26 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/generator.properties: -------------------------------------------------------------------------------- 1 | #\u4EE3\u7801\u751F\u6210\u5668\uFF0C\u914D\u7F6E\u4FE1\u606F 2 | 3 | mainPath=com.yiche.bdc.polling 4 | #\u5305\u540D 5 | package=com.yiche.bdc.polling 6 | moduleName=query 7 | #\u4F5C\u8005 8 | author=liuming 9 | #Email 10 | email=hekuangsheng@yiche.com 11 | #\u8868\u524D\u7F00(\u7C7B\u540D\u4E0D\u4F1A\u5305\u542B\u8868\u524D\u7F00) 12 | tablePrefix=tb_ 13 | 14 | #\u7C7B\u578B\u8F6C\u6362\uFF0C\u914D\u7F6E\u4FE1\u606F 15 | tinyint=Integer 16 | smallint=Integer 17 | mediumint=Integer 18 | int=Integer 19 | integer=Integer 20 | bigint=Long 21 | float=Float 22 | double=Double 23 | decimal=BigDecimal 24 | bit=Boolean 25 | 26 | char=String 27 | nchar=String 28 | varchar=String 29 | nvarchar=String 30 | tinytext=String 31 | text=String 32 | ntext=String 33 | mediumtext=String 34 | longtext=String 35 | 36 | date=Date 37 | time=Date 38 | datetime=Date 39 | timestamp=Date -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/css/main.css: -------------------------------------------------------------------------------- 1 | html { overflow-x:hidden; } 2 | .content-header { 3 | position: relative; 4 | padding: 0 0 3px 8px 5 | } 6 | 7 | .content-header>.breadcrumb { 8 | position: relative; 9 | top: 0; 10 | right: 0; 11 | float: none; 12 | margin-top: 0px; 13 | padding-left: 10px; 14 | background: #ecf0f5; 15 | } 16 | 17 | .main-footer { 18 | padding: 7px; 19 | color: #444; 20 | border-top: 1px solid #eee; 21 | } 22 | 23 | [v-cloak] { 24 | display: none; 25 | } 26 | 27 | .grid-btn{ 28 | margin-bottom:12px; 29 | } 30 | .grid-btn .btn{ 31 | margin-right:10px; 32 | } 33 | .pointer{cursor: pointer;} 34 | 35 | .ml-10 { margin-left:0 !important; } 36 | @media (min-width: 768px) { 37 | .ml-10 { margin-left:10px !important; } 38 | .col-sm-10 {width: 70%;padding-left: 0px;} 39 | .col-sm-2 {width: 24%;} 40 | } 41 | tbody > tr > th {font-weight: normal; } 42 | .panel .table { margin:0 0; } 43 | .panel .pagination { margin:0; } 44 | .panel-default>.panel-heading {background-color: #f5f5f5;} 45 | .row{ 46 | border-top: 1px solid #ddd; 47 | margin:0; 48 | padding:20px 2px 0px 2px; 49 | } 50 | .col-xs-6{padding-left: 0px;padding-right: 0px;} 51 | .form-horizontal .form-group {margin-left:0px;margin-right:0px;} 52 | .form-horizontal{ 53 | width:550px;padding-top:20px; 54 | } -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/favicon.ico -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/js/index.js: -------------------------------------------------------------------------------- 1 | //iframe自适应 2 | $(window).on('resize', function() { 3 | var $content = $('.content'); 4 | $content.height($(this).height() - 120); 5 | $content.find('iframe').each(function() { 6 | $(this).height($content.height()); 7 | }); 8 | }).resize(); 9 | 10 | 11 | var vm = new Vue({ 12 | el:'#rrapp', 13 | data:{ 14 | main:"main.html", 15 | navTitle:"欢迎页" 16 | }, 17 | methods: { 18 | donate: function () { 19 | layer.open({ 20 | type: 2, 21 | title: false, 22 | area: ['806px', '467px'], 23 | closeBtn: 1, 24 | shadeClose: false, 25 | content: ['http://cdn.renren.io/donate.jpg', 'no'] 26 | }); 27 | } 28 | } 29 | }); 30 | 31 | //路由 32 | var router = new Router(); 33 | var menus = ["main.html","generator.html"]; 34 | routerList(router, menus); 35 | router.start(); 36 | 37 | function routerList(router, menus){ 38 | for(var index in menus){ 39 | router.add('#'+menus[index], function() { 40 | var url = window.location.hash; 41 | 42 | //替换iframe的url 43 | vm.main = url.replace('#', ''); 44 | 45 | //导航菜单展开 46 | $(".treeview-menu li").removeClass("active"); 47 | $("a[href='"+url+"']").parents("li").addClass("active"); 48 | 49 | vm.navTitle = $("a[href='"+url+"']").text(); 50 | }); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/plugins/jqgrid/ui.jqgrid-bootstrap-ui.css: -------------------------------------------------------------------------------- 1 | /* 2 | To change this license header, choose License Headers in Project Properties. 3 | To change this template file, choose Tools | Templates 4 | and open the template in the editor. 5 | */ 6 | /* 7 | Created on : Mar 16, 2015, 10:24:01 AM 8 | Author : tony 9 | */ 10 | 11 | .ui-jqgrid tr.jqgrow td { height: 26px;} 12 | .ui-jqgrid .ui-pg-input,.ui-jqgrid .ui-jqgrid-toppager .ui-pg-input { height:20px } 13 | .ui-state-hover 14 | { 15 | border: .15em solid; 16 | border-color: inherit; 17 | 18 | } 19 | .ui-jqdialog .ui-jqdialog-titlebar { 20 | height:29px; 21 | border-color: inherit; 22 | } 23 | 24 | .ui-jqdialog-content input.FormElement { 25 | padding: 0.25em; 26 | } 27 | 28 | .fm-button { 29 | height:30px; 30 | } 31 | #nData, #pData { height:20px; width:18px; } -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/plugins/layer/skin/default/icon-ext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/plugins/layer/skin/default/icon-ext.png -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/plugins/layer/skin/default/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/plugins/layer/skin/default/icon.png -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/plugins/layer/skin/default/loading-0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/plugins/layer/skin/default/loading-0.gif -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/plugins/layer/skin/default/loading-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/plugins/layer/skin/default/loading-1.gif -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/plugins/layer/skin/default/loading-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/plugins/layer/skin/default/loading-2.gif -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/static/plugins/layer/skin/moon/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-renren-generator/src/main/resources/static/plugins/layer/skin/moon/default.png -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/template/Dao.java.vm: -------------------------------------------------------------------------------- 1 | package ${package}.${moduleName}.dao; 2 | 3 | import ${package}.${moduleName}.entity.${className}Entity; 4 | import ${mainPath}.modules.sys.dao.BaseDao; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * ${comments} 9 | * 10 | * @author ${author} 11 | * @email ${email} 12 | * @date ${datetime} 13 | */ 14 | @Mapper 15 | public interface ${className}Dao extends BaseDao<${className}Entity> { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/template/Entity.java.vm: -------------------------------------------------------------------------------- 1 | package ${package}.${moduleName}.entity; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | #if(${hasBigDecimal}) 6 | import java.math.BigDecimal; 7 | #end 8 | 9 | 10 | /** 11 | * ${comments} 12 | * 13 | * @author ${author} 14 | * @email ${email} 15 | * @date ${datetime} 16 | */ 17 | public class ${className}Entity implements Serializable { 18 | private static final long serialVersionUID = 1L; 19 | 20 | #foreach ($column in $columns) 21 | //$column.comments 22 | private $column.attrType $column.attrname; 23 | #end 24 | 25 | #foreach ($column in $columns) 26 | /** 27 | * 设置:${column.comments} 28 | */ 29 | public void set${column.attrName}($column.attrType $column.attrname) { 30 | this.$column.attrname = $column.attrname; 31 | } 32 | /** 33 | * 获取:${column.comments} 34 | */ 35 | public $column.attrType get${column.attrName}() { 36 | return $column.attrname; 37 | } 38 | #end 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/template/Service.java.vm: -------------------------------------------------------------------------------- 1 | package ${package}.${moduleName}.service; 2 | 3 | import ${package}.${moduleName}.entity.${className}Entity; 4 | 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | /** 9 | * ${comments} 10 | * 11 | * @author ${author} 12 | * @email ${email} 13 | * @date ${datetime} 14 | */ 15 | public interface ${className}Service { 16 | 17 | ${className}Entity queryObject(${pk.attrType} ${pk.attrname}); 18 | 19 | List<${className}Entity> queryList(Map map); 20 | 21 | int queryTotal(Map map); 22 | 23 | void save(${className}Entity ${classname}); 24 | 25 | void update(${className}Entity ${classname}); 26 | 27 | void delete(${pk.attrType} ${pk.attrname}); 28 | 29 | void deleteBatch(${pk.attrType}[] ${pk.attrname}s); 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/template/menu.sql.vm: -------------------------------------------------------------------------------- 1 | -- 菜单SQL 2 | INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) 3 | VALUES ('1', '${comments}', 'modules/${moduleName}/${pathName}.html', NULL, '1', 'fa fa-file-code-o', '6'); 4 | 5 | -- 按钮父菜单ID 6 | set @parentId = @@identity; 7 | 8 | -- 菜单对应按钮SQL 9 | INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) 10 | SELECT @parentId, '查看', null, '${moduleName}:${pathName}:list,${moduleName}:${pathName}:info', '2', null, '6'; 11 | INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) 12 | SELECT @parentId, '新增', null, '${moduleName}:${pathName}:save', '2', null, '6'; 13 | INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) 14 | SELECT @parentId, '修改', null, '${moduleName}:${pathName}:update', '2', null, '6'; 15 | INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) 16 | SELECT @parentId, '删除', null, '${moduleName}:${pathName}:delete', '2', null, '6'; 17 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/views/generator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 代码生成器 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |

22 |
23 |
24 | 25 |
26 | 查询 27 |  生成代码 28 |
29 |
30 |
31 |
32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/main/resources/views/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 欢迎页 7 | 8 | 9 | 10 | 11 |
12 |
基本信息
13 |
14 |

   获取帮助

15 | 20 | 21 |

   官方QQ群

22 |
    23 |
  • 高级群:324780204(大牛云集,跟大牛学习新技能)
  • 24 |
  • 普通群:145799952(学习交流,互相解答各种疑问)
  • 25 |
26 |
27 |
28 | 29 | -------------------------------------------------------------------------------- /spring-boot-renren-generator/src/test/java/com/hks/RenrenApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hks; 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 RenrenApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-rocketmq/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /spring-boot-rocketmq/src/main/java/com/hks/example/rocketmq/SpringBootRocketmqApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.example.rocketmq; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootRocketmqApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootRocketmqApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-rocketmq/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | # 消费者的组名 3 | apache.rocketmq.consumer.PushConsumer=PushConsumer 4 | 5 | # 生产者的组名 6 | apache.rocketmq.producer.producerGroup=Producer 7 | 8 | # NameServer地址 9 | apache.rocketmq.namesrvAddr=127.0.0.1:9876 -------------------------------------------------------------------------------- /spring-boot-rocketmq/src/test/java/com/hks/example/rocketmq/SpringBootRocketmqApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hks.example.rocketmq; 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 SpringBootRocketmqApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-rocketmq/src/test/java/com/hks/example/rocketmq/test.java: -------------------------------------------------------------------------------- 1 | package com.hks.example.rocketmq; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | /** 8 | * 描述: 9 | * 10 | * @author hekuangsheng 11 | * @create 2018-02-02 16:50 12 | **/ 13 | public class test { 14 | 15 | public static void main(String[] args) { 16 | 17 | List names = Arrays.asList("1", "3", "2", "4"); 18 | 19 | Collections.sort(names,(a,b) -> b.compareTo(a)); 20 | 21 | System.out.println(names); 22 | 23 | 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-shutdown/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot-shutdown/src/main/java/com/heks/shutdown/ShutdownApplication.java: -------------------------------------------------------------------------------- 1 | package com.heks.shutdown; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ShutdownApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ShutdownApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-shutdown/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-shutdown/src/test/java/com/heks/shutdown/ShutdownApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.heks.shutdown; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ShutdownApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-solr-cloud/src/main/java/com/hks/solr/YmqRepository.java: -------------------------------------------------------------------------------- 1 | package com.hks.solr; 2 | 3 | import com.hks.solr.po.Ymq; 4 | import org.springframework.data.solr.repository.SolrCrudRepository; 5 | 6 | import org.springframework.data.solr.repository.Query; 7 | 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 描述: 继承 SolrCrudRepository 13 | * 14 | * @author hekuangsheng 15 | * @create 2017-10-18 10:34 16 | **/ 17 | public interface YmqRepository extends SolrCrudRepository { 18 | 19 | /** 20 | * 通过标题查询 21 | * 22 | * @param ymqTitle 23 | * @return 24 | */ 25 | @Query(" ymqTitle:*?0* ") 26 | public List findByQueryAnnotation(String ymqTitle); 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-solr-cloud/src/main/java/com/hks/solr/config/SolrConfig.java: -------------------------------------------------------------------------------- 1 | package com.hks.solr.config; 2 | 3 | import org.apache.solr.client.solrj.impl.CloudSolrClient; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.data.solr.repository.config.EnableSolrRepositories; 8 | 9 | /** 10 | * 描述: 开启 CloudSolrClient 连接 11 | * 12 | * @author hekuangsheng 13 | * @create 2017-10-18 18:15 14 | **/ 15 | @Configuration 16 | @EnableSolrRepositories(basePackages = {"com.hks.solr"}, multicoreSupport = true) 17 | public class SolrConfig { 18 | 19 | @Value("${spring.data.solr.zk-host}") 20 | private String zkHost; 21 | 22 | @Bean 23 | public CloudSolrClient solrClient() { 24 | return new CloudSolrClient(zkHost); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-solr-cloud/src/main/java/com/hks/solr/pagehelper/ISelect.java: -------------------------------------------------------------------------------- 1 | package com.hks.solr.pagehelper; 2 | 3 | /** 4 | * 分页查询接口 5 | * 6 | * @author hekuangsheng 7 | * @since 2015-12-18 18:51 8 | */ 9 | public interface ISelect { 10 | 11 | /** 12 | * 在接口中调用自己的查询方法,不要在该方法内写过多代码,只要一行查询方法最好 13 | */ 14 | void doSelect(); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-solr-cloud/src/main/java/com/hks/solr/pagehelper/PageInfoFacet.java: -------------------------------------------------------------------------------- 1 | package com.hks.solr.pagehelper; 2 | 3 | import org.apache.solr.client.solrj.response.FacetField; 4 | 5 | import java.util.List; 6 | 7 | public class PageInfoFacet { 8 | private PageInfo pageInfo; 9 | 10 | private List facetFieldList; 11 | 12 | public PageInfo getPageInfo() { 13 | return pageInfo; 14 | } 15 | 16 | public void setPageInfo(PageInfo pageInfo) { 17 | this.pageInfo = pageInfo; 18 | } 19 | 20 | public List getFacetFieldList() { 21 | return facetFieldList; 22 | } 23 | 24 | public void setFacetFieldList(List facetFieldList) { 25 | this.facetFieldList = facetFieldList; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-solr-cloud/src/main/java/com/hks/solr/pagehelper/RowBounds.java: -------------------------------------------------------------------------------- 1 | 2 | package com.hks.solr.pagehelper; 3 | 4 | /** 5 | * @author hekuangsheng 6 | */ 7 | public class RowBounds { 8 | 9 | public static final int NO_ROW_OFFSET = 0; 10 | public static final int NO_ROW_LIMIT = Integer.MAX_VALUE; 11 | public static final RowBounds DEFAULT = new RowBounds(); 12 | 13 | private final int offset; 14 | private final int limit; 15 | 16 | public RowBounds() { 17 | this.offset = NO_ROW_OFFSET; 18 | this.limit = NO_ROW_LIMIT; 19 | } 20 | 21 | public RowBounds(int offset, int limit) { 22 | this.offset = offset; 23 | this.limit = limit; 24 | } 25 | 26 | public int getOffset() { 27 | return offset; 28 | } 29 | 30 | public int getLimit() { 31 | return limit; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-solr-cloud/src/main/java/com/hks/solr/po/Ymq.java: -------------------------------------------------------------------------------- 1 | package com.hks.solr.po; 2 | 3 | 4 | import org.apache.solr.client.solrj.beans.Field; 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.solr.core.mapping.SolrDocument; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 描述: 映射的实体类必须有@ID主键 12 | * 13 | * @author hekuangsheng 14 | * @create 2017-10-17 18:28 15 | **/ 16 | @SolrDocument(solrCoreName = "test_collection") 17 | public class Ymq implements Serializable { 18 | 19 | @Id 20 | @Field 21 | private String id; 22 | 23 | @Field 24 | private String ymqTitle; 25 | 26 | @Field 27 | private String ymqUrl; 28 | 29 | @Field 30 | private String ymqContent; 31 | 32 | 33 | public String getId() { 34 | return id; 35 | } 36 | 37 | public void setId(String id) { 38 | this.id = id; 39 | } 40 | 41 | public String getYmqTitle() { 42 | return ymqTitle; 43 | } 44 | 45 | public void setYmqTitle(String ymqTitle) { 46 | this.ymqTitle = ymqTitle; 47 | } 48 | 49 | public String getYmqUrl() { 50 | return ymqUrl; 51 | } 52 | 53 | public void setYmqUrl(String ymqUrl) { 54 | this.ymqUrl = ymqUrl; 55 | } 56 | 57 | public String getYmqContent() { 58 | return ymqContent; 59 | } 60 | 61 | public void setYmqContent(String ymqContent) { 62 | this.ymqContent = ymqContent; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /spring-boot-solr-cloud/src/main/java/com/hks/solr/run/SolrApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.solr.run; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | /** 8 | * 描述: 启动服务 9 | * 10 | * @author hekuangsheng 11 | * @create 2017-10-18 10:38 12 | **/ 13 | @SpringBootApplication 14 | @ComponentScan(value = {"com.hks.solr"}) 15 | public class SolrApplication { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(SolrApplication.class, args); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-solr-cloud/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spring-boot-solr-cloud 2 | server.port=8089 3 | 4 | #SolrCloud zookeeper 5 | spring.data.solr.zk-host=127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183 -------------------------------------------------------------------------------- /spring-boot-spark/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /nbbuild/ 22 | /dist/ 23 | /nbdist/ 24 | /.nb-gradle/ 25 | /build/ 26 | -------------------------------------------------------------------------------- /spring-boot-spark/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.3.RELEASE 9 | 10 | 11 | com.hks 12 | spring-boot-spark 13 | 0.0.1-SNAPSHOT 14 | spring-boot-spark 15 | spring-boot-spark project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-test 30 | test 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-maven-plugin 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /spring-boot-spark/src/main/java/com/hks/spark/SparkApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.spark; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SparkApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SparkApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-spark/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-spark/src/test/java/com/hks/spark/SparkApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hks.spark; 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 SparkApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-starter-simple-use/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | -------------------------------------------------------------------------------- /spring-boot-starter-simple-use/src/main/java/com/example/use/UseApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.use; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class UseApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(UseApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-starter-simple-use/src/main/java/com/example/use/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.example.use.controller; 2 | 3 | import com.hks.service.ExampleService; 4 | import org.springframework.beans.factory.annotation.Autowire; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestMethod; 9 | import org.springframework.web.bind.annotation.ResponseBody; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | @RestController 13 | public class HelloController { 14 | 15 | @Autowired 16 | private ExampleService exampleService; 17 | 18 | @RequestMapping(value = "/hello", method = RequestMethod.GET) 19 | @ResponseBody 20 | public String testStarter() { 21 | return exampleService.wrap("hello"); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-starter-simple-use/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | example.service: 2 | enabled: true 3 | prefix: ppp 4 | suffix: sss 5 | -------------------------------------------------------------------------------- /spring-boot-starter-simple-use/src/test/java/com/example/use/UseApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.use; 2 | 3 | import com.hks.service.ExampleService; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | @RunWith(SpringRunner.class) 11 | @SpringBootTest 12 | public class UseApplicationTests { 13 | 14 | @Test 15 | public void contextLoads() { 16 | } 17 | 18 | @Autowired 19 | private ExampleService exampleService; 20 | 21 | @Test 22 | public void testStarter() { 23 | System.out.println(exampleService.wrap("hello")); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-starter-simple/src/main/java/com/hks/config/ExampleAutoConfigure.java: -------------------------------------------------------------------------------- 1 | package com.hks.config; 2 | 3 | import com.hks.service.ExampleService; 4 | import com.hks.service.ExampleServiceProperties; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 8 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 9 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | 13 | @Configuration 14 | @ConditionalOnClass(ExampleService.class) 15 | @EnableConfigurationProperties(ExampleServiceProperties.class) 16 | public class ExampleAutoConfigure { 17 | 18 | private final ExampleServiceProperties properties; 19 | 20 | @Autowired 21 | public ExampleAutoConfigure(ExampleServiceProperties properties) { 22 | this.properties = properties; 23 | } 24 | 25 | @Bean 26 | @ConditionalOnMissingBean 27 | @ConditionalOnProperty(prefix = "example.service", value = "enabled",havingValue = "true") 28 | ExampleService exampleService (){ 29 | return new ExampleService(properties.getPrefix(),properties.getSuffix()); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-starter-simple/src/main/java/com/hks/service/ExampleService.java: -------------------------------------------------------------------------------- 1 | package com.hks.service; 2 | 3 | public class ExampleService { 4 | 5 | private String prefix; 6 | private String suffix; 7 | 8 | public ExampleService(String prefix, String suffix) { 9 | this.prefix = prefix; 10 | this.suffix = suffix; 11 | } 12 | public String wrap(String word) { 13 | return prefix + word + suffix; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-starter-simple/src/main/java/com/hks/service/ExampleServiceProperties.java: -------------------------------------------------------------------------------- 1 | package com.hks.service; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | @ConfigurationProperties("example.service") 6 | public class ExampleServiceProperties { 7 | private String prefix; 8 | private String suffix; 9 | 10 | public String getPrefix() { 11 | return prefix; 12 | } 13 | 14 | public void setPrefix(String prefix) { 15 | this.prefix = prefix; 16 | } 17 | 18 | public String getSuffix() { 19 | return suffix; 20 | } 21 | 22 | public void setSuffix(String suffix) { 23 | this.suffix = suffix; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-starter-simple/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | com.hks.config.ExampleAutoConfigure -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/java/com/hks/swagger/model/User.java: -------------------------------------------------------------------------------- 1 | package com.hks.swagger.model; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | /** 7 | * 描述: 8 | * 9 | * @author: hekuangsheng 10 | * @create: 2017/10/26 16:19 11 | */ 12 | @ApiModel(value = "User", description = "请求入参 User") 13 | public class User { 14 | 15 | @ApiModelProperty(value = "id") 16 | private Long id; 17 | 18 | @ApiModelProperty(value = "姓名") 19 | private String name; 20 | 21 | @ApiModelProperty(value = "年龄") 22 | private Integer age; 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public void setId(Long id) { 29 | this.id = id; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public void setName(String name) { 37 | this.name = name; 38 | } 39 | 40 | public Integer getAge() { 41 | return age; 42 | } 43 | 44 | public void setAge(Integer age) { 45 | this.age = age; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/java/com/hks/swagger/run/SwaggerApplication.java: -------------------------------------------------------------------------------- 1 | package com.hks.swagger.run; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | /** 8 | * 描述:启动服务 9 | * 10 | * @author hekuangsheng 11 | * @create 2017-10-26 16:37 12 | **/ 13 | @SpringBootApplication 14 | @ComponentScan(value = {"com.hks.swagger"}) 15 | public class SwaggerApplication { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(SwaggerApplication.class, args); 19 | 20 | /** 21 | * 22 | * 中文 http://127.0.0.1:8080/swagger/index.html 23 | * 24 | * 默认 http://127.0.0.1:8080/swagger-ui.html 25 | * 26 | * 在浏览器:http://127.0.0.1:8080/v2/api-docs 生成 swagger.yaml 文件内容 27 | * 28 | */ 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spring-boot-swagger 2 | server.port=8040 3 | -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/css/reset.css: -------------------------------------------------------------------------------- 1 | a,abbr,acronym,address,applet,article,aside,audio,b,big,blockquote,body,canvas,caption,center,cite,code,dd,del,details,dfn,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,html,i,iframe,img,ins,kbd,label,legend,li,mark,menu,nav,object,ol,output,p,pre,q,ruby,s,samp,section,small,span,strike,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,tt,u,ul,var,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:'';content:none}table{border-collapse:collapse;border-spacing:0} -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/css/typography.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-swagger/src/main/resources/static/swagger/css/typography.css -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/fonts/DroidSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-swagger/src/main/resources/static/swagger/fonts/DroidSans-Bold.ttf -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/fonts/DroidSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-swagger/src/main/resources/static/swagger/fonts/DroidSans.ttf -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/images/collapse.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-swagger/src/main/resources/static/swagger/images/collapse.gif -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/images/expand.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-swagger/src/main/resources/static/swagger/images/expand.gif -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/images/explorer_icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-swagger/src/main/resources/static/swagger/images/explorer_icons.png -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/images/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-swagger/src/main/resources/static/swagger/images/favicon-16x16.png -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/images/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-swagger/src/main/resources/static/swagger/images/favicon-32x32.png -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-swagger/src/main/resources/static/swagger/images/favicon.ico -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-swagger/src/main/resources/static/swagger/images/logo.png -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/images/logo_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-swagger/src/main/resources/static/swagger/images/logo_small.png -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/images/pet_store_api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-swagger/src/main/resources/static/swagger/images/pet_store_api.png -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/images/throbber.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-swagger/src/main/resources/static/swagger/images/throbber.gif -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/images/wordnik_api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singgel/SpringBoot-Templates/42712588db110720dcc43c58dcfc406c39d86bcb/spring-boot-swagger/src/main/resources/static/swagger/images/wordnik_api.png -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/lib/highlight.9.1.0.pack_extended.js: -------------------------------------------------------------------------------- 1 | "use strict";!function(){var h,l;h=hljs.configure,hljs.configure=function(l){var i=l.highlightSizeThreshold;hljs.highlightSizeThreshold=i===+i?i:null,h.call(this,l)},l=hljs.highlightBlock,hljs.highlightBlock=function(h){var i=h.innerHTML,g=hljs.highlightSizeThreshold;(null==g||g>i.length)&&l.call(hljs,h)}}(); -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/lib/jquery.slideto.min.js: -------------------------------------------------------------------------------- 1 | !function(i){i.fn.slideto=function(o){return o=i.extend({slide_duration:"slow",highlight_duration:3e3,highlight:!0,highlight_color:"#FFFF99"},o),this.each(function(){obj=i(this),i("body").animate({scrollTop:obj.offset().top},o.slide_duration,function(){o.highlight&&i.ui.version&&obj.effect("highlight",{color:o.highlight_color},o.highlight_duration)})})}}(jQuery); -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/lib/jquery.wiggle.min.js: -------------------------------------------------------------------------------- 1 | jQuery.fn.wiggle=function(e){var a={speed:50,wiggles:3,travel:5,callback:null},e=jQuery.extend(a,e);return this.each(function(){var a=this,l=(jQuery(this).wrap('
').css("position","relative"),0);for(i=1;i<=e.wiggles;i++)jQuery(this).animate({left:"-="+e.travel},e.speed).animate({left:"+="+2*e.travel},2*e.speed).animate({left:"-="+e.travel},e.speed,function(){l++,jQuery(a).parent().hasClass("wiggle-wrap")&&jQuery(a).parent().replaceWith(a),l==e.wiggles&&jQuery.isFunction(e.callback)&&e.callback()})})}; -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/static/swagger/lib/object-assign-pollyfill.js: -------------------------------------------------------------------------------- 1 | "function"!=typeof Object.assign&&!function(){Object.assign=function(n){"use strict";if(void 0===n||null===n)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(n),o=1;o 2 | var qp = null; 3 | if(/code|token|error/.test(window.location.hash)) { 4 | qp = location.hash.substring(1); 5 | } 6 | else { 7 | qp = location.search.substring(1); 8 | } 9 | qp = qp ? JSON.parse('{"' + qp.replace(/&/g, '","').replace(/=/g,'":"') + '"}', 10 | function(key, value) { 11 | return key===""?value:decodeURIComponent(value) } 12 | ):{} 13 | 14 | if (window.opener.swaggerUiAuth.tokenUrl) 15 | window.opener.processOAuthCode(qp); 16 | else 17 | window.opener.onOAuthComplete(qp); 18 | 19 | window.close(); 20 | 21 | -------------------------------------------------------------------------------- /spring-boot-zookeeper/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /spring-boot-zookeeper/src/main/java/com/heks/demo/ZookeeperApplication.java: -------------------------------------------------------------------------------- 1 | package com.heks.demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ZookeeperApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ZookeeperApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-zookeeper/src/main/java/com/heks/demo/config/ZkConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.heks.demo.config; 2 | 3 | import com.heks.demo.model.ZkClient; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | public class ZkConfiguration { 10 | 11 | @Value("${zookeeper.server}") 12 | private String zookeeperServer; 13 | @Value(("${zookeeper.sessionTimeoutMs}")) 14 | private int sessionTimeoutMs; 15 | @Value("${zookeeper.connectionTimeoutMs}") 16 | private int connectionTimeoutMs; 17 | @Value("${zookeeper.maxRetries}") 18 | private int maxRetries; 19 | @Value("${zookeeper.baseSleepTimeMs}") 20 | private int baseSleepTimeMs; 21 | 22 | @Bean(initMethod = "init", destroyMethod = "stop") 23 | public ZkClient zkClient() { 24 | ZkClient zkClient = new ZkClient(); 25 | zkClient.setZookeeperServer(zookeeperServer); 26 | zkClient.setSessionTimeoutMs(sessionTimeoutMs); 27 | zkClient.setConnectionTimeoutMs(connectionTimeoutMs); 28 | zkClient.setMaxRetries(maxRetries); 29 | zkClient.setBaseSleepTimeMs(baseSleepTimeMs); 30 | return zkClient; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /spring-boot-zookeeper/src/main/java/com/heks/demo/controller/ZkController.java: -------------------------------------------------------------------------------- 1 | package com.heks.demo.controller; 2 | 3 | import com.heks.demo.model.ZkClient; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | import javax.annotation.Resource; 8 | 9 | @RestController 10 | public class ZkController { 11 | 12 | @Resource 13 | ZkClient zkClient; 14 | 15 | /** 16 | * 17 | * @param path /aa/bb 18 | * @return 19 | */ 20 | @RequestMapping(value = "addNode") 21 | public String insertZkNode(String path){ 22 | try{ 23 | zkClient.register(path ); 24 | } catch (Exception ex){ 25 | return ex.getMessage(); 26 | } 27 | return "SUCCESS"; 28 | } 29 | 30 | /** 31 | * 32 | * @param path /aa 33 | * @return 34 | */ 35 | @RequestMapping(value = "searchNode") 36 | public String searchNode(String path){ 37 | return zkClient.getChildren(path).toString(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-boot-zookeeper/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | 2 | zookeeper: 3 | server: sep.zookeeper.inter.xueqiu.com:2181 4 | sessionTimeoutMs: 6000 5 | connectionTimeoutMs: 6000 6 | maxRetries: 3 7 | baseSleepTimeMs: 1000 -------------------------------------------------------------------------------- /spring-boot-zookeeper/src/test/java/com/heks/demo/ZookeeperApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.heks.demo; 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 ZookeeperApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | --------------------------------------------------------------------------------