├── .gitignore ├── .mvn └── wrapper │ └── maven-wrapper.properties ├── LICENSE ├── README.md ├── jeebiz-boot-sample-flowable-app └── pom.xml ├── jeebiz-boot-sample-flowable └── pom.xml ├── mvnw ├── mvnw.cmd ├── pom.xml ├── spring-boot-sample-axis2 └── pom.xml ├── spring-boot-sample-casclient └── pom.xml ├── spring-boot-sample-cxf └── pom.xml ├── spring-boot-sample-disruptor ├── pom.xml └── src │ ├── main │ ├── docker │ │ └── Dockerfile │ ├── java │ │ └── com │ │ │ └── lmax │ │ │ └── disruptor │ │ │ └── spring │ │ │ └── boot │ │ │ ├── DisruptorApplication.java │ │ │ ├── config │ │ │ └── DisruptorConfig.java │ │ │ └── handlers │ │ │ ├── EmailDisruptorHandler.java │ │ │ └── SmsDisruptorHandler.java │ └── resources │ │ ├── application.properties │ │ ├── application.yml │ │ └── log4j2.xml │ └── test │ └── java │ └── com │ └── lmax │ └── disruptor │ └── spring │ └── boot │ └── DisruptorApplicationTests.java ├── spring-boot-sample-druid-shiro ├── pom.xml ├── runenv │ ├── jeebiz-boot │ ├── setenv │ └── setenv.bat └── src │ └── main │ ├── java │ └── net │ │ └── jeebiz │ │ └── boot │ │ └── demo │ │ ├── DemoApplication.java │ │ ├── dao │ │ ├── IAuthzLoginDao.java │ │ ├── IDemoDao.java │ │ └── entities │ │ │ ├── AuthzLoginModel.java │ │ │ └── DemoModel.java │ │ ├── service │ │ ├── IAuthzLoginService.java │ │ ├── IDemoService.java │ │ └── impl │ │ │ ├── AuthzLoginServiceImpl.java │ │ │ ├── AuthzPrincipalRepositoryImpl.java │ │ │ └── DemoServiceImpl.java │ │ ├── setup │ │ ├── config │ │ │ ├── BootWebMvcConfig.java │ │ │ ├── DataSourceConfig.java │ │ │ ├── MybatisPlusConfig.java │ │ │ └── ShiroConfig.java │ │ ├── data │ │ │ └── LogConstant.java │ │ └── shiro │ │ │ └── LoginAuthorizingRealm.java │ │ └── web │ │ ├── mvc │ │ ├── AuthzLoginController.java │ │ ├── DemoController.java │ │ └── IndexController.java │ │ └── vo │ │ └── DemoVo.java │ └── resources │ ├── application.properties │ ├── application.yml │ ├── banner.txt │ ├── conf │ ├── ehcache │ │ ├── ehcache-metrics.xml │ │ └── ehcache.xml │ ├── log4j2-dev.xml │ ├── log4j2.xml │ ├── mybatis │ │ └── sqlMapConfig.xml │ └── security │ │ └── jeebiz-antixss-policy.xml │ ├── db │ └── migration │ │ ├── mysql │ │ ├── V1_0_0__初始化.sql │ │ └── V1_0_1__升级.sql │ │ └── oracle │ │ ├── V1_0_0__初始化.sql │ │ └── V1_0_1__升级.sql │ ├── i18n │ ├── messages.properties │ ├── messages_en_US.properties │ └── messages_zh_CN.properties │ ├── net │ └── jeebiz │ │ └── boot │ │ └── demo │ │ └── dao │ │ └── sqlmap │ │ ├── mysql │ │ ├── AuthzLoginMapper.xml │ │ └── DemoMapper.xml │ │ └── oracle │ │ ├── AuthzLoginMapper.xml │ │ └── DemoMapper.xml │ └── templates │ └── html │ ├── demo │ ├── edit-demo.html │ ├── index.html │ └── new-demo.html │ ├── footer.html │ └── index.html ├── spring-boot-sample-druid ├── pom.xml └── src │ ├── main │ ├── docker │ │ └── Dockerfile │ ├── java │ │ └── com │ │ │ └── alibaba │ │ │ └── druid │ │ │ └── spring │ │ │ └── boot │ │ │ ├── DruidApplication.java │ │ │ ├── dao │ │ │ ├── daointerface │ │ │ │ └── IUuidDao.java │ │ │ └── impl │ │ │ │ └── UuidDaoImpl.java │ │ │ ├── service │ │ │ ├── impl │ │ │ │ └── IUuidServiceImpl.java │ │ │ └── svcinterface │ │ │ │ └── IUuidService.java │ │ │ └── web │ │ │ └── controller │ │ │ └── HelloWorldController.java │ └── resources │ │ ├── application.properties │ │ ├── application.yml │ │ └── log4j2.xml │ └── test │ └── java │ └── com │ └── alibaba │ └── druid │ └── spring │ └── boot │ └── DruidApplicationTests.java ├── spring-boot-sample-ehcache3 ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── ehcache │ │ └── spring │ │ └── boot │ │ └── Ehcache3Application.java │ └── resources │ ├── application.yml │ └── log4j2.xml ├── spring-boot-sample-flyway ├── pom.xml └── src │ ├── main │ ├── docker │ │ └── Dockerfile │ ├── java │ │ └── org │ │ │ └── mybatis │ │ │ └── spring │ │ │ └── boot │ │ │ ├── MybatisApplication.java │ │ │ ├── dao │ │ │ └── daointerface │ │ │ │ └── IUuidDao.java │ │ │ ├── service │ │ │ ├── impl │ │ │ │ └── IUuidServiceImpl.java │ │ │ └── svcinterface │ │ │ │ └── IUuidService.java │ │ │ └── web │ │ │ └── controller │ │ │ └── HelloWorldController.java │ └── resources │ │ ├── application.yml │ │ ├── conf │ │ └── mybatis │ │ │ └── sqlMapConfig.xml │ │ └── log4j2.xml │ └── test │ └── java │ └── org │ └── mybatis │ └── spring │ └── boot │ └── MybatisApplicationTests.java ├── spring-boot-sample-hikaricp-shiro ├── pom.xml ├── runenv │ ├── jeebiz-boot │ ├── setenv │ └── setenv.bat └── src │ └── main │ ├── docker │ └── Dockerfile │ ├── java │ └── net │ │ └── jeebiz │ │ └── boot │ │ └── demo │ │ ├── DemoApplication.java │ │ ├── dao │ │ ├── IAuthzLoginDao.java │ │ ├── IDemoDao.java │ │ └── entities │ │ │ ├── AuthzLoginModel.java │ │ │ └── DemoModel.java │ │ ├── service │ │ ├── IAuthzLoginService.java │ │ ├── IDemoService.java │ │ └── impl │ │ │ ├── AuthzLoginServiceImpl.java │ │ │ ├── AuthzPrincipalRepositoryImpl.java │ │ │ └── DemoServiceImpl.java │ │ ├── setup │ │ ├── config │ │ │ ├── BootWebMvcConfig.java │ │ │ ├── DataSourceConfig.java │ │ │ ├── MybatisPlusConfig.java │ │ │ └── ShiroConfig.java │ │ ├── data │ │ │ └── LogConstant.java │ │ └── shiro │ │ │ └── LoginAuthorizingRealm.java │ │ └── web │ │ ├── mvc │ │ ├── AuthzLoginController.java │ │ ├── DemoController.java │ │ └── IndexController.java │ │ └── vo │ │ └── DemoVo.java │ └── resources │ ├── application.properties │ ├── application.yml │ ├── banner.txt │ ├── conf │ ├── ehcache │ │ ├── ehcache-metrics.xml │ │ └── ehcache.xml │ ├── log4j2-dev.xml │ ├── log4j2.xml │ ├── mybatis │ │ └── sqlMapConfig.xml │ └── security │ │ └── jeebiz-antixss-policy.xml │ ├── db │ └── migration │ │ ├── mysql │ │ ├── V1_0_0_10__初始化.sql │ │ └── V1_0_0_11__升级.sql │ │ └── oracle │ │ ├── V1_0_0_10__初始化.sql │ │ └── V1_0_0_11__升级.sql │ ├── i18n │ ├── messages.properties │ ├── messages_en_US.properties │ └── messages_zh_CN.properties │ ├── net │ └── jeebiz │ │ └── boot │ │ └── demo │ │ └── dao │ │ └── sqlmap │ │ ├── mysql │ │ ├── AuthzLoginMapper.xml │ │ └── DemoMapper.xml │ │ └── oracle │ │ ├── AuthzLoginMapper.xml │ │ └── DemoMapper.xml │ └── templates │ └── html │ ├── demo │ ├── edit-demo.html │ ├── index.html │ └── new-demo.html │ ├── footer.html │ └── index.html ├── spring-boot-sample-hikaricp ├── pom.xml └── src │ └── main │ ├── docker │ └── Dockerfile │ ├── java │ └── com │ │ └── zaxxer │ │ └── hikari │ │ └── spring │ │ └── boot │ │ └── HikariCPApplication.java │ └── resources │ ├── application.properties │ ├── application.yml │ └── log4j2.xml ├── spring-boot-sample-jetbrick ├── pom.xml └── src │ ├── main │ └── resources │ │ └── application.yml │ └── test │ └── resources │ └── application.yml ├── spring-boot-sample-kaptcha ├── pom.xml └── src │ └── main │ ├── docker │ └── Dockerfile │ ├── java │ └── com │ │ └── google │ │ └── code │ │ └── kaptcha │ │ └── spring │ │ └── boot │ │ └── KaptchaApplication.java │ └── resources │ ├── application.yml │ └── log4j2.xml ├── spring-boot-sample-log4j2 ├── pom.xml └── src │ └── main │ ├── docker │ └── Dockerfile │ ├── java │ └── org │ │ └── apache │ │ └── logging │ │ └── log4j │ │ └── spring │ │ └── boot │ │ └── Log4j2Application.java │ └── resources │ ├── application.yml │ └── log4j2.xml ├── spring-boot-sample-pf4j ├── pf4j-plugin-sample │ ├── README.md │ ├── pf4j-plugin-api │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── pf4j │ │ │ └── plugin │ │ │ └── api │ │ │ ├── AuthcExtensionPoint.java │ │ │ ├── AuthcExtensionPointAdepter.java │ │ │ ├── annotation │ │ │ ├── ApiExtensionMapping.java │ │ │ ├── ExtensionMapping.java │ │ │ └── PluginMapping.java │ │ │ └── exception │ │ │ └── PluginInvokeException.java │ ├── pf4j-plugin-impl1 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── assembly │ │ │ └── assembly.xml │ │ │ └── java │ │ │ └── pf4j │ │ │ └── plugin │ │ │ └── impl │ │ │ ├── AuthcPluginImpl1.java │ │ │ ├── extensions │ │ │ └── AuthcExtensionPointImpl1.java │ │ │ └── utils │ │ │ └── Constant.java │ ├── pf4j-plugin-impl2 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── assembly │ │ │ └── assembly.xml │ │ │ └── java │ │ │ └── pf4j │ │ │ └── plugin │ │ │ └── impl │ │ │ ├── AuthcPluginImpl2.java │ │ │ ├── extensions │ │ │ └── AuthcExtensionPointImpl2.java │ │ │ └── utils │ │ │ └── Constant.java │ ├── pf4j-plugin-test │ │ ├── plugins │ │ │ └── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── pf4j │ │ │ │ └── plugin │ │ │ │ └── test │ │ │ │ └── AuthcPluginTest.java │ │ │ └── resources │ │ │ ├── README.md │ │ │ ├── log4j-参数意义说明.properties │ │ │ └── log4j.properties │ └── pom.xml ├── plugins │ └── README.md ├── pom.xml └── src │ └── main │ ├── docker │ └── Dockerfile │ ├── java │ └── ro │ │ └── fortsoft │ │ └── pf4j │ │ └── spring │ │ └── boot │ │ └── Pf4jApplication.java │ └── resources │ ├── application.yml │ └── log4j2.xml ├── spring-boot-sample-pf4j2 ├── pf4j2-plugin-sample │ ├── README.md │ ├── pf4j2-plugin-api │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── pf4j2 │ │ │ └── plugin │ │ │ └── api │ │ │ ├── AuthcExtensionPoint.java │ │ │ ├── AuthcExtensionPointAdepter.java │ │ │ ├── annotation │ │ │ ├── ApiExtensionMapping.java │ │ │ ├── ExtensionMapping.java │ │ │ └── PluginMapping.java │ │ │ └── exception │ │ │ └── PluginInvokeException.java │ ├── pf4j2-plugin-impl1 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── assembly │ │ │ └── assembly.xml │ │ │ └── java │ │ │ └── pf4j2 │ │ │ └── plugin │ │ │ └── impl │ │ │ ├── AuthcPluginImpl1.java │ │ │ ├── extensions │ │ │ └── AuthcExtensionPointImpl1.java │ │ │ └── utils │ │ │ └── Constant.java │ ├── pf4j2-plugin-impl2 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── assembly │ │ │ └── assembly.xml │ │ │ └── java │ │ │ └── pf4j2 │ │ │ └── plugin │ │ │ └── impl │ │ │ ├── AuthcPluginImpl2.java │ │ │ ├── extensions │ │ │ └── AuthcExtensionPointImpl2.java │ │ │ └── utils │ │ │ └── Constant.java │ ├── pf4j2-plugin-test │ │ ├── plugins │ │ │ └── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── pf4j2 │ │ │ │ └── plugin │ │ │ │ └── test │ │ │ │ └── AuthcPluginTest.java │ │ │ └── resources │ │ │ ├── README.md │ │ │ ├── log4j-参数意义说明.properties │ │ │ └── log4j.properties │ └── pom.xml ├── plugins │ └── README.md ├── pom.xml └── src │ └── main │ ├── docker │ └── Dockerfile │ ├── java │ └── org │ │ └── pf4j │ │ └── spring │ │ └── boot │ │ └── Pf4jApplication.java │ └── resources │ ├── application.yml │ └── log4j2.xml ├── spring-boot-sample-rocketmq ├── pom.xml └── src │ ├── main │ ├── docker │ │ └── Dockerfile │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── rocketmq │ │ │ └── spring │ │ │ └── boot │ │ │ ├── RocketmqApplication.java │ │ │ ├── consumer │ │ │ └── pull │ │ │ │ ├── PullMessageQueueListener.java │ │ │ │ └── PullTaskCallbackImpl.java │ │ │ ├── event │ │ │ └── listener │ │ │ │ └── ConsumerListen.java │ │ │ ├── setup │ │ │ ├── LogProducer.java │ │ │ ├── Producer.java │ │ │ ├── QueueName.java │ │ │ ├── RocketmqDataInDbHandler.java │ │ │ └── RocketmqDataSmsHandler.java │ │ │ └── web │ │ │ └── controller │ │ │ ├── ProducerController.java │ │ │ ├── RocketMQController.java │ │ │ └── UserController.java │ └── resources │ │ ├── application.properties │ │ ├── application.yml │ │ └── log4j2.xml │ └── test │ └── java │ └── org │ └── apache │ └── rocketmq │ └── spring │ └── boot │ ├── RocketmqApplicationTests.java │ ├── org │ ├── BatchProducer.java │ ├── BroadcastConsumer.java │ ├── BroadcastProducer.java │ ├── ListSplitter.java │ ├── OrderedConsumer.java │ ├── OrderedProducer.java │ ├── ScheduledMessageConsumer.java │ ├── ScheduledMessageProducer.java │ ├── SimpleAsyncProducer.java │ ├── SimpleOnewayProducer.java │ └── SimpleSyncProducer.java │ └── quick-start.md ├── spring-boot-sample-sharding-jdbc └── pom.xml ├── spring-boot-sample-socketio ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── corundumstudio │ │ └── socketio │ │ └── spring │ │ └── boot │ │ ├── SocketioApplication.java │ │ ├── SocketioIndeController.java │ │ ├── config │ │ └── SocketioConfig.java │ │ ├── handler │ │ ├── MessageInfo.java │ │ └── SocketEventHandler.java │ │ └── listener │ │ ├── SocketConnectListener.java │ │ ├── SocketDataListener.java │ │ ├── SocketDisconnectListener.java │ │ ├── SocketExceptionListener.java │ │ └── SocketPingListener.java │ └── resources │ ├── application.yml │ ├── log4j2.xml │ └── templates │ └── html │ └── socketio │ ├── index.html │ └── tmp.js ├── spring-boot-sample-swagger2 ├── pom.xml └── src │ ├── main │ ├── docker │ │ └── Dockerfile │ ├── java │ │ └── io │ │ │ └── swagger2 │ │ │ └── spring │ │ │ └── boot │ │ │ ├── SwaggerApplication.java │ │ │ ├── dao │ │ │ ├── Result.java │ │ │ └── UserDto.java │ │ │ ├── setup │ │ │ └── config │ │ │ │ └── HttpStatus.java │ │ │ └── web │ │ │ └── controller │ │ │ ├── HelloWorldController.java │ │ │ └── UserController.java │ └── resources │ │ ├── application.yml │ │ └── log4j2.xml │ └── test │ └── java │ └── swagger2 │ └── spring │ └── boot │ └── DemoApplicationTests.java └── spring-boot-sample-websocket ├── pom.xml └── src └── main ├── java └── com │ └── github │ └── vindell │ └── websocket │ ├── HandshakeInterceptor.java │ ├── Monitor.java │ ├── WebSocketConfig.java │ ├── WebSocketHandshakeInterceptor.java │ ├── WebSocketTest.java │ ├── config │ ├── DefaultWebSocketBrokerConfig.java │ ├── DefaultWebSocketConfig.java │ └── WebSocketConfig.java │ ├── handler │ ├── ChatWebSocketHandler.java │ └── WebsocketEndPoint.java │ └── sd.java └── resources ├── static └── assets │ └── js │ ├── sockjs-pull-demo.js │ ├── sockjs-push-demo.js │ └── sockjs-stomp-demo.js └── templates └── html └── sockets ├── echo.ftl ├── index.ftl ├── reverse.ftl ├── snake.ftl ├── test.ftl ├── test2.ftl └── test3.ftl /.gitignore: -------------------------------------------------------------------------------- 1 | *# 2 | *.iml 3 | *.ipr 4 | *.iws 5 | *.jar 6 | *.sw? 7 | *~ 8 | .#* 9 | .*.md.html 10 | .apt_generated 11 | .DS_Store 12 | .classpath 13 | .factorypath 14 | .gradle 15 | .idea 16 | .metadata 17 | .project 18 | .recommenders 19 | .settings 20 | .springBeans 21 | .sts4-cache 22 | /build 23 | /code 24 | MANIFEST.MF 25 | _site/ 26 | activemq-data 27 | bin 28 | build 29 | build.log 30 | dependency-reduced-pom.xml 31 | dump.rdb 32 | interpolated*.xml 33 | lib/ 34 | manifest.yml 35 | overridedb.* 36 | settings.xml 37 | target 38 | transaction-logs 39 | .flattened-pom.xml 40 | secrets.yml 41 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spring-boot-starter-samples 2 | spring-boot-starter-samples 3 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 10 | 11 | net.jeebiz 12 | jeebiz-boot-parent 13 | 1.0.2-SNAPSHOT 14 | 15 | 16 | 17 | com.github.hiwepy 18 | spring-boot-starter-samples 19 | 1.0.0-SNAPSHOT 20 | 21 | pom 22 | Spring Boot Starter Samples 23 | Spring Boot Starter Samples 24 | 25 | 26 | spring-boot-sample-axis2 27 | spring-boot-sample-casclient 28 | spring-boot-sample-cxf 29 | spring-boot-sample-disruptor 30 | spring-boot-sample-druid 31 | spring-boot-sample-ehcache3 32 | spring-boot-sample-flyway 33 | spring-boot-sample-hikaricp 34 | spring-boot-sample-jetbrick 35 | spring-boot-sample-kaptcha 36 | spring-boot-sample-log4j2 37 | spring-boot-sample-pf4j 38 | spring-boot-sample-rocketmq 39 | spring-boot-sample-swagger2 40 | spring-boot-sample-websocket 41 | spring-boot-sample-sharding-jdbc 42 | spring-boot-sample-pf4j2 43 | spring-boot-sample-socketio 44 | 45 | 46 | -------------------------------------------------------------------------------- /spring-boot-sample-axis2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.github.hiwepy 8 | spring-boot-starter-samples 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | spring-boot-sample-axis2 13 | Spring Boot Axis2 Sample 14 | Spring Boot Axis2 Sample 15 | 16 | 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-logging 26 | 27 | 28 | 29 | 30 | com.github.hiwepy 31 | spring-boot-starter-axis2 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-web 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-maven-plugin 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /spring-boot-sample-casclient/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | 8 | com.github.hiwepy 9 | spring-boot-starter-samples 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | spring-boot-sample-casclient 14 | Spring Boot CasClient Sample 15 | Spring Boot CasClient Sample 16 | 17 | 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-logging 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | com.github.hiwepy 43 | spring-boot-starter-casclient 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-maven-plugin 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /spring-boot-sample-cxf/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | 8 | com.github.hiwepy 9 | spring-boot-starter-samples 10 | 1.0.0-SNAPSHOT 11 | 12 | 13 | spring-boot-sample-cxf 14 | Spring Boot Cxf Sample 15 | Spring Boot Cxf Sample 16 | 17 | 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-logging 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-web 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | com.github.hiwepy 43 | spring-boot-starter-cxf-jaxws-plus 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-maven-plugin 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /spring-boot-sample-disruptor/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.71.33.155/zfsoft/openjdk:1.8 2 | ENV LC_ALL en_US.UTF-8 3 | ENV TZ 'Asia/Shanghai' 4 | 5 | #创建日志目录和临时目录 6 | RUN mkdir -p /u01/boot/{logs,tmp} 7 | 8 | #拷贝本地文件到指定目录 9 | ADD /lib $BOOT/lib 10 | ADD /conf $BOOT/conf 11 | 12 | #ENV JAVA_HOME /opt/jdk 13 | #ENV PATH $PATH:$JAVA_HOME/bin 14 | 15 | EXPOSE 8081 16 | CMD ["java", "-classpath", "/u01/boot/conf:/u01/boot/lib/zftal-boot-datay.jar", "org.springframework.boot.loader.JarLauncher"] 17 | -------------------------------------------------------------------------------- /spring-boot-sample-disruptor/src/main/java/com/lmax/disruptor/spring/boot/DisruptorApplication.java: -------------------------------------------------------------------------------- 1 | package com.lmax.disruptor.spring.boot; 2 | 3 | import org.springframework.boot.ApplicationArguments; 4 | import org.springframework.boot.ApplicationRunner; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.scheduling.annotation.EnableScheduling; 11 | 12 | @Configuration // 配置控制 13 | @EnableScheduling 14 | @EnableAutoConfiguration // 启用自动配置 15 | @SpringBootApplication 16 | public class DisruptorApplication implements ApplicationRunner, CommandLineRunner { 17 | 18 | public static void main(String[] args) throws Exception { 19 | SpringApplication.run(DisruptorApplication.class, args); 20 | } 21 | 22 | @Override 23 | public void run(ApplicationArguments args) throws Exception { 24 | 25 | } 26 | 27 | @Override 28 | public void run(String... args) throws Exception { 29 | 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /spring-boot-sample-disruptor/src/main/java/com/lmax/disruptor/spring/boot/handlers/EmailDisruptorHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.lmax.disruptor.spring.boot.handlers; 17 | 18 | import org.springframework.stereotype.Component; 19 | 20 | import com.lmax.disruptor.spring.boot.annotation.EventRule; 21 | import com.lmax.disruptor.spring.boot.event.DisruptorBindEvent; 22 | import com.lmax.disruptor.spring.boot.event.handler.DisruptorHandler; 23 | import com.lmax.disruptor.spring.boot.event.handler.chain.HandlerChain; 24 | 25 | @EventRule("/Event-Output/TagA-Output/**") 26 | @Component("emailHandler") 27 | public class EmailDisruptorHandler implements DisruptorHandler { 28 | 29 | @Override 30 | public void doHandler(DisruptorBindEvent event, HandlerChain handlerChain) throws Exception { 31 | System.out.println(event.toString()); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-sample-disruptor/src/main/java/com/lmax/disruptor/spring/boot/handlers/SmsDisruptorHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.lmax.disruptor.spring.boot.handlers; 17 | 18 | import org.springframework.stereotype.Component; 19 | 20 | import com.lmax.disruptor.spring.boot.annotation.EventRule; 21 | import com.lmax.disruptor.spring.boot.event.DisruptorBindEvent; 22 | import com.lmax.disruptor.spring.boot.event.handler.DisruptorHandler; 23 | import com.lmax.disruptor.spring.boot.event.handler.chain.HandlerChain; 24 | 25 | @EventRule("/Event-Output/TagB-Output/**") 26 | @Component("smsHandler") 27 | public class SmsDisruptorHandler implements DisruptorHandler { 28 | 29 | @Override 30 | public void doHandler(DisruptorBindEvent event, HandlerChain handlerChain) throws Exception { 31 | System.out.println(event.toString()); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-sample-disruptor/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-disruptor/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-sample-disruptor/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8085 3 | 4 | spring: 5 | output: 6 | ansi: 7 | enabled: always 8 | messages: 9 | basename: /i18n/message 10 | profiles: 11 | active: dev 12 | 13 | ################################################################################################################ 14 | ###Disruptor (DisruptorProperties) 基本配置: 15 | ################################################################################################################ 16 | disruptor: 17 | enabled: true 18 | multi-producer: false 19 | ring-buffer-size: 1024 20 | ring-thread-numbers: 4 21 | #handler-definitions: 22 | # - /Event-DC-Output/TagA-Output/** = emailHandler 23 | # - /Event-DC-Output/TagB-Output/** = smsHandler 24 | 25 | #日志级别 26 | logging: 27 | config: classpath:log4j2.xml 28 | -------------------------------------------------------------------------------- /spring-boot-sample-disruptor/src/test/java/com/lmax/disruptor/spring/boot/DisruptorApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.lmax.disruptor.spring.boot; 2 | import org.junit.Test; 3 | import org.junit.runner.RunWith; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | import org.springframework.test.context.junit4.SpringRunner; 6 | 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 10 | public class DisruptorApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/runenv/jeebiz-boot: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #chkconfig: 2345 80 90 3 | #description:jeebiz-boot-app server 4 | #processname:jeebiz-boot-app 5 | 6 | #source function library 7 | #. /etc/rc.d/init.d/functions 8 | 9 | #application home 10 | export APP_HOME=/u01/jeebiz-boot-app 11 | 12 | #Document the app path 13 | echo document the curren path: "$APP_HOME" 14 | 15 | #Java environment 16 | #export JAVA_HOME="$APP_HOME/jre" 17 | #export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$CLASSPATH 18 | #export PATH=$JAVA_HOME/bin:$PATH 19 | 20 | start() 21 | { 22 | echo -n $"Starting $prog:" 23 | $APP_HOME/bin/jeebiz-boot.sh & 24 | } 25 | 26 | stop() 27 | { 28 | echo -n $"Stopping $prog:" 29 | pid=$(ps x | grep jeebiz-boot-app | grep -v grep | awk '{print $1}') 30 | echo pid = "$pid" 31 | kill -9 $pid 32 | 33 | } 34 | 35 | case "$1" in 36 | start) 37 | start 38 | ;; 39 | stop) 40 | stop 41 | ;; 42 | *) 43 | echo $"Usage: $0 {start|stop}" 44 | RETVAL=1 45 | esac 46 | exit $RETVAL -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/runenv/setenv: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -r "$BASEDIR/jre" ]; 3 | then 4 | #Java environment 5 | export JAVA_HOME=$BASEDIR/jre 6 | export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$CLASSPATH 7 | export PATH=$JAVA_HOME/bin:$PATH 8 | echo "JAVA_HOME $JAVA_HOME" 9 | echo "CLASSPATH $CLASSPATH" 10 | else 11 | echo "JAVA_HOME $JAVA_HOME" 12 | echo "CLASSPATH $CLASSPATH" 13 | fi 14 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/runenv/setenv.bat: -------------------------------------------------------------------------------- 1 | :: 关闭终端回显 2 | @echo off 3 | setlocal enabledelayedexpansion 4 | 5 | if exist "%BASEDIR%\jre" goto setenv 6 | echo JAVA_HOME %JAVA_HOME% 7 | echo CLASSPATH %CLASSPATH% 8 | goto end 9 | 10 | :: Set Java environment 11 | :setenv 12 | SET "JAVA_HOME=%BASEDIR%\jre" 13 | SET "CLASSPATH=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar;" 14 | SET "Path=%JAVA_HOME%\bin;%path%" 15 | echo JAVA_HOME %JAVA_HOME% 16 | echo CLASSPATH %CLASSPATH% 17 | goto end 18 | 19 | :end 20 | exit /b 0 -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/java/net/jeebiz/boot/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package net.jeebiz.boot.demo; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import org.dozer.spring.boot.EnableDozerMapper; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | import org.springframework.cache.annotation.EnableCaching; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.jdbc.datasource.DataSourceTransactionManager; 13 | import org.springframework.scheduling.annotation.EnableScheduling; 14 | import org.springframework.transaction.PlatformTransactionManager; 15 | import org.springframework.transaction.annotation.EnableTransactionManagement; 16 | 17 | import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; 18 | import com.spring4all.swagger.EnableSwagger2Doc; 19 | 20 | import net.jeebiz.boot.autoconfigure.EnableServiceConfiguration; 21 | import net.jeebiz.boot.autoconfigure.EnableWebMvcConfiguration; 22 | 23 | // 这里特别注意排除Druid的默认初始化对象 24 | @EnableAutoConfiguration(exclude={DruidDataSourceAutoConfigure.class}) 25 | @EnableCaching(proxyTargetClass = true) 26 | @EnableSwagger2Doc 27 | @EnableDozerMapper 28 | @EnableScheduling 29 | @EnableServiceConfiguration 30 | @EnableWebMvcConfiguration 31 | @EnableTransactionManagement 32 | @SpringBootApplication 33 | public class DemoApplication implements CommandLineRunner { 34 | 35 | // 其中 dataSource 框架会自动为我们注入 36 | @Bean 37 | public PlatformTransactionManager txManager(DataSource dataSource) { 38 | return new DataSourceTransactionManager(dataSource); 39 | } 40 | 41 | public static void main(String[] args) throws Exception { 42 | SpringApplication.run(DemoApplication.class, args); 43 | } 44 | 45 | @Override 46 | public void run(String... args) throws Exception { 47 | System.err.println("Spring Boot Application(Jeebiz-Demo) Started !"); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/java/net/jeebiz/boot/demo/dao/IAuthzLoginDao.java: -------------------------------------------------------------------------------- 1 | package net.jeebiz.boot.demo.dao; 2 | 3 | import java.util.Map; 4 | 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import net.jeebiz.boot.api.dao.BaseDao; 9 | import net.jeebiz.boot.demo.dao.entities.AuthzLoginModel; 10 | 11 | /** 12 | * 登录查询Dao 13 | * 14 | * @author hiwepy 15 | */ 16 | @Mapper 17 | public interface IAuthzLoginDao extends BaseDao { 18 | 19 | /** 20 | * 根据用户ID和密码查询用户可否登录,角色数量等信息 21 | * @param username : 用户名 22 | * @param password : 密码,可不填 23 | * @return 用户账号状态信息 24 | */ 25 | public Map getAccountStatus(@Param(value = "username") String username, 26 | @Param(value = "password") String password); 27 | 28 | /*** 29 | * 根据用户ID和密码查询用户信息 30 | * @param username : 用户名 31 | * @param password : 密码,可不填 32 | * @return 用户登录信息 33 | */ 34 | public AuthzLoginModel getAccount(@Param(value = "username") String username, 35 | @Param(value = "password") String password); 36 | 37 | /*** 38 | * 根据用户ID无密码查询用户信息;用于单点登录 39 | * @param username : 用户名 40 | * @return 用户登录信息 41 | */ 42 | public AuthzLoginModel getAccountWithoutPwd(@Param(value = "username") String username); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/java/net/jeebiz/boot/demo/dao/IDemoDao.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.dao; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | import org.apache.ibatis.annotations.Mapper; 11 | 12 | import net.jeebiz.boot.api.dao.BaseDao; 13 | import net.jeebiz.boot.demo.dao.entities.DemoModel; 14 | 15 | @Mapper 16 | public interface IDemoDao extends BaseDao{ 17 | 18 | /** 19 | * 获取指定ID关联的信息,以便进行删除前的逻辑检查 20 | * @param list 21 | * @return 22 | */ 23 | List> getDependencies(List list); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/java/net/jeebiz/boot/demo/dao/entities/DemoModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.dao.entities; 6 | 7 | import net.jeebiz.boot.api.dao.entities.BaseModel; 8 | 9 | public class DemoModel extends BaseModel{ 10 | 11 | private static final long serialVersionUID = 6189820231775242317L; 12 | 13 | private String id; 14 | 15 | private String name; 16 | 17 | private String text; 18 | 19 | public String getId() { 20 | return id; 21 | } 22 | 23 | public void setId(String id) { 24 | this.id = id; 25 | } 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | 35 | public String getText() { 36 | return text; 37 | } 38 | 39 | public void setText(String text) { 40 | this.text = text; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/java/net/jeebiz/boot/demo/service/IAuthzLoginService.java: -------------------------------------------------------------------------------- 1 | package net.jeebiz.boot.demo.service; 2 | 3 | import java.security.GeneralSecurityException; 4 | import java.security.interfaces.RSAPublicKey; 5 | import java.util.Map; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | import net.jeebiz.boot.api.service.BaseService; 10 | import net.jeebiz.boot.demo.dao.entities.AuthzLoginModel; 11 | 12 | public interface IAuthzLoginService extends BaseService{ 13 | 14 | RSAPublicKey genPublicKey(HttpServletRequest request) throws GeneralSecurityException; 15 | 16 | /** 17 | * 根据用户ID和密码查询用户可否登录,角色数量等信息 18 | * @param username : 用户名 19 | * @param password : 密码,可不填 20 | * @return 用户账号状态信息 21 | */ 22 | Map getAccountStatus(String username, String password); 23 | 24 | /*** 25 | * 根据用户ID和密码查询用户信息 26 | * @param username : 用户名 27 | * @param password : 密码,可不填 28 | * @return 用户登录信息 29 | */ 30 | AuthzLoginModel getAccount(String username, String password); 31 | 32 | /*** 33 | * 根据用户ID无密码查询用户信息;用于单点登录 34 | * @param username : 用户名 35 | * @return 用户登录信息 36 | */ 37 | AuthzLoginModel getAccountWithoutPwd(String username); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/java/net/jeebiz/boot/demo/service/IDemoService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.service; 6 | 7 | import net.jeebiz.boot.api.service.BaseService; 8 | import net.jeebiz.boot.demo.dao.entities.DemoModel; 9 | 10 | public interface IDemoService extends BaseService{ 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/java/net/jeebiz/boot/demo/service/impl/AuthzLoginServiceImpl.java: -------------------------------------------------------------------------------- 1 | package net.jeebiz.boot.demo.service.impl; 2 | 3 | 4 | import java.security.GeneralSecurityException; 5 | import java.security.interfaces.RSAPublicKey; 6 | import java.util.Map; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | 10 | import org.springframework.stereotype.Service; 11 | 12 | import net.jeebiz.boot.api.service.BaseServiceImpl; 13 | import net.jeebiz.boot.demo.dao.IAuthzLoginDao; 14 | import net.jeebiz.boot.demo.dao.entities.AuthzLoginModel; 15 | import net.jeebiz.boot.demo.service.IAuthzLoginService; 16 | 17 | @Service 18 | public class AuthzLoginServiceImpl extends BaseServiceImpl 19 | implements IAuthzLoginService { 20 | 21 | public static final String PRIVATE_KEY_ATTRIBUTE_NAME = "privateKey"; 22 | 23 | @Override 24 | public Map getAccountStatus(String username, String password) { 25 | return getDao().getAccountStatus(username, password); 26 | } 27 | 28 | @Override 29 | public AuthzLoginModel getAccount(String username, String password) { 30 | return getDao().getAccount(username, password); 31 | } 32 | 33 | @Override 34 | public AuthzLoginModel getAccountWithoutPwd(String username) { 35 | return getDao().getAccountWithoutPwd(username); 36 | } 37 | 38 | @Override 39 | public RSAPublicKey genPublicKey(HttpServletRequest request) throws GeneralSecurityException { 40 | 41 | /*KeyPair keyPair = SecretKeyUtils.genKeyPair("RSA"); 42 | RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); 43 | RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); 44 | 45 | SubjectUtils.getSession().setAttribute(PRIVATE_KEY_ATTRIBUTE_NAME, privateKey); 46 | 47 | return publicKey;*/ 48 | 49 | return null; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/java/net/jeebiz/boot/demo/service/impl/DemoServiceImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.service.impl; 6 | 7 | import org.springframework.stereotype.Service; 8 | 9 | import net.jeebiz.boot.api.service.BaseServiceImpl; 10 | import net.jeebiz.boot.demo.dao.IDemoDao; 11 | import net.jeebiz.boot.demo.dao.entities.DemoModel; 12 | import net.jeebiz.boot.demo.service.IDemoService; 13 | 14 | @Service 15 | public class DemoServiceImpl extends BaseServiceImpl implements IDemoService{ 16 | 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/java/net/jeebiz/boot/demo/setup/config/BootWebMvcConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.setup.config; 6 | 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 9 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 10 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 11 | import org.springframework.web.servlet.resource.PathResourceResolver; 12 | import org.springframework.web.servlet.resource.WebJarsResourceResolver; 13 | 14 | @Configuration 15 | @EnableWebMvc 16 | public class BootWebMvcConfig implements WebMvcConfigurer { 17 | 18 | 19 | @Override 20 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 21 | registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/static/assets/"); 22 | registry.addResourceHandler("/resources/**").addResourceLocations("/resources/"); 23 | registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/") 24 | .resourceChain(false).addResolver(new WebJarsResourceResolver()) 25 | .addResolver(new PathResourceResolver()); 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/java/net/jeebiz/boot/demo/setup/config/DataSourceConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.setup.config; 6 | 7 | import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties; 8 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | @Configuration 12 | @EnableConfigurationProperties(LiquibaseProperties.class) 13 | public class DataSourceConfig { 14 | 15 | /*@Bean 16 | * 17 | * https://www.cnblogs.com/jin-zhe/p/8203890.html 18 | public DataSource dragonHADataSource() throws Exception { 19 | return new DragonHADatasourceBuilder().build("dragon/dragon-ha-config.xml"); 20 | }*/ 21 | 22 | } -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/java/net/jeebiz/boot/demo/setup/data/LogConstant.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.setup.data; 6 | 7 | public class LogConstant { 8 | 9 | public static class Module{ 10 | 11 | public static final String N01 = "Demo模块"; 12 | } 13 | 14 | public static class BUSINESS { 15 | public static final String N010001 = "Demo业务"; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/java/net/jeebiz/boot/demo/setup/shiro/LoginAuthorizingRealm.java: -------------------------------------------------------------------------------- 1 | package net.jeebiz.boot.demo.setup.shiro; 2 | 3 | import org.apache.shiro.authc.UsernamePasswordToken; 4 | import org.apache.shiro.biz.realm.AbstractAuthorizingRealm; 5 | 6 | /** 7 | * Login AuthorizingRealm 8 | */ 9 | public class LoginAuthorizingRealm extends AbstractAuthorizingRealm { 10 | 11 | @Override 12 | public Class> getAuthenticationTokenClass() { 13 | return UsernamePasswordToken.class;// 此Realm只支持UsernamePasswordToken 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/java/net/jeebiz/boot/demo/web/mvc/IndexController.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.web.mvc; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | 13 | /** 14 | * 系统默认的重定向地址 15 | */ 16 | @Controller 17 | public class IndexController { 18 | 19 | /** 20 | * 登录成功后的默认重定向地址:可重写返回的路径进行业务系统定制 21 | */ 22 | @RequestMapping("/index") 23 | public String index(HttpServletRequest request, Model model) { 24 | return "html/index"; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/java/net/jeebiz/boot/demo/web/vo/DemoVo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.web.vo; 6 | 7 | import javax.validation.constraints.NotBlank; 8 | 9 | import org.hibernate.validator.constraints.SafeHtml; 10 | import org.springframework.web.multipart.MultipartFile; 11 | 12 | import io.swagger.annotations.ApiModel; 13 | import io.swagger.annotations.ApiModelProperty; 14 | 15 | @ApiModel(value = "DemoVo", description = "xxx数据传输对象") 16 | public class DemoVo { 17 | 18 | @ApiModelProperty(value = "xxID", required = true) 19 | private String id; 20 | @ApiModelProperty(value = "xx名称", required = true) 21 | @NotBlank(message = "名称必填") 22 | @SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE) 23 | private String name; 24 | @ApiModelProperty(value = "xx描述", required = true) 25 | @NotBlank(message = "描述必填") 26 | @SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE) 27 | private String text; 28 | @ApiModelProperty(value = "文件") 29 | //@StrictMimeTypeCheck 30 | private MultipartFile file; 31 | 32 | public String getId() { 33 | return id; 34 | } 35 | 36 | public void setId(String id) { 37 | this.id = id; 38 | } 39 | 40 | public String getName() { 41 | return name; 42 | } 43 | 44 | public void setName(String name) { 45 | this.name = name; 46 | } 47 | 48 | public String getText() { 49 | return text; 50 | } 51 | 52 | public void setText(String text) { 53 | this.text = text; 54 | } 55 | 56 | public MultipartFile getFile() { 57 | return file; 58 | } 59 | 60 | public void setFile(MultipartFile file) { 61 | this.file = file; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.main.allow-bean-definition-overriding=true -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ___ _ _ ______ _ 2 | |_ | | | (_) | ___ \ | | 3 | | | ___ ___| |__ _ ____ | |_/ / ___ ___ | |_ 4 | | |/ _ \/ _ \ '_ \| |_ / | ___ \/ _ \ / _ \| __| 5 | /\__/ / __/ __/ |_) | |/ / | |_/ / (_) | (_) | |_ 6 | \____/ \___|\___|_.__/|_/___| \____/ \___/ \___/ \__| 7 | 8 | Application Version: ${info.app.version} 9 | Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version} -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/resources/db/migration/mysql/V1_0_0__初始化.sql: -------------------------------------------------------------------------------- 1 | 2 | SET FOREIGN_KEY_CHECKS=0; 3 | 4 | -- ---------------------------- 5 | -- Table structure for JEEBIZ_DEMO 6 | -- ---------------------------- 7 | DROP TABLE IF EXISTS `JEEBIZ_DEMO`; 8 | CREATE TABLE `JEEBIZ_DEMO` ( 9 | `ID` int(11) NOT NULL COMMENT 'ID', 10 | `NAME` varchar(50) DEFAULT NULL COMMENT '名称', 11 | `TEXT` varchar(255) DEFAULT NULL COMMENT '简述' 12 | PRIMARY KEY (`M_ID`) 13 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Demo示例表'; 14 | 15 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/resources/db/migration/mysql/V1_0_1__升级.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-druid-shiro/src/main/resources/db/migration/mysql/V1_0_1__升级.sql -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/resources/db/migration/oracle/V1_0_0__初始化.sql: -------------------------------------------------------------------------------- 1 | -- Create table 2 | create table JEEBIZ_DEMO ( 3 | ID VARCHAR2(32) default sys_guid() not null, 4 | NAME VARCHAR2(100), 5 | TEXT CLOB null 6 | ); 7 | -- Add comments to the table 8 | comment on table JEEBIZ_DEMO is 'Demo示例表'; 9 | -- Add comments to the columns 10 | comment on column JEEBIZ_DEMO.ID is 'ID'; 11 | comment on column JEEBIZ_DEMO.NAME is '名称'; 12 | comment on column JEEBIZ_DEMO.TEXT is '简述'; 13 | -- Create/Recreate primary, unique and foreign key constraints 14 | alter table ZFTAL_SIMPLE_SIMPLE add constraint PK_JEEBIZ_DEMO primary key (ID); 15 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/resources/db/migration/oracle/V1_0_1__升级.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-druid-shiro/src/main/resources/db/migration/oracle/V1_0_1__升级.sql -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/resources/i18n/messages.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-druid-shiro/src/main/resources/i18n/messages.properties -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/resources/i18n/messages_en_US.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-druid-shiro/src/main/resources/i18n/messages_en_US.properties -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/resources/i18n/messages_zh_CN.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-druid-shiro/src/main/resources/i18n/messages_zh_CN.properties -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/resources/net/jeebiz/boot/demo/dao/sqlmap/mysql/DemoMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | insert into BIZ_SIMPLE(NAME,TEXT) values(#{name},#{text}) 14 | 15 | 16 | 17 | delete from BIZ_SIMPLE t where t.id = #{id} 18 | 19 | 20 | 21 | delete from BIZ_SIMPLE where id in 22 | 23 | #{ids} 24 | 25 | 26 | 27 | 28 | update BIZ_SIMPLE 29 | 30 | name = #{name}, 31 | text = #{text}, 32 | 33 | where id = #{id} 34 | 35 | 36 | 37 | SELECT distinct 38 | t.ID, 39 | t.NAME 40 | FROM BIZ_SIMPLE t, Table2 x 41 | WHERE t.ID = x.SIMPLE_ID 42 | AND t.ID in 43 | 44 | #{ids} 45 | 46 | 47 | 48 | 49 | select ID,NAME,TEXT from BIZ_SIMPLE t WHERE t.ID = #{id} 50 | 51 | 52 | 53 | select ID,NAME,TEXT from BIZ_SIMPLE t 54 | 55 | t.name like CONCAT('%',#{model.name},'%') 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/resources/net/jeebiz/boot/demo/dao/sqlmap/oracle/DemoMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | insert into BIZ_SIMPLE(NAME,TEXT) values(#{name},#{text}) 14 | 15 | 16 | 17 | delete from BIZ_SIMPLE t where t.id = #{id} 18 | 19 | 20 | 21 | delete from BIZ_SIMPLE where id in 22 | 23 | #{ids} 24 | 25 | 26 | 27 | 28 | update BIZ_SIMPLE 29 | 30 | name = #{name}, 31 | text = #{text}, 32 | 33 | where id = #{id} 34 | 35 | 36 | 37 | SELECT distinct 38 | t.ID, 39 | t.NAME 40 | FROM BIZ_SIMPLE t, Table2 x 41 | WHERE t.ID = x.SIMPLE_ID 42 | AND t.ID in 43 | 44 | #{ids} 45 | 46 | 47 | 48 | 49 | select ID,NAME,TEXT from BIZ_SIMPLE t WHERE t.ID = #{id} 50 | 51 | 52 | 53 | select ID,NAME,TEXT from BIZ_SIMPLE t 54 | 55 | t.name like '%'||#{model.name} ||'%' 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/resources/templates/html/demo/edit-demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Demo名称 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Demo描述 20 | 21 | ${rtModel.text} 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/resources/templates/html/demo/new-demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Demo名称 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Demo描述 19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/resources/templates/html/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Copyright (C) 2018 Jeebiz (http://jeebiz.net). All Rights Reserved. 6 | 7 | 8 | -------------------------------------------------------------------------------- /spring-boot-sample-druid-shiro/src/main/resources/templates/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 我是主页,请根据系统情况,采用异步加载模式,渲染当前主页:我是个性化页面 6 | 7 | ${base} 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-sample-druid/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.71.33.155/zfsoft/openjdk:1.8 2 | ENV LC_ALL en_US.UTF-8 3 | ENV TZ 'Asia/Shanghai' 4 | 5 | #创建日志目录和临时目录 6 | RUN mkdir -p /u01/boot/{logs,tmp} 7 | 8 | #拷贝本地文件到指定目录 9 | ADD /lib $BOOT/lib 10 | ADD /conf $BOOT/conf 11 | 12 | #ENV JAVA_HOME /opt/jdk 13 | #ENV PATH $PATH:$JAVA_HOME/bin 14 | 15 | EXPOSE 8081 16 | CMD ["java", "-classpath", "/u01/boot/conf:/u01/boot/lib/zftal-boot-datay.jar", "org.springframework.boot.loader.JarLauncher"] 17 | -------------------------------------------------------------------------------- /spring-boot-sample-druid/src/main/java/com/alibaba/druid/spring/boot/DruidApplication.java: -------------------------------------------------------------------------------- 1 | package com.alibaba.druid.spring.boot; 2 | 3 | import org.springframework.boot.ApplicationArguments; 4 | import org.springframework.boot.ApplicationRunner; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.scheduling.annotation.EnableScheduling; 11 | 12 | @Configuration // 配置控制 13 | @EnableScheduling 14 | @EnableAutoConfiguration // 启用自动配置 15 | @SpringBootApplication 16 | public class DruidApplication implements ApplicationRunner, CommandLineRunner { 17 | 18 | /* @Bean 19 | public JdbcTemplate jdbcTemplate(DataSource dataSource) { 20 | return new JdbcTemplate(dataSource); 21 | } 22 | */ 23 | public static void main(String[] args) throws Exception { 24 | 25 | SpringApplication.run(DruidApplication.class, args); 26 | 27 | } 28 | 29 | @Override 30 | public void run(ApplicationArguments args) throws Exception { 31 | 32 | } 33 | 34 | @Override 35 | public void run(String... args) throws Exception { 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-sample-druid/src/main/java/com/alibaba/druid/spring/boot/dao/daointerface/IUuidDao.java: -------------------------------------------------------------------------------- 1 | package com.alibaba.druid.spring.boot.dao.daointerface; 2 | 3 | public interface IUuidDao { 4 | 5 | String get(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-sample-druid/src/main/java/com/alibaba/druid/spring/boot/dao/impl/UuidDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.alibaba.druid.spring.boot.dao.impl; 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.alibaba.druid.spring.boot.dao.daointerface.IUuidDao; 8 | 9 | @Repository 10 | public class UuidDaoImpl implements IUuidDao { 11 | 12 | @Autowired 13 | private JdbcTemplate jdbcTemplate; 14 | 15 | @Override 16 | public String get() { 17 | //SELECT UUID() as id 18 | return jdbcTemplate.queryForObject("select sys_guid() as id from dual ", String.class ); 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-sample-druid/src/main/java/com/alibaba/druid/spring/boot/service/impl/IUuidServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.alibaba.druid.spring.boot.service.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | 6 | import com.alibaba.druid.spring.boot.dao.daointerface.IUuidDao; 7 | import com.alibaba.druid.spring.boot.service.svcinterface.IUuidService; 8 | 9 | @Service 10 | public class IUuidServiceImpl implements IUuidService { 11 | 12 | @Autowired 13 | protected IUuidDao uuidDao; 14 | 15 | @Override 16 | public String get() { 17 | return uuidDao.get(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-sample-druid/src/main/java/com/alibaba/druid/spring/boot/service/svcinterface/IUuidService.java: -------------------------------------------------------------------------------- 1 | package com.alibaba.druid.spring.boot.service.svcinterface; 2 | 3 | public interface IUuidService { 4 | 5 | public String get(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-sample-druid/src/main/java/com/alibaba/druid/spring/boot/web/controller/HelloWorldController.java: -------------------------------------------------------------------------------- 1 | package com.alibaba.druid.spring.boot.web.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import com.alibaba.druid.spring.boot.service.svcinterface.IUuidService; 9 | 10 | @RestController 11 | public class HelloWorldController { 12 | 13 | @Autowired 14 | protected IUuidService uuidService; 15 | 16 | @RequestMapping(value = "/", method = RequestMethod.GET) 17 | public String uuid() { 18 | return "uuid: " + uuidService.get(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-sample-druid/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-druid/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-sample-druid/src/test/java/com/alibaba/druid/spring/boot/DruidApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.alibaba.druid.spring.boot; 2 | import org.junit.Test; 3 | import org.junit.runner.RunWith; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | import com.alibaba.druid.spring.boot.service.svcinterface.IUuidService; 10 | 11 | @Configuration 12 | @RunWith(SpringRunner.class) 13 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 14 | public class DruidApplicationTests { 15 | 16 | @Autowired 17 | protected IUuidService uuidService; 18 | 19 | @Test 20 | public void uuid() { 21 | System.out.println( "uuid: " + uuidService.get());; 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-sample-ehcache3/src/main/java/org/ehcache/spring/boot/Ehcache3Application.java: -------------------------------------------------------------------------------- 1 | package org.ehcache.spring.boot; 2 | 3 | import org.springframework.boot.ApplicationArguments; 4 | import org.springframework.boot.ApplicationRunner; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.scheduling.annotation.EnableScheduling; 11 | 12 | 13 | @Configuration // 配置控制 14 | @EnableScheduling 15 | @EnableAutoConfiguration // 启用自动配置 16 | @SpringBootApplication 17 | public class Ehcache3Application implements ApplicationRunner, CommandLineRunner { 18 | 19 | public static void main(String[] args) throws Exception { 20 | 21 | SpringApplication.run(Ehcache3Application.class, args); 22 | 23 | } 24 | 25 | 26 | @Override 27 | public void run(ApplicationArguments args) throws Exception { 28 | 29 | System.out.println("============="); 30 | 31 | 32 | } 33 | 34 | @Override 35 | public void run(String... args) throws Exception { 36 | 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-boot-sample-ehcache3/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # 默认的profile为dev,其他环境通过指定启动参数使用不同的profile,比如: 2 | # 测试环境:java -jar my-spring-boot.jar --spring.profiles.active=test 3 | # 生产环境:java -jar my-spring-boot.jar --spring.profiles.active=prod 4 | 5 | pf4j: 6 | enabled: true 7 | mode: deployment 8 | plugins-dir: plugins 9 | 10 | server: 11 | port: 8085 12 | 13 | info: 14 | app: 15 | name: "@project.name@" #从pom.xml中获取 16 | description: "@project.description@" 17 | version: "@project.version@" 18 | spring-boot-version: "@project.parent.version@" 19 | 20 | spring: 21 | output: 22 | ansi: 23 | enabled: always 24 | messages: 25 | basename: /i18n/message 26 | profiles: 27 | active: dev 28 | 29 | #日志级别 30 | logging: 31 | config: classpath:log4j2.xml 32 | -------------------------------------------------------------------------------- /spring-boot-sample-flyway/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.71.33.155/zfsoft/openjdk:1.8 2 | ENV LC_ALL en_US.UTF-8 3 | ENV TZ 'Asia/Shanghai' 4 | 5 | #创建日志目录和临时目录 6 | RUN mkdir -p /u01/boot/{logs,tmp} 7 | 8 | #拷贝本地文件到指定目录 9 | ADD /lib $BOOT/lib 10 | ADD /conf $BOOT/conf 11 | 12 | #ENV JAVA_HOME /opt/jdk 13 | #ENV PATH $PATH:$JAVA_HOME/bin 14 | 15 | EXPOSE 8081 16 | CMD ["java", "-classpath", "/u01/boot/conf:/u01/boot/lib/zftal-boot-datay.jar", "org.springframework.boot.loader.JarLauncher"] 17 | -------------------------------------------------------------------------------- /spring-boot-sample-flyway/src/main/java/org/mybatis/spring/boot/MybatisApplication.java: -------------------------------------------------------------------------------- 1 | package org.mybatis.spring.boot; 2 | 3 | import org.springframework.boot.ApplicationArguments; 4 | import org.springframework.boot.ApplicationRunner; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.scheduling.annotation.EnableScheduling; 11 | 12 | @Configuration // 配置控制 13 | @EnableScheduling 14 | @EnableAutoConfiguration // 启用自动配置 15 | @SpringBootApplication 16 | public class MybatisApplication implements ApplicationRunner, CommandLineRunner { 17 | 18 | public static void main(String[] args) throws Exception { 19 | 20 | SpringApplication.run(MybatisApplication.class, args); 21 | 22 | } 23 | 24 | @Override 25 | public void run(ApplicationArguments args) throws Exception { 26 | 27 | } 28 | 29 | @Override 30 | public void run(String... args) throws Exception { 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-sample-flyway/src/main/java/org/mybatis/spring/boot/dao/daointerface/IUuidDao.java: -------------------------------------------------------------------------------- 1 | package org.mybatis.spring.boot.dao.daointerface; 2 | 3 | import org.apache.ibatis.annotations.Mapper; 4 | 5 | @Mapper 6 | public interface IUuidDao { 7 | 8 | String get(); 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-sample-flyway/src/main/java/org/mybatis/spring/boot/service/impl/IUuidServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.mybatis.spring.boot.service.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | 6 | import org.mybatis.spring.boot.dao.daointerface.IUuidDao; 7 | import org.mybatis.spring.boot.service.svcinterface.IUuidService; 8 | 9 | @Service 10 | public class IUuidServiceImpl implements IUuidService { 11 | 12 | @Autowired 13 | protected IUuidDao uuidDao; 14 | 15 | @Override 16 | public String get() { 17 | return uuidDao.get(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-sample-flyway/src/main/java/org/mybatis/spring/boot/service/svcinterface/IUuidService.java: -------------------------------------------------------------------------------- 1 | package org.mybatis.spring.boot.service.svcinterface; 2 | 3 | public interface IUuidService { 4 | 5 | public String get(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-sample-flyway/src/main/java/org/mybatis/spring/boot/web/controller/HelloWorldController.java: -------------------------------------------------------------------------------- 1 | package org.mybatis.spring.boot.web.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import org.mybatis.spring.boot.service.svcinterface.IUuidService; 9 | 10 | @RestController 11 | public class HelloWorldController { 12 | 13 | @Autowired 14 | protected IUuidService uuidService; 15 | 16 | @RequestMapping(value = "/", method = RequestMethod.GET) 17 | public String uuid() { 18 | return "uuid: " + uuidService.get(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-sample-flyway/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # 配置参考 : https://segmentfault.com/a/1190000004315890 2 | # 默认的profile为dev,其他环境通过指定启动参数使用不同的profile,比如: 3 | # 测试环境:java -jar my-spring-boot.jar --spring.profiles.active=test 4 | # 生产环境:java -jar my-spring-boot.jar --spring.profiles.active=prod 5 | #debug : true 6 | 7 | spring: 8 | messages: 9 | #指定message的basename,多个以逗号分隔,如果不加包名的话,默认从classpath路径开始,默认: messages 10 | basename: i18n/messages 11 | #设定加载的资源文件缓存失效时间,-1的话为永不过期,默认为-1 12 | cache-seconds: 6000 13 | #设定Message bundles的编码,默认: UTF-8 14 | encoding: UTF-8 15 | 16 | profiles: 17 | active: dev 18 | 19 | #数据源配置 20 | datasource: 21 | name: db_demo 22 | driver-class-name: oracle.jdbc.OracleDriver 23 | url: jdbc:oracle:thin:@127.0.0.1:1521:orcl 24 | username: db_demo 25 | password: db_demo 26 | type: com.zaxxer.hikari.HikariDataSource 27 | # HiKariCP的数据源配置: 28 | hikari: 29 | connection-timeout: 30000 #等待连接池分配连接的最大时长(毫秒),超过这个时长还没可用的连接则发生SQLException, 缺省:30秒 30 | idle-timeout: 600000 #一个连接idle状态的最大时长(毫秒),超时则被释放(retired),缺省:10分钟 31 | maxLifetime: 1800000 #一个连接的生命时长(毫秒),超时而且没被使用则被释放(retired),缺省:30分钟,建议设置比数据库超时时长少30秒以上,参考MySQL wait_timeout参数(show variables like '%timeout%';) 32 | maximum-pool-size: 15 #连接池中允许的最大连接数。缺省值:10;推荐的公式:((core_count * 2) + effective_spindle_count) 33 | 34 | #http://www.cnblogs.com/yhtboke/p/Mybatis.html 35 | mybatis: 36 | check-config-location: true 37 | config-location: classpath:/conf/mybatis/sqlMapConfig.xml 38 | type-aliases-package: org.mybatis.spring.boot.dao.entities 39 | #自动扫描Dao的根目录,多个使用,分割 40 | base-package: net.jeebiz.**.dao 41 | #Mapper.xml匹配规则 42 | mapper-locations: 43 | - classpath*:org/mybatis/**/dao/**/sqlmap/*.xml 44 | 45 | #日志级别 46 | logging: 47 | config: classpath:log4j2.xml 48 | -------------------------------------------------------------------------------- /spring-boot-sample-flyway/src/test/java/org/mybatis/spring/boot/MybatisApplicationTests.java: -------------------------------------------------------------------------------- 1 | package org.mybatis.spring.boot; 2 | import org.junit.Test; 3 | import org.junit.runner.RunWith; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | import org.mybatis.spring.boot.service.svcinterface.IUuidService; 9 | 10 | 11 | @RunWith(SpringRunner.class) 12 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 13 | public class MybatisApplicationTests { 14 | 15 | @Autowired 16 | protected IUuidService uuidService; 17 | 18 | @Test 19 | public void uuid() { 20 | System.out.println( "uuid: " + uuidService.get());; 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/runenv/jeebiz-boot: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #chkconfig: 2345 80 90 3 | #description:jeebiz-boot-app server 4 | #processname:jeebiz-boot-app 5 | 6 | #source function library 7 | #. /etc/rc.d/init.d/functions 8 | 9 | #application home 10 | export APP_HOME=/u01/jeebiz-boot-app 11 | 12 | #Document the app path 13 | echo document the curren path: "$APP_HOME" 14 | 15 | #Java environment 16 | #export JAVA_HOME="$APP_HOME/jre" 17 | #export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$CLASSPATH 18 | #export PATH=$JAVA_HOME/bin:$PATH 19 | 20 | start() 21 | { 22 | echo -n $"Starting $prog:" 23 | $APP_HOME/bin/jeebiz-boot.sh & 24 | } 25 | 26 | stop() 27 | { 28 | echo -n $"Stopping $prog:" 29 | pid=$(ps x | grep jeebiz-boot-app | grep -v grep | awk '{print $1}') 30 | echo pid = "$pid" 31 | kill -9 $pid 32 | 33 | } 34 | 35 | case "$1" in 36 | start) 37 | start 38 | ;; 39 | stop) 40 | stop 41 | ;; 42 | *) 43 | echo $"Usage: $0 {start|stop}" 44 | RETVAL=1 45 | esac 46 | exit $RETVAL -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/runenv/setenv: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -r "$BASEDIR/jre" ]; 3 | then 4 | #Java environment 5 | export JAVA_HOME=$BASEDIR/jre 6 | export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$CLASSPATH 7 | export PATH=$JAVA_HOME/bin:$PATH 8 | echo "JAVA_HOME $JAVA_HOME" 9 | echo "CLASSPATH $CLASSPATH" 10 | else 11 | echo "JAVA_HOME $JAVA_HOME" 12 | echo "CLASSPATH $CLASSPATH" 13 | fi 14 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/runenv/setenv.bat: -------------------------------------------------------------------------------- 1 | :: 关闭终端回显 2 | @echo off 3 | setlocal enabledelayedexpansion 4 | 5 | if exist "%BASEDIR%\jre" goto setenv 6 | echo JAVA_HOME %JAVA_HOME% 7 | echo CLASSPATH %CLASSPATH% 8 | goto end 9 | 10 | :: Set Java environment 11 | :setenv 12 | SET "JAVA_HOME=%BASEDIR%\jre" 13 | SET "CLASSPATH=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar;" 14 | SET "Path=%JAVA_HOME%\bin;%path%" 15 | echo JAVA_HOME %JAVA_HOME% 16 | echo CLASSPATH %CLASSPATH% 17 | goto end 18 | 19 | :end 20 | exit /b 0 -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.71.33.155/zfsoft/openjdk:1.8 2 | ENV LC_ALL en_US.UTF-8 3 | ENV TZ 'Asia/Shanghai' 4 | 5 | #创建日志目录和临时目录 6 | RUN mkdir -p /u01/boot/{logs,tmp} 7 | 8 | #拷贝本地文件到指定目录 9 | ADD /lib $BOOT/lib 10 | ADD /conf $BOOT/conf 11 | 12 | #ENV JAVA_HOME /opt/jdk 13 | #ENV PATH $PATH:$JAVA_HOME/bin 14 | 15 | EXPOSE 8081 16 | CMD ["java", "-classpath", "/u01/boot/conf:/u01/boot/lib/zftal-boot-datay.jar", "org.springframework.boot.loader.JarLauncher"] 17 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/java/net/jeebiz/boot/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package net.jeebiz.boot.demo; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import org.dozer.spring.boot.EnableDozerMapper; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | import org.springframework.cache.annotation.EnableCaching; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.jdbc.datasource.DataSourceTransactionManager; 13 | import org.springframework.scheduling.annotation.EnableScheduling; 14 | import org.springframework.transaction.PlatformTransactionManager; 15 | import org.springframework.transaction.annotation.EnableTransactionManagement; 16 | 17 | import com.spring4all.swagger.EnableSwagger2Doc; 18 | 19 | import net.jeebiz.boot.autoconfigure.EnableServiceConfiguration; 20 | import net.jeebiz.boot.autoconfigure.EnableWebMvcConfiguration; 21 | 22 | @EnableAutoConfiguration 23 | @EnableCaching(proxyTargetClass = true) 24 | @EnableSwagger2Doc 25 | @EnableDozerMapper 26 | @EnableScheduling 27 | @EnableServiceConfiguration 28 | @EnableWebMvcConfiguration 29 | @EnableTransactionManagement 30 | @SpringBootApplication 31 | public class DemoApplication implements CommandLineRunner { 32 | 33 | // 其中 dataSource 框架会自动为我们注入 34 | @Bean 35 | public PlatformTransactionManager txManager(DataSource dataSource) { 36 | return new DataSourceTransactionManager(dataSource); 37 | } 38 | 39 | public static void main(String[] args) throws Exception { 40 | SpringApplication.run(DemoApplication.class, args); 41 | } 42 | 43 | @Override 44 | public void run(String... args) throws Exception { 45 | System.err.println("Spring Boot Application(Jeebiz-Demo) Started !"); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/java/net/jeebiz/boot/demo/dao/IAuthzLoginDao.java: -------------------------------------------------------------------------------- 1 | package net.jeebiz.boot.demo.dao; 2 | 3 | import java.util.Map; 4 | 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import net.jeebiz.boot.api.dao.BaseDao; 9 | import net.jeebiz.boot.demo.dao.entities.AuthzLoginModel; 10 | 11 | /** 12 | * 登录查询Dao 13 | * 14 | * @author hiwepy 15 | */ 16 | @Mapper 17 | public interface IAuthzLoginDao extends BaseDao { 18 | 19 | /** 20 | * 根据用户ID和密码查询用户可否登录,角色数量等信息 21 | * @param username : 用户名 22 | * @param password : 密码,可不填 23 | * @return 用户账号状态信息 24 | */ 25 | public Map getAccountStatus(@Param(value = "username") String username, 26 | @Param(value = "password") String password); 27 | 28 | /*** 29 | * 根据用户ID和密码查询用户信息 30 | * @param username : 用户名 31 | * @param password : 密码,可不填 32 | * @return 用户登录信息 33 | */ 34 | public AuthzLoginModel getAccount(@Param(value = "username") String username, 35 | @Param(value = "password") String password); 36 | 37 | /*** 38 | * 根据用户ID无密码查询用户信息;用于单点登录 39 | * @param username : 用户名 40 | * @return 用户登录信息 41 | */ 42 | public AuthzLoginModel getAccountWithoutPwd(@Param(value = "username") String username); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/java/net/jeebiz/boot/demo/dao/IDemoDao.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.dao; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | import org.apache.ibatis.annotations.Mapper; 11 | 12 | import net.jeebiz.boot.api.dao.BaseDao; 13 | import net.jeebiz.boot.demo.dao.entities.DemoModel; 14 | 15 | @Mapper 16 | public interface IDemoDao extends BaseDao{ 17 | 18 | /** 19 | * 获取指定ID关联的信息,以便进行删除前的逻辑检查 20 | * @param list 21 | * @return 22 | */ 23 | List> getDependencies(List list); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/java/net/jeebiz/boot/demo/dao/entities/DemoModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.dao.entities; 6 | 7 | import net.jeebiz.boot.api.dao.entities.BaseModel; 8 | 9 | public class DemoModel extends BaseModel{ 10 | 11 | private static final long serialVersionUID = 6189820231775242317L; 12 | 13 | private String id; 14 | 15 | private String name; 16 | 17 | private String text; 18 | 19 | public String getId() { 20 | return id; 21 | } 22 | 23 | public void setId(String id) { 24 | this.id = id; 25 | } 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | 35 | public String getText() { 36 | return text; 37 | } 38 | 39 | public void setText(String text) { 40 | this.text = text; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/java/net/jeebiz/boot/demo/service/IAuthzLoginService.java: -------------------------------------------------------------------------------- 1 | package net.jeebiz.boot.demo.service; 2 | 3 | import java.security.GeneralSecurityException; 4 | import java.security.interfaces.RSAPublicKey; 5 | import java.util.Map; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | import net.jeebiz.boot.api.service.BaseService; 10 | import net.jeebiz.boot.demo.dao.entities.AuthzLoginModel; 11 | 12 | public interface IAuthzLoginService extends BaseService{ 13 | 14 | RSAPublicKey genPublicKey(HttpServletRequest request) throws GeneralSecurityException; 15 | 16 | /** 17 | * 根据用户ID和密码查询用户可否登录,角色数量等信息 18 | * @param username : 用户名 19 | * @param password : 密码,可不填 20 | * @return 用户账号状态信息 21 | */ 22 | Map getAccountStatus(String username, String password); 23 | 24 | /*** 25 | * 根据用户ID和密码查询用户信息 26 | * @param username : 用户名 27 | * @param password : 密码,可不填 28 | * @return 用户登录信息 29 | */ 30 | AuthzLoginModel getAccount(String username, String password); 31 | 32 | /*** 33 | * 根据用户ID无密码查询用户信息;用于单点登录 34 | * @param username : 用户名 35 | * @return 用户登录信息 36 | */ 37 | AuthzLoginModel getAccountWithoutPwd(String username); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/java/net/jeebiz/boot/demo/service/IDemoService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.service; 6 | 7 | import net.jeebiz.boot.api.service.BaseService; 8 | import net.jeebiz.boot.demo.dao.entities.DemoModel; 9 | 10 | public interface IDemoService extends BaseService{ 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/java/net/jeebiz/boot/demo/service/impl/AuthzLoginServiceImpl.java: -------------------------------------------------------------------------------- 1 | package net.jeebiz.boot.demo.service.impl; 2 | 3 | 4 | import java.security.GeneralSecurityException; 5 | import java.security.interfaces.RSAPublicKey; 6 | import java.util.Map; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | 10 | import org.springframework.stereotype.Service; 11 | 12 | import net.jeebiz.boot.api.service.BaseServiceImpl; 13 | import net.jeebiz.boot.demo.dao.IAuthzLoginDao; 14 | import net.jeebiz.boot.demo.dao.entities.AuthzLoginModel; 15 | import net.jeebiz.boot.demo.service.IAuthzLoginService; 16 | 17 | @Service 18 | public class AuthzLoginServiceImpl extends BaseServiceImpl 19 | implements IAuthzLoginService { 20 | 21 | public static final String PRIVATE_KEY_ATTRIBUTE_NAME = "privateKey"; 22 | 23 | @Override 24 | public Map getAccountStatus(String username, String password) { 25 | return getDao().getAccountStatus(username, password); 26 | } 27 | 28 | @Override 29 | public AuthzLoginModel getAccount(String username, String password) { 30 | return getDao().getAccount(username, password); 31 | } 32 | 33 | @Override 34 | public AuthzLoginModel getAccountWithoutPwd(String username) { 35 | return getDao().getAccountWithoutPwd(username); 36 | } 37 | 38 | @Override 39 | public RSAPublicKey genPublicKey(HttpServletRequest request) throws GeneralSecurityException { 40 | 41 | /*KeyPair keyPair = SecretKeyUtils.genKeyPair("RSA"); 42 | RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); 43 | RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); 44 | 45 | SubjectUtils.getSession().setAttribute(PRIVATE_KEY_ATTRIBUTE_NAME, privateKey); 46 | 47 | return publicKey;*/ 48 | 49 | return null; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/java/net/jeebiz/boot/demo/service/impl/DemoServiceImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.service.impl; 6 | 7 | import org.springframework.stereotype.Service; 8 | 9 | import net.jeebiz.boot.api.service.BaseServiceImpl; 10 | import net.jeebiz.boot.demo.dao.IDemoDao; 11 | import net.jeebiz.boot.demo.dao.entities.DemoModel; 12 | import net.jeebiz.boot.demo.service.IDemoService; 13 | 14 | @Service 15 | public class DemoServiceImpl extends BaseServiceImpl implements IDemoService{ 16 | 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/java/net/jeebiz/boot/demo/setup/config/BootWebMvcConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.setup.config; 6 | 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 9 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 10 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 11 | import org.springframework.web.servlet.resource.PathResourceResolver; 12 | import org.springframework.web.servlet.resource.WebJarsResourceResolver; 13 | 14 | @Configuration 15 | @EnableWebMvc 16 | public class BootWebMvcConfig implements WebMvcConfigurer { 17 | 18 | 19 | @Override 20 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 21 | registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/static/assets/"); 22 | registry.addResourceHandler("/resources/**").addResourceLocations("/resources/"); 23 | registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/") 24 | .resourceChain(false).addResolver(new WebJarsResourceResolver()) 25 | .addResolver(new PathResourceResolver()); 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/java/net/jeebiz/boot/demo/setup/config/DataSourceConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.setup.config; 6 | 7 | import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties; 8 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | @Configuration 12 | @EnableConfigurationProperties(LiquibaseProperties.class) 13 | public class DataSourceConfig { 14 | 15 | /*@Bean 16 | * 17 | * https://www.cnblogs.com/jin-zhe/p/8203890.html 18 | public DataSource dragonHADataSource() throws Exception { 19 | return new DragonHADatasourceBuilder().build("dragon/dragon-ha-config.xml"); 20 | }*/ 21 | 22 | } -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/java/net/jeebiz/boot/demo/setup/data/LogConstant.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.setup.data; 6 | 7 | public class LogConstant { 8 | 9 | public static class Module{ 10 | 11 | public static final String N01 = "Demo模块"; 12 | } 13 | 14 | public static class BUSINESS { 15 | public static final String N010001 = "Demo业务"; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/java/net/jeebiz/boot/demo/setup/shiro/LoginAuthorizingRealm.java: -------------------------------------------------------------------------------- 1 | package net.jeebiz.boot.demo.setup.shiro; 2 | 3 | import org.apache.shiro.authc.UsernamePasswordToken; 4 | import org.apache.shiro.biz.realm.AbstractAuthorizingRealm; 5 | 6 | /** 7 | * Login AuthorizingRealm 8 | */ 9 | public class LoginAuthorizingRealm extends AbstractAuthorizingRealm { 10 | 11 | @Override 12 | public Class> getAuthenticationTokenClass() { 13 | return UsernamePasswordToken.class;// 此Realm只支持UsernamePasswordToken 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/java/net/jeebiz/boot/demo/web/mvc/IndexController.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.web.mvc; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | 13 | /** 14 | * 系统默认的重定向地址 15 | */ 16 | @Controller 17 | public class IndexController { 18 | 19 | /** 20 | * 登录成功后的默认重定向地址:可重写返回的路径进行业务系统定制 21 | */ 22 | @RequestMapping("/index") 23 | public String index(HttpServletRequest request, Model model) { 24 | return "html/index"; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/java/net/jeebiz/boot/demo/web/vo/DemoVo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2018 Jeebiz (http://jeebiz.net). 3 | * All Rights Reserved. 4 | */ 5 | package net.jeebiz.boot.demo.web.vo; 6 | 7 | import javax.validation.constraints.NotBlank; 8 | 9 | import org.github.hiwepy.validator.constraints.StrictMimeTypeCheck; 10 | import org.hibernate.validator.constraints.SafeHtml; 11 | import org.springframework.web.multipart.MultipartFile; 12 | 13 | import io.swagger.annotations.ApiModel; 14 | import io.swagger.annotations.ApiModelProperty; 15 | 16 | @ApiModel(value = "DemoVo", description = "xxx数据传输对象") 17 | public class DemoVo { 18 | 19 | @ApiModelProperty(value = "xxID", required = true) 20 | private String id; 21 | @ApiModelProperty(value = "xx名称", required = true) 22 | @NotBlank(message = "名称必填") 23 | @SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE) 24 | private String name; 25 | @ApiModelProperty(value = "xx描述", required = true) 26 | @NotBlank(message = "描述必填") 27 | @SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE) 28 | private String text; 29 | @ApiModelProperty(value = "文件") 30 | @StrictMimeTypeCheck 31 | private MultipartFile file; 32 | 33 | public String getId() { 34 | return id; 35 | } 36 | 37 | public void setId(String id) { 38 | this.id = id; 39 | } 40 | 41 | public String getName() { 42 | return name; 43 | } 44 | 45 | public void setName(String name) { 46 | this.name = name; 47 | } 48 | 49 | public String getText() { 50 | return text; 51 | } 52 | 53 | public void setText(String text) { 54 | this.text = text; 55 | } 56 | 57 | public MultipartFile getFile() { 58 | return file; 59 | } 60 | 61 | public void setFile(MultipartFile file) { 62 | this.file = file; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.main.allow-bean-definition-overriding=true -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ___ _ _ ______ _ 2 | |_ | | | (_) | ___ \ | | 3 | | | ___ ___| |__ _ ____ | |_/ / ___ ___ | |_ 4 | | |/ _ \/ _ \ '_ \| |_ / | ___ \/ _ \ / _ \| __| 5 | /\__/ / __/ __/ |_) | |/ / | |_/ / (_) | (_) | |_ 6 | \____/ \___|\___|_.__/|_/___| \____/ \___/ \___/ \__| 7 | 8 | Application Version: ${info.app.version} 9 | Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version} -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/resources/db/migration/mysql/V1_0_0_10__初始化.sql: -------------------------------------------------------------------------------- 1 | 2 | SET FOREIGN_KEY_CHECKS=0; 3 | 4 | -- ---------------------------- 5 | -- Table structure for JEEBIZ_DEMO 6 | -- ---------------------------- 7 | DROP TABLE IF EXISTS `JEEBIZ_DEMO`; 8 | CREATE TABLE `JEEBIZ_DEMO` ( 9 | `ID` int(11) NOT NULL COMMENT 'ID', 10 | `NAME` varchar(50) DEFAULT NULL COMMENT '名称', 11 | `TEXT` varchar(255) DEFAULT NULL COMMENT '简述' 12 | PRIMARY KEY (`M_ID`) 13 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Demo示例表'; 14 | 15 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/resources/db/migration/mysql/V1_0_0_11__升级.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-hikaricp-shiro/src/main/resources/db/migration/mysql/V1_0_0_11__升级.sql -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/resources/db/migration/oracle/V1_0_0_10__初始化.sql: -------------------------------------------------------------------------------- 1 | -- Create table 2 | create table JEEBIZ_DEMO ( 3 | ID VARCHAR2(32) default sys_guid() not null, 4 | NAME VARCHAR2(100), 5 | TEXT CLOB null 6 | ); 7 | -- Add comments to the table 8 | comment on table JEEBIZ_DEMO is 'Demo示例表'; 9 | -- Add comments to the columns 10 | comment on column JEEBIZ_DEMO.ID is 'ID'; 11 | comment on column JEEBIZ_DEMO.NAME is '名称'; 12 | comment on column JEEBIZ_DEMO.TEXT is '简述'; 13 | -- Create/Recreate primary, unique and foreign key constraints 14 | alter table ZFTAL_SIMPLE_SIMPLE add constraint PK_JEEBIZ_DEMO primary key (ID); 15 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/resources/db/migration/oracle/V1_0_0_11__升级.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-hikaricp-shiro/src/main/resources/db/migration/oracle/V1_0_0_11__升级.sql -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/resources/i18n/messages.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-hikaricp-shiro/src/main/resources/i18n/messages.properties -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/resources/i18n/messages_en_US.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-hikaricp-shiro/src/main/resources/i18n/messages_en_US.properties -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/resources/i18n/messages_zh_CN.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-hikaricp-shiro/src/main/resources/i18n/messages_zh_CN.properties -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/resources/templates/html/demo/edit-demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Demo名称 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Demo描述 20 | 21 | ${rtModel.text} 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/resources/templates/html/demo/new-demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Demo名称 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Demo描述 19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/resources/templates/html/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Copyright (C) 2018 Jeebiz (http://jeebiz.net). All Rights Reserved. 6 | 7 | 8 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp-shiro/src/main/resources/templates/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 我是主页,请根据系统情况,采用异步加载模式,渲染当前主页:我是个性化页面 6 | 7 | ${base} 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.71.33.155/zfsoft/openjdk:1.8 2 | ENV LC_ALL en_US.UTF-8 3 | ENV TZ 'Asia/Shanghai' 4 | 5 | #创建日志目录和临时目录 6 | RUN mkdir -p /u01/boot/{logs,tmp} 7 | 8 | #拷贝本地文件到指定目录 9 | ADD /lib $BOOT/lib 10 | ADD /conf $BOOT/conf 11 | 12 | #ENV JAVA_HOME /opt/jdk 13 | #ENV PATH $PATH:$JAVA_HOME/bin 14 | 15 | EXPOSE 8081 16 | CMD ["java", "-classpath", "/u01/boot/conf:/u01/boot/lib/zftal-boot-datay.jar", "org.springframework.boot.loader.JarLauncher"] 17 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp/src/main/java/com/zaxxer/hikari/spring/boot/HikariCPApplication.java: -------------------------------------------------------------------------------- 1 | package com.zaxxer.hikari.spring.boot; 2 | 3 | import org.springframework.boot.ApplicationArguments; 4 | import org.springframework.boot.ApplicationRunner; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.scheduling.annotation.EnableAsync; 11 | import org.springframework.scheduling.annotation.EnableScheduling; 12 | 13 | 14 | @Configuration // 配置控制 15 | @EnableAsync //(异步回调)让@Async注解能够生效,不能加在静态方法上 16 | @EnableScheduling // 开启Scheduling 注解 17 | @EnableAutoConfiguration // 启用自动配置 18 | @SpringBootApplication 19 | public class HikariCPApplication implements ApplicationRunner, CommandLineRunner { 20 | 21 | public static void main(String[] args) throws Exception { 22 | SpringApplication.run(HikariCPApplication.class, args); 23 | } 24 | 25 | @Override 26 | public void run(ApplicationArguments args) throws Exception { 27 | 28 | } 29 | 30 | @Override 31 | public void run(String... args) throws Exception { 32 | 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-hikaricp/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-sample-hikaricp/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | spring: 4 | messages: 5 | basename: /i18n/message 6 | profiles: 7 | active: dev 8 | datasource: 9 | type: com.zaxxer.hikari.HikariDataSource 10 | driver-class-name: org.sqlite.JDBC 11 | url: jdbc:sqlite:example.db 12 | #username: 13 | # password: 14 | 15 | logging: 16 | config: classpath:log4j2.xml 17 | -------------------------------------------------------------------------------- /spring-boot-sample-jetbrick/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.github.hiwepy 7 | spring-boot-starter-samples 8 | 1.0.0-SNAPSHOT 9 | 10 | spring-boot-sample-jetbrick 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 2.1.10 16 | 17 | 18 | 19 | 20 | 21 | 22 | javax.servlet 23 | javax.servlet-api 24 | true 25 | 26 | 27 | 28 | org.slf4j 29 | slf4j-api 30 | 31 | 32 | org.slf4j 33 | slf4j-log4j12 34 | test 35 | 36 | 37 | 38 | 39 | 40 | com.github.subchen 41 | jetbrick-template 42 | ${jetbrick.version} 43 | 44 | 45 | 46 | com.github.subchen 47 | jetbrick-template-springmvc 48 | ${jetbrick.version} 49 | 50 | 51 | 52 | com.github.subchen 53 | jetbrick-template-shiro 54 | ${jetbrick.version} 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /spring-boot-sample-jetbrick/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | tomcat: 3 | max-threads: 100 4 | min-spare-threads: 20 5 | connection-timeout: 5000 6 | ssl: 7 | key-store: classpath:.keystore 8 | key-store-type: JKS 9 | key-password: qq123456 10 | key-alias: tomcat 11 | port: 8080 12 | spring: 13 | jetbrick: 14 | template: 15 | enabled: true -------------------------------------------------------------------------------- /spring-boot-sample-jetbrick/src/test/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | tomcat: 3 | max-threads: 100 4 | min-spare-threads: 20 5 | connection-timeout: 5000 6 | ssl: 7 | key-store: classpath:.keystore 8 | key-store-type: JKS 9 | key-password: qq123456 10 | key-alias: tomcat 11 | port: 8080 12 | spring: 13 | jetbrick: 14 | template: 15 | enabled: true -------------------------------------------------------------------------------- /spring-boot-sample-kaptcha/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.71.33.155/zfsoft/openjdk:1.8 2 | ENV LC_ALL en_US.UTF-8 3 | ENV TZ 'Asia/Shanghai' 4 | 5 | #创建日志目录和临时目录 6 | RUN mkdir -p /u01/boot/{logs,tmp} 7 | 8 | #拷贝本地文件到指定目录 9 | ADD /lib $BOOT/lib 10 | ADD /conf $BOOT/conf 11 | 12 | #ENV JAVA_HOME /opt/jdk 13 | #ENV PATH $PATH:$JAVA_HOME/bin 14 | 15 | EXPOSE 8081 16 | CMD ["java", "-classpath", "/u01/boot/conf:/u01/boot/lib/zftal-boot-datay.jar", "org.springframework.boot.loader.JarLauncher"] 17 | -------------------------------------------------------------------------------- /spring-boot-sample-kaptcha/src/main/java/com/google/code/kaptcha/spring/boot/KaptchaApplication.java: -------------------------------------------------------------------------------- 1 | package com.google.code.kaptcha.spring.boot; 2 | 3 | import org.springframework.boot.ApplicationArguments; 4 | import org.springframework.boot.ApplicationRunner; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.scheduling.annotation.EnableScheduling; 11 | 12 | @Configuration // 配置控制 13 | @EnableScheduling 14 | @EnableAutoConfiguration // 启用自动配置 15 | @SpringBootApplication 16 | public class KaptchaApplication implements ApplicationRunner, CommandLineRunner { 17 | 18 | public static void main(String[] args) throws Exception { 19 | 20 | SpringApplication.run(KaptchaApplication.class, args); 21 | 22 | } 23 | 24 | @Override 25 | public void run(ApplicationArguments args) throws Exception { 26 | 27 | } 28 | 29 | @Override 30 | public void run(String... args) throws Exception { 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-sample-kaptcha/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # 默认的profile为dev,其他环境通过指定启动参数使用不同的profile,比如: 2 | # 测试环境:java -jar my-spring-boot.jar --spring.profiles.active=test 3 | # 生产环境:java -jar my-spring-boot.jar --spring.profiles.active=prod 4 | 5 | server: 6 | port: 8085 7 | management: 8 | port: 54002 9 | health: 10 | mail: 11 | enabled: false 12 | info: 13 | app: 14 | name: "@project.name@" #从pom.xml中获取 15 | description: "@project.description@" 16 | version: "@project.version@" 17 | spring-boot-version: "@project.parent.version@" 18 | 19 | spring: 20 | output: 21 | ansi: 22 | enabled: always 23 | messages: 24 | basename: /i18n/message 25 | profiles: 26 | active: dev 27 | 28 | #日志级别 29 | logging: 30 | config: classpath:log4j2.xml 31 | -------------------------------------------------------------------------------- /spring-boot-sample-log4j2/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.71.33.155/zfsoft/openjdk:1.8 2 | ENV LC_ALL en_US.UTF-8 3 | ENV TZ 'Asia/Shanghai' 4 | 5 | #创建日志目录和临时目录 6 | RUN mkdir -p /u01/boot/{logs,tmp} 7 | 8 | #拷贝本地文件到指定目录 9 | ADD /lib $BOOT/lib 10 | ADD /conf $BOOT/conf 11 | 12 | #ENV JAVA_HOME /opt/jdk 13 | #ENV PATH $PATH:$JAVA_HOME/bin 14 | 15 | EXPOSE 8081 16 | CMD ["java", "-classpath", "/u01/boot/conf:/u01/boot/lib/zftal-boot-datay.jar", "org.springframework.boot.loader.JarLauncher"] 17 | -------------------------------------------------------------------------------- /spring-boot-sample-log4j2/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2Application.java: -------------------------------------------------------------------------------- 1 | package org.apache.logging.log4j.spring.boot; 2 | 3 | import org.apache.logging.log4j.spring.boot.Markers; 4 | import org.apache.logging.log4j.spring.boot.utils.Log4jUtils; 5 | import org.springframework.boot.ApplicationArguments; 6 | import org.springframework.boot.ApplicationRunner; 7 | import org.springframework.boot.CommandLineRunner; 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 10 | import org.springframework.boot.autoconfigure.SpringBootApplication; 11 | import org.springframework.context.annotation.Configuration; 12 | import org.springframework.scheduling.annotation.EnableScheduling; 13 | 14 | 15 | @Configuration // 配置控制 16 | @EnableScheduling 17 | @EnableAutoConfiguration // 启用自动配置 18 | @SpringBootApplication 19 | public class Log4j2Application implements ApplicationRunner, CommandLineRunner { 20 | 21 | public static void main(String[] args) throws Exception { 22 | 23 | SpringApplication.run(Log4j2Application.class, args); 24 | 25 | } 26 | 27 | 28 | @Override 29 | public void run(ApplicationArguments args) throws Exception { 30 | Log4jUtils.instance("opt").debug(Markers.DB, "test1"); 31 | } 32 | 33 | @Override 34 | public void run(String... args) throws Exception { 35 | Log4jUtils.instance("opt").debug(Markers.DB, "test2"); 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-sample-log4j2/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # 配置参考 : https://segmentfault.com/a/1190000004315890 2 | # 默认的profile为dev,其他环境通过指定启动参数使用不同的profile,比如: 3 | # 测试环境:java -jar my-spring-boot.jar --spring.profiles.active=test 4 | # 生产环境:java -jar my-spring-boot.jar --spring.profiles.active=prod 5 | #debug : true 6 | 7 | spring: 8 | messages: 9 | #指定message的basename,多个以逗号分隔,如果不加包名的话,默认从classpath路径开始,默认: messages 10 | basename: i18n/messages 11 | #设定加载的资源文件缓存失效时间,-1的话为永不过期,默认为-1 12 | cache-seconds: 6000 13 | #设定Message bundles的编码,默认: UTF-8 14 | encoding: UTF-8 15 | 16 | profiles: 17 | active: dev 18 | 19 | #数据源配置 20 | datasource: 21 | name: db_demo 22 | driver-class-name: oracle.jdbc.driver.OracleDriver 23 | url: jdbc:oracle:thin:@127.0.0.1:1521:orcl 24 | username: db_demo 25 | password: db_demo 26 | type: com.zaxxer.hikari.HikariDataSource 27 | # HiKariCP的数据源配置: 28 | hikari: 29 | connection-timeout: 30000 #等待连接池分配连接的最大时长(毫秒),超过这个时长还没可用的连接则发生SQLException, 缺省:30秒 30 | idle-timeout: 600000 #一个连接idle状态的最大时长(毫秒),超时则被释放(retired),缺省:10分钟 31 | maxLifetime: 1800000 #一个连接的生命时长(毫秒),超时而且没被使用则被释放(retired),缺省:30分钟,建议设置比数据库超时时长少30秒以上,参考MySQL wait_timeout参数(show variables like '%timeout%';) 32 | maximum-pool-size: 15 #连接池中允许的最大连接数。缺省值:10;推荐的公式:((core_count * 2) + effective_spindle_count) 33 | 34 | #日志级别 35 | logging: 36 | log4j: 37 | enabled: true 38 | table-name: ZFTAL_LOG_BIZ 39 | config: classpath:log4j2.xml 40 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/README.md: -------------------------------------------------------------------------------- 1 | 2 | #pf4j2-plugin-sample 3 | 4 | 基于pf4j2的插件简单示例 5 | 6 | 7 | ### pf4j2-plugin-api 8 | 1、插件接口定义 9 | 10 | ### pf4j2-plugin-impl1 11 | 1、插件实现1 12 | 13 | ### pf4j2-plugin-impl2 14 | 1、插件实现2 15 | 16 | ### pf4j2-plugin-test 17 | 1、插件测试 -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-api/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.github.hiwepy 6 | pf4j-plugin 7 | 1.0.0-SNAPSHOT 8 | 9 | pf4j-plugin-api 10 | 11 | 12 | 13 | 14 | org.slf4j 15 | slf4j-api 16 | 17 | 18 | 19 | 20 | javax.servlet 21 | javax.servlet-api 22 | 23 | 24 | 25 | 26 | ro.fortsoft.pf4j 27 | pf4j 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-api/src/main/java/pf4j/plugin/api/AuthcExtensionPoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j.plugin.api; 17 | 18 | import java.util.Map; 19 | 20 | import javax.servlet.http.HttpServletRequest; 21 | 22 | import ro.fortsoft.pf4j.ExtensionPoint; 23 | import ro.fortsoft.pf4j.PluginException; 24 | 25 | public interface AuthcExtensionPoint extends ExtensionPoint { 26 | 27 | String getToken(Map par,HttpServletRequest req) throws PluginException; 28 | 29 | void handleHeaderParams(Map par,HttpServletRequest req) throws PluginException; 30 | 31 | void handleRequestParams(Map par,HttpServletRequest req) throws PluginException; 32 | 33 | Object handleResult(Object res) throws PluginException; 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-api/src/main/java/pf4j/plugin/api/AuthcExtensionPointAdepter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j.plugin.api; 17 | 18 | import java.util.Map; 19 | 20 | import javax.servlet.http.HttpServletRequest; 21 | 22 | import ro.fortsoft.pf4j.PluginException; 23 | 24 | public class AuthcExtensionPointAdepter implements AuthcExtensionPoint{ 25 | 26 | @Override 27 | public String getToken(Map par, HttpServletRequest req) throws PluginException{ 28 | return null; 29 | } 30 | 31 | @Override 32 | public void handleHeaderParams(Map par, HttpServletRequest req) throws PluginException { 33 | } 34 | 35 | @Override 36 | public void handleRequestParams(Map par, HttpServletRequest req) throws PluginException { 37 | } 38 | 39 | @Override 40 | public Object handleResult(Object res) throws PluginException { 41 | return res; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-api/src/main/java/pf4j/plugin/api/annotation/ApiExtensionMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j.plugin.api.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Inherited; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | @Retention(RetentionPolicy.RUNTIME) 26 | @Target(ElementType.TYPE) 27 | @Documented 28 | @Inherited 29 | public @interface ApiExtensionMapping { 30 | 31 | public String id(); 32 | 33 | public String title() default ""; 34 | 35 | public String desc() default ""; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-api/src/main/java/pf4j/plugin/api/annotation/ExtensionMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j.plugin.api.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Inherited; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 27 | * @className : ExtensionMapping 28 | * @description :扩展点注解:用于某个功能扩展点的信息 29 | * @author : hiwepy 30 | * @date : 2018年3月15日 下午5:55:10 31 | * @version V1.0 32 | */ 33 | @Retention(RetentionPolicy.RUNTIME) 34 | @Target(ElementType.TYPE) 35 | @Documented 36 | @Inherited 37 | public @interface ExtensionMapping { 38 | 39 | public String id(); 40 | 41 | public String title() default ""; 42 | 43 | public String ver() default "1.0.0"; 44 | 45 | public String desc() default ""; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-api/src/main/java/pf4j/plugin/api/annotation/PluginMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j.plugin.api.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Inherited; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * @className : PluginMapping 27 | * @description :插件注解:用于标记插件的信息 28 | * @author : hiwepy 29 | * @version V1.0 30 | */ 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Target(ElementType.TYPE) 33 | @Documented 34 | @Inherited 35 | public @interface PluginMapping { 36 | 37 | public String title() default ""; 38 | 39 | public String detail() default ""; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-api/src/main/java/pf4j/plugin/api/exception/PluginInvokeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j.plugin.api.exception; 17 | 18 | import ro.fortsoft.pf4j.PluginException; 19 | 20 | @SuppressWarnings("serial") 21 | public class PluginInvokeException extends PluginException{ 22 | 23 | private String pluginId; 24 | 25 | private String extensionId; 26 | 27 | public PluginInvokeException(String pluginId, Throwable cause) { 28 | super("Plugin '" + pluginId + "' invoke error.", cause); 29 | this.pluginId = pluginId; 30 | } 31 | 32 | public PluginInvokeException(String pluginId, String extensionId, Throwable cause) { 33 | super("Plugin '" + pluginId + "' extensionId '"+extensionId+"' invoke error.", cause); 34 | this.pluginId = pluginId; 35 | this.extensionId = extensionId; 36 | } 37 | 38 | public String getPluginId() { 39 | return pluginId; 40 | } 41 | 42 | public String getExtensionId() { 43 | return extensionId; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-impl1/src/main/assembly/assembly.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | plugin 8 | 9 | zip 10 | 11 | false 12 | 13 | 14 | false 15 | runtime 16 | lib 17 | 18 | *:jar:* 19 | 20 | 21 | 22 | 30 | 31 | 32 | target/plugin-classes 33 | classes 34 | 35 | 36 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-impl1/src/main/java/pf4j/plugin/impl/AuthcPluginImpl1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j.plugin.impl; 17 | 18 | 19 | import org.apache.commons.lang.StringUtils; 20 | 21 | import pf4j.plugin.api.annotation.PluginMapping; 22 | import ro.fortsoft.pf4j.Plugin; 23 | import ro.fortsoft.pf4j.PluginWrapper; 24 | import ro.fortsoft.pf4j.RuntimeMode; 25 | 26 | @PluginMapping 27 | public class AuthcPluginImpl1 extends Plugin { 28 | 29 | public AuthcPluginImpl1(PluginWrapper wrapper) { 30 | super(wrapper); 31 | } 32 | 33 | @Override 34 | public void start() { 35 | System.out.println("AuthcPluginImpl1.start()"); 36 | // for testing the development mode 37 | if (RuntimeMode.DEVELOPMENT.equals(wrapper.getRuntimeMode())) { 38 | System.out.println(StringUtils.upperCase("AuthcPluginImpl1")); 39 | } 40 | } 41 | 42 | @Override 43 | public void stop() { 44 | System.out.println("AuthcPluginImpl1.stop()"); 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-impl1/src/main/java/pf4j/plugin/impl/extensions/AuthcExtensionPointImpl1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j.plugin.impl.extensions; 17 | 18 | import java.text.SimpleDateFormat; 19 | import java.util.Map; 20 | 21 | import javax.servlet.http.HttpServletRequest; 22 | 23 | import pf4j.plugin.api.AuthcExtensionPointAdepter; 24 | import pf4j.plugin.api.annotation.ExtensionMapping; 25 | import pf4j.plugin.impl.utils.Constant; 26 | import ro.fortsoft.pf4j.Extension; 27 | 28 | @Extension 29 | @ExtensionMapping(id = Constant.STANDARD_EXTENSION_ID, title = "认证接口实现1") 30 | public class AuthcExtensionPointImpl1 extends AuthcExtensionPointAdepter { 31 | 32 | private final String appKey = ""; 33 | private final String appSecret = ""; 34 | private final String version = "1.0"; 35 | private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 36 | 37 | @Override 38 | public void handleRequestParams(Map par, HttpServletRequest req) { 39 | 40 | par.put("appKey", appKey); 41 | par.put("appSecret", appSecret); 42 | par.put("version", version); 43 | par.put("time", sdf.format(System.currentTimeMillis())); 44 | 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-impl1/src/main/java/pf4j/plugin/impl/utils/Constant.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j.plugin.impl.utils; 17 | 18 | public class Constant { 19 | 20 | /** 用于关联业务的ID */ 21 | public static final String STANDARD_EXTENSION_ID = "Extension-ID-impl1"; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-impl2/src/main/assembly/assembly.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | plugin 8 | 9 | zip 10 | 11 | false 12 | 13 | 14 | false 15 | runtime 16 | lib 17 | 18 | *:jar:* 19 | 20 | 21 | 22 | 30 | 31 | 32 | target/plugin-classes 33 | classes 34 | 35 | 36 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-impl2/src/main/java/pf4j/plugin/impl/AuthcPluginImpl2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j.plugin.impl; 17 | 18 | 19 | import org.apache.commons.lang.StringUtils; 20 | 21 | import pf4j.plugin.api.annotation.PluginMapping; 22 | import ro.fortsoft.pf4j.Plugin; 23 | import ro.fortsoft.pf4j.PluginWrapper; 24 | import ro.fortsoft.pf4j.RuntimeMode; 25 | 26 | @PluginMapping 27 | public class AuthcPluginImpl2 extends Plugin { 28 | 29 | public AuthcPluginImpl2(PluginWrapper wrapper) { 30 | super(wrapper); 31 | } 32 | 33 | @Override 34 | public void start() { 35 | System.out.println("AuthcPluginImpl1.start()"); 36 | // for testing the development mode 37 | if (RuntimeMode.DEVELOPMENT.equals(wrapper.getRuntimeMode())) { 38 | System.out.println(StringUtils.upperCase("AuthcPluginImpl1")); 39 | } 40 | } 41 | 42 | @Override 43 | public void stop() { 44 | System.out.println("AuthcPluginImpl1.stop()"); 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-impl2/src/main/java/pf4j/plugin/impl/extensions/AuthcExtensionPointImpl2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j.plugin.impl.extensions; 17 | 18 | import java.text.SimpleDateFormat; 19 | import java.util.Map; 20 | 21 | import javax.servlet.http.HttpServletRequest; 22 | 23 | import pf4j.plugin.api.AuthcExtensionPointAdepter; 24 | import pf4j.plugin.api.annotation.ExtensionMapping; 25 | import pf4j.plugin.impl.utils.Constant; 26 | import ro.fortsoft.pf4j.Extension; 27 | 28 | @Extension 29 | @ExtensionMapping(id = Constant.STANDARD_EXTENSION_ID, title = "认证接口实现2") 30 | public class AuthcExtensionPointImpl2 extends AuthcExtensionPointAdepter { 31 | 32 | private final String appKey = ""; 33 | private final String appSecret = ""; 34 | private final String version = "1.0"; 35 | private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 36 | 37 | @Override 38 | public void handleRequestParams(Map par, HttpServletRequest req) { 39 | 40 | par.put("appKey", appKey); 41 | par.put("appSecret", appSecret); 42 | par.put("version", version); 43 | par.put("time", sdf.format(System.currentTimeMillis())); 44 | 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-impl2/src/main/java/pf4j/plugin/impl/utils/Constant.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j.plugin.impl.utils; 17 | 18 | public class Constant { 19 | 20 | /** 用于关联业务的ID */ 21 | public static final String STANDARD_EXTENSION_ID = "Extension-ID-impl2"; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-test/plugins/README.md: -------------------------------------------------------------------------------- 1 | pf4j2-plugin-impl1-1.0.0-SNAPSHOT.jar 2 | pf4j2-plugin-impl2-1.0.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-test/src/main/resources/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-pf4j/pf4j-plugin-sample/pf4j-plugin-test/src/main/resources/README.md -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/plugins/README.md: -------------------------------------------------------------------------------- 1 | pf4j2-plugin-impl1-1.0.0-SNAPSHOT.jar 2 | pf4j2-plugin-impl2-1.0.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.71.33.155/zfsoft/openjdk:1.8 2 | ENV LC_ALL en_US.UTF-8 3 | ENV TZ 'Asia/Shanghai' 4 | 5 | #创建日志目录和临时目录 6 | RUN mkdir -p /u01/boot/{logs,tmp} 7 | 8 | #拷贝本地文件到指定目录 9 | ADD /lib $BOOT/lib 10 | ADD /conf $BOOT/conf 11 | 12 | #ENV JAVA_HOME /opt/jdk 13 | #ENV PATH $PATH:$JAVA_HOME/bin 14 | 15 | EXPOSE 8081 16 | CMD ["java", "-classpath", "/u01/boot/conf:/u01/boot/lib/zftal-boot-datay.jar", "org.springframework.boot.loader.JarLauncher"] 17 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # 默认的profile为dev,其他环境通过指定启动参数使用不同的profile,比如: 2 | # 测试环境:java -jar my-spring-boot.jar --spring.profiles.active=test 3 | # 生产环境:java -jar my-spring-boot.jar --spring.profiles.active=prod 4 | 5 | server: 6 | port: 8085 7 | 8 | spring: 9 | 10 | output: 11 | ansi: 12 | enabled: always 13 | 14 | profiles: 15 | active: dev 16 | 17 | # 国际化配置: 18 | messages: 19 | #指定message的basename,多个以逗号分隔,如果不加包名的话,默认从classpath路径开始,默认: messages 20 | basename: i18n/messages 21 | #设定Message bundles的编码,默认: UTF-8 22 | encoding: UTF-8 23 | 24 | # 视图配置: 25 | mvc: 26 | static-path-pattern: /** 27 | view: 28 | prefix: classpath:/templates/ 29 | 30 | pf4j: 31 | enabled: true 32 | plugins-root: plugins 33 | 34 | #日志级别 35 | logging: 36 | config: classpath:log4j2.xml 37 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/README.md: -------------------------------------------------------------------------------- 1 | 2 | #pf4j2-plugin-sample 3 | 4 | 基于pf4j2的插件简单示例 5 | 6 | 7 | ### pf4j2-plugin-api 8 | 1、插件接口定义 9 | 10 | ### pf4j2-plugin-impl1 11 | 1、插件实现1 12 | 13 | ### pf4j2-plugin-impl2 14 | 1、插件实现2 15 | 16 | ### pf4j2-plugin-test 17 | 1、插件测试 -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-api/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.github.hiwepy 6 | pf4j2-plugin 7 | 1.0.0-SNAPSHOT 8 | 9 | pf4j2-plugin-api 10 | 11 | 12 | 13 | 14 | org.slf4j 15 | slf4j-api 16 | 17 | 18 | 19 | 20 | javax.servlet 21 | javax.servlet-api 22 | 23 | 24 | 25 | 26 | org.pf4j 27 | pf4j 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-api/src/main/java/pf4j2/plugin/api/AuthcExtensionPoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j2.plugin.api; 17 | 18 | import java.util.Map; 19 | 20 | import javax.servlet.http.HttpServletRequest; 21 | 22 | import org.pf4j.ExtensionPoint; 23 | import org.pf4j.PluginException; 24 | 25 | public interface AuthcExtensionPoint extends ExtensionPoint { 26 | 27 | String getToken(Map par,HttpServletRequest req) throws PluginException; 28 | 29 | void handleHeaderParams(Map par,HttpServletRequest req) throws PluginException; 30 | 31 | void handleRequestParams(Map par,HttpServletRequest req) throws PluginException; 32 | 33 | Object handleResult(Object res) throws PluginException; 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-api/src/main/java/pf4j2/plugin/api/AuthcExtensionPointAdepter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j2.plugin.api; 17 | 18 | import java.util.Map; 19 | 20 | import javax.servlet.http.HttpServletRequest; 21 | 22 | import org.pf4j.PluginException; 23 | 24 | public class AuthcExtensionPointAdepter implements AuthcExtensionPoint{ 25 | 26 | @Override 27 | public String getToken(Map par, HttpServletRequest req) throws PluginException{ 28 | return null; 29 | } 30 | 31 | @Override 32 | public void handleHeaderParams(Map par, HttpServletRequest req) throws PluginException { 33 | } 34 | 35 | @Override 36 | public void handleRequestParams(Map par, HttpServletRequest req) throws PluginException { 37 | } 38 | 39 | @Override 40 | public Object handleResult(Object res) throws PluginException { 41 | return res; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-api/src/main/java/pf4j2/plugin/api/annotation/ApiExtensionMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j2.plugin.api.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Inherited; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | @Retention(RetentionPolicy.RUNTIME) 26 | @Target(ElementType.TYPE) 27 | @Documented 28 | @Inherited 29 | public @interface ApiExtensionMapping { 30 | 31 | public String id(); 32 | 33 | public String title() default ""; 34 | 35 | public String desc() default ""; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-api/src/main/java/pf4j2/plugin/api/annotation/ExtensionMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j2.plugin.api.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Inherited; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 27 | * @className : ExtensionMapping 28 | * @description :扩展点注解:用于某个功能扩展点的信息 29 | * @author : hiwepy 30 | * @date : 2018年3月15日 下午5:55:10 31 | * @version V1.0 32 | */ 33 | @Retention(RetentionPolicy.RUNTIME) 34 | @Target(ElementType.TYPE) 35 | @Documented 36 | @Inherited 37 | public @interface ExtensionMapping { 38 | 39 | public String id(); 40 | 41 | public String title() default ""; 42 | 43 | public String ver() default "1.0.0"; 44 | 45 | public String desc() default ""; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-api/src/main/java/pf4j2/plugin/api/annotation/PluginMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j2.plugin.api.annotation; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Inherited; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * @className : PluginMapping 27 | * @description :插件注解:用于标记插件的信息 28 | * @author : hiwepy 29 | * @version V1.0 30 | */ 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Target(ElementType.TYPE) 33 | @Documented 34 | @Inherited 35 | public @interface PluginMapping { 36 | 37 | public String title() default ""; 38 | 39 | public String detail() default ""; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-api/src/main/java/pf4j2/plugin/api/exception/PluginInvokeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j2.plugin.api.exception; 17 | 18 | import org.pf4j.PluginException; 19 | 20 | @SuppressWarnings("serial") 21 | public class PluginInvokeException extends PluginException{ 22 | 23 | private String pluginId; 24 | 25 | private String extensionId; 26 | 27 | public PluginInvokeException(String pluginId, Throwable cause) { 28 | super("Plugin '" + pluginId + "' invoke error.", cause); 29 | this.pluginId = pluginId; 30 | } 31 | 32 | public PluginInvokeException(String pluginId, String extensionId, Throwable cause) { 33 | super("Plugin '" + pluginId + "' extensionId '"+extensionId+"' invoke error.", cause); 34 | this.pluginId = pluginId; 35 | this.extensionId = extensionId; 36 | } 37 | 38 | public String getPluginId() { 39 | return pluginId; 40 | } 41 | 42 | public String getExtensionId() { 43 | return extensionId; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-impl1/src/main/assembly/assembly.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | plugin 8 | 9 | zip 10 | 11 | false 12 | 13 | 14 | false 15 | runtime 16 | lib 17 | 18 | *:jar:* 19 | 20 | 21 | 22 | 30 | 31 | 32 | target/plugin-classes 33 | classes 34 | 35 | 36 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-impl1/src/main/java/pf4j2/plugin/impl/AuthcPluginImpl1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j2.plugin.impl; 17 | 18 | 19 | import org.apache.commons.lang.StringUtils; 20 | import org.pf4j.Plugin; 21 | import org.pf4j.PluginWrapper; 22 | import org.pf4j.RuntimeMode; 23 | 24 | import pf4j2.plugin.api.annotation.PluginMapping; 25 | 26 | @PluginMapping 27 | public class AuthcPluginImpl1 extends Plugin { 28 | 29 | public AuthcPluginImpl1(PluginWrapper wrapper) { 30 | super(wrapper); 31 | } 32 | 33 | @Override 34 | public void start() { 35 | System.out.println("AuthcPluginImpl1.start()"); 36 | // for testing the development mode 37 | if (RuntimeMode.DEVELOPMENT.equals(wrapper.getRuntimeMode())) { 38 | System.out.println(StringUtils.upperCase("AuthcPluginImpl1")); 39 | } 40 | } 41 | 42 | @Override 43 | public void stop() { 44 | System.out.println("AuthcPluginImpl1.stop()"); 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-impl1/src/main/java/pf4j2/plugin/impl/extensions/AuthcExtensionPointImpl1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j2.plugin.impl.extensions; 17 | 18 | import java.text.SimpleDateFormat; 19 | import java.util.Map; 20 | 21 | import javax.servlet.http.HttpServletRequest; 22 | 23 | import org.pf4j.Extension; 24 | 25 | import pf4j2.plugin.api.AuthcExtensionPointAdepter; 26 | import pf4j2.plugin.api.annotation.ExtensionMapping; 27 | import pf4j2.plugin.impl.utils.Constant; 28 | 29 | @Extension 30 | @ExtensionMapping(id = Constant.STANDARD_EXTENSION_ID, title = "认证接口实现1") 31 | public class AuthcExtensionPointImpl1 extends AuthcExtensionPointAdepter { 32 | 33 | private final String appKey = ""; 34 | private final String appSecret = ""; 35 | private final String version = "1.0"; 36 | private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 37 | 38 | @Override 39 | public void handleRequestParams(Map par, HttpServletRequest req) { 40 | 41 | par.put("appKey", appKey); 42 | par.put("appSecret", appSecret); 43 | par.put("version", version); 44 | par.put("time", sdf.format(System.currentTimeMillis())); 45 | 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-impl1/src/main/java/pf4j2/plugin/impl/utils/Constant.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j2.plugin.impl.utils; 17 | 18 | public class Constant { 19 | 20 | /** 用于关联业务的ID */ 21 | public static final String STANDARD_EXTENSION_ID = "Extension-ID-impl1"; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-impl2/src/main/assembly/assembly.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | plugin 8 | 9 | zip 10 | 11 | false 12 | 13 | 14 | false 15 | runtime 16 | lib 17 | 18 | *:jar:* 19 | 20 | 21 | 22 | 30 | 31 | 32 | target/plugin-classes 33 | classes 34 | 35 | 36 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-impl2/src/main/java/pf4j2/plugin/impl/AuthcPluginImpl2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j2.plugin.impl; 17 | 18 | 19 | import org.apache.commons.lang.StringUtils; 20 | import org.pf4j.Plugin; 21 | import org.pf4j.PluginWrapper; 22 | import org.pf4j.RuntimeMode; 23 | 24 | import pf4j2.plugin.api.annotation.PluginMapping; 25 | 26 | @PluginMapping 27 | public class AuthcPluginImpl2 extends Plugin { 28 | 29 | public AuthcPluginImpl2(PluginWrapper wrapper) { 30 | super(wrapper); 31 | } 32 | 33 | @Override 34 | public void start() { 35 | System.out.println("AuthcPluginImpl1.start()"); 36 | // for testing the development mode 37 | if (RuntimeMode.DEVELOPMENT.equals(wrapper.getRuntimeMode())) { 38 | System.out.println(StringUtils.upperCase("AuthcPluginImpl1")); 39 | } 40 | } 41 | 42 | @Override 43 | public void stop() { 44 | System.out.println("AuthcPluginImpl1.stop()"); 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-impl2/src/main/java/pf4j2/plugin/impl/extensions/AuthcExtensionPointImpl2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j2.plugin.impl.extensions; 17 | 18 | import java.text.SimpleDateFormat; 19 | import java.util.Map; 20 | 21 | import javax.servlet.http.HttpServletRequest; 22 | 23 | import org.pf4j.Extension; 24 | 25 | import pf4j2.plugin.api.AuthcExtensionPointAdepter; 26 | import pf4j2.plugin.api.annotation.ExtensionMapping; 27 | import pf4j2.plugin.impl.utils.Constant; 28 | 29 | @Extension 30 | @ExtensionMapping(id = Constant.STANDARD_EXTENSION_ID, title = "认证接口实现2") 31 | public class AuthcExtensionPointImpl2 extends AuthcExtensionPointAdepter { 32 | 33 | private final String appKey = ""; 34 | private final String appSecret = ""; 35 | private final String version = "1.0"; 36 | private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 37 | 38 | @Override 39 | public void handleRequestParams(Map par, HttpServletRequest req) { 40 | 41 | par.put("appKey", appKey); 42 | par.put("appSecret", appSecret); 43 | par.put("version", version); 44 | par.put("time", sdf.format(System.currentTimeMillis())); 45 | 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-impl2/src/main/java/pf4j2/plugin/impl/utils/Constant.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package pf4j2.plugin.impl.utils; 17 | 18 | public class Constant { 19 | 20 | /** 用于关联业务的ID */ 21 | public static final String STANDARD_EXTENSION_ID = "Extension-ID-impl2"; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-test/plugins/README.md: -------------------------------------------------------------------------------- 1 | pf4j2-plugin-impl1-1.0.0-SNAPSHOT.jar 2 | pf4j2-plugin-impl2-1.0.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-test/src/main/resources/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-pf4j2/pf4j2-plugin-sample/pf4j2-plugin-test/src/main/resources/README.md -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/plugins/README.md: -------------------------------------------------------------------------------- 1 | pf4j2-plugin-impl1-1.0.0-SNAPSHOT.jar 2 | pf4j2-plugin-impl2-1.0.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.71.33.155/zfsoft/openjdk:1.8 2 | ENV LC_ALL en_US.UTF-8 3 | ENV TZ 'Asia/Shanghai' 4 | 5 | #创建日志目录和临时目录 6 | RUN mkdir -p /u01/boot/{logs,tmp} 7 | 8 | #拷贝本地文件到指定目录 9 | ADD /lib $BOOT/lib 10 | ADD /conf $BOOT/conf 11 | 12 | #ENV JAVA_HOME /opt/jdk 13 | #ENV PATH $PATH:$JAVA_HOME/bin 14 | 15 | EXPOSE 8081 16 | CMD ["java", "-classpath", "/u01/boot/conf:/u01/boot/lib/zftal-boot-datay.jar", "org.springframework.boot.loader.JarLauncher"] 17 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/src/main/java/org/pf4j/spring/boot/Pf4jApplication.java: -------------------------------------------------------------------------------- 1 | package org.pf4j.spring.boot; 2 | 3 | import java.util.List; 4 | 5 | import org.pf4j.PluginManager; 6 | import org.pf4j.PluginWrapper; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.ApplicationArguments; 9 | import org.springframework.boot.ApplicationRunner; 10 | import org.springframework.boot.CommandLineRunner; 11 | import org.springframework.boot.SpringApplication; 12 | import org.springframework.boot.autoconfigure.SpringBootApplication; 13 | import org.springframework.context.annotation.Configuration; 14 | import org.springframework.scheduling.annotation.EnableScheduling; 15 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 16 | 17 | 18 | @Configuration // 配置控制 19 | @EnableScheduling 20 | @EnableWebMvc 21 | @SpringBootApplication 22 | public class Pf4jApplication implements ApplicationRunner, CommandLineRunner { 23 | 24 | @Autowired 25 | private PluginManager pluginManager; 26 | 27 | public static void main(String[] args) throws Exception { 28 | 29 | SpringApplication.run(Pf4jApplication.class, args); 30 | 31 | } 32 | 33 | @Override 34 | public void run(ApplicationArguments args) throws Exception { 35 | 36 | List list = pluginManager.getPlugins(); 37 | for (PluginWrapper pluginWrapper : list) { 38 | System.out.println(pluginWrapper.getPluginId()); 39 | 40 | List> extensions = pluginManager.getExtensions(pluginWrapper.getPluginId()); 41 | for (Object extension : extensions) { 42 | 43 | System.out.println(extension); 44 | 45 | } 46 | 47 | } 48 | 49 | pluginManager.stopPlugins(); 50 | 51 | System.out.println("============="); 52 | 53 | 54 | } 55 | 56 | @Override 57 | public void run(String... args) throws Exception { 58 | 59 | } 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /spring-boot-sample-pf4j2/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # 默认的profile为dev,其他环境通过指定启动参数使用不同的profile,比如: 2 | # 测试环境:java -jar my-spring-boot.jar --spring.profiles.active=test 3 | # 生产环境:java -jar my-spring-boot.jar --spring.profiles.active=prod 4 | 5 | server: 6 | port: 8085 7 | 8 | spring: 9 | 10 | output: 11 | ansi: 12 | enabled: always 13 | 14 | profiles: 15 | active: dev 16 | 17 | # 国际化配置: 18 | messages: 19 | #指定message的basename,多个以逗号分隔,如果不加包名的话,默认从classpath路径开始,默认: messages 20 | basename: i18n/messages 21 | #设定Message bundles的编码,默认: UTF-8 22 | encoding: UTF-8 23 | 24 | # 视图配置: 25 | mvc: 26 | static-path-pattern: /** 27 | view: 28 | prefix: classpath:/templates/ 29 | 30 | pf4j: 31 | enabled: true 32 | plugins-root: plugins 33 | 34 | #日志级别 35 | logging: 36 | config: classpath:log4j2.xml 37 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.71.33.155/zfsoft/openjdk:1.8 2 | ENV LC_ALL en_US.UTF-8 3 | ENV TZ 'Asia/Shanghai' 4 | 5 | #创建日志目录和临时目录 6 | RUN mkdir -p /u01/boot/{logs,tmp} 7 | 8 | #拷贝本地文件到指定目录 9 | ADD /lib $BOOT/lib 10 | ADD /conf $BOOT/conf 11 | 12 | #ENV JAVA_HOME /opt/jdk 13 | #ENV PATH $PATH:$JAVA_HOME/bin 14 | 15 | EXPOSE 8081 16 | CMD ["java", "-classpath", "/u01/boot/conf:/u01/boot/lib/zftal-boot-datay.jar", "org.springframework.boot.loader.JarLauncher"] 17 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/main/java/org/apache/rocketmq/spring/boot/RocketmqApplication.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot; 2 | 3 | import org.springframework.boot.ApplicationArguments; 4 | import org.springframework.boot.ApplicationRunner; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.scheduling.annotation.EnableAsync; 11 | import org.springframework.scheduling.annotation.EnableScheduling; 12 | 13 | 14 | @Configuration // 配置控制 15 | @EnableAsync //(异步回调)让@Async注解能够生效,不能加在静态方法上 16 | @EnableScheduling // 开启Scheduling 注解 17 | @EnableAutoConfiguration // 启用自动配置 18 | @SpringBootApplication 19 | public class RocketmqApplication implements ApplicationRunner, CommandLineRunner { 20 | 21 | public static void main(String[] args) throws Exception { 22 | SpringApplication.run(RocketmqApplication.class, args); 23 | } 24 | 25 | @Override 26 | public void run(ApplicationArguments args) throws Exception { 27 | 28 | } 29 | 30 | @Override 31 | public void run(String... args) throws Exception { 32 | 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/main/java/org/apache/rocketmq/spring/boot/consumer/pull/PullMessageQueueListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package org.apache.rocketmq.spring.boot.consumer.pull; 17 | 18 | import java.util.Set; 19 | 20 | import org.apache.rocketmq.client.consumer.MessageQueueListener; 21 | import org.apache.rocketmq.common.message.MessageQueue; 22 | import org.apache.rocketmq.spring.boot.annotation.RocketmqPullTopic; 23 | 24 | @RocketmqPullTopic("xxx") 25 | public class PullMessageQueueListener implements MessageQueueListener { 26 | 27 | @Override 28 | public void messageQueueChanged(String topic, Set mqAll, Set mqDivided) { 29 | // TODO Auto-generated method stub 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/main/java/org/apache/rocketmq/spring/boot/event/listener/ConsumerListen.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.event.listener; 2 | 3 | import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; 4 | import org.apache.rocketmq.client.consumer.MQPushConsumer; 5 | import org.apache.rocketmq.client.exception.MQBrokerException; 6 | import org.apache.rocketmq.client.exception.MQClientException; 7 | import org.apache.rocketmq.remoting.exception.RemotingException; 8 | import org.apache.rocketmq.spring.boot.RocketmqPushConsumerTemplate; 9 | import org.apache.rocketmq.spring.boot.event.RocketmqEvent; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.context.event.EventListener; 12 | import org.springframework.stereotype.Component; 13 | 14 | /** 15 | * @Author:钟志苗 16 | * @Date: 8:35 2017/5/13 17 | * @Description:消费监听器 18 | */ 19 | @Component 20 | public class ConsumerListen { 21 | 22 | @Autowired 23 | private RocketmqPushConsumerTemplate consumerTemplate; 24 | 25 | @EventListener(condition = "#event.topic=='test'") 26 | public void testListen(RocketmqEvent event) { 27 | MQPushConsumer consumer = consumerTemplate.getConsumer(); 28 | try { 29 | String id = new String(event.getMessageExt().getBody(),"utf-8"); 30 | System.out.println("bl"+ id); 31 | } catch (Exception e) { 32 | e.printStackTrace(); 33 | if (event.getMessageExt().getReconsumeTimes() <= 1) {// 重复消费1次 34 | try { 35 | consumer.sendMessageBack(event.getMessageExt(), 1, null); 36 | } catch (RemotingException | MQBrokerException | InterruptedException | MQClientException e1) { 37 | e1.printStackTrace(); 38 | //消息进行定时重试 39 | } 40 | } else { 41 | System.out.println("消息消费失败,定时重试"); 42 | } 43 | } 44 | } 45 | 46 | @EventListener(condition = "#event.topic=='order'") 47 | public void normalListen(RocketmqEvent event) { 48 | try { 49 | System.out.println("顺序消息:" + new String(event.getMessageExt().getBody(),"utf-8")); 50 | }catch (Exception e){ 51 | e.printStackTrace(); 52 | } 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/main/java/org/apache/rocketmq/spring/boot/setup/LogProducer.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.setup; 2 | 3 | import org.apache.rocketmq.client.producer.SendResult; 4 | import org.apache.rocketmq.common.message.Message; 5 | import org.apache.rocketmq.spring.boot.RocketmqProducerTemplate; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.CommandLineRunner; 10 | import org.springframework.stereotype.Component; 11 | 12 | @Component 13 | public class LogProducer implements CommandLineRunner { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(LogProducer.class); 16 | 17 | @Autowired(required = false) 18 | protected RocketmqProducerTemplate rocketmqTemplate; 19 | 20 | public void send(String text) throws Exception { 21 | 22 | Message msg = new Message("Topic-DC-Output", // topic 23 | "TagB-Output", // tag 24 | "KKK", // key用于标识业务的唯一性; key 消息关键词,多个Key用KEY_SEPARATOR隔开(查询消息使用) 25 | text.getBytes() // body 二进制字节数组 26 | ); 27 | SendResult result = rocketmqTemplate.send(msg); 28 | System.out.println(result); 29 | 30 | } 31 | 32 | @Override 33 | public void run(String... strings) throws Exception { 34 | send("This is a log message."); 35 | LOGGER.info("Log Message was sent to the Queue named sample.log"); 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/main/java/org/apache/rocketmq/spring/boot/setup/Producer.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.setup; 2 | 3 | import java.util.Date; 4 | 5 | import org.apache.rocketmq.client.producer.SendResult; 6 | import org.apache.rocketmq.common.message.Message; 7 | import org.apache.rocketmq.spring.boot.RocketmqProducerTemplate; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.CommandLineRunner; 10 | import org.springframework.scheduling.annotation.EnableScheduling; 11 | import org.springframework.scheduling.annotation.Scheduled; 12 | import org.springframework.stereotype.Component; 13 | 14 | @Component 15 | @EnableScheduling 16 | public class Producer implements CommandLineRunner { 17 | 18 | @Autowired(required = false) 19 | protected RocketmqProducerTemplate rocketmqTemplate; 20 | 21 | @Scheduled(fixedDelay = 3000) // 每3s执行1次 22 | public void send() throws Exception { 23 | 24 | /*// send queue. 25 | 26 | MessageQueue mq = new MessageQueue("TEST", "brokerName", 1); 27 | Message msg = new Message("TEST", // topic 28 | "TEST", // tag 29 | "KKK", // key用于标识业务的唯一性 30 | "hi,RocketMQ".getBytes()// body 二进制字节数组 31 | ); 32 | 33 | SendResult result = rocketmqTemplate.send(msg, mq); 34 | System.out.println(result);*/ 35 | 36 | // send topic. 37 | Message msg2 = new Message("Topic-DC-Output", // topic 38 | "TagA-Output", // tag 39 | "KKK", // key用于标识业务的唯一性; key 消息关键词,多个Key用KEY_SEPARATOR隔开(查询消息使用) 40 | (new Date() + ": hi,RocketMQ(topic) ").getBytes()// body 二进制字节数组 41 | ); 42 | 43 | SendResult result2 = rocketmqTemplate.send(msg2); 44 | //System.out.println(result2); 45 | 46 | } 47 | 48 | @Override 49 | public void run(String... args) throws Exception { 50 | System.out.println("Message was sent to the Queue"); 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/main/java/org/apache/rocketmq/spring/boot/setup/QueueName.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.setup; 2 | 3 | public class QueueName { 4 | 5 | public static final String LOG_QUEUE = "sample.queue"; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/main/java/org/apache/rocketmq/spring/boot/setup/RocketmqDataInDbHandler.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.setup; 2 | 3 | import org.apache.rocketmq.spring.boot.annotation.RocketmqPushRule; 4 | import org.apache.rocketmq.spring.boot.event.RocketmqEvent; 5 | import org.apache.rocketmq.spring.boot.handler.EventHandler; 6 | import org.apache.rocketmq.spring.boot.handler.chain.HandlerChain; 7 | import org.springframework.stereotype.Component; 8 | 9 | 10 | @Component("inDbHandler") 11 | @RocketmqPushRule("/Topic-DC-Input/TagA-Input/**") 12 | public class RocketmqDataInDbHandler implements EventHandler { 13 | 14 | @Override 15 | public void doHandler(RocketmqEvent event, HandlerChain handlerChain) throws Exception { 16 | 17 | System.out.println("=============================================================="); 18 | System.out.println("Rule : /Topic-DC-Input/TagA-Input/** "); 19 | 20 | long threadId = Thread.currentThread().getId(); 21 | System.out.println(String.format("Thread Id %s Topic %s Tag %s into db ....", threadId , event.getTopic() , event.getTag() )); 22 | System.out.println(String.format("Receive New Message: %s ", event.getMsgBody() )); 23 | 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/main/java/org/apache/rocketmq/spring/boot/setup/RocketmqDataSmsHandler.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.setup; 2 | 3 | import org.apache.rocketmq.spring.boot.annotation.RocketmqPushRule; 4 | import org.apache.rocketmq.spring.boot.event.RocketmqEvent; 5 | import org.apache.rocketmq.spring.boot.handler.EventHandler; 6 | import org.apache.rocketmq.spring.boot.handler.chain.HandlerChain; 7 | import org.springframework.stereotype.Component; 8 | 9 | @Component("smsHandler") 10 | @RocketmqPushRule("/Topic-DC-Input/TagB-Input/**") 11 | public class RocketmqDataSmsHandler implements EventHandler { 12 | 13 | @Override 14 | public void doHandler(RocketmqEvent event, HandlerChain handlerChain) throws Exception { 15 | 16 | System.out.println("=============================================================="); 17 | System.out.println("Rule : /Topic-DC-Input/TagB-Input/** "); 18 | 19 | long threadId = Thread.currentThread().getId(); 20 | System.out.println(String.format("Thread Id %s Topic %s Tag %s sms to user ....", threadId, event.getTopic(), 21 | event.getTag())); 22 | System.out.println(String.format("Receive New Message: %s ", event.getMsgBody() )); 23 | 24 | } 25 | 26 | 27 | } -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/main/java/org/apache/rocketmq/spring/boot/web/controller/RocketMQController.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.web.controller; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.apache.rocketmq.spring.boot.setup.LogProducer; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.util.StringUtils; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | @RestController 13 | public class RocketMQController { 14 | 15 | @Autowired 16 | private LogProducer logProducer; 17 | 18 | @GetMapping("/rocketmq/send/{msg}") 19 | public String activemq(HttpServletRequest request,@PathVariable("msg") String msg) { 20 | msg = StringUtils.isEmpty(msg) ? "This is Empty Msg." : msg; 21 | 22 | try { 23 | logProducer.send(msg); 24 | } catch (Exception e) { 25 | e.printStackTrace(); 26 | } 27 | return "Rocketmq has sent OK."; 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/main/java/org/apache/rocketmq/spring/boot/web/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.web.controller; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import com.alibaba.fastjson.JSON; 12 | 13 | 14 | @RestController 15 | @RequestMapping("/rest/user") 16 | public class UserController { 17 | 18 | @RequestMapping(value = "/getUser",method = RequestMethod.POST) 19 | public Object getUser(String key,String sign) { 20 | Map obj = new HashMap<>(); 21 | obj.put("key", key);obj.put("sign", sign); 22 | System.out.println(obj); 23 | return obj; 24 | } 25 | 26 | @RequestMapping(value = "/getUser2",method = RequestMethod.GET) 27 | public Object getUser(@RequestParam Map map) { 28 | System.out.println(JSON.toJSONString(map)); 29 | return map; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiwepy/spring-boot-starter-samples/76d0df029b3b8f9d00b23f5aefdd394cc92869ae/spring-boot-sample-rocketmq/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # 默认的profile为dev,其他环境通过指定启动参数使用不同的profile,比如: 2 | # 测试环境:java -jar my-spring-boot.jar --spring.profiles.active=test 3 | # 生产环境:java -jar my-spring-boot.jar --spring.profiles.active=prod 4 | 5 | server: 6 | port: 8085 7 | 8 | info: 9 | app: 10 | name: "@project.name@" #从pom.xml中获取 11 | description: "@project.description@" 12 | version: "@project.version@" 13 | spring-boot-version: "@project.parent.version@" 14 | 15 | spring: 16 | output: 17 | ansi: 18 | enabled: always 19 | messages: 20 | basename: /i18n/message 21 | profiles: 22 | active: dev 23 | 24 | ## URL of the ActiveMQ broker. Auto-generated by default. For instance `tcp://localhost:61616` 25 | # failover:(tcp://localhost:61616,tcp://localhost:61617) 26 | # tcp://localhost:61616 27 | rocketmq: 28 | producer: 29 | enabled: true 30 | producer-group: rmq-group2 31 | instance-name: rmq-instance 32 | namesrv-addr: 10.71.19.230:9876 33 | consumer: 34 | enabled: true 35 | consumer-group: rmq-group2 36 | instance-name: rmq-instance 37 | namesrv-addr: 10.71.19.230:9876 38 | subscription: 39 | #topic名称 : 根据实际情况设置消息的tag 40 | #数据中心数据上行主题 : 各个系统的标记 41 | Topic-DC-Input : TagA-Input || TagB-Input || TagC-Input || TagD-Input 42 | event: 43 | definition-map: 44 | /Topic-DC-Input/TagA-Input/** : inDbHandler 45 | /Topic-DC-Input/TagB-Input/** : smsHandler 46 | 47 | #日志级别 48 | logging: 49 | config: classpath:log4j2.xml 50 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/test/java/org/apache/rocketmq/spring/boot/RocketmqApplicationTests.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot; 2 | 3 | import org.apache.rocketmq.client.exception.MQBrokerException; 4 | import org.apache.rocketmq.client.exception.MQClientException; 5 | import org.apache.rocketmq.client.producer.SendResult; 6 | import org.apache.rocketmq.common.message.Message; 7 | import org.apache.rocketmq.remoting.exception.RemotingException; 8 | import org.apache.rocketmq.spring.boot.RocketmqProducerTemplate; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.context.SpringBootTest; 13 | import org.springframework.test.context.junit4.SpringRunner; 14 | 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 18 | public class RocketmqApplicationTests { 19 | 20 | @Autowired 21 | protected RocketmqProducerTemplate rocketmqTemplate; 22 | 23 | @Test 24 | public void contextLoads() throws MQClientException, RemotingException, MQBrokerException, InterruptedException { 25 | // Destination destination = new ActiveMQQueue("mytest.queue"); 26 | Message msg = new Message("TEST", // topic 27 | "TEST", // tag 28 | "KKK", // key用于标识业务的唯一性 29 | "hi,RocketMQ".getBytes()// body 二进制字节数组 30 | ); 31 | 32 | for(int i=0; i<100; i++){ 33 | SendResult result = rocketmqTemplate.send(msg); 34 | System.out.println(result); 35 | 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/test/java/org/apache/rocketmq/spring/boot/org/BatchProducer.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.org; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.apache.rocketmq.client.producer.DefaultMQProducer; 7 | import org.apache.rocketmq.common.message.Message; 8 | 9 | /** 10 | * http://rocketmq.apache.org/docs/batch-example/ 11 | */ 12 | public class BatchProducer { 13 | 14 | public static void main(String[] args) throws Exception { 15 | //Instantiate with a producer group name. 16 | DefaultMQProducer producer = new DefaultMQProducer("ExampleProducerGroup"); 17 | producer.setRetryTimesWhenSendAsyncFailed(0); 18 | //Launch the instance. 19 | producer.start(); 20 | 21 | String topic = "BatchTest"; 22 | List messages = new ArrayList(); 23 | messages.add(new Message(topic, "TagA", "OrderID001", "Hello world 0".getBytes())); 24 | messages.add(new Message(topic, "TagA", "OrderID002", "Hello world 1".getBytes())); 25 | messages.add(new Message(topic, "TagA", "OrderID003", "Hello world 2".getBytes())); 26 | try { 27 | producer.send(messages); 28 | } catch (Exception e) { 29 | e.printStackTrace(); 30 | //handle the error 31 | } 32 | 33 | 34 | //then you could split the large list into small ones: 35 | ListSplitter splitter = new ListSplitter(messages); 36 | while (splitter.hasNext()) { 37 | try { 38 | List listItem = splitter.next(); 39 | producer.send(listItem); 40 | } catch (Exception e) { 41 | e.printStackTrace(); 42 | //handle the error 43 | } 44 | } 45 | 46 | //Shut down once the producer instance is not longer in use. 47 | producer.shutdown(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/test/java/org/apache/rocketmq/spring/boot/org/BroadcastConsumer.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.org; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; 6 | import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; 7 | import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; 8 | import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; 9 | import org.apache.rocketmq.common.consumer.ConsumeFromWhere; 10 | import org.apache.rocketmq.common.message.MessageExt; 11 | import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; 12 | 13 | /** 14 | * http://rocketmq.apache.org/docs/broadcast-example/ 15 | */ 16 | public class BroadcastConsumer { 17 | 18 | public static void main(String[] args) throws Exception { 19 | 20 | DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("example_group_name"); 21 | 22 | consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); 23 | 24 | // set to broadcast mode 25 | consumer.setMessageModel(MessageModel.BROADCASTING); 26 | 27 | consumer.subscribe("TopicTest", "TagA || TagC || TagD"); 28 | 29 | consumer.registerMessageListener(new MessageListenerConcurrently() { 30 | 31 | @Override 32 | public ConsumeConcurrentlyStatus consumeMessage(List msgs, ConsumeConcurrentlyContext context) { 33 | System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n"); 34 | return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; 35 | } 36 | }); 37 | 38 | consumer.start(); 39 | System.out.printf("Broadcast Consumer Started.%n"); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/test/java/org/apache/rocketmq/spring/boot/org/BroadcastProducer.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.org; 2 | 3 | import org.apache.rocketmq.client.producer.DefaultMQProducer; 4 | import org.apache.rocketmq.client.producer.SendResult; 5 | import org.apache.rocketmq.common.message.Message; 6 | import org.apache.rocketmq.remoting.common.RemotingHelper; 7 | 8 | /** 9 | * http://rocketmq.apache.org/docs/broadcast-example/ 10 | */ 11 | public class BroadcastProducer { 12 | 13 | public static void main(String[] args) throws Exception { 14 | DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName"); 15 | producer.start(); 16 | 17 | for (int i = 0; i < 100; i++){ 18 | Message msg = new Message("TopicTest", 19 | "TagA", 20 | "OrderID188", 21 | "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET)); 22 | SendResult sendResult = producer.send(msg); 23 | System.out.printf("%s%n", sendResult); 24 | } 25 | producer.shutdown(); 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/test/java/org/apache/rocketmq/spring/boot/org/ListSplitter.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.org; 2 | 3 | import java.util.Iterator; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import org.apache.rocketmq.common.message.Message; 8 | 9 | public class ListSplitter implements Iterator> { 10 | private final int SIZE_LIMIT = 1000 * 1000; 11 | private final List messages; 12 | private int currIndex; 13 | public ListSplitter(List messages) { 14 | this.messages = messages; 15 | } 16 | @Override public boolean hasNext() { 17 | return currIndex < messages.size(); 18 | } 19 | @Override public List next() { 20 | int nextIndex = currIndex; 21 | int totalSize = 0; 22 | for (; nextIndex < messages.size(); nextIndex++) { 23 | Message message = messages.get(nextIndex); 24 | int tmpSize = message.getTopic().length() + message.getBody().length; 25 | Map properties = message.getProperties(); 26 | for (Map.Entry entry : properties.entrySet()) { 27 | tmpSize += entry.getKey().length() + entry.getValue().length(); 28 | } 29 | tmpSize = tmpSize + 20; //for log overhead 30 | if (tmpSize > SIZE_LIMIT) { 31 | //it is unexpected that single message exceeds the SIZE_LIMIT 32 | //here just let it go, otherwise it will block the splitting process 33 | if (nextIndex - currIndex == 0) { 34 | //if the next sublist has no element, add this one and then break, otherwise just break 35 | nextIndex++; 36 | } 37 | break; 38 | } 39 | if (tmpSize + totalSize > SIZE_LIMIT) { 40 | break; 41 | } else { 42 | totalSize += tmpSize; 43 | } 44 | 45 | } 46 | List subList = messages.subList(currIndex, nextIndex); 47 | currIndex = nextIndex; 48 | return subList; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/test/java/org/apache/rocketmq/spring/boot/org/OrderedConsumer.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.org; 2 | 3 | import java.util.List; 4 | import java.util.concurrent.atomic.AtomicLong; 5 | 6 | import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; 7 | import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyContext; 8 | import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyStatus; 9 | import org.apache.rocketmq.client.consumer.listener.MessageListenerOrderly; 10 | import org.apache.rocketmq.common.consumer.ConsumeFromWhere; 11 | import org.apache.rocketmq.common.message.MessageExt; 12 | 13 | /** 14 | * http://rocketmq.apache.org/docs/order-example/ 15 | */ 16 | public class OrderedConsumer { 17 | 18 | public static void main(String[] args) throws Exception { 19 | 20 | DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("example_group_name"); 21 | 22 | consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); 23 | 24 | consumer.subscribe("TopicTest", "TagA || TagC || TagD"); 25 | 26 | consumer.registerMessageListener(new MessageListenerOrderly() { 27 | 28 | AtomicLong consumeTimes = new AtomicLong(0); 29 | 30 | @Override 31 | public ConsumeOrderlyStatus consumeMessage(List msgs, ConsumeOrderlyContext context) { 32 | context.setAutoCommit(false); 33 | System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n"); 34 | this.consumeTimes.incrementAndGet(); 35 | if ((this.consumeTimes.get() % 2) == 0) { 36 | return ConsumeOrderlyStatus.SUCCESS; 37 | } else if ((this.consumeTimes.get() % 3) == 0) { 38 | return ConsumeOrderlyStatus.ROLLBACK; 39 | } else if ((this.consumeTimes.get() % 4) == 0) { 40 | return ConsumeOrderlyStatus.COMMIT; 41 | } else if ((this.consumeTimes.get() % 5) == 0) { 42 | context.setSuspendCurrentQueueTimeMillis(3000); 43 | return ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT; 44 | } 45 | return ConsumeOrderlyStatus.SUCCESS; 46 | 47 | } 48 | }); 49 | 50 | consumer.start(); 51 | 52 | System.out.printf("Consumer Started.%n"); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/test/java/org/apache/rocketmq/spring/boot/org/OrderedProducer.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.org; 2 | 3 | 4 | import java.util.List; 5 | 6 | import org.apache.rocketmq.client.producer.DefaultMQProducer; 7 | import org.apache.rocketmq.client.producer.MQProducer; 8 | import org.apache.rocketmq.client.producer.MessageQueueSelector; 9 | import org.apache.rocketmq.client.producer.SendResult; 10 | import org.apache.rocketmq.common.message.Message; 11 | import org.apache.rocketmq.common.message.MessageQueue; 12 | import org.apache.rocketmq.remoting.common.RemotingHelper; 13 | 14 | /** 15 | * http://rocketmq.apache.org/docs/order-example/ 16 | */ 17 | public class OrderedProducer { 18 | public static void main(String[] args) throws Exception { 19 | //Instantiate with a producer group name. 20 | MQProducer producer = new DefaultMQProducer("example_group_name"); 21 | //Launch the instance. 22 | producer.start(); 23 | String[] tags = new String[] {"TagA", "TagB", "TagC", "TagD", "TagE"}; 24 | for (int i = 0; i < 100; i++) { 25 | int orderId = i % 10; 26 | //Create a message instance, specifying topic, tag and message body. 27 | Message msg = new Message("TopicTestjjj", tags[i % tags.length], "KEY" + i, 28 | ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)); 29 | SendResult sendResult = producer.send(msg, new MessageQueueSelector() { 30 | @Override 31 | public MessageQueue select(List mqs, Message msg, Object arg) { 32 | Integer id = (Integer) arg; 33 | int index = id % mqs.size(); 34 | return mqs.get(index); 35 | } 36 | }, orderId); 37 | 38 | System.out.printf("%s%n", sendResult); 39 | } 40 | //server shutdown 41 | producer.shutdown(); 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/test/java/org/apache/rocketmq/spring/boot/org/ScheduledMessageConsumer.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.org; 2 | 3 | import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; 4 | import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; 5 | import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; 6 | import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; 7 | import org.apache.rocketmq.common.message.MessageExt; 8 | import java.util.List; 9 | 10 | /** 11 | * http://rocketmq.apache.org/docs/schedule-example/ 12 | */ 13 | public class ScheduledMessageConsumer { 14 | 15 | public static void main(String[] args) throws Exception { 16 | // Instantiate message consumer 17 | DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("ExampleConsumer"); 18 | // Subscribe topics 19 | consumer.subscribe("TestTopic", "*"); 20 | // Register message listener 21 | consumer.registerMessageListener(new MessageListenerConcurrently() { 22 | @Override 23 | public ConsumeConcurrentlyStatus consumeMessage(List messages, ConsumeConcurrentlyContext context) { 24 | for (MessageExt message : messages) { 25 | // Print approximate delay time period 26 | System.out.println("Receive message[msgId=" + message.getMsgId() + "] " 27 | + (System.currentTimeMillis() - message.getStoreTimestamp()) + "ms later"); 28 | } 29 | return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; 30 | } 31 | }); 32 | // Launch consumer 33 | consumer.start(); 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/test/java/org/apache/rocketmq/spring/boot/org/ScheduledMessageProducer.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.org; 2 | 3 | import org.apache.rocketmq.client.producer.DefaultMQProducer; 4 | import org.apache.rocketmq.common.message.Message; 5 | 6 | /** 7 | * http://rocketmq.apache.org/docs/schedule-example/ 8 | */ 9 | public class ScheduledMessageProducer { 10 | 11 | public static void main(String[] args) throws Exception { 12 | // Instantiate a producer to send scheduled messages 13 | DefaultMQProducer producer = new DefaultMQProducer("ExampleProducerGroup"); 14 | // Launch producer 15 | producer.start(); 16 | int totalMessagesToSend = 100; 17 | for (int i = 0; i < totalMessagesToSend; i++) { 18 | Message message = new Message("TestTopic", ("Hello scheduled message " + i).getBytes()); 19 | // This message will be delivered to consumer 10 seconds later. 20 | message.setDelayTimeLevel(3); 21 | // Send the message 22 | producer.send(message); 23 | } 24 | 25 | // Shutdown producer after use. 26 | producer.shutdown(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/test/java/org/apache/rocketmq/spring/boot/org/SimpleAsyncProducer.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.org; 2 | 3 | import org.apache.rocketmq.client.producer.DefaultMQProducer; 4 | import org.apache.rocketmq.client.producer.SendCallback; 5 | import org.apache.rocketmq.client.producer.SendResult; 6 | import org.apache.rocketmq.common.message.Message; 7 | import org.apache.rocketmq.remoting.common.RemotingHelper; 8 | 9 | /** 10 | * http://rocketmq.apache.org/docs/simple-example/ 11 | */ 12 | public class SimpleAsyncProducer { 13 | 14 | 15 | public static void main(String[] args) throws Exception { 16 | //Instantiate with a producer group name. 17 | DefaultMQProducer producer = new DefaultMQProducer("ExampleProducerGroup"); 18 | //Launch the instance. 19 | producer.start(); 20 | producer.setRetryTimesWhenSendAsyncFailed(0); 21 | for (int i = 0; i < 100; i++) { 22 | final int index = i; 23 | //Create a message instance, specifying topic, tag and message body. 24 | Message msg = new Message("TopicTest", 25 | "TagA", 26 | "OrderID188", 27 | "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET)); 28 | producer.send(msg, new SendCallback() { 29 | 30 | @Override 31 | public void onSuccess(SendResult sendResult) { 32 | System.out.printf("%-10d OK %s %n", index, 33 | sendResult.getMsgId()); 34 | } 35 | @Override 36 | public void onException(Throwable e) { 37 | System.out.printf("%-10d Exception %s %n", index, e); 38 | e.printStackTrace(); 39 | } 40 | 41 | }); 42 | } 43 | //Shut down once the producer instance is not longer in use. 44 | producer.shutdown(); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/test/java/org/apache/rocketmq/spring/boot/org/SimpleOnewayProducer.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.org; 2 | 3 | import org.apache.rocketmq.client.producer.DefaultMQProducer; 4 | import org.apache.rocketmq.common.message.Message; 5 | import org.apache.rocketmq.remoting.common.RemotingHelper; 6 | /** 7 | * http://rocketmq.apache.org/docs/simple-example/ 8 | */ 9 | public class SimpleOnewayProducer { 10 | 11 | public static void main(String[] args) throws Exception{ 12 | //Instantiate with a producer group name. 13 | DefaultMQProducer producer = new DefaultMQProducer("ExampleProducerGroup"); 14 | //Launch the instance. 15 | producer.start(); 16 | for (int i = 0; i < 100; i++) { 17 | //Create a message instance, specifying topic, tag and message body. 18 | Message msg = new Message("TopicTest" /* Topic */, 19 | "TagA" /* Tag */, 20 | ("Hello RocketMQ " + 21 | i).getBytes(RemotingHelper.DEFAULT_CHARSET) /* Message body */ 22 | ); 23 | //Call send message to deliver message to one of brokers. 24 | producer.sendOneway(msg); 25 | 26 | } 27 | //Shut down once the producer instance is not longer in use. 28 | producer.shutdown(); 29 | } 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/test/java/org/apache/rocketmq/spring/boot/org/SimpleSyncProducer.java: -------------------------------------------------------------------------------- 1 | package org.apache.rocketmq.spring.boot.org; 2 | 3 | import org.apache.rocketmq.client.producer.DefaultMQProducer; 4 | import org.apache.rocketmq.client.producer.SendResult; 5 | import org.apache.rocketmq.common.message.Message; 6 | import org.apache.rocketmq.remoting.common.RemotingHelper; 7 | /** 8 | * http://rocketmq.apache.org/docs/simple-example/ 9 | */ 10 | public class SimpleSyncProducer { 11 | 12 | public static void main(String[] args) throws Exception { 13 | // Instantiate with a producer group name. 14 | DefaultMQProducer producer = new DefaultMQProducer("please_rename_unique_group_name"); 15 | // Launch the instance. 16 | producer.start(); 17 | for (int i = 0; i < 100; i++) { 18 | // Create a message instance, specifying topic, tag and message body. 19 | Message msg = new Message("TopicTest" /* Topic */, "TagA" /* Tag */, 20 | ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET) /* Message body */ 21 | ); 22 | // Call send message to deliver message to one of brokers. 23 | SendResult sendResult = producer.send(msg); 24 | System.out.printf("%s%n", sendResult); 25 | } 26 | // Shut down once the producer instance is not longer in use. 27 | producer.shutdown(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-sample-rocketmq/src/test/java/org/apache/rocketmq/spring/boot/quick-start.md: -------------------------------------------------------------------------------- 1 | #http://rocketmq.apache.org/docs/quick-start/ 2 | 3 | 一、系统要求 4 | 5 | The following softwares are assumed installed: 6 | 7 | 64bit OS, Linux/Unix/Mac is recommended; 8 | 64bit JDK 1.8+; 9 | Maven 3.2.x 10 | Git 11 | 12 | 二、服务安装: 13 | 14 | 1、安装包模式 15 | 16 | https://www.apache.org/dyn/closer.cgi?path=incubator/rocketmq/ 17 | 下载最新版本 18 | 参照 http://blog.csdn.net/loongshawn/article/details/51086876 安装 19 | 20 | 21 | 2、源码没模式 22 | 23 | Clone & Build 24 | 25 | > git clone -b release-4.1.0-incubating https://github.com/apache/incubator-rocketmq.git 26 | > cd incubator-rocketmq 27 | > mvn -Prelease-all -DskipTests clean install -U 28 | > cd distribution/target/apache-rocketmq 29 | 30 | 三、服务启动、关闭 31 | 32 | Start Name Server 33 | 34 | > nohup sh mqnamesrv 1>$ROCKETMQ_HOME/logs/ng.log 2>$ROCKETMQ_HOME/logs/ng-err.log & 35 | 36 | > nohup sh bin/mqnamesrv & 37 | > tail -f ~/logs/rocketmqlogs/namesrv.log 38 | The Name Server boot success... 39 | 40 | Start Broker 41 | 42 | > nohup sh bin/mqbroker -n localhost:9876 & 43 | > tail -f ~/logs/rocketmqlogs/broker.log 44 | The broker[%s, 172.30.30.233:10911] boot success... 45 | 46 | 47 | Send & Receive Messages 48 | 49 | Before sending/receiving messages, we need to tell clients the location of name servers. RocketMQ provides multiple ways to achieve this. For simplicity, we use environment variable NAMESRV_ADDR 50 | 51 | > export NAMESRV_ADDR=localhost:9876 52 | > sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer 53 | SendResult [sendStatus=SEND_OK, msgId= ... 54 | 55 | > sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer 56 | ConsumeMessageThread_%d Receive New Messages: [MessageExt... 57 | 58 | Shutdown Servers 59 | 60 | > sh bin/mqshutdown broker 61 | The mqbroker(36695) is running... 62 | Send shutdown request to mqbroker(36695) OK 63 | 64 | > sh bin/mqshutdown namesrv 65 | The mqnamesrv(36664) is running... 66 | Send shutdown request to mqnamesrv(36664) OK 67 | 68 | -------------------------------------------------------------------------------- /spring-boot-sample-socketio/src/main/java/com/corundumstudio/socketio/spring/boot/SocketioIndeController.java: -------------------------------------------------------------------------------- 1 | package com.corundumstudio.socketio.spring.boot; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | 7 | @Controller 8 | public class SocketioIndeController { 9 | 10 | @RequestMapping(value = "/", method = RequestMethod.GET) 11 | public String uuid() { 12 | return "html/socketio/index"; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-sample-socketio/src/main/java/com/corundumstudio/socketio/spring/boot/config/SocketioConfig.java: -------------------------------------------------------------------------------- 1 | package com.corundumstudio.socketio.spring.boot.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import com.corundumstudio.socketio.AuthorizationListener; 7 | import com.corundumstudio.socketio.handler.SuccessAuthorizationListener; 8 | import com.corundumstudio.socketio.listener.ExceptionListener; 9 | import com.corundumstudio.socketio.spring.boot.listener.SocketExceptionListener; 10 | 11 | @Configuration 12 | public class SocketioConfig { 13 | 14 | @Bean 15 | public ExceptionListener exceptionListener() { 16 | return new SocketExceptionListener(); 17 | } 18 | 19 | @Bean 20 | public AuthorizationListener socketAuthzListener() { 21 | return new SuccessAuthorizationListener(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-sample-socketio/src/main/java/com/corundumstudio/socketio/spring/boot/handler/MessageInfo.java: -------------------------------------------------------------------------------- 1 | package com.corundumstudio.socketio.spring.boot.handler; 2 | 3 | public class MessageInfo { 4 | 5 | private String from; 6 | private String to; 7 | private String content; 8 | 9 | public String getFrom() { 10 | return from; 11 | } 12 | public void setFrom(String from) { 13 | this.from = from; 14 | } 15 | public String getTo() { 16 | return to; 17 | } 18 | public void setTo(String to) { 19 | this.to = to; 20 | } 21 | public String getContent() { 22 | return content; 23 | } 24 | public void setContent(String content) { 25 | this.content = content; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return "Msg [from=" + from + ", to=" + to + ", content=" + content + "]"; 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /spring-boot-sample-socketio/src/main/java/com/corundumstudio/socketio/spring/boot/listener/SocketConnectListener.java: -------------------------------------------------------------------------------- 1 | package com.corundumstudio.socketio.spring.boot.listener; 2 | 3 | import com.corundumstudio.socketio.SocketIOClient; 4 | import com.corundumstudio.socketio.listener.ConnectListener; 5 | 6 | public class SocketConnectListener implements ConnectListener { 7 | 8 | @Override 9 | public void onConnect(SocketIOClient client) { 10 | 11 | System.out.printf("建立连接: Session ID %s", client.getSessionId()); 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-sample-socketio/src/main/java/com/corundumstudio/socketio/spring/boot/listener/SocketDataListener.java: -------------------------------------------------------------------------------- 1 | package com.corundumstudio.socketio.spring.boot.listener; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import com.corundumstudio.socketio.AckCallback; 7 | import com.corundumstudio.socketio.AckRequest; 8 | import com.corundumstudio.socketio.SocketIOClient; 9 | import com.corundumstudio.socketio.listener.DataListener; 10 | import com.corundumstudio.socketio.spring.boot.handler.MessageInfo; 11 | 12 | public class SocketDataListener implements DataListener { 13 | 14 | Logger logger = LoggerFactory.getLogger(getClass()); 15 | 16 | @Override 17 | public void onData(final SocketIOClient client, MessageInfo data, AckRequest ackRequest) { 18 | // 握手 19 | if (data.getContent().equals("hello")) { 20 | 21 | String userid = data.getFrom(); 22 | logger.info(Thread.currentThread().getName() + "web读取到的userid:" + userid); 23 | 24 | // send message back to client with ack callback 25 | // WITH data 26 | client.sendEvent("onSocketEvent", new AckCallback(String.class) { 27 | @Override 28 | public void onSuccess(String result) { 29 | logger.info("ack from client: " + client.getSessionId() + " data: " + result); 30 | } 31 | }, 1000); 32 | 33 | } else { 34 | logger.info("行情接收到了不应该有的web客户端请求1111..."); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spring-boot-sample-socketio/src/main/java/com/corundumstudio/socketio/spring/boot/listener/SocketDisconnectListener.java: -------------------------------------------------------------------------------- 1 | package com.corundumstudio.socketio.spring.boot.listener; 2 | 3 | import com.corundumstudio.socketio.SocketIOClient; 4 | import com.corundumstudio.socketio.listener.DisconnectListener; 5 | 6 | public class SocketDisconnectListener implements DisconnectListener { 7 | 8 | @Override 9 | public void onDisconnect(SocketIOClient client) { 10 | System.out.printf("关闭连接: Session ID %s", client.getSessionId()); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-sample-socketio/src/main/java/com/corundumstudio/socketio/spring/boot/listener/SocketExceptionListener.java: -------------------------------------------------------------------------------- 1 | package com.corundumstudio.socketio.spring.boot.listener; 2 | 3 | import java.util.List; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import com.corundumstudio.socketio.SocketIOClient; 9 | import com.corundumstudio.socketio.listener.DefaultExceptionListener; 10 | import com.corundumstudio.socketio.listener.ExceptionListenerAdapter; 11 | 12 | import io.netty.channel.ChannelHandlerContext; 13 | 14 | public class SocketExceptionListener extends ExceptionListenerAdapter { 15 | 16 | private static final Logger log = LoggerFactory.getLogger(DefaultExceptionListener.class); 17 | 18 | @Override 19 | public void onEventException(Exception e, List args, SocketIOClient client) { 20 | log.error(e.getMessage(), e); 21 | } 22 | 23 | @Override 24 | public void onDisconnectException(Exception e, SocketIOClient client) { 25 | log.error(e.getMessage(), e); 26 | } 27 | 28 | @Override 29 | public void onConnectException(Exception e, SocketIOClient client) { 30 | log.error(e.getMessage(), e); 31 | } 32 | 33 | @Override 34 | public void onPingException(Exception e, SocketIOClient client) { 35 | log.error(e.getMessage(), e); 36 | } 37 | 38 | @Override 39 | public boolean exceptionCaught(ChannelHandlerContext ctx, Throwable e) throws Exception { 40 | log.error(e.getMessage(), e); 41 | return true; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /spring-boot-sample-socketio/src/main/java/com/corundumstudio/socketio/spring/boot/listener/SocketPingListener.java: -------------------------------------------------------------------------------- 1 | package com.corundumstudio.socketio.spring.boot.listener; 2 | 3 | import com.corundumstudio.socketio.SocketIOClient; 4 | import com.corundumstudio.socketio.listener.PingListener; 5 | 6 | public class SocketPingListener implements PingListener { 7 | 8 | @Override 9 | public void onPing(SocketIOClient client) { 10 | System.out.printf("Ping: Session ID %s", client.getSessionId()); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-sample-swagger2/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 10.71.33.155/zfsoft/openjdk:1.8 2 | ENV LC_ALL en_US.UTF-8 3 | ENV TZ 'Asia/Shanghai' 4 | 5 | #创建日志目录和临时目录 6 | RUN mkdir -p /u01/boot/{logs,tmp} 7 | 8 | #拷贝本地文件到指定目录 9 | ADD /lib $BOOT/lib 10 | ADD /conf $BOOT/conf 11 | 12 | #ENV JAVA_HOME /opt/jdk 13 | #ENV PATH $PATH:$JAVA_HOME/bin 14 | 15 | EXPOSE 8081 16 | CMD ["java", "-classpath", "/u01/boot/conf:/u01/boot/lib/zftal-boot-datay.jar", "org.springframework.boot.loader.JarLauncher"] 17 | -------------------------------------------------------------------------------- /spring-boot-sample-swagger2/src/main/java/io/swagger2/spring/boot/SwaggerApplication.java: -------------------------------------------------------------------------------- 1 | package io.swagger2.spring.boot; 2 | 3 | import org.springframework.boot.ApplicationArguments; 4 | import org.springframework.boot.ApplicationRunner; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.scheduling.annotation.EnableScheduling; 11 | 12 | import com.spring4all.swagger.EnableSwagger2Doc; 13 | 14 | @Configuration // 配置控制 15 | @EnableScheduling 16 | @EnableAutoConfiguration // 启用自动配置 17 | @EnableSwagger2Doc 18 | @SpringBootApplication 19 | public class SwaggerApplication implements ApplicationRunner, CommandLineRunner { 20 | 21 | public static void main(String[] args) throws Exception { 22 | 23 | SpringApplication.run(SwaggerApplication.class, args); 24 | 25 | } 26 | 27 | @Override 28 | public void run(ApplicationArguments args) throws Exception { 29 | 30 | } 31 | 32 | @Override 33 | public void run(String... args) throws Exception { 34 | 35 | 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-sample-swagger2/src/main/java/io/swagger2/spring/boot/dao/Result.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.swagger2.spring.boot.dao; 17 | 18 | public class Result { 19 | 20 | private T data; 21 | 22 | public T getData() { 23 | return data; 24 | } 25 | 26 | public void setData(T data) { 27 | this.data = data; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-sample-swagger2/src/main/java/io/swagger2/spring/boot/web/controller/HelloWorldController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.swagger2.spring.boot.web.controller; 17 | 18 | import org.springframework.web.bind.annotation.PathVariable; 19 | import org.springframework.web.bind.annotation.RequestMapping; 20 | import org.springframework.web.bind.annotation.RequestMethod; 21 | import org.springframework.web.bind.annotation.RestController; 22 | 23 | @RestController 24 | public class HelloWorldController { 25 | 26 | /*@RequestMapping(value = "/{name}", method = RequestMethod.GET) 27 | public String sayWorld(@PathVariable("name") String name) { 28 | return "Hello " + name; 29 | }*/ 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /spring-boot-sample-swagger2/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | 2 | spring: 3 | output: 4 | ansi: 5 | enabled: always 6 | messages: 7 | basename: /i18n/message 8 | profiles: 9 | active: dev 10 | #MVC 11 | mvc: 12 | static-path-pattern: /** 13 | view: 14 | prefix: classpath:/templates/ 15 | 16 | #日志级别 17 | logging: 18 | config: classpath:log4j2.xml 19 | 20 | swagger: 21 | enabled: true 22 | title: spring-boot-starter-swagger 23 | base-package: io.swagger2.spring.boot 24 | base-path: 25 | - /** 26 | description: Starter for swagger 2.x 27 | exclude-path: 28 | - /error 29 | - /ops/** 30 | version: 1.1.0.RELEASE 31 | license: Apache License, Version 2.0 32 | license-url: https://www.apache.org/licenses/LICENSE-2.0.html 33 | terms-of-service-url: https://github.com/dyc87112/spring-boot-starter-swagger 34 | contact: 35 | name : hiwepy 36 | email: hnxyhcwdl1003@163.com 37 | url : https://github.com/hiwepy -------------------------------------------------------------------------------- /spring-boot-sample-websocket/src/main/java/com/github/vindell/websocket/HandshakeInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.github.hiwepy.websocket; 2 | 3 | import java.util.Map; 4 | 5 | import org.springframework.http.server.ServerHttpRequest; 6 | import org.springframework.http.server.ServerHttpResponse; 7 | import org.springframework.web.socket.WebSocketHandler; 8 | import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; 9 | 10 | public class HandshakeInterceptor extends HttpSessionHandshakeInterceptor { 11 | 12 | @Override 13 | public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, 14 | Map attributes) throws Exception { 15 | System.out.println("Before Handshake"); 16 | return super.beforeHandshake(request, response, wsHandler, attributes); 17 | } 18 | 19 | @Override 20 | public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, 21 | Exception ex) { 22 | System.out.println("After Handshake"); 23 | super.afterHandshake(request, response, wsHandler, ex); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /spring-boot-sample-websocket/src/main/java/com/github/vindell/websocket/Monitor.java: -------------------------------------------------------------------------------- 1 | package com.github.hiwepy.websocket; 2 | 3 | import java.util.Date; 4 | import java.util.concurrent.Executors; 5 | import java.util.concurrent.ScheduledExecutorService; 6 | import java.util.concurrent.TimeUnit; 7 | 8 | 9 | public class Monitor implements Runnable { 10 | 11 | 12 | public void run() { 13 | WebSocketTest webSocketTest = new WebSocketTest(); 14 | webSocketTest.sendMsg("当前时间:" + new Date()); 15 | } 16 | 17 | public void sendMsg() { 18 | ScheduledExecutorService newScheduledThreadPool = Executors.newSingleThreadScheduledExecutor(); 19 | newScheduledThreadPool.scheduleWithFixedDelay(new Monitor(), 20, 5, TimeUnit.SECONDS); 20 | 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /spring-boot-sample-websocket/src/main/java/com/github/vindell/websocket/WebSocketHandshakeInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.github.hiwepy.websocket; 17 | 18 | import java.util.Map; 19 | 20 | import org.springframework.http.server.ServerHttpRequest; 21 | import org.springframework.http.server.ServerHttpResponse; 22 | import org.springframework.http.server.ServletServerHttpRequest; 23 | import org.springframework.web.socket.WebSocketHandler; 24 | import org.springframework.web.socket.server.HandshakeInterceptor; 25 | 26 | public class WebSocketHandshakeInterceptor implements HandshakeInterceptor { 27 | 28 | @Override 29 | public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, 30 | Map attributes) throws Exception { 31 | if (request instanceof ServletServerHttpRequest) { 32 | attributes.put("username", ""); 33 | } 34 | return true; 35 | } 36 | 37 | @Override 38 | public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, 39 | Exception exception) { 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-boot-sample-websocket/src/main/java/com/github/vindell/websocket/config/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package com.github.hiwepy.websocket.config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Qualifier; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.socket.config.annotation.WebSocketConfigurer; 8 | import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; 9 | 10 | import com.github.hiwepy.websocket.handler.BroadcastWebSocketsHandler; 11 | import com.github.hiwepy.websocket.handler.MessageEventWebSocketHandler; 12 | import com.github.hiwepy.websocket.interceptor.HandshakeSessionInterceptor; 13 | import com.github.hiwepy.websocket.session.SessionFilter; 14 | import com.github.hiwepy.websocket.session.SessionUriPathFilter; 15 | 16 | @Configuration 17 | public class WebSocketConfig implements WebSocketConfigurer { 18 | 19 | @Autowired 20 | @Qualifier("dashboardWebSocketsHandler") 21 | private BroadcastWebSocketsHandler dashboardWebSocketsHandler; 22 | 23 | @Bean("dashboardSessionFilter") 24 | public SessionFilter dashboardSessionFilter() { 25 | return new SessionUriPathFilter("/metric-dashboard/**"); 26 | } 27 | 28 | @Bean("dashboardWebSocketsHandler") 29 | public BroadcastWebSocketsHandler dashboardWebSocketsHandler( 30 | @Qualifier("dashboardSessionFilter") SessionFilter filter) { 31 | return new BroadcastWebSocketsHandler(filter); 32 | } 33 | 34 | @Autowired 35 | private MessageEventWebSocketHandler messageEventWebSocketHandler; 36 | 37 | @Override 38 | public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { 39 | 40 | registry.addHandler(messageEventWebSocketHandler, "/metrics") 41 | .addInterceptors(new HandshakeSessionInterceptor()).setAllowedOrigins("*").withSockJS(); 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-boot-sample-websocket/src/main/java/com/github/vindell/websocket/handler/WebsocketEndPoint.java: -------------------------------------------------------------------------------- 1 | package com.github.hiwepy.websocket.handler; 2 | 3 | import org.springframework.web.socket.TextMessage; 4 | import org.springframework.web.socket.WebSocketSession; 5 | import org.springframework.web.socket.handler.TextWebSocketHandler; 6 | 7 | public class WebsocketEndPoint extends TextWebSocketHandler { 8 | 9 | @Override 10 | protected void handleTextMessage(WebSocketSession session, 11 | TextMessage message) throws Exception { 12 | super.handleTextMessage(session, message); 13 | TextMessage returnMessage = new TextMessage(message.getPayload()+" received at server"); 14 | session.sendMessage(returnMessage); 15 | } 16 | } -------------------------------------------------------------------------------- /spring-boot-sample-websocket/src/main/java/com/github/vindell/websocket/sd.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, hiwepy (https://github.com/hiwepy). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.github.hiwepy.websocket; 17 | 18 | public class sd { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-sample-websocket/src/main/resources/static/assets/js/sockjs-pull-demo.js: -------------------------------------------------------------------------------- 1 | jQuery(function($){ 2 | 3 | //===========================定时数据刷新============================== 4 | 5 | // 创建 SockJS 连接;SockJS 可以接收相对url; 6 | var socket = new SockJS('/metrics'); 7 | var timeSend = null; 8 | socket.onopen = function () { 9 | console.log('Info: WebSocket connection opened.'); 10 | if($("#refresh-background").prop("checked")){ 11 | timeSend = setInterval(function() { 12 | socket.send(JSON.stringify({ 13 | "appKey" : $("#query-app-type").val(), 14 | "bizName" : $("#query-biz-type").val() 15 | })); 16 | 17 | }, 60 * 1000); 18 | } 19 | }; 20 | socket.onmessage = function (event) { 21 | var data = JSON.parse(event.data); 22 | initPieCharts(data); 23 | initLineCharts(data); 24 | initTopList(data,true); 25 | console.log('Received: ' + event.data); 26 | }; 27 | socket.onclose = function () { 28 | console.log('Info: WebSocket connection closed.'); 29 | clearInterval(timeSend); 30 | }; 31 | 32 | }) -------------------------------------------------------------------------------- /spring-boot-sample-websocket/src/main/resources/static/assets/js/sockjs-push-demo.js: -------------------------------------------------------------------------------- 1 | jQuery(function($){ 2 | 3 | //===========================定时数据刷新============================== 4 | 5 | // 创建 SockJS 连接;SockJS 可以接收相对url; 6 | var socket = new SockJS('/metrics'); 7 | var timeSend = null; 8 | socket.onopen = function () { 9 | console.log('Info: WebSocket connection opened.'); 10 | if($("#refresh-background").prop("checked")){ 11 | timeSend = setInterval(function() { 12 | socket.send(JSON.stringify({ 13 | "appKey" : $("#query-app-type").val(), 14 | "bizName" : $("#query-biz-type").val() 15 | })); 16 | 17 | }, 60 * 1000); 18 | } 19 | }; 20 | socket.onmessage = function (event) { 21 | var data = JSON.parse(event.data); 22 | initPieCharts(data); 23 | initLineCharts(data); 24 | initTopList(data,true); 25 | console.log('Received: ' + event.data); 26 | }; 27 | socket.onclose = function () { 28 | console.log('Info: WebSocket connection closed.'); 29 | clearInterval(timeSend); 30 | }; 31 | 32 | }) -------------------------------------------------------------------------------- /spring-boot-sample-websocket/src/main/resources/static/assets/js/sockjs-stomp-demo.js: -------------------------------------------------------------------------------- 1 | jQuery(function($){ 2 | 3 | //===========================定时数据刷新============================== 4 | 5 | // 创建 SockJS 连接;SockJS 可以接收相对url; 6 | var socket = new SockJS('/metrics'); 7 | var timeSend = null; 8 | socket.onopen = function () { 9 | console.log('Info: WebSocket connection opened.'); 10 | if($("#refresh-background").prop("checked")){ 11 | timeSend = setInterval(function() { 12 | socket.send(JSON.stringify({ 13 | "key1" : "value1", 14 | "key2" : "value2" 15 | })); 16 | }, 1000); 17 | } 18 | }; 19 | socket.onmessage = function (event) { 20 | var data = JSON.parse(event.data); 21 | 22 | // do something 23 | 24 | console.log('Received: ' + event.data); 25 | }; 26 | socket.onclose = function () { 27 | console.log('Info: WebSocket connection closed.'); 28 | clearInterval(timeSend); 29 | }; 30 | 31 | }) -------------------------------------------------------------------------------- /spring-boot-sample-websocket/src/main/resources/templates/html/sockets/index.ftl: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 21 | Apache Tomcat WebSocket Examples: Index 22 | 23 | 24 | Seems your browser doesn't support Javascript! Websockets rely on Javascript being enabled. Please enable 25 | Javascript and reload this page! 26 | Please select the sample you would like to try. 27 | 28 | Echo 29 | Reverse 30 | Snake 31 | 32 | 33 | 34 | --------------------------------------------------------------------------------
Please select the sample you would like to try.