├── springboot-action-cache ├── .gitignore ├── README.md ├── .settings │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── lianggzone │ │ │ └── springboot │ │ │ └── cache │ │ │ ├── config │ │ │ └── CacheConfiguration.java │ │ │ ├── main │ │ │ └── WebMain.java │ │ │ ├── guava │ │ │ ├── GuavaCacheConfig.java │ │ │ ├── CacheService.java │ │ │ └── CacheController.java │ │ │ ├── ehcache │ │ │ ├── CacheService.java │ │ │ └── CacheController.java │ │ │ ├── redis │ │ │ ├── CacheService.java │ │ │ └── CacheController.java │ │ │ └── concurrenmapcache │ │ │ ├── CacheService.java │ │ │ └── CacheController.java │ │ └── resources │ │ ├── ehcache.xml │ │ └── application.properties ├── .project ├── .classpath └── pom.xml ├── springboot-action-sample ├── .gitignore ├── src │ ├── main │ │ ├── filters │ │ │ ├── filter-product.properties │ │ │ ├── filter-test.properties │ │ │ ├── filter-development.properties │ │ │ ├── filter-preproduction.properties │ │ │ └── resources │ │ │ │ ├── product │ │ │ │ └── application.properties │ │ │ │ ├── test │ │ │ │ └── application.properties │ │ │ │ ├── preproduction │ │ │ │ └── application.properties │ │ │ │ └── development │ │ │ │ ├── application.yml │ │ │ │ └── application.properties │ │ ├── resources │ │ │ ├── application-test.properties │ │ │ ├── application-product.properties │ │ │ ├── application-development.properties │ │ │ ├── application-preproduction.properties │ │ │ ├── config │ │ │ │ ├── redis.properties │ │ │ │ └── source.properties │ │ │ ├── templates │ │ │ │ └── welcome.ftl │ │ │ ├── init │ │ │ │ ├── springboot-db-20161213.sql │ │ │ │ ├── springboot_db1-2016-12-19.sql │ │ │ │ └── springboot_db2-2016-12-19.sql │ │ │ └── mybatis │ │ │ │ └── AuthorMapper.xml │ │ ├── webapp │ │ │ ├── index.jsp │ │ │ └── WEB-INF │ │ │ │ └── web.xml │ │ └── java │ │ │ └── com │ │ │ └── lianggzone │ │ │ └── springboot │ │ │ ├── action │ │ │ ├── core │ │ │ │ ├── mail │ │ │ │ │ └── package-info.java │ │ │ │ └── async │ │ │ │ │ ├── config │ │ │ │ │ └── AsyncConfig.java │ │ │ │ │ ├── MsgServer.java │ │ │ │ │ └── MsgFutureServer.java │ │ │ ├── data │ │ │ │ ├── config │ │ │ │ │ ├── ElasticSearchConfig.java │ │ │ │ │ ├── JPAConfig.java │ │ │ │ │ ├── ElasticsearchConfig2.java │ │ │ │ │ ├── BeanConfig.java │ │ │ │ │ ├── BeanConfig2.java │ │ │ │ │ ├── MongoConfig.java │ │ │ │ │ └── RedisConfig.java │ │ │ │ ├── redis │ │ │ │ │ ├── model │ │ │ │ │ │ └── package-info.java │ │ │ │ │ └── dao │ │ │ │ │ │ ├── ValueRedisDao.java │ │ │ │ │ │ └── RedisBaseDao.java │ │ │ │ ├── jpa │ │ │ │ │ ├── repository │ │ │ │ │ │ ├── AuthorDao.java │ │ │ │ │ │ ├── AuthorRepository.java │ │ │ │ │ │ └── AuthorDaoImpl.java │ │ │ │ │ ├── service │ │ │ │ │ │ ├── AuthorService2.java │ │ │ │ │ │ └── AuthorService.java │ │ │ │ │ ├── entity │ │ │ │ │ │ └── Author.java │ │ │ │ │ └── controller │ │ │ │ │ │ ├── AuthorController.java │ │ │ │ │ │ └── AuthorController2.java │ │ │ │ ├── mybatis │ │ │ │ │ ├── dao │ │ │ │ │ │ ├── AuthorMapper2.java │ │ │ │ │ │ └── AuthorMapper.java │ │ │ │ │ ├── service │ │ │ │ │ │ ├── AuthorService2.java │ │ │ │ │ │ └── AuthorService.java │ │ │ │ │ ├── entity │ │ │ │ │ │ └── Author.java │ │ │ │ │ └── controller │ │ │ │ │ │ ├── AuthorController2.java │ │ │ │ │ │ └── AuthorController.java │ │ │ │ ├── jdbc │ │ │ │ │ ├── dao │ │ │ │ │ │ ├── AuthorDao.java │ │ │ │ │ │ └── impl │ │ │ │ │ │ │ └── AuthorDaoImpl.java │ │ │ │ │ ├── service │ │ │ │ │ │ ├── AuthorService.java │ │ │ │ │ │ └── impl │ │ │ │ │ │ │ └── AuthorServiceImpl.java │ │ │ │ │ ├── entity │ │ │ │ │ │ └── Author.java │ │ │ │ │ └── controller │ │ │ │ │ │ └── AuthorController.java │ │ │ │ ├── elasticsearch │ │ │ │ │ ├── dao │ │ │ │ │ │ └── NewsRepository.java │ │ │ │ │ ├── service │ │ │ │ │ │ └── NewsService.java │ │ │ │ │ ├── entity │ │ │ │ │ │ └── News.java │ │ │ │ │ └── controller │ │ │ │ │ │ └── NewsController.java │ │ │ │ ├── transactional │ │ │ │ │ ├── dao │ │ │ │ │ │ └── AuthorDao.java │ │ │ │ │ ├── entity │ │ │ │ │ │ └── Author.java │ │ │ │ │ └── service │ │ │ │ │ │ └── AuthorService.java │ │ │ │ └── mongodb │ │ │ │ │ ├── entity │ │ │ │ │ └── Author.java │ │ │ │ │ ├── service │ │ │ │ │ └── AuthorService.java │ │ │ │ │ ├── dao │ │ │ │ │ └── AuthorDao.java │ │ │ │ │ └── controller │ │ │ │ │ └── AuthorController.java │ │ │ └── template │ │ │ │ └── freemarker │ │ │ │ └── controller │ │ │ │ ├── WelcomeController.java │ │ │ │ └── Welcome2Controller.java │ │ │ ├── demo │ │ │ ├── ApplicationDemo.java │ │ │ └── RestfulApiWebDemo.java │ │ │ ├── custom │ │ │ └── AuthorAutoConfigDemo.java │ │ │ └── main │ │ │ └── WebMain.java │ └── test │ │ └── java │ │ └── com │ │ └── lianggzone │ │ └── springboot │ │ ├── core │ │ └── async │ │ │ ├── AsyncTest.java │ │ │ └── AsyncFutureTest.java │ │ ├── data │ │ ├── redis │ │ │ └── RedisTest.java │ │ ├── jdbc │ │ │ └── JdbcTest.java │ │ └── transactional │ │ │ └── TransactionalTest.java │ │ └── demo │ │ └── PropertiesTest.java ├── .settings │ ├── org.eclipse.wst.jsdt.ui.superType.name │ ├── org.eclipse.wst.validation.prefs │ ├── org.eclipse.wst.jsdt.ui.superType.container │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.jdt.ui.prefs │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.wst.common.project.facet.core.xml │ ├── .jsdtscope │ └── org.eclipse.wst.common.component ├── README.md ├── .classpath └── .project ├── springboot-action-web ├── .gitignore ├── src │ └── main │ │ ├── filters │ │ ├── filter-test.properties │ │ ├── filter-development.properties │ │ ├── filter-product.properties │ │ ├── filter-preproduction.properties │ │ └── resources │ │ │ ├── test │ │ │ └── application.properties │ │ │ ├── product │ │ │ └── application.properties │ │ │ ├── preproduction │ │ │ └── application.properties │ │ │ └── development │ │ │ └── application.properties │ │ ├── webapp │ │ ├── index.jsp │ │ └── WEB-INF │ │ │ └── web.xml │ │ └── java │ │ └── com │ │ └── lianggzone │ │ └── springboot │ │ └── web │ │ └── tomcat │ │ ├── ServletInitializer.java │ │ ├── TomcatConfig.java │ │ └── RestfulApiWebController.java ├── .settings │ ├── org.eclipse.wst.jsdt.ui.superType.name │ ├── org.eclipse.wst.validation.prefs │ ├── org.eclipse.wst.jsdt.ui.superType.container │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.wst.common.project.facet.core.xml │ ├── org.eclipse.jdt.core.prefs │ ├── .jsdtscope │ └── org.eclipse.wst.common.component ├── README.md ├── .classpath ├── .project └── pom.xml ├── springboot-action-actuator ├── .gitignore ├── README.md ├── src │ └── main │ │ ├── resources │ │ ├── application.yml │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── lianggzone │ │ └── springboot │ │ └── actuator │ │ ├── endpoint │ │ ├── EndpointConfig.java │ │ └── ServerTimeEndpoint.java │ │ ├── main │ │ └── RestfulApiWebDemo.java │ │ └── health │ │ ├── CusStatusHealthIndicator.java │ │ └── CusDiskSpaceHealthIndicator.java ├── .settings │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── .project ├── .classpath └── pom.xml ├── springboot-action-autoconfig ├── .gitignore ├── README.md ├── .settings │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── spring.factories │ │ └── java │ │ └── com │ │ └── lianggzone │ │ └── springboot │ │ └── autoconfig │ │ └── author │ │ ├── AuthorServer.java │ │ ├── AuthorProperties.java │ │ └── AuthorAutoConfiguration.java ├── .project ├── .classpath └── pom.xml ├── springboot-action-autoload ├── .gitignore ├── README.md ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.m2e.core.prefs │ └── org.eclipse.jdt.core.prefs ├── src │ └── main │ │ └── java │ │ └── com │ │ └── lianggzone │ │ └── springboot │ │ └── autoload │ │ └── demo │ │ └── RestfulApiWebDemo.java ├── .project ├── .classpath └── pom.xml ├── springboot-action-messagequeue ├── .gitignore ├── README.md ├── .settings │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── lianggzone │ │ │ └── springboot │ │ │ └── mq │ │ │ ├── rabbitmq │ │ │ ├── exchange │ │ │ │ ├── Receiver.java │ │ │ │ └── Sender.java │ │ │ └── simple │ │ │ │ ├── Receiver.java │ │ │ │ └── Sender.java │ │ │ ├── config │ │ │ ├── RabbitMQConfig.java │ │ │ └── RabbitMQConfig2.java │ │ │ └── RunMain.java │ └── test │ │ └── java │ │ └── com │ │ └── lianggzone │ │ └── springboot │ │ └── mq │ │ └── rabbitmq │ │ ├── simple │ │ └── RabbitMQTest.java │ │ └── exchange │ │ └── RabbitMQTest.java ├── .project ├── .classpath └── pom.xml ├── springboot-action-statemachine ├── .gitignore ├── README.md ├── .settings │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── src │ └── main │ │ └── java │ │ └── com │ │ └── lianggzone │ │ └── springboot │ │ └── statemachine │ │ └── reg │ │ ├── enums │ │ ├── RegStatusEnum.java │ │ └── RegEventEnum.java │ │ ├── RunMain.java │ │ └── config │ │ ├── StateMachineEventConfig.java │ │ └── StateMachineConfig.java ├── .project ├── .classpath └── pom.xml ├── springboot-action-tomcat-https ├── .gitignore ├── .settings │ ├── org.eclipse.wst.jsdt.ui.superType.name │ ├── org.eclipse.wst.jsdt.ui.superType.container │ ├── org.eclipse.wst.validation.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.wst.common.project.facet.core.xml │ ├── org.eclipse.jdt.core.prefs │ ├── .jsdtscope │ └── org.eclipse.wst.common.component ├── README.md ├── src │ └── main │ │ ├── resources │ │ ├── keystore.p12 │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── lianggzone │ │ └── springboot │ │ └── web │ │ └── tomcat │ │ └── WebMain.java ├── .classpath ├── .project.bak ├── .project └── pom.xml └── README.md /springboot-action-cache/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springboot-action-sample/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springboot-action-web/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springboot-action-actuator/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springboot-action-autoconfig/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springboot-action-autoload/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springboot-action-messagequeue/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springboot-action-statemachine/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springboot-action-tomcat-https/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /springboot-action-web/src/main/filters/filter-test.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/filters/filter-product.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/filters/filter-test.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-action-web/src/main/filters/filter-development.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-action-web/src/main/filters/filter-product.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/filters/filter-development.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/filters/filter-preproduction.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-action-web/src/main/filters/filter-preproduction.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-action-web/.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /springboot-action-web/src/main/filters/resources/test/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-action-sample/.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /springboot-action-sample/src/main/filters/resources/product/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/filters/resources/test/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-action-web/src/main/filters/resources/product/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/filters/resources/preproduction/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-action-tomcat-https/.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /springboot-action-web/src/main/filters/resources/preproduction/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springboot-action-sample/README.md: -------------------------------------------------------------------------------- 1 | # springboot-action-sample 2 | 3 | Spring Boot 揭秘与实战 源代码(实战案例) -------------------------------------------------------------------------------- /springboot-action-web/README.md: -------------------------------------------------------------------------------- 1 | # springboot-action-web 2 | 3 | Spring Boot 揭秘与实战 源代码(Web开发 实战案例) -------------------------------------------------------------------------------- /springboot-action-cache/README.md: -------------------------------------------------------------------------------- 1 | # springboot-action-cache 2 | 3 | Spring Boot 揭秘与实战 源代码(缓存管理 实战案例) -------------------------------------------------------------------------------- /springboot-action-web/src/main/filters/resources/development/application.properties: -------------------------------------------------------------------------------- 1 | #server.port=8089 -------------------------------------------------------------------------------- /springboot-action-actuator/README.md: -------------------------------------------------------------------------------- 1 | # spring-boot-sample-actuator 2 | 3 | Spring Boot 揭秘与实战 源代码(监控 实战案例) -------------------------------------------------------------------------------- /springboot-action-autoload/README.md: -------------------------------------------------------------------------------- 1 | # springboot-action-autoload 2 | 3 | Spring Boot 揭秘与实战 源代码(热部署 实战案例) -------------------------------------------------------------------------------- /springboot-action-sample/src/main/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | project.env=\u6d4b\u8bd5\u73af\u5883 -------------------------------------------------------------------------------- /springboot-action-autoconfig/README.md: -------------------------------------------------------------------------------- 1 | # springboot-action-autoconfig 2 | 3 | Spring Boot 揭秘与实战 源代码(自动配置 实战案例) -------------------------------------------------------------------------------- /springboot-action-sample/src/main/resources/application-product.properties: -------------------------------------------------------------------------------- 1 | project.env=\u751f\u4ea7\u73af\u5883 -------------------------------------------------------------------------------- /springboot-action-statemachine/README.md: -------------------------------------------------------------------------------- 1 | # springboot-action-statemachine 2 | 3 | Spring Boot 揭秘与实战 源代码(状态机 实战案例) -------------------------------------------------------------------------------- /springboot-action-messagequeue/README.md: -------------------------------------------------------------------------------- 1 | # springboot-action-messagequeue 2 | 3 | Spring Boot 揭秘与实战 源代码(消息队列 实战案例) -------------------------------------------------------------------------------- /springboot-action-sample/src/main/resources/application-development.properties: -------------------------------------------------------------------------------- 1 | project.env=\u5f00\u53d1\u73af\u5883 -------------------------------------------------------------------------------- /springboot-action-tomcat-https/README.md: -------------------------------------------------------------------------------- 1 | # springboot-action-tomcat-https 2 | 3 | Spring Boot 揭秘与实战 源代码(HTTPS配置 实战案例) -------------------------------------------------------------------------------- /springboot-action-sample/.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/resources/application-preproduction.properties: -------------------------------------------------------------------------------- 1 | project.env=\u9884\u751f\u4ea7\u73af\u5883 -------------------------------------------------------------------------------- /springboot-action-sample/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Hello World!

4 | 5 | 6 | -------------------------------------------------------------------------------- /springboot-action-web/.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /springboot-action-web/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Hello World!

4 | 5 | 6 | -------------------------------------------------------------------------------- /springboot-action-sample/.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /springboot-action-web/.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /springboot-action-tomcat-https/.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /springboot-action-tomcat-https/.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /springboot-action-actuator/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | info.author: 2 | email: lianggzone@163.com 3 | blog: http://blog.720ui.com 4 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/resources/config/redis.properties: -------------------------------------------------------------------------------- 1 | redis.host=localhost 2 | redis.port=6379 3 | redis.password= 4 | redis.database=1 -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/core/mail/package-info.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.core.mail; -------------------------------------------------------------------------------- /springboot-action-sample/src/main/filters/resources/development/application.yml: -------------------------------------------------------------------------------- 1 | author: 2 | email: lianggzone@163.com 3 | blog: http://blog.720ui.com 4 | -------------------------------------------------------------------------------- /springboot-action-cache/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /springboot-action-sample/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /springboot-action-web/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /springboot-action-actuator/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /springboot-action-autoconfig/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /springboot-action-autoload/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding/=UTF-8 4 | -------------------------------------------------------------------------------- /springboot-action-autoload/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /springboot-action-messagequeue/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /springboot-action-statemachine/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /springboot-action-tomcat-https/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /springboot-action-tomcat-https/src/main/resources/keystore.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lianggzone/springboot-action/HEAD/springboot-action-tomcat-https/src/main/resources/keystore.p12 -------------------------------------------------------------------------------- /springboot-action-sample/.settings/org.eclipse.jdt.ui.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile 3 | formatter_settings_version=12 4 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/resources/templates/welcome.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Date: ${time?date}
5 | Message: ${message} 6 | 7 | -------------------------------------------------------------------------------- /springboot-action-cache/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /springboot-action-actuator/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /springboot-action-autoconfig/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /springboot-action-statemachine/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /springboot-action-messagequeue/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #rabbitmq 2 | spring.rabbitmq.host=localhost 3 | spring.rabbitmq.port=5672 4 | spring.rabbitmq.username=guest 5 | spring.rabbitmq.password=guest -------------------------------------------------------------------------------- /springboot-action-autoconfig/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | # CUSTOM 2 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 3 | com.lianggzone.springboot.autoconfig.author.AuthorAutoConfiguration -------------------------------------------------------------------------------- /springboot-action-messagequeue/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /springboot-action-tomcat-https/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port:8443 2 | server.ssl.key-store: classpath:keystore.p12 3 | server.ssl.key-store-password: 123456 4 | server.ssl.keyStoreType: PKCS12 5 | server.ssl.keyAlias: springboot -------------------------------------------------------------------------------- /springboot-action-actuator/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | info.author.realname=\u6881\u6842\u948a 2 | info.author.nickname=LiangGzone 3 | 4 | endpoints.shutdown.enabled=true 5 | 6 | #management.context-path=/manage 7 | #management.port=9090 8 | #management.port=-1 -------------------------------------------------------------------------------- /springboot-action-tomcat-https/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding//src/test/resources=UTF-8 6 | encoding/=UTF-8 7 | -------------------------------------------------------------------------------- /springboot-action-web/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | Archetype Created Web Application 7 | 8 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | Archetype Created Web Application 7 | 8 | -------------------------------------------------------------------------------- /springboot-action-cache/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 3 | org.eclipse.jdt.core.compiler.compliance=1.7 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.7 6 | -------------------------------------------------------------------------------- /springboot-action-actuator/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 3 | org.eclipse.jdt.core.compiler.compliance=1.7 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.7 6 | -------------------------------------------------------------------------------- /springboot-action-autoconfig/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 3 | org.eclipse.jdt.core.compiler.compliance=1.7 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.7 6 | -------------------------------------------------------------------------------- /springboot-action-autoload/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 3 | org.eclipse.jdt.core.compiler.compliance=1.7 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.7 6 | -------------------------------------------------------------------------------- /springboot-action-messagequeue/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 3 | org.eclipse.jdt.core.compiler.compliance=1.7 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.7 6 | -------------------------------------------------------------------------------- /springboot-action-statemachine/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 3 | org.eclipse.jdt.core.compiler.compliance=1.7 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.7 6 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/config/ElasticSearchConfig.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.config; 2 | 3 | //@Configuration 4 | //@EnableElasticsearchRepositories("com.lianggzone.springboot.action.data.elasticsearch") 5 | public class ElasticSearchConfig { 6 | 7 | } -------------------------------------------------------------------------------- /springboot-action-web/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/filters/resources/development=UTF-8 3 | encoding//src/main/java=UTF-8 4 | encoding//src/main/resources=UTF-8 5 | encoding//src/test/java=UTF-8 6 | encoding//src/test/resources=UTF-8 7 | encoding/=UTF-8 8 | -------------------------------------------------------------------------------- /springboot-action-sample/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/filters/resources/development=UTF-8 3 | encoding//src/main/java=UTF-8 4 | encoding//src/main/resources=UTF-8 5 | encoding//src/test/java=UTF-8 6 | encoding//src/test/resources=UTF-8 7 | encoding/=UTF-8 8 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/redis/model/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

概要:

3 | *

功能:

4 | *

履历:

5 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 6 | * @author 粱桂钊 7 | * @since 0.1 8 | */ 9 | package com.lianggzone.springboot.action.data.redis.model; -------------------------------------------------------------------------------- /springboot-action-cache/src/main/java/com/lianggzone/springboot/cache/config/CacheConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.cache.config; 2 | 3 | import org.springframework.cache.annotation.EnableCaching; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | @EnableCaching 8 | public class CacheConfiguration {} -------------------------------------------------------------------------------- /springboot-action-cache/src/main/resources/ehcache.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/resources/config/source.properties: -------------------------------------------------------------------------------- 1 | # mysql 2 | source.driverClassName = com.mysql.jdbc.Driver 3 | source.url = jdbc:mysql://localhost:3306/springboot_db?useUnicode = true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull 4 | source.username = root 5 | source.password = root 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /springboot-action-cache/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #redis 2 | spring.redis.host=localhost 3 | spring.redis.port=6379 4 | spring.redis.password= 5 | spring.redis.database=1 6 | spring.redis.pool.max-active=8 7 | spring.redis.pool.max-wait=-1 8 | spring.redis.pool.max-idle=500 9 | spring.redis.pool.min-idle=0 10 | spring.redis.timeout=0 11 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/core/async/config/AsyncConfig.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.core.async.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.scheduling.annotation.EnableAsync; 5 | 6 | @Configuration 7 | @EnableAsync 8 | public class AsyncConfig { 9 | 10 | } -------------------------------------------------------------------------------- /springboot-action-web/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /springboot-action-sample/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /springboot-action-tomcat-https/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /springboot-action-messagequeue/src/main/java/com/lianggzone/springboot/mq/rabbitmq/exchange/Receiver.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.mq.rabbitmq.exchange; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | @Service 6 | public class Receiver { 7 | 8 | public void receiveMessage(String message) { 9 | System.out.println("Received <" + message + ">"); 10 | } 11 | } -------------------------------------------------------------------------------- /springboot-action-web/src/main/java/com/lianggzone/springboot/web/tomcat/ServletInitializer.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.web.tomcat; 2 | 3 | public class ServletInitializer {}/*extends SpringBootServletInitializer { 4 | 5 | @Override 6 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 7 | return application.sources(RestfulApiWebDemo.class); 8 | } 9 | 10 | }*/ -------------------------------------------------------------------------------- /springboot-action-messagequeue/src/main/java/com/lianggzone/springboot/mq/rabbitmq/simple/Receiver.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.mq.rabbitmq.simple; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 4 | 5 | //@Service 6 | public class Receiver { 7 | 8 | @RabbitListener(queues = "spring-boot-simple") 9 | public void receiveMessage(String message) { 10 | System.out.println("Received <" + message + ">"); 11 | } 12 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/demo/ApplicationDemo.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.demo; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | 5 | @SpringBootApplication 6 | public class ApplicationDemo { 7 | 8 | /*public static void main(String[] args) throws Exception { 9 | System.out.println(" springApplication run !"); 10 | SpringApplication.run(ApplicationDemo.class, args); 11 | }*/ 12 | } -------------------------------------------------------------------------------- /springboot-action-messagequeue/src/main/java/com/lianggzone/springboot/mq/config/RabbitMQConfig.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.mq.config; 2 | 3 | import org.springframework.amqp.core.Queue; 4 | import org.springframework.context.annotation.Bean; 5 | 6 | //@Configuration 7 | public class RabbitMQConfig { 8 | 9 | public static final String QUEUE_NAME = "spring-boot-simple"; 10 | 11 | @Bean 12 | public Queue queue() { 13 | return new Queue(QUEUE_NAME); 14 | } 15 | } -------------------------------------------------------------------------------- /springboot-action-web/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.compliance=1.7 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 8 | org.eclipse.jdt.core.compiler.source=1.7 9 | -------------------------------------------------------------------------------- /springboot-action-tomcat-https/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.compliance=1.7 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 8 | org.eclipse.jdt.core.compiler.source=1.7 9 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/resources/init/springboot-db-20161213.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE /*!32312 IF NOT EXISTS*/`springboot_db` /*!40100 DEFAULT CHARACTER SET utf8 */; 2 | 3 | USE `springboot_db`; 4 | 5 | DROP TABLE IF EXISTS `t_author`; 6 | 7 | CREATE TABLE `t_author` ( 8 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户ID', 9 | `real_name` varchar(32) NOT NULL COMMENT '用户名称', 10 | `nick_name` varchar(32) NOT NULL COMMENT '用户匿名', 11 | PRIMARY KEY (`id`) 12 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/config/JPAConfig.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.config; 2 | 3 | import org.springframework.boot.orm.jpa.EntityScan; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 6 | 7 | @Configuration 8 | @EnableJpaRepositories("com.lianggzone.springboot.action.data.jpa") 9 | @EntityScan("com.lianggzone.springboot.action.data.jpa.entity") 10 | public class JPAConfig {} -------------------------------------------------------------------------------- /springboot-action-statemachine/src/main/java/com/lianggzone/springboot/statemachine/reg/enums/RegStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.statemachine.reg.enums; 2 | 3 | /** 4 | *

    概要:

    RegStatusEnum

    5 | *

    功能:

    注册状态枚举

    6 | *

    履历:

    7 | *
  • 2017年3月21日 v0.1 版本内容: 新建
  • 8 | * @author 粱桂钊 9 | * @since 0.1 10 | */ 11 | public enum RegStatusEnum { 12 | 13 | // 未连接 14 | UNCONNECTED, 15 | // 已连接 16 | CONNECTED, 17 | // 注册中 18 | REGISTERING, 19 | // 已注册 20 | REGISTERED; 21 | 22 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/jpa/repository/AuthorDao.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.jpa.repository; 2 | 3 | import java.util.List; 4 | 5 | import com.lianggzone.springboot.action.data.jpa.entity.Author; 6 | 7 | /** 8 | *

    概要:

    AuthorDao

    9 | *

    功能:

    AuthorDao

    10 | *

    履历:

    11 | *
  • 2017年01月03日 v0.1 版本内容: 新建
  • 12 | * @author 粱桂钊 13 | * @since 0.1 14 | */ 15 | public interface AuthorDao { 16 | List findAll(); 17 | Author findAuthor(Long id); 18 | } 19 | -------------------------------------------------------------------------------- /springboot-action-statemachine/src/main/java/com/lianggzone/springboot/statemachine/reg/enums/RegEventEnum.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.statemachine.reg.enums; 2 | 3 | /** 4 | *

    概要:

    RegEventEnum

    5 | *

    功能:

    注册事件枚举

    6 | *

    履历:

    7 | *
  • 2017年3月21日 v0.1 版本内容: 新建
  • 8 | * @author 粱桂钊 9 | * @since 0.1 10 | */ 11 | public enum RegEventEnum { 12 | // 连接 13 | CONNECT, 14 | // 注册 15 | REGISTER, 16 | // 注册成功 17 | REGISTER_SUCCESS, 18 | // 注册失败 19 | REGISTER_FAILED, 20 | // 注销 21 | UN_REGISTER; 22 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/custom/AuthorAutoConfigDemo.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.custom; 2 | 3 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | @EnableAutoConfiguration 8 | public class AuthorAutoConfigDemo { 9 | 10 | /*@Resource 11 | private AuthorServer authorServer; 12 | 13 | @RequestMapping("/custom/author") 14 | String home() { 15 | return "发布者:"+ authorServer.getAuthor(); 16 | }*/ 17 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/mybatis/dao/AuthorMapper2.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.mybatis.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | 5 | import com.lianggzone.springboot.action.data.mybatis.entity.Author; 6 | 7 | /** 8 | *

    概要:

    AuthorMapper

    9 | *

    功能:

    AuthorMapper(通过XML配置文件的方式)

    10 | *

    履历:

    11 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 12 | * @author 粱桂钊 13 | * @since 0.1 14 | */ 15 | public interface AuthorMapper2 { 16 | Author findAuthor(@Param("id") Long id); 17 | } -------------------------------------------------------------------------------- /springboot-action-autoconfig/src/main/java/com/lianggzone/springboot/autoconfig/author/AuthorServer.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.autoconfig.author; 2 | 3 | /** 4 | *

    概要:

    AuthorServer

    5 | *

    功能:

    自定义作者服务

    6 | *

    履历:

    7 | *
  • 2016年12月31日 v0.1 版本内容: 新建
  • 8 | * @author 粱桂钊 9 | * @since 0.1 10 | */ 11 | public class AuthorServer { 12 | 13 | public String author; 14 | 15 | public String getAuthor() { 16 | return author; 17 | } 18 | 19 | public void setAuthor(String author) { 20 | this.author = author; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /springboot-action-messagequeue/src/main/java/com/lianggzone/springboot/mq/rabbitmq/simple/Sender.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.mq.rabbitmq.simple; 2 | 3 | import org.springframework.amqp.core.AmqpTemplate; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | 6 | import com.lianggzone.springboot.mq.config.RabbitMQConfig; 7 | 8 | //@Service 9 | public class Sender { 10 | 11 | @Autowired 12 | private AmqpTemplate rabbitTemplate; 13 | 14 | public void send() { 15 | System.out.println("梁桂钊 发送消息..."); 16 | rabbitTemplate.convertAndSend(RabbitMQConfig.QUEUE_NAME, "你好, 梁桂钊!"); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /springboot-action-messagequeue/src/main/java/com/lianggzone/springboot/mq/RunMain.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.mq; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.ComponentScan; 7 | 8 | @SpringBootApplication 9 | @EnableAutoConfiguration 10 | @ComponentScan(basePackages = { "com.lianggzone.springboot" }) 11 | public class RunMain { 12 | public static void main(String[] args) { 13 | SpringApplication.run(RunMain.class, args); 14 | } 15 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/jdbc/dao/AuthorDao.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.jdbc.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.lianggzone.springboot.action.data.jdbc.entity.Author; 6 | 7 | /** 8 | *

    概要:

    AuthorDao

    9 | *

    功能:

    AuthorDao

    10 | *

    履历:

    11 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 12 | * @author 粱桂钊 13 | * @since 0.1 14 | */ 15 | public interface AuthorDao { 16 | int add(Author author); 17 | int update(Author author); 18 | int delete(Long id); 19 | Author findAuthor(Long id); 20 | List findAuthorList(); 21 | } -------------------------------------------------------------------------------- /springboot-action-web/.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /springboot-action-sample/.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/redis/dao/ValueRedisDao.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.redis.dao; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public class ValueRedisDao { 8 | 9 | @Autowired 10 | public RedisBaseDao redisBaseDao; 11 | 12 | private String getKey(){ 13 | return "param"; 14 | } 15 | 16 | public void save(String param){ 17 | this.redisBaseDao.addValue(this.getKey(), param); 18 | } 19 | 20 | public String getParam(){ 21 | return this.redisBaseDao.getValue(this.getKey()); 22 | } 23 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/demo/RestfulApiWebDemo.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.demo; 2 | 3 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | @EnableAutoConfiguration 9 | public class RestfulApiWebDemo { 10 | 11 | @RequestMapping("/demo/hello") 12 | String home() { 13 | return "Hello World!"; 14 | } 15 | 16 | /*public static void main(String[] args) throws Exception { 17 | SpringApplication.run(RestfulApiWebDemo.class, args); 18 | }*/ 19 | } -------------------------------------------------------------------------------- /springboot-action-tomcat-https/.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/jdbc/service/AuthorService.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.jdbc.service; 2 | 3 | import java.util.List; 4 | 5 | import com.lianggzone.springboot.action.data.jdbc.entity.Author; 6 | 7 | /** 8 | *

    概要:

    AuthorService

    9 | *

    功能:

    AuthorService

    10 | *

    履历:

    11 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 12 | * @author 粱桂钊 13 | * @since 0.1 14 | */ 15 | public interface AuthorService { 16 | int add(Author author); 17 | int update(Author author); 18 | int delete(Long id); 19 | Author findAuthor(Long id); 20 | List findAuthorList(); 21 | } -------------------------------------------------------------------------------- /springboot-action-messagequeue/src/main/java/com/lianggzone/springboot/mq/rabbitmq/exchange/Sender.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.mq.rabbitmq.exchange; 2 | 3 | import org.springframework.amqp.core.AmqpTemplate; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Service; 6 | 7 | import com.lianggzone.springboot.mq.config.RabbitMQConfig2; 8 | 9 | @Service 10 | public class Sender { 11 | 12 | @Autowired 13 | private AmqpTemplate rabbitTemplate; 14 | 15 | public void send() { 16 | System.out.println("梁桂钊 发送消息..."); 17 | rabbitTemplate.convertAndSend(RabbitMQConfig2.QUEUE_NAME, "你好, 梁桂钊!"); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/redis/dao/RedisBaseDao.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.redis.dao; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.springframework.data.redis.core.ValueOperations; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Repository 9 | public class RedisBaseDao { 10 | 11 | @Resource(name="redisTemplate") 12 | protected ValueOperations valueOperations; 13 | 14 | public void addValue(String key, String value){ 15 | valueOperations.set(key, value); 16 | } 17 | 18 | public String getValue(String key){ 19 | return valueOperations.get(key); 20 | } 21 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/elasticsearch/dao/NewsRepository.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.elasticsearch.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; 6 | 7 | import com.lianggzone.springboot.action.data.elasticsearch.entity.News; 8 | 9 | /** 10 | *

    概要:

    NewsRepository

    11 | *

    功能:

    NewsRepository

    12 | *

    履历:

    13 | *
  • 2016年12月14日 v0.1 版本内容: 新建
  • 14 | * @author 粱桂钊 15 | * @since 0.1 16 | */ 17 | public interface NewsRepository extends ElasticsearchRepository { 18 | public List findByTitle(String title); 19 | } 20 | -------------------------------------------------------------------------------- /springboot-action-autoload/src/main/java/com/lianggzone/springboot/autoload/demo/RestfulApiWebDemo.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.autoload.demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | @EnableAutoConfiguration 10 | public class RestfulApiWebDemo { 11 | 12 | @RequestMapping("/home") 13 | String home() { 14 | return "Hello World!!!"; 15 | } 16 | 17 | public static void main(String[] args) throws Exception { 18 | SpringApplication.run(RestfulApiWebDemo.class, args); 19 | } 20 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/resources/mybatis/AuthorMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | -------------------------------------------------------------------------------- /springboot-action-actuator/src/main/java/com/lianggzone/springboot/actuator/endpoint/EndpointConfig.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.actuator.endpoint; 2 | 3 | import java.util.Map; 4 | 5 | import org.springframework.boot.actuate.endpoint.Endpoint; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | /** 10 | *

    概要:

    EndpointConfig

    11 | *

    功能:

    端点配置类

    12 | *

    履历:

    13 | *
  • 2017年1月13日 v0.1 版本内容: 新建
  • 14 | * @author 粱桂钊 15 | * @since 0.1 16 | */ 17 | @Configuration 18 | public class EndpointConfig { 19 | 20 | @Bean 21 | public static Endpoint> servertime() { 22 | return new ServerTimeEndpoint(); 23 | } 24 | } -------------------------------------------------------------------------------- /springboot-action-tomcat-https/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /springboot-action-autoconfig/src/main/java/com/lianggzone/springboot/autoconfig/author/AuthorProperties.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.autoconfig.author; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | /** 6 | *

    概要:

    AuthorProperties

    7 | *

    功能:

    自定义作者配置类

    8 | *

    履历:

    9 | *
  • 2016年12月31日 v0.1 版本内容: 新建
  • 10 | * @author 粱桂钊 11 | * @since 0.1 12 | */ 13 | @ConfigurationProperties(prefix = "custom") 14 | public class AuthorProperties { 15 | 16 | public static final String DEFAULT_AUTHOR = "LiangGzone"; 17 | 18 | public String author = DEFAULT_AUTHOR; 19 | 20 | public String getAuthor() { 21 | return author; 22 | } 23 | 24 | public void setAuthor(String author) { 25 | this.author = author; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/main/WebMain.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.main; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | *

    概要:

    WebMain

    10 | *

    功能:

    WebMain

    11 | *

    履历:

    12 | *
  • 2016年12月10日 v0.1 版本内容: 新建
  • 13 | * @author 粱桂钊 14 | * @since 0.1 15 | */ 16 | @RestController 17 | @EnableAutoConfiguration 18 | @ComponentScan(basePackages = { "com.lianggzone.springboot" }) 19 | public class WebMain { 20 | 21 | public static void main(String[] args) throws Exception { 22 | SpringApplication.run(WebMain.class, args); 23 | } 24 | } -------------------------------------------------------------------------------- /springboot-action-messagequeue/src/test/java/com/lianggzone/springboot/mq/rabbitmq/simple/RabbitMQTest.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.mq.rabbitmq.simple; 2 | 3 | 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.SpringApplicationConfiguration; 8 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 9 | 10 | import com.lianggzone.springboot.mq.RunMain; 11 | import com.lianggzone.springboot.mq.rabbitmq.simple.Sender; 12 | 13 | @RunWith(SpringJUnit4ClassRunner.class) 14 | @SpringApplicationConfiguration(classes = RunMain.class) 15 | public class RabbitMQTest { 16 | 17 | @Autowired 18 | private Sender sender; 19 | 20 | @Test 21 | public void send() throws Exception { 22 | sender.send(); 23 | } 24 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/test/java/com/lianggzone/springboot/core/async/AsyncTest.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.core.async; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.SpringApplicationConfiguration; 7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 8 | 9 | import com.lianggzone.springboot.action.core.async.MsgServer; 10 | import com.lianggzone.springboot.main.WebMain; 11 | 12 | @RunWith(SpringJUnit4ClassRunner.class) 13 | @SpringApplicationConfiguration(classes = WebMain.class) 14 | public class AsyncTest { 15 | 16 | @Autowired 17 | private MsgServer msgServer; 18 | 19 | @Test 20 | public void test() throws Exception { 21 | msgServer.sendA(); 22 | msgServer.sendB(); 23 | } 24 | } -------------------------------------------------------------------------------- /springboot-action-cache/src/main/java/com/lianggzone/springboot/cache/main/WebMain.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.cache.main; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | *

    概要:

    WebMain

    10 | *

    功能:

    WebMain

    11 | *

    履历:

    12 | *
  • 2017年1月5日 v0.1 版本内容: 新建
  • 13 | * @author 粱桂钊 14 | * @since 0.1 15 | */ 16 | @RestController 17 | @EnableAutoConfiguration 18 | @ComponentScan(basePackages = { "com.lianggzone.springboot" }) 19 | public class WebMain { 20 | 21 | public static void main(String[] args) throws Exception { 22 | SpringApplication.run(WebMain.class, args); 23 | } 24 | } -------------------------------------------------------------------------------- /springboot-action-messagequeue/src/test/java/com/lianggzone/springboot/mq/rabbitmq/exchange/RabbitMQTest.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.mq.rabbitmq.exchange; 2 | 3 | 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.SpringApplicationConfiguration; 8 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 9 | 10 | import com.lianggzone.springboot.mq.RunMain; 11 | import com.lianggzone.springboot.mq.rabbitmq.exchange.Sender; 12 | 13 | @RunWith(SpringJUnit4ClassRunner.class) 14 | @SpringApplicationConfiguration(classes = RunMain.class) 15 | public class RabbitMQTest { 16 | 17 | @Autowired 18 | private Sender sender; 19 | 20 | @Test 21 | public void send() throws Exception { 22 | sender.send(); 23 | } 24 | } -------------------------------------------------------------------------------- /springboot-action-actuator/src/main/java/com/lianggzone/springboot/actuator/main/RestfulApiWebDemo.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.actuator.main; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | @RestController 10 | @EnableAutoConfiguration 11 | @ComponentScan(basePackages = { "com.lianggzone.springboot" }) 12 | public class RestfulApiWebDemo { 13 | 14 | @RequestMapping("/home") 15 | String home() { 16 | return "Hello World!"; 17 | } 18 | 19 | public static void main(String[] args) throws Exception { 20 | SpringApplication.run(RestfulApiWebDemo.class, args); 21 | } 22 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/jpa/repository/AuthorRepository.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.jpa.repository; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.data.repository.query.Param; 8 | 9 | import com.lianggzone.springboot.action.data.jpa.entity.Author; 10 | 11 | /** 12 | *

    概要:

    AuthorRepository

    13 | *

    功能:

    AuthorRepository

    14 | *

    履历:

    15 | *
  • 2017年01月03日 v0.1 版本内容: 新建
  • 16 | * @author 粱桂钊 17 | * @since 0.1 18 | */ 19 | public interface AuthorRepository extends JpaRepository { 20 | 21 | List findAll(); 22 | 23 | @Query("from Author where id = :id") 24 | Author findAuthor(@Param("id") Long id); 25 | } 26 | -------------------------------------------------------------------------------- /springboot-action-cache/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | springboot-action-cache 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | com.genuitec.eclipse.springframework.springbuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | com.genuitec.eclipse.springframework.springnature 26 | org.eclipse.jdt.core.javanature 27 | org.eclipse.m2e.core.maven2Nature 28 | 29 | 30 | -------------------------------------------------------------------------------- /springboot-action-actuator/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | springboot-action-actuator 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | com.genuitec.eclipse.springframework.springbuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | com.genuitec.eclipse.springframework.springnature 26 | org.eclipse.jdt.core.javanature 27 | org.eclipse.m2e.core.maven2Nature 28 | 29 | 30 | -------------------------------------------------------------------------------- /springboot-action-autoload/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | springboot-action-autoload 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | com.genuitec.eclipse.springframework.springbuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | com.genuitec.eclipse.springframework.springnature 26 | org.eclipse.jdt.core.javanature 27 | org.eclipse.m2e.core.maven2Nature 28 | 29 | 30 | -------------------------------------------------------------------------------- /springboot-action-web/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /springboot-action-autoconfig/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | springboot-action-autoconfig 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | com.genuitec.eclipse.springframework.springbuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | com.genuitec.eclipse.springframework.springnature 26 | org.eclipse.jdt.core.javanature 27 | org.eclipse.m2e.core.maven2Nature 28 | 29 | 30 | -------------------------------------------------------------------------------- /springboot-action-messagequeue/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | springboot-action-messagequeue 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | com.genuitec.eclipse.springframework.springbuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | com.genuitec.eclipse.springframework.springnature 26 | org.eclipse.jdt.core.javanature 27 | org.eclipse.m2e.core.maven2Nature 28 | 29 | 30 | -------------------------------------------------------------------------------- /springboot-action-sample/src/test/java/com/lianggzone/springboot/data/redis/RedisTest.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.data.redis; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.SpringApplicationConfiguration; 7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 8 | 9 | import com.lianggzone.springboot.action.data.redis.dao.ValueRedisDao; 10 | import com.lianggzone.springboot.main.WebMain; 11 | 12 | @RunWith(SpringJUnit4ClassRunner.class) 13 | @SpringApplicationConfiguration(WebMain.class) 14 | public class RedisTest { 15 | 16 | @Autowired 17 | private ValueRedisDao valueRedisDao; 18 | 19 | @Test 20 | public void test() throws Exception { 21 | this.valueRedisDao.save("LiangGzone"); 22 | System.out.println(this.valueRedisDao.getParam()); 23 | } 24 | } -------------------------------------------------------------------------------- /springboot-action-statemachine/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | springboot-action-statemachine 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | com.genuitec.eclipse.springframework.springbuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | com.genuitec.eclipse.springframework.springnature 26 | org.eclipse.jdt.core.javanature 27 | org.eclipse.m2e.core.maven2Nature 28 | 29 | 30 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/mybatis/service/AuthorService2.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.mybatis.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | 6 | import com.lianggzone.springboot.action.data.mybatis.dao.AuthorMapper2; 7 | import com.lianggzone.springboot.action.data.mybatis.entity.Author; 8 | 9 | /** 10 | *

    概要:

    AuthorService

    11 | *

    功能:

    AuthorService(通过XML配置文件的方式)

    12 | *

    履历:

    13 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 14 | * @author 粱桂钊 15 | * @since 0.1 16 | */ 17 | @Service("mybatis.authorService2") 18 | public class AuthorService2 { 19 | 20 | @Autowired 21 | private AuthorMapper2 authorMapper; 22 | 23 | public Author findAuthor(Long id) { 24 | return this.authorMapper.findAuthor(id); 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /springboot-action-cache/src/main/java/com/lianggzone/springboot/cache/guava/GuavaCacheConfig.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.cache.guava; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | import org.springframework.cache.CacheManager; 6 | import org.springframework.cache.annotation.EnableCaching; 7 | import org.springframework.cache.guava.GuavaCacheManager; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | import com.google.common.cache.CacheBuilder; 12 | 13 | @Configuration 14 | @EnableCaching 15 | public class GuavaCacheConfig { 16 | @Bean 17 | public CacheManager cacheManager() { 18 | GuavaCacheManager cacheManager = new GuavaCacheManager(); 19 | cacheManager.setCacheBuilder( 20 | CacheBuilder.newBuilder(). 21 | expireAfterWrite(10, TimeUnit.SECONDS). 22 | maximumSize(1000)); 23 | return cacheManager; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /springboot-action-web/src/main/java/com/lianggzone/springboot/web/tomcat/TomcatConfig.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.web.tomcat; 2 | 3 | import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; 4 | import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | *

    概要:

    TomcatConfig

    10 | *

    功能:

    TomcatConfig

    11 | *

    履历:

    12 | *
  • 2017年01月03日 v0.1 版本内容: 新建
  • 13 | * @author 粱桂钊 14 | * @since 0.1 15 | */ 16 | @Configuration 17 | public class TomcatConfig { 18 | 19 | @Bean 20 | public EmbeddedServletContainerFactory servletContainer() { 21 | TomcatEmbeddedServletContainerFactory tomcatFactory = new TomcatEmbeddedServletContainerFactory(); 22 | tomcatFactory.setPort(8089); 23 | return tomcatFactory; 24 | } 25 | } -------------------------------------------------------------------------------- /springboot-action-sample/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/jdbc/entity/Author.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.jdbc.entity; 2 | 3 | /** 4 | *

    概要:

    Author实体对象

    5 | *

    功能:

    Author

    6 | *

    履历:

    7 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 8 | * @author 粱桂钊 9 | * @since 0.1 10 | */ 11 | public class Author { 12 | private Long id; 13 | private String realName; 14 | private String nickName; 15 | 16 | // SET和GET方法 17 | public Long getId() { 18 | return id; 19 | } 20 | public void setId(Long id) { 21 | this.id = id; 22 | } 23 | public String getRealName() { 24 | return realName; 25 | } 26 | public void setRealName(String realName) { 27 | this.realName = realName; 28 | } 29 | public String getNickName() { 30 | return nickName; 31 | } 32 | public void setNickName(String nickName) { 33 | this.nickName = nickName; 34 | } 35 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/jpa/service/AuthorService2.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.jpa.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.lianggzone.springboot.action.data.jpa.entity.Author; 9 | import com.lianggzone.springboot.action.data.jpa.repository.AuthorDao; 10 | 11 | /** 12 | *

    概要:

    AuthorService

    13 | *

    功能:

    AuthorService

    14 | *

    履历:

    15 | *
  • 2016年12月14日 v0.1 版本内容: 新建
  • 16 | * @author 粱桂钊 17 | * @since 0.1 18 | */ 19 | @Service("jpa.authorService2") 20 | public class AuthorService2 { 21 | 22 | @Autowired 23 | private AuthorDao authorDao; 24 | 25 | public List findAll() { 26 | return this.authorDao.findAll(); 27 | } 28 | 29 | public Author findAuthor(Long id){ 30 | return this.authorDao.findAuthor(id); 31 | } 32 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/transactional/dao/AuthorDao.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.transactional.dao; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.jdbc.core.JdbcTemplate; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import com.lianggzone.springboot.action.data.transactional.entity.Author; 8 | 9 | /** 10 | *

    概要:

    AuthorDaoImpl

    11 | *

    功能:

    AuthorDaoImpl

    12 | *

    履历:

    13 | *
  • 2017年01月04日 v0.1 版本内容: 新建
  • 14 | * @author 粱桂钊 15 | * @since 0.1 16 | */ 17 | @Repository("transactional.authorDao") 18 | public class AuthorDao { 19 | 20 | @Autowired 21 | private JdbcTemplate jdbcTemplate; 22 | 23 | public int add(Author author) { 24 | return jdbcTemplate.update("insert into t_author(real_name, nick_name) values(?, ?)", 25 | author.getRealName(), author.getNickName()); 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/jpa/service/AuthorService.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.jpa.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.lianggzone.springboot.action.data.jpa.entity.Author; 9 | import com.lianggzone.springboot.action.data.jpa.repository.AuthorRepository; 10 | 11 | /** 12 | *

    概要:

    AuthorService

    13 | *

    功能:

    AuthorService

    14 | *

    履历:

    15 | *
  • 2016年12月14日 v0.1 版本内容: 新建
  • 16 | * @author 粱桂钊 17 | * @since 0.1 18 | */ 19 | @Service("jpa.authorService") 20 | public class AuthorService { 21 | 22 | @Autowired 23 | private AuthorRepository authorRepository; 24 | 25 | public List findAll() { 26 | return this.authorRepository.findAll(); 27 | } 28 | 29 | public Author findAuthor(Long id){ 30 | return this.authorRepository.findAuthor(id); 31 | } 32 | } -------------------------------------------------------------------------------- /springboot-action-tomcat-https/src/main/java/com/lianggzone/springboot/web/tomcat/WebMain.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.web.tomcat; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | /** 10 | *

    概要:

    WebMain

    11 | *

    功能:

    WebMain

    12 | *

    履历:

    13 | *
  • 2017年03月28日 v0.1 版本内容: 新建
  • 14 | * @author 粱桂钊 15 | * @since 0.1 16 | */ 17 | @RestController 18 | @EnableAutoConfiguration 19 | @ComponentScan(basePackages = { "com.lianggzone.springboot" }) 20 | public class WebMain { 21 | 22 | @RequestMapping("/demo/hello") 23 | String home() { 24 | return "Hello World!"; 25 | } 26 | 27 | public static void main(String[] args) throws Exception { 28 | SpringApplication.run(WebMain.class, args); 29 | } 30 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/core/async/MsgServer.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.core.async; 2 | 3 | import org.springframework.scheduling.annotation.Async; 4 | import org.springframework.stereotype.Service; 5 | 6 | /** 7 | *

    概要:

    MsgServer

    8 | *

    功能:

    任务服务类

    9 | *

    履历:

    10 | *
  • 2017年01月05日 v0.1 版本内容: 新建
  • 11 | * @author 粱桂钊 12 | * @since 0.1 13 | */ 14 | @Service 15 | public class MsgServer { 16 | 17 | @Async 18 | public void sendA() throws Exception { 19 | System.out.println("send A"); 20 | Long startTime = System.currentTimeMillis(); 21 | Thread.sleep(2000); 22 | Long endTime = System.currentTimeMillis(); 23 | System.out.println("耗时:" + (endTime - startTime)); 24 | } 25 | 26 | @Async 27 | public void sendB() throws Exception { 28 | System.out.println("send B"); 29 | Long startTime = System.currentTimeMillis(); 30 | Thread.sleep(2000); 31 | Long endTime = System.currentTimeMillis(); 32 | System.out.println("耗时:" + (endTime - startTime)); 33 | } 34 | } -------------------------------------------------------------------------------- /springboot-action-web/src/main/java/com/lianggzone/springboot/web/tomcat/RestfulApiWebController.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.web.tomcat; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | /** 10 | *

    概要:

    RestfulApiWebController

    11 | *

    功能:

    RestfulApiWebController

    12 | *

    履历:

    13 | *
  • 2017年01月03日 v0.1 版本内容: 新建
  • 14 | * @author 粱桂钊 15 | * @since 0.1 16 | */ 17 | @RestController 18 | @EnableAutoConfiguration 19 | @ComponentScan(basePackages = { "com.lianggzone.springboot" }) 20 | public class RestfulApiWebController { 21 | 22 | @RequestMapping("/demo/hello") 23 | String home() { 24 | return "Hello World!"; 25 | } 26 | 27 | public static void main(String[] args) throws Exception { 28 | SpringApplication.run(RestfulApiWebController.class, args); 29 | } 30 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/test/java/com/lianggzone/springboot/data/jdbc/JdbcTest.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.data.jdbc; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.boot.test.SpringApplicationConfiguration; 8 | import org.springframework.jdbc.core.JdbcTemplate; 9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 10 | 11 | import com.lianggzone.springboot.main.WebMain; 12 | 13 | @RunWith(SpringJUnit4ClassRunner.class) 14 | @SpringApplicationConfiguration(WebMain.class) 15 | public class JdbcTest { 16 | 17 | @Resource(name="oneJdbcTemplate") 18 | protected JdbcTemplate jdbcTemplate1; 19 | @Resource(name="twoJdbcTemplate") 20 | protected JdbcTemplate jdbcTemplate2; 21 | 22 | @Test 23 | public void test() throws Exception { 24 | jdbcTemplate1.update("insert into t_author(id, real_name, nick_name) values(?, ?, ?)", 2, "梁桂钊", "LiangGzone"); 25 | jdbcTemplate2.update("insert into t_author(id, real_name, nick_name) values(?, ?, ?)", 2, "梁桂钊", "LiangGzone"); 26 | } 27 | } -------------------------------------------------------------------------------- /springboot-action-autoload/.classpath: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/mybatis/entity/Author.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.mybatis.entity; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | 5 | /** 6 | *

    概要:

    Author实体对象

    7 | *

    功能:

    Author

    8 | *

    履历:

    9 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 10 | * @author 粱桂钊 11 | * @since 0.1 12 | */ 13 | public class Author { 14 | private Long id; 15 | @JSONField(name="real_name") 16 | private String realName; 17 | @JSONField(name="nick_name") 18 | private String nickName; 19 | 20 | // SET和GET方法 21 | public Long getId() { 22 | return id; 23 | } 24 | public void setId(Long id) { 25 | this.id = id; 26 | } 27 | public String getRealName() { 28 | return realName; 29 | } 30 | public void setRealName(String realName) { 31 | this.realName = realName; 32 | } 33 | public String getNickName() { 34 | return nickName; 35 | } 36 | public void setNickName(String nickName) { 37 | this.nickName = nickName; 38 | } 39 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/transactional/entity/Author.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.transactional.entity; 2 | 3 | /** 4 | *

    概要:

    Author实体对象

    5 | *

    功能:

    Author

    6 | *

    履历:

    7 | *
  • 2017年01月04日 v0.1 版本内容: 新建
  • 8 | * @author 粱桂钊 9 | * @since 0.1 10 | */ 11 | public class Author { 12 | private Long id; 13 | private String realName; 14 | private String nickName; 15 | 16 | public Author() {} 17 | public Author(String realName, String nickName) { 18 | this.realName = realName; 19 | this.nickName = nickName; 20 | } 21 | // SET和GET方法 22 | public Long getId() { 23 | return id; 24 | } 25 | public void setId(Long id) { 26 | this.id = id; 27 | } 28 | public String getRealName() { 29 | return realName; 30 | } 31 | public void setRealName(String realName) { 32 | this.realName = realName; 33 | } 34 | public String getNickName() { 35 | return nickName; 36 | } 37 | public void setNickName(String nickName) { 38 | this.nickName = nickName; 39 | } 40 | } -------------------------------------------------------------------------------- /springboot-action-actuator/src/main/java/com/lianggzone/springboot/actuator/endpoint/ServerTimeEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.actuator.endpoint; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.joda.time.DateTime; 7 | import org.springframework.boot.actuate.endpoint.AbstractEndpoint; 8 | import org.springframework.boot.context.properties.ConfigurationProperties; 9 | 10 | /** 11 | *

    概要:

    ServerTimeEndpoint

    12 | *

    功能:

    服务器时间端点类

    13 | *

    履历:

    14 | *
  • 2017年1月13日 v0.1 版本内容: 新建
  • 15 | * @author 粱桂钊 16 | * @since 0.1 17 | */ 18 | @ConfigurationProperties(prefix = "endpoints.servertime") 19 | public class ServerTimeEndpoint extends AbstractEndpoint> { 20 | 21 | public ServerTimeEndpoint() { 22 | super("servertime", false); 23 | } 24 | 25 | @Override 26 | public Map invoke() { 27 | Map result = new HashMap(); 28 | DateTime dateTime = DateTime.now(); 29 | result.put("server_time", dateTime.toString()); 30 | result.put("ms_format", dateTime.getMillis()); 31 | return result; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/mongodb/entity/Author.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.mongodb.entity; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.mongodb.core.mapping.Document; 5 | 6 | /** 7 | *

    概要:

    Author实体对象

    8 | *

    功能:

    Author

    9 | *

    履历:

    10 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 11 | * @author 粱桂钊 12 | * @since 0.1 13 | */ 14 | @Document(collection = "author") 15 | public class Author { 16 | 17 | @Id 18 | private Long id; 19 | private String realName; 20 | private String nickName; 21 | 22 | // SET和GET方法 23 | public Long getId() { 24 | return id; 25 | } 26 | public void setId(Long id) { 27 | this.id = id; 28 | } 29 | public String getRealName() { 30 | return realName; 31 | } 32 | public void setRealName(String realName) { 33 | this.realName = realName; 34 | } 35 | public String getNickName() { 36 | return nickName; 37 | } 38 | public void setNickName(String nickName) { 39 | this.nickName = nickName; 40 | } 41 | } -------------------------------------------------------------------------------- /springboot-action-actuator/src/main/java/com/lianggzone/springboot/actuator/health/CusStatusHealthIndicator.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.actuator.health; 2 | 3 | import org.springframework.boot.actuate.health.Health; 4 | import org.springframework.boot.actuate.health.HealthIndicator; 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | *

    概要:

    CusStatusHealthIndicator

    10 | *

    功能:

    自定义健康状态检测类

    11 | *

    履历:

    12 | *
  • 2017年01月12日 v0.1 版本内容: 新建
  • 13 | * @author 粱桂钊 14 | * @since 0.1 15 | */ 16 | //@Component 17 | public class CusStatusHealthIndicator implements HealthIndicator { 18 | 19 | @Override 20 | public Health health() { 21 | int errorCode = check(); 22 | if (errorCode != 0) { 23 | return Health.down() 24 | .withDetail("status", errorCode) 25 | .withDetail("message", "服务故障") 26 | .build(); 27 | } 28 | return Health.up().build(); 29 | } 30 | 31 | private int check(){ 32 | // 对监控对象的检测操作 33 | return HttpStatus.NOT_FOUND.value(); 34 | } 35 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/jpa/repository/AuthorDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.jpa.repository; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.PersistenceContext; 7 | 8 | import org.springframework.stereotype.Repository; 9 | 10 | import com.lianggzone.springboot.action.data.jpa.entity.Author; 11 | 12 | /** 13 | *

    概要:

    AuthorDaoImpl

    14 | *

    功能:

    AuthorDaoImpl

    15 | *

    履历:

    16 | *
  • 2017年01月03日 v0.1 版本内容: 新建
  • 17 | * @author 粱桂钊 18 | * @since 0.1 19 | */ 20 | @Repository 21 | public class AuthorDaoImpl implements AuthorDao { 22 | 23 | @PersistenceContext 24 | private EntityManager entityManager; 25 | 26 | @Override 27 | public List findAll() { 28 | return this.entityManager 29 | .createQuery("select t from Author t", Author.class) 30 | .getResultList(); 31 | } 32 | 33 | @Override 34 | public Author findAuthor(Long id){ 35 | return this.entityManager 36 | .createQuery("select t from Author t where id = ?", Author.class) 37 | .setParameter(1, id) 38 | .getSingleResult(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /springboot-action-sample/src/test/java/com/lianggzone/springboot/core/async/AsyncFutureTest.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.core.async; 2 | 3 | import java.util.concurrent.Future; 4 | 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.SpringApplicationConfiguration; 9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 10 | 11 | import com.lianggzone.springboot.action.core.async.MsgFutureServer; 12 | import com.lianggzone.springboot.main.WebMain; 13 | 14 | @RunWith(SpringJUnit4ClassRunner.class) 15 | @SpringApplicationConfiguration(classes = WebMain.class) 16 | public class AsyncFutureTest { 17 | 18 | @Autowired 19 | private MsgFutureServer msgFutureServer; 20 | 21 | @Test 22 | public void test() throws Exception { 23 | long startTime = System.currentTimeMillis(); 24 | 25 | Future task1 = msgFutureServer.sendA(); 26 | Future task2 = msgFutureServer.sendB(); 27 | 28 | while(true) { 29 | if(task1.isDone() && task2.isDone() ) { 30 | break; 31 | } 32 | } 33 | 34 | long endTime = System.currentTimeMillis(); 35 | System.out.println("总耗时:" + (endTime - startTime)); 36 | } 37 | } -------------------------------------------------------------------------------- /springboot-action-actuator/.classpath: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /springboot-action-cache/.classpath: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /springboot-action-autoconfig/.classpath: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /springboot-action-messagequeue/.classpath: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /springboot-action-statemachine/.classpath: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /springboot-action-tomcat-https/.classpath: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /springboot-action-cache/src/main/java/com/lianggzone/springboot/cache/ehcache/CacheService.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.cache.ehcache; 2 | 3 | import java.sql.Timestamp; 4 | 5 | import org.springframework.cache.annotation.CacheEvict; 6 | import org.springframework.cache.annotation.CachePut; 7 | import org.springframework.cache.annotation.Cacheable; 8 | import org.springframework.stereotype.Service; 9 | /** 10 | *

    概要:

    CacheService

    11 | *

    功能:

    EhCache 缓存管理

    12 | *

    履历:

    13 | *
  • 2017年1月5日 v0.1 版本内容: 新建
  • 14 | * @author 粱桂钊 15 | * @since 0.1 16 | */ 17 | @Service("ehcache.cacheService") 18 | public class CacheService { 19 | 20 | @CachePut(value = "ehcache") 21 | public long save() { 22 | long timestamp = new Timestamp(System.currentTimeMillis()).getTime(); 23 | System.out.println("进行缓存:" + timestamp); 24 | return timestamp; 25 | } 26 | 27 | @CacheEvict(value = "ehcache") 28 | public void delete() { 29 | System.out.println("删除缓存"); 30 | } 31 | 32 | @Cacheable(value = "ehcache") 33 | public long getByCache() { 34 | try { 35 | Thread.sleep(3 * 1000); 36 | } catch (InterruptedException e) { 37 | e.printStackTrace(); 38 | } 39 | return new Timestamp(System.currentTimeMillis()).getTime(); 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /springboot-action-cache/src/main/java/com/lianggzone/springboot/cache/guava/CacheService.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.cache.guava; 2 | 3 | import java.sql.Timestamp; 4 | 5 | import org.springframework.cache.annotation.CacheEvict; 6 | import org.springframework.cache.annotation.CachePut; 7 | import org.springframework.cache.annotation.Cacheable; 8 | import org.springframework.stereotype.Service; 9 | /** 10 | *

    概要:

    CacheService

    11 | *

    功能:

    GuavaCache 缓存管理

    12 | *

    履历:

    13 | *
  • 2017年1月5日 v0.1 版本内容: 新建
  • 14 | * @author 粱桂钊 15 | * @since 0.1 16 | */ 17 | @Service("guava.cacheService") 18 | public class CacheService { 19 | 20 | @CachePut(value = "guavacache") 21 | public long save() { 22 | long timestamp = new Timestamp(System.currentTimeMillis()).getTime(); 23 | System.out.println("进行缓存:" + timestamp); 24 | return timestamp; 25 | } 26 | 27 | @CacheEvict(value = "guavacache") 28 | public void delete() { 29 | System.out.println("删除缓存"); 30 | } 31 | 32 | @Cacheable(value = "guavacache") 33 | public long getByCache() { 34 | try { 35 | Thread.sleep(3 * 1000); 36 | } catch (InterruptedException e) { 37 | e.printStackTrace(); 38 | } 39 | return new Timestamp(System.currentTimeMillis()).getTime(); 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /springboot-action-cache/src/main/java/com/lianggzone/springboot/cache/redis/CacheService.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.cache.redis; 2 | 3 | import java.sql.Timestamp; 4 | 5 | import org.springframework.cache.annotation.CacheEvict; 6 | import org.springframework.cache.annotation.CachePut; 7 | import org.springframework.cache.annotation.Cacheable; 8 | import org.springframework.stereotype.Service; 9 | /** 10 | *

    概要:

    CacheService

    11 | *

    功能:

    RedisCache 缓存管理

    12 | *

    履历:

    13 | *
  • 2017年1月5日 v0.1 版本内容: 新建
  • 14 | * @author 粱桂钊 15 | * @since 0.1 16 | */ 17 | @Service("redis.cacheService") 18 | public class CacheService { 19 | 20 | @CachePut(value = "rediscache") 21 | public long save() { 22 | long timestamp = new Timestamp(System.currentTimeMillis()).getTime(); 23 | System.out.println("进行缓存:" + timestamp); 24 | return timestamp; 25 | } 26 | 27 | @CacheEvict(value = "rediscache") 28 | public void delete() { 29 | System.out.println("删除缓存"); 30 | } 31 | 32 | @Cacheable(value = "rediscache") 33 | public long getByCache() { 34 | try { 35 | Thread.sleep(3 * 1000); 36 | } catch (InterruptedException e) { 37 | e.printStackTrace(); 38 | } 39 | return new Timestamp(System.currentTimeMillis()).getTime(); 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/mongodb/service/AuthorService.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.mongodb.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.lianggzone.springboot.action.data.mongodb.dao.AuthorDao; 9 | import com.lianggzone.springboot.action.data.mongodb.entity.Author; 10 | 11 | 12 | /** 13 | *

    概要:

    AuthorServiceImpl

    14 | *

    功能:

    AuthorServiceImpl

    15 | *

    履历:

    16 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 17 | * @author 粱桂钊 18 | * @since 0.1 19 | */ 20 | @Service("mongodb.authorService") 21 | public class AuthorService { 22 | 23 | @Autowired 24 | private AuthorDao authorDao; 25 | 26 | public void add(Author author) { 27 | this.authorDao.add(author); 28 | } 29 | 30 | public void update(Author author) { 31 | this.authorDao.update(author); 32 | } 33 | 34 | public void delete(Long id) { 35 | this.authorDao.delete(id); 36 | } 37 | 38 | 39 | public Author findAuthor(Long id) { 40 | return this.authorDao.findAuthor(id); 41 | } 42 | 43 | 44 | public List findAuthorList() { 45 | return this.authorDao.findAuthorList(); 46 | } 47 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/template/freemarker/controller/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.template.freemarker.controller; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.Date; 6 | import java.util.Map; 7 | 8 | import org.apache.commons.io.FileUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.ui.freemarker.FreeMarkerTemplateUtils; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | 14 | import freemarker.core.ParseException; 15 | import freemarker.template.Configuration; 16 | import freemarker.template.MalformedTemplateNameException; 17 | import freemarker.template.Template; 18 | import freemarker.template.TemplateNotFoundException; 19 | 20 | /** 21 | *

    概要:

    AuthorController

    22 | *

    功能:

    AuthorController

    23 | *

    履历:

    24 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 25 | * @author 粱桂钊 26 | * @since 0.1 27 | */ 28 | @Controller("template.freemarkerController") 29 | public class WelcomeController { 30 | 31 | @RequestMapping("/template/freemarker/welcome") 32 | public String welcome(Map model) { 33 | model.put("time", new Date()); 34 | model.put("message", "梁桂钊"); 35 | return "welcome"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/core/async/MsgFutureServer.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.core.async; 2 | 3 | import java.util.Random; 4 | import java.util.concurrent.Future; 5 | 6 | import org.springframework.scheduling.annotation.Async; 7 | import org.springframework.scheduling.annotation.AsyncResult; 8 | import org.springframework.stereotype.Service; 9 | 10 | /** 11 | *

    概要:

    MsgFutureServer

    12 | *

    功能:

    任务服务类

    13 | *

    履历:

    14 | *
  • 2017年01月05日 v0.1 版本内容: 新建
  • 15 | * @author 粱桂钊 16 | * @since 0.1 17 | */ 18 | @Service 19 | public class MsgFutureServer { 20 | public static Random random = new Random(); 21 | 22 | @Async 23 | public Future sendA() throws Exception { 24 | System.out.println("send A"); 25 | Long startTime = System.currentTimeMillis(); 26 | Thread.sleep(2000); 27 | Long endTime = System.currentTimeMillis(); 28 | System.out.println("耗时:" + (endTime - startTime)); 29 | return new AsyncResult("success"); 30 | } 31 | 32 | @Async 33 | public Future sendB() throws Exception { 34 | System.out.println("send B"); 35 | Long startTime = System.currentTimeMillis(); 36 | Thread.sleep(2000); 37 | Long endTime = System.currentTimeMillis(); 38 | System.out.println("耗时:" + (endTime - startTime)); 39 | return new AsyncResult("success"); 40 | } 41 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/jpa/entity/Author.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.jpa.entity; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | 10 | /** 11 | *

    概要:

    Author实体对象

    12 | *

    功能:

    Author

    13 | *

    履历:

    14 | *
  • 2017年01月03日 v0.1 版本内容: 新建
  • 15 | * @author 粱桂钊 16 | * @since 0.1 17 | */ 18 | @Entity 19 | @Table(name = "t_author") 20 | public class Author{ 21 | 22 | @Id 23 | @GeneratedValue(strategy = GenerationType.AUTO) 24 | private Long id; 25 | 26 | @Column(name="real_name") 27 | private String realName; 28 | 29 | @Column(name="nick_name") 30 | private String nickName; 31 | 32 | // SET和GET方法 33 | public Long getId() { 34 | return id; 35 | } 36 | public void setId(Long id) { 37 | this.id = id; 38 | } 39 | public String getRealName() { 40 | return realName; 41 | } 42 | public void setRealName(String realName) { 43 | this.realName = realName; 44 | } 45 | public String getNickName() { 46 | return nickName; 47 | } 48 | public void setNickName(String nickName) { 49 | this.nickName = nickName; 50 | } 51 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/test/java/com/lianggzone/springboot/data/transactional/TransactionalTest.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.data.transactional; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.SpringApplicationConfiguration; 7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 8 | 9 | import com.lianggzone.springboot.action.data.transactional.entity.Author; 10 | import com.lianggzone.springboot.action.data.transactional.service.AuthorService; 11 | import com.lianggzone.springboot.main.WebMain; 12 | 13 | @RunWith(SpringJUnit4ClassRunner.class) 14 | @SpringApplicationConfiguration(WebMain.class) 15 | public class TransactionalTest { 16 | 17 | @Autowired 18 | protected AuthorService authorService; 19 | 20 | //@Test 21 | public void add1() throws Exception { 22 | authorService.add1(new Author("梁桂钊", "梁桂钊")); 23 | authorService.add1(new Author("LiangGzone", "LiangGzone")); 24 | } 25 | 26 | //@Test 27 | public void add2() throws Exception { 28 | authorService.add2(new Author("梁桂钊", "梁桂钊")); 29 | authorService.add2(new Author("LiangGzone", "LiangGzone")); 30 | } 31 | 32 | @Test 33 | public void add3() throws Exception { 34 | authorService.add3(new Author("梁桂钊", "梁桂钊")); 35 | authorService.add3(new Author("LiangGzone", "LiangGzone")); 36 | } 37 | } -------------------------------------------------------------------------------- /springboot-action-cache/src/main/java/com/lianggzone/springboot/cache/concurrenmapcache/CacheService.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.cache.concurrenmapcache; 2 | 3 | import java.sql.Timestamp; 4 | 5 | import org.springframework.cache.annotation.CacheEvict; 6 | import org.springframework.cache.annotation.CachePut; 7 | import org.springframework.cache.annotation.Cacheable; 8 | import org.springframework.stereotype.Service; 9 | 10 | /** 11 | *

    概要:

    CacheService

    12 | *

    功能:

    ConcurrentMapCache 缓存管理

    13 | *

    履历:

    14 | *
  • 2017年1月5日 v0.1 版本内容: 新建
  • 15 | * @author 粱桂钊 16 | * @since 0.1 17 | */ 18 | @Service("concurrenmapcache.cacheService") 19 | public class CacheService { 20 | 21 | @CachePut(value = "concurrenmapcache") 22 | public long save() { 23 | long timestamp = new Timestamp(System.currentTimeMillis()).getTime(); 24 | System.out.println("进行缓存:" + timestamp); 25 | return timestamp; 26 | } 27 | 28 | @CacheEvict(value = "concurrenmapcache") 29 | public void delete() { 30 | System.out.println("删除缓存"); 31 | } 32 | 33 | @Cacheable(value = "concurrenmapcache") 34 | public long getByCache() { 35 | try { 36 | Thread.sleep(3 * 1000); 37 | } catch (InterruptedException e) { 38 | e.printStackTrace(); 39 | } 40 | return new Timestamp(System.currentTimeMillis()).getTime(); 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /springboot-action-web/.classpath: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/mybatis/service/AuthorService.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.mybatis.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.lianggzone.springboot.action.data.mybatis.dao.AuthorMapper; 9 | import com.lianggzone.springboot.action.data.mybatis.entity.Author; 10 | 11 | /** 12 | *

    概要:

    AuthorService

    13 | *

    功能:

    AuthorService(通过注解的方式)

    14 | *

    履历:

    15 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 16 | * @author 粱桂钊 17 | * @since 0.1 18 | */ 19 | @Service("mybatis.authorService") 20 | public class AuthorService { 21 | 22 | @Autowired 23 | private AuthorMapper authorMapper; 24 | 25 | public int add(String realName, String nickName) { 26 | return this.authorMapper.add(realName, nickName); 27 | } 28 | 29 | public int update(String realName, String nickName, Long id) { 30 | return this.authorMapper.update(realName, nickName, id); 31 | } 32 | 33 | public int delete(Long id) { 34 | return this.authorMapper.delete(id); 35 | } 36 | 37 | public Author findAuthor(Long id) { 38 | return this.authorMapper.findAuthor(id); 39 | } 40 | 41 | public List findAuthorList() { 42 | return this.authorMapper.findAuthorList(); 43 | } 44 | } -------------------------------------------------------------------------------- /springboot-action-autoconfig/src/main/java/com/lianggzone/springboot/autoconfig/author/AuthorAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.autoconfig.author; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 8 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | /** 13 | *

    概要:

    AuthorAutoConfiguration

    14 | *

    功能:

    自定义自动加载配置类

    15 | *

    履历:

    16 | *
  • 2016年12月31日 v0.1 版本内容: 新建
  • 17 | * @author 粱桂钊 18 | * @since 0.1 19 | */ 20 | @Configuration 21 | @ConditionalOnClass({ AuthorServer.class }) 22 | @EnableConfigurationProperties(AuthorProperties.class) 23 | public class AuthorAutoConfiguration { 24 | 25 | @Resource 26 | private AuthorProperties authorProperties; 27 | 28 | @Bean 29 | @ConditionalOnMissingBean(AuthorServer.class) 30 | @ConditionalOnProperty(name = "custom.author.enabled", matchIfMissing = true) 31 | public AuthorServer authorResolver() { 32 | AuthorServer authorServer = new AuthorServer(); 33 | authorServer.setAuthor(authorProperties.getAuthor()); 34 | return authorServer; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/jdbc/service/impl/AuthorServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.jdbc.service.impl; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.lianggzone.springboot.action.data.jdbc.dao.AuthorDao; 9 | import com.lianggzone.springboot.action.data.jdbc.entity.Author; 10 | import com.lianggzone.springboot.action.data.jdbc.service.AuthorService; 11 | 12 | /** 13 | *

    概要:

    AuthorServiceImpl

    14 | *

    功能:

    AuthorServiceImpl

    15 | *

    履历:

    16 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 17 | * @author 粱桂钊 18 | * @since 0.1 19 | */ 20 | @Service("jdbc.authorService") 21 | public class AuthorServiceImpl implements AuthorService { 22 | @Autowired 23 | private AuthorDao authorDao; 24 | 25 | @Override 26 | public int add(Author author) { 27 | return this.authorDao.add(author); 28 | } 29 | 30 | @Override 31 | public int update(Author author) { 32 | return this.authorDao.update(author); 33 | } 34 | 35 | @Override 36 | public int delete(Long id) { 37 | return this.authorDao.delete(id); 38 | } 39 | 40 | @Override 41 | public Author findAuthor(Long id) { 42 | return this.authorDao.findAuthor(id); 43 | } 44 | 45 | @Override 46 | public List findAuthorList() { 47 | return this.authorDao.findAuthorList(); 48 | } 49 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/resources/init/springboot_db1-2016-12-19.sql: -------------------------------------------------------------------------------- 1 | /* 2 | SQLyog Ultimate v11.11 (32 bit) 3 | MySQL - 5.7.11 : Database - springboot_db1 4 | ********************************************************************* 5 | */ 6 | 7 | /*!40101 SET NAMES utf8 */; 8 | 9 | /*!40101 SET SQL_MODE=''*/; 10 | 11 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 12 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 13 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 14 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 15 | CREATE DATABASE /*!32312 IF NOT EXISTS*/`springboot_db1` /*!40100 DEFAULT CHARACTER SET utf8 */; 16 | 17 | USE `springboot_db1`; 18 | 19 | /*Table structure for table `t_author` */ 20 | 21 | DROP TABLE IF EXISTS `t_author`; 22 | 23 | CREATE TABLE `t_author` ( 24 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户ID', 25 | `real_name` varchar(32) NOT NULL COMMENT '用户名称', 26 | `nick_name` varchar(32) NOT NULL COMMENT '用户匿名', 27 | PRIMARY KEY (`id`) 28 | ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; 29 | 30 | /*Data for the table `t_author` */ 31 | 32 | insert into `t_author`(`id`,`real_name`,`nick_name`) values (1,'梁桂钊','LiangGzone'),(2,'梁桂钊','LiangGzone'); 33 | 34 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 35 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 36 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 37 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 38 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/resources/init/springboot_db2-2016-12-19.sql: -------------------------------------------------------------------------------- 1 | /* 2 | SQLyog Ultimate v11.11 (32 bit) 3 | MySQL - 5.7.11 : Database - springboot_db2 4 | ********************************************************************* 5 | */ 6 | 7 | /*!40101 SET NAMES utf8 */; 8 | 9 | /*!40101 SET SQL_MODE=''*/; 10 | 11 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 12 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 13 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 14 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 15 | CREATE DATABASE /*!32312 IF NOT EXISTS*/`springboot_db2` /*!40100 DEFAULT CHARACTER SET utf8 */; 16 | 17 | USE `springboot_db2`; 18 | 19 | /*Table structure for table `t_author` */ 20 | 21 | DROP TABLE IF EXISTS `t_author`; 22 | 23 | CREATE TABLE `t_author` ( 24 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户ID', 25 | `real_name` varchar(32) NOT NULL COMMENT '用户名称', 26 | `nick_name` varchar(32) NOT NULL COMMENT '用户匿名', 27 | PRIMARY KEY (`id`) 28 | ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; 29 | 30 | /*Data for the table `t_author` */ 31 | 32 | insert into `t_author`(`id`,`real_name`,`nick_name`) values (1,'梁桂钊','LiangGzone'),(2,'梁桂钊','LiangGzone'); 33 | 34 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 35 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 36 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 37 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 38 | -------------------------------------------------------------------------------- /springboot-action-sample/.classpath: -------------------------------------------------------------------------------- 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 | 36 | 37 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/mybatis/controller/AuthorController2.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.mybatis.controller; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestMethod; 9 | 10 | import com.lianggzone.springboot.action.data.mybatis.entity.Author; 11 | import com.lianggzone.springboot.action.data.mybatis.service.AuthorService2; 12 | 13 | /** 14 | *

    概要:

    AuthorController

    15 | *

    功能:

    AuthorController(通过XML配置文件的方式)

    16 | *

    履历:

    17 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 18 | * @author 粱桂钊 19 | * @since 0.1 20 | */ 21 | // @RestController("mybatis.authorController2") 22 | // @RequestMapping(value="/data/mybatis/author2") 23 | // @MapperScan("com.lianggzone.springboot.action.data.mybatis.dao") 24 | public class AuthorController2 { 25 | 26 | @Autowired 27 | private AuthorService2 authorService; 28 | 29 | /** 30 | * 查询用户信息 31 | */ 32 | @RequestMapping(value = "/{userId:\\d+}", method = RequestMethod.GET) 33 | public Author getAuthor(@PathVariable Long userId, HttpServletRequest request) { 34 | Author author = this.authorService.findAuthor(userId); 35 | if (author == null) { 36 | throw new RuntimeException("查询错误"); 37 | } 38 | return author; 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/config/ElasticsearchConfig2.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.config; 2 | 3 | import org.elasticsearch.client.Client; 4 | import org.elasticsearch.client.transport.TransportClient; 5 | import org.elasticsearch.common.transport.InetSocketTransportAddress; 6 | import org.elasticsearch.common.transport.TransportAddress; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.data.elasticsearch.core.ElasticsearchOperations; 10 | import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; 11 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 12 | 13 | /** 14 | * ElasticsearchConfig 15 | * @author 梁桂钊 16 | * @since 17 | *

    更新时间: 2016年1月18日 v0.1

    版本内容: 创建

    18 | */ 19 | @Configuration 20 | @EnableElasticsearchRepositories("com.lianggzone.springboot.action.data.elasticsearch") 21 | public class ElasticsearchConfig2 { 22 | 23 | private String hostname = "127.0.0.1"; 24 | private int port = 9300; 25 | 26 | @Bean 27 | public ElasticsearchOperations elasticsearchTemplate() { 28 | return new ElasticsearchTemplate(client()); 29 | } 30 | 31 | @Bean 32 | public Client client() { 33 | TransportClient client = new TransportClient(); 34 | TransportAddress address = new InetSocketTransportAddress(hostname, port); 35 | 36 | client.addTransportAddress(address); 37 | return client; 38 | } 39 | } -------------------------------------------------------------------------------- /springboot-action-cache/src/main/java/com/lianggzone/springboot/cache/guava/CacheController.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.cache.guava; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 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 | /** 9 | *

    概要:

    CacheController

    10 | *

    功能:

    GuavaCache 缓存管理

    11 | *

    履历:

    12 | *
  • 2017年1月5日 v0.1 版本内容: 新建
  • 13 | * @author 粱桂钊 14 | * @since 0.1 15 | */ 16 | @RestController("guava.cacheController") 17 | @RequestMapping(value = "/guava/cache") 18 | public class CacheController { 19 | @Autowired 20 | private CacheService cacheService; 21 | 22 | /** 23 | * 查询方法 24 | */ 25 | @RequestMapping(value = "", method = RequestMethod.GET) 26 | public String getByCache() { 27 | Long startTime = System.currentTimeMillis(); 28 | long timestamp = this.cacheService.getByCache(); 29 | Long endTime = System.currentTimeMillis(); 30 | System.out.println("耗时: " + (endTime - startTime)); 31 | return timestamp+""; 32 | } 33 | 34 | /** 35 | * 保存方法 36 | */ 37 | @RequestMapping(value = "", method = RequestMethod.POST) 38 | public void save() { 39 | this.cacheService.save(); 40 | } 41 | 42 | /** 43 | * 删除方法 44 | */ 45 | @RequestMapping(value = "", method = RequestMethod.DELETE) 46 | public void delete() { 47 | this.cacheService.delete(); 48 | } 49 | } -------------------------------------------------------------------------------- /springboot-action-cache/src/main/java/com/lianggzone/springboot/cache/redis/CacheController.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.cache.redis; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 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 | /** 9 | *

    概要:

    CacheController

    10 | *

    功能:

    RedisCache 缓存管理

    11 | *

    履历:

    12 | *
  • 2017年1月5日 v0.1 版本内容: 新建
  • 13 | * @author 粱桂钊 14 | * @since 0.1 15 | */ 16 | @RestController("redis.cacheController") 17 | @RequestMapping(value = "/redis/cache") 18 | public class CacheController { 19 | @Autowired 20 | private CacheService cacheService; 21 | 22 | /** 23 | * 查询方法 24 | */ 25 | @RequestMapping(value = "", method = RequestMethod.GET) 26 | public String getByCache() { 27 | Long startTime = System.currentTimeMillis(); 28 | long timestamp = this.cacheService.getByCache(); 29 | Long endTime = System.currentTimeMillis(); 30 | System.out.println("耗时: " + (endTime - startTime)); 31 | return timestamp+""; 32 | } 33 | 34 | /** 35 | * 保存方法 36 | */ 37 | @RequestMapping(value = "", method = RequestMethod.POST) 38 | public void save() { 39 | this.cacheService.save(); 40 | } 41 | 42 | /** 43 | * 删除方法 44 | */ 45 | @RequestMapping(value = "", method = RequestMethod.DELETE) 46 | public void delete() { 47 | this.cacheService.delete(); 48 | } 49 | } -------------------------------------------------------------------------------- /springboot-action-cache/src/main/java/com/lianggzone/springboot/cache/ehcache/CacheController.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.cache.ehcache; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 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 | /** 9 | *

    概要:

    CacheController

    10 | *

    功能:

    EhCache 缓存管理

    11 | *

    履历:

    12 | *
  • 2017年1月5日 v0.1 版本内容: 新建
  • 13 | * @author 粱桂钊 14 | * @since 0.1 15 | */ 16 | @RestController("ehcache.cacheController") 17 | @RequestMapping(value = "/ehcache/cache") 18 | public class CacheController { 19 | @Autowired 20 | private CacheService cacheService; 21 | 22 | /** 23 | * 查询方法 24 | */ 25 | @RequestMapping(value = "", method = RequestMethod.GET) 26 | public String getByCache() { 27 | Long startTime = System.currentTimeMillis(); 28 | long timestamp = this.cacheService.getByCache(); 29 | Long endTime = System.currentTimeMillis(); 30 | System.out.println("耗时: " + (endTime - startTime)); 31 | return timestamp+""; 32 | } 33 | 34 | /** 35 | * 保存方法 36 | */ 37 | @RequestMapping(value = "", method = RequestMethod.POST) 38 | public void save() { 39 | this.cacheService.save(); 40 | } 41 | 42 | /** 43 | * 删除方法 44 | */ 45 | @RequestMapping(value = "", method = RequestMethod.DELETE) 46 | public void delete() { 47 | this.cacheService.delete(); 48 | } 49 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/config/BeanConfig.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.config; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.context.annotation.PropertySource; 9 | import org.springframework.core.env.Environment; 10 | import org.springframework.jdbc.core.JdbcTemplate; 11 | import org.springframework.transaction.annotation.EnableTransactionManagement; 12 | 13 | import com.alibaba.druid.pool.DruidDataSource; 14 | 15 | @Configuration 16 | @EnableTransactionManagement 17 | @PropertySource(value = {"classpath:config/source.properties"}) 18 | public class BeanConfig { 19 | 20 | @Autowired 21 | private Environment env; 22 | 23 | @Bean(destroyMethod = "close") 24 | public DataSource dataSource() { 25 | DruidDataSource dataSource = new DruidDataSource(); 26 | dataSource.setDriverClassName(env.getProperty("source.driverClassName").trim()); 27 | dataSource.setUrl(env.getProperty("source.url").trim()); 28 | dataSource.setUsername(env.getProperty("source.username").trim()); 29 | dataSource.setPassword(env.getProperty("source.password").trim()); 30 | return dataSource; 31 | } 32 | 33 | @Bean 34 | public JdbcTemplate jdbcTemplate() { 35 | JdbcTemplate jdbcTemplate = new JdbcTemplate(); 36 | jdbcTemplate.setDataSource(dataSource()); 37 | return jdbcTemplate; 38 | } 39 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/config/BeanConfig2.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.config; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import org.springframework.beans.factory.annotation.Qualifier; 6 | import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; 7 | import org.springframework.boot.context.properties.ConfigurationProperties; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Primary; 10 | import org.springframework.jdbc.core.JdbcTemplate; 11 | 12 | //@Configuration 13 | //@EnableTransactionManagement 14 | public class BeanConfig2 { 15 | 16 | /*@Bean(name = "oneDataSource") 17 | @Qualifier("oneDataSource") 18 | @Primary 19 | @ConfigurationProperties(prefix="spring.datasource.one") 20 | public DataSource primaryDataSource() { 21 | return DataSourceBuilder.create().build(); 22 | } 23 | 24 | @Bean(name = "twoDataSource") 25 | @Qualifier("twoDataSource") 26 | @ConfigurationProperties(prefix="spring.datasource.two") 27 | public DataSource secondaryDataSource() { 28 | return DataSourceBuilder.create().build(); 29 | } 30 | 31 | @Bean(name = "oneJdbcTemplate") 32 | public JdbcTemplate oneJdbcTemplate(@Qualifier("oneDataSource") DataSource dataSource) { 33 | return new JdbcTemplate(dataSource); 34 | } 35 | @Bean(name = "twoJdbcTemplate") 36 | public JdbcTemplate twoJdbcTemplate(@Qualifier("twoDataSource") DataSource dataSource) { 37 | return new JdbcTemplate(dataSource); 38 | }*/ 39 | } 40 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/mongodb/dao/AuthorDao.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.mongodb.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.data.mongodb.core.MongoTemplate; 7 | import org.springframework.data.mongodb.core.query.Criteria; 8 | import org.springframework.data.mongodb.core.query.Query; 9 | import org.springframework.stereotype.Repository; 10 | 11 | import com.lianggzone.springboot.action.data.mongodb.entity.Author; 12 | 13 | /** 14 | *

    概要:

    AuthorDao

    15 | *

    功能:

    AuthorDao

    16 | *

    履历:

    17 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 18 | * @author 粱桂钊 19 | * @since 0.1 20 | */ 21 | @Repository("mongodb.authorDao") 22 | public class AuthorDao { 23 | 24 | @Autowired 25 | private MongoTemplate mongoTemplate; 26 | 27 | public void add(Author author) { 28 | this.mongoTemplate.insert(author); 29 | } 30 | 31 | public void update(Author author) { 32 | this.mongoTemplate.save(author); 33 | } 34 | 35 | public void delete(Long id) { 36 | Query query = new Query(); 37 | query.addCriteria(Criteria.where("_id").is(id)); 38 | this.mongoTemplate.remove(query, Author.class); 39 | } 40 | 41 | public Author findAuthor(Long id) { 42 | return this.mongoTemplate.findById(id, Author.class); 43 | } 44 | 45 | public List findAuthorList() { 46 | Query query = new Query(); 47 | return this.mongoTemplate.find(query, Author.class); 48 | } 49 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/mybatis/dao/AuthorMapper.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.mybatis.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Delete; 6 | import org.apache.ibatis.annotations.Insert; 7 | import org.apache.ibatis.annotations.Mapper; 8 | import org.apache.ibatis.annotations.Param; 9 | import org.apache.ibatis.annotations.Select; 10 | import org.apache.ibatis.annotations.Update; 11 | 12 | import com.lianggzone.springboot.action.data.mybatis.entity.Author; 13 | 14 | /** 15 | *

    概要:

    AuthorMapper

    16 | *

    功能:

    AuthorMapper(通过注解的方式)

    17 | *

    履历:

    18 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 19 | * @author 粱桂钊 20 | * @since 0.1 21 | */ 22 | @Mapper 23 | public interface AuthorMapper { 24 | 25 | @Insert("insert into t_author(real_name, nick_name) values(#{real_name}, #{nick_name})") 26 | int add(@Param("realName") String realName, @Param("nickName") String nickName); 27 | 28 | @Update("update t_author set real_name = #{real_name}, nick_name = #{nick_name} where id = #{id}") 29 | int update(@Param("real_name") String realName, @Param("nick_name") String nickName, @Param("id") Long id); 30 | 31 | @Delete("delete from t_author where id = #{id}") 32 | int delete(Long id); 33 | 34 | @Select("select id, real_name as realName, nick_name as nickName from t_author where id = #{id}") 35 | Author findAuthor(@Param("id") Long id); 36 | 37 | @Select("select id, real_name as realName, nick_name as nickName from t_author") 38 | List findAuthorList(); 39 | } -------------------------------------------------------------------------------- /springboot-action-cache/src/main/java/com/lianggzone/springboot/cache/concurrenmapcache/CacheController.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.cache.concurrenmapcache; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 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 | /** 9 | *

    概要:

    CacheController

    10 | *

    功能:

    ConcurrentMapCache 缓存管理

    11 | *

    履历:

    12 | *
  • 2017年1月5日 v0.1 版本内容: 新建
  • 13 | * @author 粱桂钊 14 | * @since 0.1 15 | */ 16 | @RestController("concurrenmapcache.cacheController") 17 | @RequestMapping(value = "/concurrenmapcache/cache") 18 | public class CacheController { 19 | @Autowired 20 | private CacheService cacheService; 21 | 22 | /** 23 | * 查询方法 24 | */ 25 | @RequestMapping(value = "", method = RequestMethod.GET) 26 | public String getByCache() { 27 | Long startTime = System.currentTimeMillis(); 28 | long timestamp = this.cacheService.getByCache(); 29 | Long endTime = System.currentTimeMillis(); 30 | System.out.println("耗时: " + (endTime - startTime)); 31 | return timestamp+""; 32 | } 33 | 34 | /** 35 | * 保存方法 36 | */ 37 | @RequestMapping(value = "", method = RequestMethod.POST) 38 | public void save() { 39 | this.cacheService.save(); 40 | } 41 | 42 | /** 43 | * 删除方法 44 | */ 45 | @RequestMapping(value = "", method = RequestMethod.DELETE) 46 | public void delete() { 47 | this.cacheService.delete(); 48 | } 49 | } -------------------------------------------------------------------------------- /springboot-action-statemachine/src/main/java/com/lianggzone/springboot/statemachine/reg/RunMain.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.statemachine.reg; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.CommandLineRunner; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.statemachine.StateMachine; 9 | 10 | import com.lianggzone.springboot.statemachine.reg.enums.RegEventEnum; 11 | import com.lianggzone.springboot.statemachine.reg.enums.RegStatusEnum; 12 | 13 | /** 14 | *

    概要:

    RunMain

    15 | *

    功能:

    RunMain

    16 | *

    履历:

    17 | *
  • 2017年3月21日 v0.1 版本内容: 新建
  • 18 | * @author 粱桂钊 19 | * @since 0.1 20 | */ 21 | //@SpringBootApplication 22 | //@ComponentScan(basePackages = { "com.lianggzone.springboot" }) 23 | public class RunMain implements CommandLineRunner { 24 | 25 | @Autowired 26 | private StateMachine stateMachine; 27 | 28 | public static void main(String[] args) { 29 | SpringApplication.run(RunMain.class, args); 30 | } 31 | 32 | @Override 33 | public void run(String... args) throws Exception { 34 | stateMachine.start(); 35 | stateMachine.sendEvent(RegEventEnum.CONNECT); 36 | stateMachine.sendEvent(RegEventEnum.REGISTER); 37 | stateMachine.sendEvent(RegEventEnum.REGISTER_SUCCESS); 38 | stateMachine.sendEvent(RegEventEnum.UN_REGISTER); 39 | 40 | stateMachine.sendEvent(RegEventEnum.CONNECT); 41 | } 42 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/transactional/service/AuthorService.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.transactional.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | import com.lianggzone.springboot.action.data.transactional.dao.AuthorDao; 8 | import com.lianggzone.springboot.action.data.transactional.entity.Author; 9 | 10 | 11 | /** 12 | *

    概要:

    AuthorService

    13 | *

    功能:

    AuthorService

    14 | *

    履历:

    15 | *
  • 2017年01月04日 v0.1 版本内容: 新建
  • 16 | * @author 粱桂钊 17 | * @since 0.1 18 | */ 19 | @Service("transactional.authorService") 20 | public class AuthorService { 21 | 22 | @Autowired 23 | private AuthorDao authorDao; 24 | 25 | public int add1(Author author) { 26 | int n = this.authorDao.add(author); 27 | if(author.getRealName().length() > 5){ 28 | throw new IllegalArgumentException("author real name is too long."); 29 | } 30 | return n; 31 | } 32 | 33 | @Transactional(noRollbackFor={IllegalArgumentException.class}) 34 | public int add2(Author author) { 35 | int n = this.authorDao.add(author); 36 | if(author.getRealName().length() > 5){ 37 | throw new IllegalArgumentException("author real name is too long."); 38 | } 39 | return n; 40 | } 41 | 42 | @Transactional(rollbackFor={IllegalArgumentException.class}) 43 | public int add3(Author author) { 44 | int n = this.authorDao.add(author); 45 | if(author.getRealName().length() > 5){ 46 | throw new IllegalArgumentException("author real name is too long."); 47 | } 48 | return n; 49 | } 50 | } -------------------------------------------------------------------------------- /springboot-action-statemachine/src/main/java/com/lianggzone/springboot/statemachine/reg/config/StateMachineEventConfig.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.statemachine.reg.config; 2 | 3 | import org.springframework.statemachine.annotation.OnTransition; 4 | import org.springframework.statemachine.annotation.WithStateMachine; 5 | 6 | /** 7 | *

    概要:

    StateMachineConfig

    8 | *

    功能:

    StateMachineConfig

    9 | *

    履历:

    10 | *
  • 2017年3月21日 v0.1 版本内容: 新建
  • 11 | * @author 粱桂钊 12 | * @since 0.1 13 | */ 14 | @WithStateMachine 15 | public class StateMachineEventConfig { 16 | 17 | @OnTransition(source = "UNCONNECTED", target = "CONNECTED") 18 | public void connect() { 19 | System.out.println("///////////////////"); 20 | System.out.println("连接事件, 未连接 -> 已连接"); 21 | System.out.println("///////////////////"); 22 | } 23 | 24 | @OnTransition(source = "CONNECTED", target = "REGISTERING") 25 | public void register() { 26 | System.out.println("///////////////////"); 27 | System.out.println("注册事件, 已连接 -> 注册中"); 28 | System.out.println("///////////////////"); 29 | } 30 | 31 | @OnTransition(source = "REGISTERING", target = "REGISTERED") 32 | public void registerSuccess() { 33 | System.out.println("///////////////////"); 34 | System.out.println("注册成功事件, 注册中 -> 已注册"); 35 | System.out.println("///////////////////"); 36 | } 37 | 38 | @OnTransition(source = "REGISTERED", target = "UNCONNECTED") 39 | public void unRegister() { 40 | System.out.println("///////////////////"); 41 | System.out.println("注销事件, 已注册 -> 未连接"); 42 | System.out.println("///////////////////"); 43 | } 44 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/elasticsearch/service/NewsService.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.elasticsearch.service; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import org.elasticsearch.index.query.QueryBuilder; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import com.lianggzone.springboot.action.data.elasticsearch.dao.NewsRepository; 11 | import com.lianggzone.springboot.action.data.elasticsearch.entity.News; 12 | 13 | /** 14 | *

    概要:

    NewsService

    15 | *

    功能:

    NewsService

    16 | *

    履历:

    17 | *
  • 2016年12月14日 v0.1 版本内容: 新建
  • 18 | * @author 粱桂钊 19 | * @since 0.1 20 | */ 21 | @Service 22 | public class NewsService { 23 | 24 | @Autowired 25 | private NewsRepository newsRepository; 26 | 27 | public Iterable findAll(){ 28 | return newsRepository.findAll(); 29 | } 30 | 31 | public Iterable search(QueryBuilder query){ 32 | return newsRepository.search(query); 33 | } 34 | 35 | public List findByTitle(String title) { 36 | return this.newsRepository.findByTitle(title); 37 | } 38 | 39 | public void deleteAll(String id){ 40 | this.newsRepository.delete(id); 41 | } 42 | 43 | public void init(){ 44 | for (int i = 0; i < 100; i++) { 45 | News news = new News(); 46 | news.setId(i+""); 47 | news.setTitle(i + ".梁桂钊单元测试用例"); 48 | news.setContent("梁桂钊单元测试用例"+i+"xxxxx"); 49 | news.setCreatedDateTime(new Date()); 50 | this.newsRepository.save(news); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/config/MongoConfig.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.data.mongodb.config.AbstractMongoConfiguration; 8 | import org.springframework.data.mongodb.core.MongoTemplate; 9 | import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; 10 | 11 | import com.mongodb.Mongo; 12 | import com.mongodb.MongoClient; 13 | 14 | @Configuration 15 | @EnableMongoRepositories 16 | public class MongoConfig extends AbstractMongoConfiguration { 17 | 18 | private String mongoHost = "localhost"; 19 | private int mongoPort = 27017; 20 | private String dbName = "springboot-db"; 21 | 22 | private static final String MONGO_BASE_PACKAGE = "com.lianggzone.springboot.action.data.mongodb.entity"; 23 | 24 | @Autowired 25 | private ApplicationContext appContext; 26 | 27 | @Override 28 | protected String getDatabaseName() { 29 | return dbName; 30 | } 31 | 32 | @Override 33 | public Mongo mongo() throws Exception { 34 | MongoClient mongoClient = new MongoClient(mongoHost, mongoPort); 35 | return mongoClient; 36 | } 37 | 38 | @Override 39 | protected String getMappingBasePackage() { 40 | return MONGO_BASE_PACKAGE; 41 | } 42 | 43 | @Override 44 | @Bean 45 | public MongoTemplate mongoTemplate() throws Exception { 46 | return new MongoTemplate(mongo(), getDatabaseName()); 47 | } 48 | } -------------------------------------------------------------------------------- /springboot-action-web/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | springboot-action-web 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.jsdt.core.javascriptValidator 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.common.project.facet.core.builder 20 | 21 | 22 | 23 | 24 | org.eclipse.wst.validation.validationbuilder 25 | 26 | 27 | 28 | 29 | com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator 30 | 31 | 32 | 33 | 34 | com.genuitec.eclipse.springframework.springbuilder 35 | 36 | 37 | 38 | 39 | org.eclipse.m2e.core.maven2Builder 40 | 41 | 42 | 43 | 44 | 45 | com.genuitec.eclipse.springframework.springnature 46 | org.eclipse.jem.workbench.JavaEMFNature 47 | org.eclipse.wst.common.modulecore.ModuleCoreNature 48 | org.eclipse.jdt.core.javanature 49 | org.eclipse.m2e.core.maven2Nature 50 | org.eclipse.wst.common.project.facet.core.nature 51 | org.eclipse.wst.jsdt.core.jsNature 52 | 53 | 54 | -------------------------------------------------------------------------------- /springboot-action-sample/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | springboot-action-sample 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.jsdt.core.javascriptValidator 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.common.project.facet.core.builder 20 | 21 | 22 | 23 | 24 | org.eclipse.wst.validation.validationbuilder 25 | 26 | 27 | 28 | 29 | com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator 30 | 31 | 32 | 33 | 34 | com.genuitec.eclipse.springframework.springbuilder 35 | 36 | 37 | 38 | 39 | org.eclipse.m2e.core.maven2Builder 40 | 41 | 42 | 43 | 44 | 45 | com.genuitec.eclipse.springframework.springnature 46 | org.eclipse.jem.workbench.JavaEMFNature 47 | org.eclipse.wst.common.modulecore.ModuleCoreNature 48 | org.eclipse.jdt.core.javanature 49 | org.eclipse.m2e.core.maven2Nature 50 | org.eclipse.wst.common.project.facet.core.nature 51 | org.eclipse.wst.jsdt.core.jsNature 52 | 53 | 54 | -------------------------------------------------------------------------------- /springboot-action-tomcat-https/.project.bak: -------------------------------------------------------------------------------- 1 | 2 | 3 | springboot-action-web 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.jsdt.core.javascriptValidator 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.common.project.facet.core.builder 20 | 21 | 22 | 23 | 24 | org.eclipse.wst.validation.validationbuilder 25 | 26 | 27 | 28 | 29 | com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator 30 | 31 | 32 | 33 | 34 | com.genuitec.eclipse.springframework.springbuilder 35 | 36 | 37 | 38 | 39 | org.eclipse.m2e.core.maven2Builder 40 | 41 | 42 | 43 | 44 | 45 | com.genuitec.eclipse.springframework.springnature 46 | org.eclipse.jem.workbench.JavaEMFNature 47 | org.eclipse.wst.common.modulecore.ModuleCoreNature 48 | org.eclipse.jdt.core.javanature 49 | org.eclipse.m2e.core.maven2Nature 50 | org.eclipse.wst.common.project.facet.core.nature 51 | org.eclipse.wst.jsdt.core.jsNature 52 | 53 | 54 | -------------------------------------------------------------------------------- /springboot-action-tomcat-https/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | springboot-action-tomcat-https 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.jsdt.core.javascriptValidator 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.common.project.facet.core.builder 20 | 21 | 22 | 23 | 24 | org.eclipse.wst.validation.validationbuilder 25 | 26 | 27 | 28 | 29 | com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator 30 | 31 | 32 | 33 | 34 | com.genuitec.eclipse.springframework.springbuilder 35 | 36 | 37 | 38 | 39 | org.eclipse.m2e.core.maven2Builder 40 | 41 | 42 | 43 | 44 | 45 | com.genuitec.eclipse.springframework.springnature 46 | org.eclipse.jem.workbench.JavaEMFNature 47 | org.eclipse.wst.common.modulecore.ModuleCoreNature 48 | org.eclipse.jdt.core.javanature 49 | org.eclipse.m2e.core.maven2Nature 50 | org.eclipse.wst.common.project.facet.core.nature 51 | org.eclipse.wst.jsdt.core.jsNature 52 | 53 | 54 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/template/freemarker/controller/Welcome2Controller.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.template.freemarker.controller; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.Date; 6 | import java.util.Map; 7 | 8 | import org.apache.commons.io.FileUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.ui.freemarker.FreeMarkerTemplateUtils; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import freemarker.core.ParseException; 17 | import freemarker.template.Configuration; 18 | import freemarker.template.MalformedTemplateNameException; 19 | import freemarker.template.Template; 20 | import freemarker.template.TemplateNotFoundException; 21 | 22 | /** 23 | *

    概要:

    AuthorController

    24 | *

    功能:

    AuthorController

    25 | *

    履历:

    26 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 27 | * @author 粱桂钊 28 | * @since 0.1 29 | */ 30 | @RestController("template.freemarkerController2") 31 | @EnableAutoConfiguration 32 | public class Welcome2Controller { 33 | 34 | @Autowired 35 | private Configuration configuration; 36 | 37 | @RequestMapping("/template/freemarker/welcome2") 38 | public String welcome2(Map model) throws Exception { 39 | model.put("time", new Date()); 40 | model.put("message", "梁桂钊"); 41 | 42 | Template template = configuration.getTemplate("welcome.ftl"); 43 | String content = FreeMarkerTemplateUtils.processTemplateIntoString(template, model); 44 | 45 | FileUtils.writeStringToFile(new File("d:/welcome.html"), content); 46 | 47 | return "welcome"; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /springboot-action-actuator/src/main/java/com/lianggzone/springboot/actuator/health/CusDiskSpaceHealthIndicator.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.actuator.health; 2 | 3 | import java.io.IOException; 4 | import java.nio.file.FileStore; 5 | import java.nio.file.Files; 6 | import java.nio.file.Paths; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.boot.actuate.health.AbstractHealthIndicator; 11 | import org.springframework.boot.actuate.health.Health; 12 | import org.springframework.stereotype.Component; 13 | 14 | /** 15 | *

    概要:

    CusDiskSpaceHealthIndicator

    16 | *

    功能:

    自定义磁盘空间健康检测类

    17 | *

    履历:

    18 | *
  • 2017年01月12日 v0.1 版本内容: 新建
  • 19 | * @author 粱桂钊 20 | * @since 0.1 21 | */ 22 | @Component 23 | public class CusDiskSpaceHealthIndicator extends AbstractHealthIndicator { 24 | 25 | private final FileStore fileStore; 26 | private final long thresholdBytes; 27 | 28 | @Autowired 29 | public CusDiskSpaceHealthIndicator( 30 | @Value("${health.filestore.path:/}") String path, 31 | @Value("${health.filestore.threshold.bytes:10485760}") long thresholdBytes) 32 | throws IOException { 33 | fileStore = Files.getFileStore(Paths.get(path)); 34 | this.thresholdBytes = thresholdBytes; 35 | } 36 | 37 | @Override 38 | protected void doHealthCheck(Health.Builder builder) throws Exception { 39 | long diskFreeInBytes = fileStore.getUnallocatedSpace(); 40 | if (diskFreeInBytes >= thresholdBytes) { 41 | builder.up(); 42 | } else { 43 | builder.down(); 44 | } 45 | 46 | long totalSpaceInBytes = fileStore.getTotalSpace(); 47 | builder.withDetail("disk.free", diskFreeInBytes); 48 | builder.withDetail("disk.total", totalSpaceInBytes); 49 | } 50 | } -------------------------------------------------------------------------------- /springboot-action-tomcat-https/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 1.3.3.RELEASE 9 | 10 | 11 | com.lianggzone.demo 12 | springboot-action-tomcat-https 13 | 0.1 14 | jar 15 | springboot-action-tomcat-https 16 | 17 | 18 | 19 | lianggzone 20 | 梁桂钊 21 | lianggzone@163.com 22 | 23 | Architect 24 | Developer 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-web 39 | 40 | 41 | 42 | 43 | 44 | 45 | org.apache.maven.plugins 46 | maven-compiler-plugin 47 | 48 | lib 49 | 1.7 50 | 1.7 51 | UTF-8 52 | 53 | 54 | 55 | org.springframework.boot 56 | spring-boot-maven-plugin 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/config/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.context.annotation.PropertySource; 7 | import org.springframework.core.env.Environment; 8 | import org.springframework.data.redis.connection.RedisConnectionFactory; 9 | import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; 10 | import org.springframework.data.redis.core.RedisTemplate; 11 | import org.springframework.data.redis.core.StringRedisTemplate; 12 | 13 | import redis.clients.jedis.JedisPoolConfig; 14 | 15 | @Configuration 16 | @PropertySource("classpath:config/redis.properties") 17 | public class RedisConfig { 18 | 19 | @Autowired 20 | private Environment env; 21 | 22 | @Bean 23 | public RedisConnectionFactory redisConnectionFactory() { 24 | JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); 25 | JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(); 26 | jedisConnectionFactory.setHostName(env.getProperty("redis.host").trim()); 27 | jedisConnectionFactory.setPort(Integer.parseInt(env.getProperty("redis.port").trim())); 28 | jedisConnectionFactory.setPassword(env.getProperty("redis.password").trim()); 29 | jedisConnectionFactory.setDatabase(Integer.parseInt(env.getProperty("redis.database").trim())); 30 | jedisConnectionFactory.setUsePool(true); 31 | jedisConnectionFactory.setPoolConfig(jedisPoolConfig); 32 | return jedisConnectionFactory; 33 | } 34 | 35 | @Bean 36 | public RedisTemplate redisTemplate() { 37 | RedisTemplate redisTemplate = new StringRedisTemplate(); 38 | redisTemplate.setConnectionFactory(redisConnectionFactory()); 39 | redisTemplate.afterPropertiesSet(); 40 | return redisTemplate; 41 | } 42 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/elasticsearch/entity/News.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.elasticsearch.entity; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.data.annotation.CreatedDate; 6 | import org.springframework.data.annotation.Id; 7 | import org.springframework.data.elasticsearch.annotations.DateFormat; 8 | import org.springframework.data.elasticsearch.annotations.Document; 9 | import org.springframework.data.elasticsearch.annotations.Field; 10 | import org.springframework.data.elasticsearch.annotations.FieldIndex; 11 | import org.springframework.data.elasticsearch.annotations.FieldType; 12 | 13 | import com.fasterxml.jackson.annotation.JsonFormat; 14 | 15 | /** 16 | *

    概要:

    News

    17 | *

    功能:

    News

    18 | *

    履历:

    19 | *
  • 2016年12月14日 v0.1 版本内容: 新建
  • 20 | * @author 粱桂钊 21 | * @since 0.1 22 | */ 23 | @Document(indexName = "springbootdb", type = "news") 24 | public class News { 25 | 26 | @Id 27 | private String id; 28 | 29 | private String title; 30 | 31 | private String content; 32 | 33 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyyMMdd'T'HHmmss.SSS'Z'") 34 | @Field(type = FieldType.Date, format = DateFormat.basic_date_time, index = FieldIndex.not_analyzed) 35 | @CreatedDate 36 | private Date createdDateTime; 37 | 38 | // GET和SET方法 39 | public String getId() { 40 | return id; 41 | } 42 | 43 | public void setId(String id) { 44 | this.id = id; 45 | } 46 | 47 | public String getTitle() { 48 | return title; 49 | } 50 | 51 | public void setTitle(String title) { 52 | this.title = title; 53 | } 54 | 55 | public String getContent() { 56 | return content; 57 | } 58 | 59 | public void setContent(String content) { 60 | this.content = content; 61 | } 62 | 63 | public Date getCreatedDateTime() { 64 | return createdDateTime; 65 | } 66 | 67 | public void setCreatedDateTime(Date createdDateTime) { 68 | this.createdDateTime = createdDateTime; 69 | } 70 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/jpa/controller/AuthorController.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.jpa.controller; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | import com.lianggzone.springboot.action.data.jpa.entity.Author; 16 | import com.lianggzone.springboot.action.data.jpa.service.AuthorService; 17 | 18 | 19 | /** 20 | *

    概要:

    AuthorController

    21 | *

    功能:

    AuthorController

    22 | *

    履历:

    23 | *
  • 2017年01月03日 v0.1 版本内容: 新建
  • 24 | * @author 粱桂钊 25 | * @since 0.1 26 | */ 27 | @RestController("jpa.authorController") 28 | @RequestMapping(value = "/data/jpa/author") 29 | public class AuthorController { 30 | 31 | @Autowired 32 | private AuthorService authorService; 33 | 34 | /** 35 | * 查询用户列表 36 | */ 37 | @RequestMapping(method = RequestMethod.GET) 38 | public Map getAuthorList(HttpServletRequest request) { 39 | List authorList = this.authorService.findAll(); 40 | Map param = new HashMap(); 41 | param.put("total", authorList.size()); 42 | param.put("rows", authorList); 43 | return param; 44 | } 45 | 46 | /** 47 | * 查询用户信息 48 | */ 49 | @RequestMapping(value = "/{userId:\\d+}", method = RequestMethod.GET) 50 | public Author getAuthor(@PathVariable Long userId, HttpServletRequest request) { 51 | Author author = this.authorService.findAuthor(userId); 52 | if (author == null) { 53 | throw new RuntimeException("查询错误"); 54 | } 55 | return author; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/jpa/controller/AuthorController2.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.jpa.controller; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | import com.lianggzone.springboot.action.data.jpa.entity.Author; 16 | import com.lianggzone.springboot.action.data.jpa.service.AuthorService2; 17 | 18 | 19 | /** 20 | *

    概要:

    AuthorController

    21 | *

    功能:

    AuthorController

    22 | *

    履历:

    23 | *
  • 2017年01月03日 v0.1 版本内容: 新建
  • 24 | * @author 粱桂钊 25 | * @since 0.1 26 | */ 27 | @RestController("jpa.authorController2") 28 | @RequestMapping(value = "/data/jpa/author2") 29 | public class AuthorController2 { 30 | 31 | @Autowired 32 | private AuthorService2 authorService; 33 | 34 | /** 35 | * 查询用户列表 36 | */ 37 | @RequestMapping(method = RequestMethod.GET) 38 | public Map getAuthorList(HttpServletRequest request) { 39 | List authorList = this.authorService.findAll(); 40 | Map param = new HashMap(); 41 | param.put("total", authorList.size()); 42 | param.put("rows", authorList); 43 | return param; 44 | } 45 | 46 | /** 47 | * 查询用户信息 48 | */ 49 | @RequestMapping(value = "/{userId:\\d+}", method = RequestMethod.GET) 50 | public Author getAuthor(@PathVariable Long userId, HttpServletRequest request) { 51 | Author author = this.authorService.findAuthor(userId); 52 | if (author == null) { 53 | throw new RuntimeException("查询错误"); 54 | } 55 | return author; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /springboot-action-autoconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 1.3.3.RELEASE 9 | 10 | 11 | com.lianggzone.demo 12 | springboot-action-autoconfig 13 | 0.1 14 | jar 15 | springboot-action-autoconfig 16 | 17 | 18 | 19 | lianggzone 20 | 梁桂钊 21 | lianggzone@163.com 22 | 23 | Architect 24 | Developer 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-autoconfigure 33 | 34 | 35 | 36 | 37 | 38 | org.apache.maven.plugins 39 | maven-compiler-plugin 40 | 41 | lib 42 | 1.7 43 | 1.7 44 | UTF-8 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-resources-plugin 50 | 51 | UTF-8 52 | false 53 | \ 54 | 55 | ${*} 56 | 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-maven-plugin 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/jdbc/dao/impl/AuthorDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.jdbc.dao.impl; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.jdbc.core.BeanPropertyRowMapper; 7 | import org.springframework.jdbc.core.JdbcTemplate; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import com.lianggzone.springboot.action.data.jdbc.dao.AuthorDao; 11 | import com.lianggzone.springboot.action.data.jdbc.entity.Author; 12 | 13 | /** 14 | *

    概要:

    AuthorDaoImpl

    15 | *

    功能:

    AuthorDaoImpl

    16 | *

    履历:

    17 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 18 | * @author 粱桂钊 19 | * @since 0.1 20 | */ 21 | @Repository("jdbc.authorDao") 22 | public class AuthorDaoImpl implements AuthorDao { 23 | 24 | @Autowired 25 | private JdbcTemplate jdbcTemplate; 26 | 27 | @Override 28 | public int add(Author author) { 29 | return jdbcTemplate.update("insert into t_author(real_name, nick_name) values(?, ?)", 30 | author.getRealName(), author.getNickName()); 31 | } 32 | 33 | @Override 34 | public int update(Author author) { 35 | return jdbcTemplate.update("update t_author set real_name = ?, nick_name = ? where id = ?", 36 | new Object[]{author.getRealName(), author.getNickName(), author.getId()}); 37 | } 38 | 39 | @Override 40 | public int delete(Long id) { 41 | return jdbcTemplate.update("delete from t_author where id = ?", id); 42 | } 43 | 44 | @Override 45 | public Author findAuthor(Long id) { 46 | List list = jdbcTemplate.query("select * from t_author where id = ?", new Object[]{id}, new BeanPropertyRowMapper(Author.class)); 47 | if(null != list && list.size()>0){ 48 | Author auhtor = list.get(0); 49 | return auhtor; 50 | }else{ 51 | return null; 52 | } 53 | } 54 | @Override 55 | public List findAuthorList() { 56 | List list = jdbcTemplate.query("select * from t_author", new Object[]{}, new BeanPropertyRowMapper(Author.class)); 57 | return list; 58 | } 59 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/test/java/com/lianggzone/springboot/demo/PropertiesTest.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.demo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.boot.test.SpringApplicationConfiguration; 7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 8 | 9 | import com.lianggzone.springboot.main.WebMain; 10 | 11 | /** 12 | *

    概要:

    配置文件,单元测试

    13 | *

    功能:

    14 | *

    履历:

    15 | *
  • 2016年12月31日 v0.1 版本内容: 新建
  • 16 | * @author 粱桂钊 17 | * @since 0.1 18 | */ 19 | @RunWith(SpringJUnit4ClassRunner.class) 20 | @SpringApplicationConfiguration(WebMain.class) 21 | public class PropertiesTest { 22 | 23 | @Value("${author.realname}") 24 | private String realname; 25 | 26 | @Value("${author.nickname}") 27 | private String nickname; 28 | 29 | @Test 30 | public void test1() throws Exception { 31 | System.out.println("real_name : " + realname); 32 | System.out.println("nick_name : " + nickname); 33 | } 34 | 35 | @Value("${author.intro}") 36 | private String intro; 37 | 38 | @Test 39 | public void test2() throws Exception { 40 | System.out.println("intro : " + intro); 41 | } 42 | 43 | @Value("${rand.str}") 44 | private String randStr; 45 | @Value("${rand.intid}") 46 | private int randIntid; 47 | @Value("${rand.longid}") 48 | private long randLongid; 49 | @Value("${rand.number}") 50 | private int randNumber; 51 | @Value("${rand.range}") 52 | private String randRange; 53 | 54 | @Test 55 | public void test3() throws Exception { 56 | System.out.println("rand.str : " + randStr); 57 | System.out.println("rand.intid : " + randIntid); 58 | System.out.println("rand.longid : " + randLongid); 59 | System.out.println("rand.number : " + randNumber); 60 | System.out.println("rand.range : " + randRange); 61 | } 62 | 63 | @Value("${author.email}") 64 | private String email; 65 | @Value("${author.blog}") 66 | private String blog; 67 | 68 | @Test 69 | public void test4() throws Exception { 70 | System.out.println("email : " + email); 71 | System.out.println("blog : " + blog); 72 | } 73 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/elasticsearch/controller/NewsController.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.elasticsearch.controller; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | 8 | import org.elasticsearch.index.query.QueryBuilder; 9 | import org.elasticsearch.index.query.QueryBuilders; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import com.lianggzone.springboot.action.data.elasticsearch.service.NewsService; 17 | 18 | /** 19 | *

    概要:

    NewsController

    20 | *

    功能:

    NewsController

    21 | *

    履历:

    22 | *
  • 2016年12月14日 v0.1 版本内容: 新建
  • 23 | * @author 粱桂钊 24 | * @since 0.1 25 | */ 26 | @RestController("es.newsController") 27 | @RequestMapping(value="/data/elasticsearch/news") 28 | public class NewsController { 29 | 30 | @Autowired 31 | private NewsService newsService; 32 | 33 | /** 34 | * 初始化 35 | * @param request 36 | */ 37 | @RequestMapping(value = "/init", method = RequestMethod.POST) 38 | public void init(HttpServletRequest request) { 39 | this.newsService.init(); 40 | } 41 | 42 | /** 43 | * findAll 44 | * @param request 45 | * @return 46 | */ 47 | @RequestMapping(value = "/", method = RequestMethod.GET) 48 | public Map findList(HttpServletRequest request) { 49 | Map params = new HashMap(); 50 | params.put("items", this.newsService.findAll()); 51 | return params; 52 | } 53 | 54 | /** 55 | * find 56 | * @param request 57 | * @return 58 | */ 59 | @RequestMapping(value = "/{title}", method = RequestMethod.GET) 60 | public Map search(@PathVariable String title) { 61 | // 构建查询条件 62 | QueryBuilder queryBuilder = QueryBuilders.queryString(title); 63 | 64 | Map params = new HashMap(); 65 | params.put("items", this.newsService.search(queryBuilder)); 66 | return params; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /springboot-action-messagequeue/src/main/java/com/lianggzone/springboot/mq/config/RabbitMQConfig2.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.mq.config; 2 | 3 | import org.springframework.amqp.core.Binding; 4 | import org.springframework.amqp.core.BindingBuilder; 5 | import org.springframework.amqp.core.Queue; 6 | import org.springframework.amqp.core.TopicExchange; 7 | import org.springframework.amqp.rabbit.connection.ConnectionFactory; 8 | import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; 9 | import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | 13 | import com.lianggzone.springboot.mq.rabbitmq.exchange.Receiver; 14 | 15 | @Configuration 16 | public class RabbitMQConfig2 { 17 | 18 | public static final String QUEUE_NAME = "spring-boot"; 19 | public static final String QUEUE_EXCHANGE_NAME = "spring-boot-exchange"; 20 | 21 | @Bean 22 | public Queue queue() { 23 | // 是否持久化 24 | boolean durable = true; 25 | // 仅创建者可以使用的私有队列,断开后自动删除 26 | boolean exclusive = false; 27 | // 当所有消费客户端连接断开后,是否自动删除队列 28 | boolean autoDelete = false; 29 | return new Queue(QUEUE_NAME, durable, exclusive, autoDelete); 30 | } 31 | 32 | @Bean 33 | public TopicExchange exchange() { 34 | // 是否持久化 35 | boolean durable = true; 36 | // 当所有消费客户端连接断开后,是否自动删除队列 37 | boolean autoDelete = false; 38 | return new TopicExchange(QUEUE_EXCHANGE_NAME, durable, autoDelete); 39 | } 40 | 41 | @Bean 42 | public Binding binding(Queue queue, TopicExchange exchange) { 43 | return BindingBuilder.bind(queue).to(exchange).with(QUEUE_NAME); 44 | } 45 | 46 | @Bean 47 | SimpleMessageListenerContainer container(ConnectionFactory connectionFactory, 48 | MessageListenerAdapter listenerAdapter) { 49 | SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); 50 | container.setConnectionFactory(connectionFactory); 51 | container.setQueueNames(QUEUE_NAME); 52 | container.setMessageListener(listenerAdapter); 53 | return container; 54 | } 55 | 56 | @Bean 57 | MessageListenerAdapter listenerAdapter(Receiver receiver) { 58 | return new MessageListenerAdapter(receiver, "receiveMessage"); 59 | } 60 | } -------------------------------------------------------------------------------- /springboot-action-messagequeue/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 1.3.3.RELEASE 9 | 10 | 11 | com.lianggzone.demo 12 | springboot-action-messagequeue 13 | 0.1 14 | jar 15 | springboot-action-messagequeue 16 | 17 | 18 | 19 | lianggzone 20 | 梁桂钊 21 | lianggzone@163.com 22 | 23 | Architect 24 | Developer 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-test 37 | test 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-amqp 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-compiler-plugin 50 | 51 | lib 52 | 1.7 53 | 1.7 54 | UTF-8 55 | 56 | 57 | 58 | org.apache.maven.plugins 59 | maven-resources-plugin 60 | 61 | UTF-8 62 | false 63 | \ 64 | 65 | ${*} 66 | 67 | 68 | 69 | 70 | org.springframework.boot 71 | spring-boot-maven-plugin 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /springboot-action-actuator/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 1.4.3.RELEASE 9 | 10 | 11 | com.lianggzone.demo 12 | springboot-action-actuator 13 | 0.1 14 | jar 15 | springboot-action-actuator 16 | 17 | 18 | 19 | lianggzone 20 | 梁桂钊 21 | lianggzone@163.com 22 | 23 | Architect 24 | Developer 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-actuator 42 | 43 | 44 | 45 | joda-time 46 | joda-time 47 | 2.9.6 48 | 49 | 50 | 51 | 52 | 53 | 54 | org.apache.maven.plugins 55 | maven-compiler-plugin 56 | 57 | lib 58 | 1.7 59 | 1.7 60 | UTF-8 61 | 62 | 63 | 64 | org.apache.maven.plugins 65 | maven-resources-plugin 66 | 67 | UTF-8 68 | false 69 | \ 70 | 71 | ${*} 72 | 73 | 74 | 75 | 76 | org.springframework.boot 77 | spring-boot-maven-plugin 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /springboot-action-sample/src/main/filters/resources/development/application.properties: -------------------------------------------------------------------------------- 1 | #jdbc 2 | #spring.datasource.driver-class-name=com.mysql.jdbc.Driver 3 | #spring.datasource.url=jdbc:mysql://localhost:3307/springboot_db?useUnicode = true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull 4 | #spring.datasource.username=root 5 | #spring.datasource.password=root 6 | 7 | #spring.datasource.one.driver-class-name=com.mysql.jdbc.Driver 8 | #spring.datasource.one.url=jdbc:mysql://localhost:3307/springboot_db1 9 | #spring.datasource.one.username=root 10 | #spring.datasource.one.password=root 11 | 12 | #spring.datasource.two.driver-class-name=com.mysql.jdbc.Driver 13 | #spring.datasource.two.url=jdbc:mysql://localhost:3307/springboot_db2 14 | #spring.datasource.two.username=root 15 | #spring.datasource.two.password=root 16 | 17 | #mybatis 18 | #mybatis.mapper-locations=classpath*:mybatis/*Mapper.xml 19 | #mybatis.type-aliases-package=com.lianggzone.springboot.action.data.mybatis.entity 20 | 21 | #redis 22 | #spring.redis.host=localhost 23 | #spring.redis.port=6379 24 | #spring.redis.password= 25 | #spring.redis.database=1 26 | #spring.redis.pool.max-active=8 27 | #spring.redis.pool.max-wait=-1 28 | #spring.redis.pool.max-idle=500 29 | #spring.redis.pool.min-idle=0 30 | #spring.redis.timeout=0 31 | 32 | #mongodb 33 | #spring.data.mongodb.uri=mongodb://name:pass@localhost:27017/dbname 34 | #spring.data.mongodb.uri=mongodb://localhost:27017/springboot-db 35 | 36 | #elasticsearch 37 | #spring.data.elasticsearch.properties.host = 127.0.0.1 38 | #spring.data.elasticsearch.properties.port = 9300 39 | 40 | #email 41 | spring.mail.host=smtp.163.com 42 | spring.mail.username=\u8bf7\u8f93\u5165\u7528\u6237\u540d 43 | spring.mail.password=\u8bf7\u8f93\u5165\u5bc6\u7801 44 | spring.mail.port=25 45 | spring.mail.protocol=smtp 46 | spring.mail.default-encoding=UTF-8 47 | 48 | author.realname=\u6881\u6842\u948a 49 | author.nickname=LiangGzone 50 | author.product=Spring Boot \u63ed\u79d8\u4e0e\u5b9e\u6218 51 | author.project=springboot-action 52 | author.intro=${author.product} | ${author.project} | \u4f5c\u8005\uff1a${author.realname} 53 | 54 | # 32\u4f4d\u968f\u673a\u5b57\u7b26\u4e32 55 | rand.str = ${random.value} 56 | # \u968f\u673aint\u7c7b\u578b 57 | rand.intid = ${random.int} 58 | # \u968f\u673along\u7c7b\u578b 59 | rand.longid = ${random.long} 60 | # 100\u4ee5\u5185\u7684\u968f\u673aint\u7c7b\u578b 61 | rand.number = ${random.int(100)} 62 | # 0-100\u8303\u56f4\u5185\u7684\u968f\u673aint\u7c7b\u578b 63 | rand.range = ${random.int[0,100]} 64 | 65 | #custom 66 | custom.author = \u6881\u6842\u948a 67 | 68 | -------------------------------------------------------------------------------- /springboot-action-statemachine/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 1.3.3.RELEASE 9 | 10 | 11 | com.lianggzone.demo 12 | springboot-action-statemachine 13 | 0.1 14 | jar 15 | springboot-action-statemachine 16 | 17 | 18 | 19 | lianggzone 20 | 梁桂钊 21 | lianggzone@163.com 22 | 23 | Architect 24 | Developer 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-log4j 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-test 42 | test 43 | 44 | 45 | org.springframework.statemachine 46 | spring-statemachine-core 47 | 1.2.0.RELEASE 48 | 49 | 50 | 51 | 52 | 53 | org.apache.maven.plugins 54 | maven-compiler-plugin 55 | 56 | lib 57 | 1.7 58 | 1.7 59 | UTF-8 60 | 61 | 62 | 63 | org.apache.maven.plugins 64 | maven-resources-plugin 65 | 66 | UTF-8 67 | false 68 | \ 69 | 70 | ${*} 71 | 72 | 73 | 74 | 75 | org.springframework.boot 76 | spring-boot-maven-plugin 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /springboot-action-autoload/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 1.3.3.RELEASE 9 | 10 | 11 | com.lianggzone.demo 12 | springboot-action-autoload 13 | 0.1 14 | jar 15 | springboot-action-autoload 16 | 17 | 18 | 19 | lianggzone 20 | 梁桂钊 21 | lianggzone@163.com 22 | 23 | Architect 24 | Developer 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 40 | 41 | 42 | 43 | 44 | org.apache.maven.plugins 45 | maven-compiler-plugin 46 | 47 | lib 48 | 1.7 49 | 1.7 50 | UTF-8 51 | 52 | 53 | 54 | org.apache.maven.plugins 55 | maven-resources-plugin 56 | 57 | UTF-8 58 | false 59 | \ 60 | 61 | ${*} 62 | 63 | 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-maven-plugin 68 | 69 | 70 | org.springframework.boot 71 | spring-boot-maven-plugin 72 | 73 | 74 | org.springframework 75 | springloaded 76 | 1.2.6.RELEASE 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /springboot-action-cache/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 1.3.3.RELEASE 9 | 10 | 11 | com.lianggzone.demo 12 | springboot-action-cache 13 | 0.1 14 | jar 15 | springboot-action-cache 16 | 17 | 18 | 19 | lianggzone 20 | 梁桂钊 21 | lianggzone@163.com 22 | 23 | Architect 24 | Developer 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-cache 42 | 43 | 44 | 50 | 51 | 52 | com.google.guava 53 | guava 54 | 19.0 55 | 56 | 57 | 63 | 64 | 65 | 66 | 67 | org.apache.maven.plugins 68 | maven-compiler-plugin 69 | 70 | lib 71 | 1.7 72 | 1.7 73 | UTF-8 74 | 75 | 76 | 77 | org.apache.maven.plugins 78 | maven-resources-plugin 79 | 80 | UTF-8 81 | false 82 | \ 83 | 84 | ${*} 85 | 86 | 87 | 88 | 89 | org.springframework.boot 90 | spring-boot-maven-plugin 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /springboot-action-statemachine/src/main/java/com/lianggzone/springboot/statemachine/reg/config/StateMachineConfig.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.statemachine.reg.config; 2 | 3 | import java.util.EnumSet; 4 | 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.statemachine.config.EnableStateMachine; 7 | import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter; 8 | import org.springframework.statemachine.config.builders.StateMachineStateConfigurer; 9 | import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer; 10 | 11 | import com.lianggzone.springboot.statemachine.reg.enums.RegEventEnum; 12 | import com.lianggzone.springboot.statemachine.reg.enums.RegStatusEnum; 13 | 14 | /** 15 | *

    概要:

    StateMachineConfig

    16 | *

    功能:

    StateMachineConfig

    17 | *

    履历:

    18 | *
  • 2017年3月21日 v0.1 版本内容: 新建
  • 19 | * @author 粱桂钊 20 | * @since 0.1 21 | */ 22 | @Configuration 23 | @EnableStateMachine 24 | public class StateMachineConfig extends EnumStateMachineConfigurerAdapter { 25 | 26 | /** 27 | * 初始化状态机状态 28 | */ 29 | @Override 30 | public void configure(StateMachineStateConfigurer states) throws Exception { 31 | states.withStates() 32 | // 定义初始状态 33 | .initial(RegStatusEnum.UNCONNECTED) 34 | // 定义状态机状态 35 | .states(EnumSet.allOf(RegStatusEnum.class)); 36 | } 37 | /** 38 | * 初始化状态迁移事件 39 | */ 40 | @Override 41 | public void configure(StateMachineTransitionConfigurer transitions) 42 | throws Exception { 43 | transitions 44 | // 1.连接事件 45 | // 未连接 -> 已连接 46 | .withExternal() 47 | .source(RegStatusEnum.UNCONNECTED) 48 | .target(RegStatusEnum.CONNECTED) 49 | .event(RegEventEnum.CONNECT) 50 | .and() 51 | 52 | // 2.注册事件 53 | // 已连接 -> 注册中 54 | .withExternal() 55 | .source(RegStatusEnum.CONNECTED) 56 | .target(RegStatusEnum.REGISTERING) 57 | .event(RegEventEnum.REGISTER) 58 | .and() 59 | 60 | // 3.注册成功事件 61 | // 注册中 -> 已注册 62 | .withExternal() 63 | .source(RegStatusEnum.REGISTERING) 64 | .target(RegStatusEnum.REGISTERED) 65 | .event(RegEventEnum.REGISTER_SUCCESS) 66 | .and() 67 | 68 | // 5.注销事件 69 | // 已连接 -> 未连接 70 | .withExternal() 71 | .source(RegStatusEnum.CONNECTED) 72 | .target(RegStatusEnum.UNCONNECTED) 73 | .event(RegEventEnum.UN_REGISTER) 74 | .and() 75 | // 注册中 -> 未连接 76 | .withExternal() 77 | .source(RegStatusEnum.REGISTERING) 78 | .target(RegStatusEnum.UNCONNECTED) 79 | .event(RegEventEnum.UN_REGISTER) 80 | .and() 81 | // 已注册 -> 未连接 82 | .withExternal() 83 | .source(RegStatusEnum.REGISTERED) 84 | .target(RegStatusEnum.UNCONNECTED) 85 | .event(RegEventEnum.UN_REGISTER) 86 | ; 87 | } 88 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/mybatis/controller/AuthorController.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.mybatis.controller; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | import org.mybatis.spring.annotation.MapperScan; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.RequestBody; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RequestMethod; 15 | import org.springframework.web.bind.annotation.RestController; 16 | 17 | import com.alibaba.fastjson.JSONObject; 18 | import com.lianggzone.springboot.action.data.mybatis.entity.Author; 19 | import com.lianggzone.springboot.action.data.mybatis.service.AuthorService; 20 | 21 | /** 22 | *

    概要:

    AuthorController

    23 | *

    功能:

    AuthorController(通过注解的方式)

    24 | *

    履历:

    25 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 26 | * @author 粱桂钊 27 | * @since 0.1 28 | */ 29 | @RestController("mybatis.authorController") 30 | @RequestMapping(value = "/data/mybatis/author") 31 | @MapperScan("com.lianggzone.springboot.action.data.mybatis.dao") 32 | public class AuthorController { 33 | 34 | @Autowired 35 | private AuthorService authorService; 36 | 37 | /** 38 | * 查询用户列表 39 | */ 40 | @RequestMapping(method = RequestMethod.GET) 41 | public Map getAuthorList(HttpServletRequest request) { 42 | List authorList = this.authorService.findAuthorList(); 43 | Map param = new HashMap(); 44 | param.put("total", authorList.size()); 45 | param.put("rows", authorList); 46 | return param; 47 | } 48 | 49 | /** 50 | * 查询用户信息 51 | */ 52 | @RequestMapping(value = "/{userId:\\d+}", method = RequestMethod.GET) 53 | public Author getAuthor(@PathVariable Long userId, HttpServletRequest request) { 54 | Author author = this.authorService.findAuthor(userId); 55 | if (author == null) { 56 | throw new RuntimeException("查询错误"); 57 | } 58 | return author; 59 | } 60 | 61 | /** 62 | * 新增方法 63 | */ 64 | @RequestMapping(method = RequestMethod.POST) 65 | public void add(@RequestBody JSONObject jsonObject) { 66 | // String userId = jsonObject.getString("user_id"); 67 | String realName = jsonObject.getString("real_name"); 68 | String nickName = jsonObject.getString("nick_name"); 69 | 70 | try { 71 | this.authorService.add(realName, nickName); 72 | } catch (Exception e) { 73 | e.printStackTrace(); 74 | throw new RuntimeException("新增错误"); 75 | } 76 | } 77 | 78 | /** 79 | * 更新方法 80 | */ 81 | @RequestMapping(value = "/{userId:\\d+}", method = RequestMethod.PUT) 82 | public void update(@PathVariable Long userId, @RequestBody JSONObject jsonObject) { 83 | Author author = this.authorService.findAuthor(userId); 84 | String realName = jsonObject.getString("real_name"); 85 | String nickName = jsonObject.getString("nick_name"); 86 | 87 | try { 88 | this.authorService.update(realName, nickName, author.getId()); 89 | } catch (Exception e) { 90 | e.printStackTrace(); 91 | throw new RuntimeException("更新错误"); 92 | } 93 | } 94 | 95 | /** 96 | * 删除方法 97 | */ 98 | @RequestMapping(value = "/{userId:\\d+}", method = RequestMethod.DELETE) 99 | public void delete(@PathVariable Long userId) { 100 | try { 101 | this.authorService.delete(userId); 102 | } catch (Exception e) { 103 | throw new RuntimeException("删除错误"); 104 | } 105 | } 106 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/jdbc/controller/AuthorController.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.jdbc.controller; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RequestBody; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import com.alibaba.fastjson.JSONObject; 17 | import com.lianggzone.springboot.action.data.jdbc.entity.Author; 18 | import com.lianggzone.springboot.action.data.jdbc.service.AuthorService; 19 | 20 | /** 21 | *

    概要:

    AuthorController

    22 | *

    功能:

    AuthorController

    23 | *

    履历:

    24 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 25 | * @author 粱桂钊 26 | * @since 0.1 27 | */ 28 | @RestController("jdbc.authorController") 29 | @RequestMapping(value = "/data/jdbc/author") 30 | public class AuthorController { 31 | @Autowired 32 | private AuthorService authorService; 33 | 34 | /** 35 | * 查询用户列表 36 | */ 37 | @RequestMapping(method = RequestMethod.GET) 38 | public Map getAuthorList(HttpServletRequest request) { 39 | List authorList = this.authorService.findAuthorList(); 40 | Map param = new HashMap(); 41 | param.put("total", authorList.size()); 42 | param.put("rows", authorList); 43 | return param; 44 | } 45 | 46 | /** 47 | * 查询用户信息 48 | */ 49 | @RequestMapping(value = "/{userId:\\d+}", method = RequestMethod.GET) 50 | public Author getAuthor(@PathVariable Long userId, HttpServletRequest request) { 51 | Author author = this.authorService.findAuthor(userId); 52 | if (author == null) { 53 | throw new RuntimeException("查询错误"); 54 | } 55 | return author; 56 | } 57 | 58 | /** 59 | * 新增方法 60 | */ 61 | @RequestMapping(method = RequestMethod.POST) 62 | public void add(@RequestBody JSONObject jsonObject) { 63 | String userId = jsonObject.getString("user_id"); 64 | String realName = jsonObject.getString("real_name"); 65 | String nickName = jsonObject.getString("nick_name"); 66 | Author author = new Author(); 67 | if (author != null) { 68 | author.setId(Long.valueOf(userId)); 69 | } 70 | author.setRealName(realName); 71 | author.setNickName(nickName); 72 | try { 73 | this.authorService.add(author); 74 | } catch (Exception e) { 75 | e.printStackTrace(); 76 | throw new RuntimeException("新增错误"); 77 | } 78 | } 79 | 80 | /** 81 | * 更新方法 82 | */ 83 | @RequestMapping(value = "/{userId:\\d+}", method = RequestMethod.PUT) 84 | public void update(@PathVariable Long userId, @RequestBody JSONObject jsonObject) { 85 | Author author = this.authorService.findAuthor(userId); 86 | String realName = jsonObject.getString("real_name"); 87 | String nickName = jsonObject.getString("nick_name"); 88 | author.setRealName(realName); 89 | author.setNickName(nickName); 90 | try { 91 | this.authorService.update(author); 92 | } catch (Exception e) { 93 | e.printStackTrace(); 94 | throw new RuntimeException("更新错误"); 95 | } 96 | } 97 | 98 | /** 99 | * 删除方法 100 | */ 101 | @RequestMapping(value = "/{userId:\\d+}", method = RequestMethod.DELETE) 102 | public void delete(@PathVariable Long userId) { 103 | try { 104 | this.authorService.delete(userId); 105 | } catch (Exception e) { 106 | throw new RuntimeException("删除错误"); 107 | } 108 | } 109 | } -------------------------------------------------------------------------------- /springboot-action-sample/src/main/java/com/lianggzone/springboot/action/data/mongodb/controller/AuthorController.java: -------------------------------------------------------------------------------- 1 | package com.lianggzone.springboot.action.data.mongodb.controller; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RequestBody; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import com.alibaba.fastjson.JSONObject; 17 | import com.lianggzone.springboot.action.data.mongodb.entity.Author; 18 | import com.lianggzone.springboot.action.data.mongodb.service.AuthorService; 19 | 20 | /** 21 | *

    概要:

    AuthorController

    22 | *

    功能:

    AuthorController

    23 | *

    履历:

    24 | *
  • 2016年12月13日 v0.1 版本内容: 新建
  • 25 | * @author 粱桂钊 26 | * @since 0.1 27 | */ 28 | @RestController("mongodb.authorController") 29 | @RequestMapping(value = "/data/mongodb/author") 30 | public class AuthorController { 31 | @Autowired 32 | private AuthorService authorService; 33 | 34 | /** 35 | * 查询用户列表 36 | */ 37 | @RequestMapping(method = RequestMethod.GET) 38 | public Map getAuthorList(HttpServletRequest request) { 39 | List authorList = this.authorService.findAuthorList(); 40 | Map param = new HashMap(); 41 | param.put("total", authorList.size()); 42 | param.put("rows", authorList); 43 | return param; 44 | } 45 | 46 | /** 47 | * 查询用户信息 48 | */ 49 | @RequestMapping(value = "/{userId:\\d+}", method = RequestMethod.GET) 50 | public Author getAuthor(@PathVariable Long userId, HttpServletRequest request) { 51 | Author author = this.authorService.findAuthor(userId); 52 | if (author == null) { 53 | throw new RuntimeException("查询错误"); 54 | } 55 | return author; 56 | } 57 | 58 | /** 59 | * 新增方法 60 | */ 61 | @RequestMapping(method = RequestMethod.POST) 62 | public void add(@RequestBody JSONObject jsonObject) { 63 | String userId = jsonObject.getString("user_id"); 64 | String realName = jsonObject.getString("real_name"); 65 | String nickName = jsonObject.getString("nick_name"); 66 | Author author = new Author(); 67 | if (author != null) { 68 | author.setId(Long.valueOf(userId)); 69 | } 70 | author.setRealName(realName); 71 | author.setNickName(nickName); 72 | try { 73 | this.authorService.add(author); 74 | } catch (Exception e) { 75 | e.printStackTrace(); 76 | throw new RuntimeException("新增错误"); 77 | } 78 | } 79 | 80 | /** 81 | * 更新方法 82 | */ 83 | @RequestMapping(value = "/{userId:\\d+}", method = RequestMethod.PUT) 84 | public void update(@PathVariable Long userId, @RequestBody JSONObject jsonObject) { 85 | Author author = this.authorService.findAuthor(userId); 86 | String realName = jsonObject.getString("real_name"); 87 | String nickName = jsonObject.getString("nick_name"); 88 | author.setRealName(realName); 89 | author.setNickName(nickName); 90 | try { 91 | this.authorService.update(author); 92 | } catch (Exception e) { 93 | e.printStackTrace(); 94 | throw new RuntimeException("更新错误"); 95 | } 96 | } 97 | 98 | /** 99 | * 删除方法 100 | */ 101 | @RequestMapping(value = "/{userId:\\d+}", method = RequestMethod.DELETE) 102 | public void delete(@PathVariable Long userId) { 103 | try { 104 | this.authorService.delete(userId); 105 | } catch (Exception e) { 106 | throw new RuntimeException("删除错误"); 107 | } 108 | } 109 | } -------------------------------------------------------------------------------- /springboot-action-web/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 1.3.3.RELEASE 9 | 10 | 11 | com.lianggzone.demo 12 | springboot-action-web 13 | 0.1 14 | war 15 | springboot-action-web 16 | 17 | 18 | 19 | lianggzone 20 | 梁桂钊 21 | lianggzone@163.com 22 | 23 | Architect 24 | Developer 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-web 39 | 40 | 41 | 56 | 57 | 58 | 59 | com.alibaba 60 | fastjson 61 | 1.2.6 62 | 63 | 64 | com.fasterxml.jackson.core 65 | jackson-databind 66 | 67 | 68 | com.google.guava 69 | guava 70 | 18.0 71 | 72 | 73 | org.apache.commons 74 | commons-lang3 75 | 3.3 76 | 77 | 78 | 79 | 80 | 81 | 82 | org.apache.maven.plugins 83 | maven-war-plugin 84 | 85 | springboot-web-demo 86 | 87 | 88 | 89 | org.apache.maven.plugins 90 | maven-compiler-plugin 91 | 92 | lib 93 | 1.7 94 | 1.7 95 | UTF-8 96 | 97 | 98 | 99 | org.apache.maven.plugins 100 | maven-resources-plugin 101 | 102 | UTF-8 103 | false 104 | \ 105 | 106 | ${*} 107 | 108 | 109 | 110 | 111 | org.springframework.boot 112 | spring-boot-maven-plugin 113 | 114 | 115 | 116 | src/main/filters/filter-${env}.properties 117 | 118 | 119 | 120 | src/main/filters/resources/${env} 121 | 122 | 123 | src/main/resources 124 | true 125 | 126 | 127 | 128 | 129 | 130 | development 131 | 132 | development 133 | 134 | 135 | true 136 | 137 | 138 | 139 | test 140 | 141 | test 142 | 143 | 144 | 145 | preproduction 146 | 147 | preproduction 148 | 149 | 150 | 151 | product 152 | 153 | product 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 本项目内容为 《Spring Boot 揭秘与实战》系列,汇总文集。如您觉得该项目对您有用,欢迎点击右上方的 Star 按钮,给予支持!! 4 | 5 | - 博客:http://blog.720ui.com 6 | - GitHub:https://github.com/lianggzone/springboot-action 7 | 8 |
    9 | 10 | ![](http://7xivgs.com1.z0.glb.clouddn.com/%E5%85%AC%E4%BC%97%E5%8F%B7%E6%8E%A8%E9%80%8102.png) 11 | 12 | ## 快速上手篇 13 | 14 | Spring Boot 揭秘与实战(一) 快速上手 15 | 16 | ## 数据存储篇 17 | 18 | Spring Boot 揭秘与实战(二) 数据存储篇 - MySQL 19 | 20 | Spring Boot 揭秘与实战(二) 数据存储篇 - 数据访问与多数据源配置 21 | 22 | Spring Boot 揭秘与实战(二) 数据存储篇 - MyBatis整合 23 | 24 | Spring Boot 揭秘与实战(二) 数据存储篇 - JPA整合 25 | 26 | Spring Boot 揭秘与实战(二) 数据存储篇 - Redis 27 | 28 | Spring Boot 揭秘与实战(二) 数据存储篇 - MongoDB 29 | 30 | Spring Boot 揭秘与实战(二) 数据存储篇 - ElasticSearch 31 | 32 | Spring Boot 揭秘与实战(二) 数据存储篇 - 声明式事务管理 33 | 34 | ## 数据缓存篇 35 | Spring Boot 揭秘与实战(二) 数据缓存篇 - 快速入门 36 | 37 | Spring Boot 揭秘与实战(二) 数据缓存篇 - EhCache 38 | 39 | Spring Boot 揭秘与实战(二) 数据缓存篇 - Guava Cache 40 | 41 | Spring Boot 揭秘与实战(二) 数据缓存篇 - Redis Cache 42 | 43 | ## 日志框架篇 44 | Spring Boot 揭秘与实战(三) 日志框架篇 - 如何快速集成日志系统 45 | 46 | ## 配置文件篇 47 | Spring Boot 揭秘与实战(四) 配置文件篇 - 有哪些很棒的特性 48 | 49 | ## 服务器篇 50 | Spring Boot 揭秘与实战(五) 服务器篇 - 内嵌的服务器 Tomcat剖析 51 | 52 | Spring Boot 揭秘与实战(五) 服务器篇 - Tomcat 代码配置 53 | 54 | Spring Boot 揭秘与实战(五) 服务器篇 - 其他内嵌服务器 55 | 56 | Spring Boot 揭秘与实战(五) 服务器篇 - Tomcat 启用 HTTPS 57 | 58 | ## 消息队列篇 59 | Spring Boot 揭秘与实战(六) 消息队列篇 - RabbitMQ 60 | 61 | 62 | ## 实用技术篇 63 | Spring Boot 揭秘与实战(七) 实用技术篇 - FreeMarker 模板引擎 64 | 65 | Spring Boot 揭秘与实战(七) 实用技术篇 - Java Mail 发送邮件 66 | 67 | Spring Boot 揭秘与实战(七) 实用技术篇 - 异步任务 68 | 69 | Spring Boot 揭秘与实战(七) 实用技术篇 - StateMachine 状态机机制 70 | 71 | ## 发布与部署 72 | Spring Boot 揭秘与实战(八) 发布与部署 - 开发热部署 73 | 74 | Spring Boot 揭秘与实战(八) 发布与部署 - 远程调试 75 | 76 | ## 应用监控篇 77 | Spring Boot 揭秘与实战(九) 应用监控篇 - HTTP 应用监控 78 | 79 | Spring Boot 揭秘与实战(九) 应用监控篇 - HTTP 健康监控 80 | 81 | Spring Boot 揭秘与实战(九) 应用监控篇 - 自定义监控端点 82 | 83 | 84 | ## 源码分析篇 85 | Spring Boot 揭秘与实战 源码分析 - 开箱即用,内藏玄机 86 | 87 | Spring Boot 揭秘与实战 源码分析 - 工作原理剖析 88 | 89 | Spring Boot 揭秘与实战 自己实现一个简单的自动配置模块 90 | 91 | ## 附录 92 | 93 | Spring Boot 揭秘与实战 附录 - Spring Boot 公共配置 94 | 95 | ## 文章汇总 96 | > 相关文章完整汇总 : [Spring Boot 揭秘与实战 系列](http://blog.720ui.com/columns/springboot_all/) 97 | 98 | ## 源代码 99 | 100 | > 相关示例完整代码 : [springboot-action](https://github.com/lianggzone/springboot-action.git) --------------------------------------------------------------------------------