├── README.md ├── dockercompose-springboot-mysql-nginx ├── app │ ├── Dockerfile │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── neo │ │ │ │ ├── ComposeApplication.java │ │ │ │ ├── controller │ │ │ │ └── VisitorController.java │ │ │ │ ├── entity │ │ │ │ └── Visitor.java │ │ │ │ └── repository │ │ │ │ └── VisitorRepository.java │ │ └── resources │ │ │ ├── application-dev.properties │ │ │ ├── application-docker.properties │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ └── ComposeApplicationTests.java ├── docker-compose.yaml └── nginx │ └── conf.d │ └── app.conf ├── spring-boot-actuator ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── ActuatorApplication.java │ │ │ └── controller │ │ │ └── HelloController.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── neo │ ├── ActuatorApplicationTests.java │ └── controller │ ├── HelloTests.java │ └── HelloWorldControlerTests.java ├── spring-boot-admin-simple ├── pom.xml ├── spring-boot-admin-client │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── neo │ │ │ │ └── AdminClientApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ └── AdminClientApplicationTests.java └── spring-boot-admin-server │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ └── AdminServerApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── neo │ └── AdminServerApplicationTests.java ├── spring-boot-banner ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── neo │ │ └── banner │ │ └── BannerApplication.java │ └── resources │ ├── application.properties │ ├── banner.gif │ └── banner.txt ├── spring-boot-commandLineRunner ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── neo │ │ ├── CommandLineRunnerApplication.java │ │ └── runner │ │ ├── OrderRunner1.java │ │ ├── OrderRunner2.java │ │ └── Runner.java │ └── resources │ └── application.properties ├── spring-boot-docker ├── pom.xml └── src │ ├── main │ ├── docker │ │ └── Dockerfile │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── DockerApplication.java │ │ │ └── controller │ │ │ └── DockerController.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── neo │ └── DockerApplicationTests.java ├── spring-boot-elasticsearch ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── example │ │ └── elastic │ │ ├── ElasticApplication.java │ │ ├── config │ │ ├── AuthenHighLevelElastic.java │ │ └── AuthentiacationES.java │ │ ├── controller │ │ └── ElasticController.java │ │ ├── service │ │ └── ElasticService.java │ │ └── utils │ │ └── esTest.java │ └── resources │ └── application.yml ├── spring-boot-fastDFS ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── neo │ │ ├── FastDFSApplication.java │ │ ├── controller │ │ ├── GlobalExceptionHandler.java │ │ └── UploadController.java │ │ └── fastdfs │ │ ├── FastDFSClient.java │ │ └── FastDFSFile.java │ └── resources │ ├── application.properties │ ├── fdfs_client.conf │ ├── logback.xml │ └── templates │ ├── upload.html │ └── uploadStatus.html ├── spring-boot-file-upload ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── neo │ │ ├── FileUploadWebApplication.java │ │ └── controller │ │ ├── GlobalExceptionHandler.java │ │ └── UploadController.java │ └── resources │ ├── application.properties │ ├── logback.xml │ └── templates │ ├── from_file.html │ ├── upload.html │ └── uploadStatus.html ├── spring-boot-hbase ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── example │ │ └── springboothbase │ │ ├── SpringBootHbaseApplication.java │ │ ├── bean │ │ └── HBaseBean.java │ │ ├── config │ │ └── HBaseConfig.java │ │ ├── controller │ │ └── HbaseController.java │ │ ├── entity │ │ └── Student.java │ │ └── util │ │ ├── HBaseResult.java │ │ └── HBaseTemplate.java │ └── resources │ ├── application.yml │ └── hbase.properties ├── spring-boot-helloWorld ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── Application.java │ │ │ ├── controller │ │ │ └── HelloWorldController.java │ │ │ └── util │ │ │ ├── TupleUtils.java │ │ │ └── jasyptUtil.java │ └── resources │ │ ├── application.properties │ │ └── application.yml │ └── test │ └── java │ └── com │ └── neo │ ├── ApplicationTests.java │ ├── TupleTest.java │ └── controller │ ├── HelloTests.java │ └── HelloWorldControlerTests.java ├── spring-boot-influxdb └── src │ └── main │ └── java │ └── com │ └── example │ └── springbootinfluxdb │ └── SpringBootInfluxdbApplication.java ├── spring-boot-jpa-thymeleaf-curd ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── neo │ │ ├── JpaThymeleafApplication.java │ │ ├── entity │ │ └── User.java │ │ ├── repository │ │ └── UserRepository.java │ │ ├── service │ │ ├── UserService.java │ │ └── impl │ │ │ └── UserServiceImpl.java │ │ └── web │ │ ├── HelloController.java │ │ └── UserController.java │ └── resources │ ├── application.properties │ ├── static │ └── css │ │ └── bootstrap.css │ └── templates │ ├── hello.html │ └── user │ ├── list.html │ ├── userAdd.html │ └── userEdit.html ├── spring-boot-kafka ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── example │ │ └── demo │ │ ├── DemoApplication.java │ │ └── domain │ │ ├── KafkaConsumer.java │ │ └── KafkaProducer.java │ └── resources │ └── application.yml ├── spring-boot-mail ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── Application.java │ │ │ └── service │ │ │ ├── MailService.java │ │ │ └── impl │ │ │ └── MailServiceImpl.java │ └── resources │ │ ├── application.properties │ │ └── templates │ │ └── emailTemplate.html │ └── test │ └── java │ └── com │ └── neo │ ├── ApplicationTests.java │ └── service │ └── MailServiceTest.java ├── spring-boot-manual-kafka ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── example │ │ └── springbootmanualkafka │ │ ├── SpringBootManualKafkaApplication.java │ │ ├── config │ │ └── KakfaPropertiesConfig.java │ │ └── demain │ │ ├── KafkaManualConsumer.java │ │ └── TopicManualPartition.java │ └── resources │ └── application.yml ├── spring-boot-memcache-spymemcached ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── MemcacheApplication.java │ │ │ └── config │ │ │ ├── MemcacheSource.java │ │ │ └── MemcachedRunner.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── neo │ ├── MemcacheApplicationTests.java │ └── RepositoryTests.java ├── spring-boot-mongodb ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── Application.java │ │ │ ├── dao │ │ │ ├── UserDao.java │ │ │ └── impl │ │ │ │ └── UserDaoImpl.java │ │ │ └── entity │ │ │ └── UserEntity.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── neo │ ├── ApplicationTests.java │ └── dao │ └── UserDaoTest.java ├── spring-boot-multi-mongodb ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── Application.java │ │ │ ├── config │ │ │ ├── MultipleMongoConfig.java │ │ │ ├── PrimaryMongoConfig.java │ │ │ ├── SecondaryMongoConfig.java │ │ │ └── props │ │ │ │ └── MultipleMongoProperties.java │ │ │ └── model │ │ │ └── repository │ │ │ ├── primary │ │ │ ├── PrimaryMongoObject.java │ │ │ └── PrimaryRepository.java │ │ │ └── secondary │ │ │ ├── SecondaryMongoObject.java │ │ │ └── SecondaryRepository.java │ └── resources │ │ └── application.yml │ └── test │ └── java │ └── com │ └── neo │ ├── ApplicationTests.java │ └── model │ └── repository │ └── MuliDatabaseTest.java ├── spring-boot-mybatis-annotation-mulidatasource ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── Application.java │ │ │ ├── datasource │ │ │ ├── DataSource1Config.java │ │ │ └── DataSource2Config.java │ │ │ ├── entity │ │ │ └── UserEntity.java │ │ │ ├── enums │ │ │ └── UserSexEnum.java │ │ │ ├── mapper │ │ │ ├── test1 │ │ │ │ └── User1Mapper.java │ │ │ └── test2 │ │ │ │ └── User2Mapper.java │ │ │ └── web │ │ │ └── UserController.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── neo │ ├── ApplicationTests.java │ └── mapper │ ├── User1MapperTest.java │ └── User2MapperTest.java ├── spring-boot-mybatis-annotation ├── pom.xml ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── neo │ │ │ │ ├── Application.java │ │ │ │ ├── entity │ │ │ │ └── UserEntity.java │ │ │ │ ├── enums │ │ │ │ └── UserSexEnum.java │ │ │ │ ├── mapper │ │ │ │ └── UserMapper.java │ │ │ │ └── web │ │ │ │ └── UserController.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ ├── ApplicationTests.java │ │ └── mapper │ │ └── UserMapperTest.java └── users.sql ├── spring-boot-mybatis-mulidatasource ├── pom.xml ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── neo │ │ │ │ ├── Application.java │ │ │ │ ├── datasource │ │ │ │ ├── DataSource1Config.java │ │ │ │ └── DataSource2Config.java │ │ │ │ ├── entity │ │ │ │ └── UserEntity.java │ │ │ │ ├── enums │ │ │ │ └── UserSexEnum.java │ │ │ │ ├── mapper │ │ │ │ ├── test1 │ │ │ │ │ └── User1Mapper.java │ │ │ │ └── test2 │ │ │ │ │ └── User2Mapper.java │ │ │ │ └── web │ │ │ │ └── UserController.java │ │ └── resources │ │ │ ├── application.properties │ │ │ └── mybatis │ │ │ ├── mapper │ │ │ ├── test1 │ │ │ │ └── UserMapper.xml │ │ │ └── test2 │ │ │ │ └── UserMapper.xml │ │ │ └── mybatis-config.xml │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ ├── ApplicationTests.java │ │ └── mapper │ │ ├── User1MapperTest.java │ │ └── User2MapperTest.java └── users.sql ├── spring-boot-mybatis-xml ├── pom.xml ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── neo │ │ │ │ ├── Application.java │ │ │ │ ├── entity │ │ │ │ └── UserEntity.java │ │ │ │ ├── enums │ │ │ │ └── UserSexEnum.java │ │ │ │ ├── mapper │ │ │ │ └── UserMapper.java │ │ │ │ └── web │ │ │ │ └── UserController.java │ │ └── resources │ │ │ ├── application.properties │ │ │ └── mybatis │ │ │ ├── mapper │ │ │ └── UserMapper.xml │ │ │ └── mybatis-config.xml │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ ├── ApplicationTests.java │ │ ├── mapper │ │ └── UserMapperTest.java │ │ └── web │ │ └── UserControllerTest.java └── users.sql ├── spring-boot-mybatisplus ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── springbootmybatisplus │ │ │ ├── SpringBootMybatisplusApplication.java │ │ │ ├── config │ │ │ └── MybatisPlusConfig.java │ │ │ ├── controller │ │ │ └── AuObjectController.java │ │ │ ├── dao │ │ │ └── AuObjectMapper.java │ │ │ ├── mapper │ │ │ └── AuObjectMapper.xml │ │ │ ├── model │ │ │ └── AuObject.java │ │ │ └── service │ │ │ ├── AuObjectService.java │ │ │ └── impl │ │ │ └── AuObjectServiceImpl.java │ └── resources │ │ ├── application.properties │ │ ├── application.yml │ │ └── sql │ │ └── au_object.sql │ └── test │ └── java │ └── com │ └── example │ └── springbootmybatisplus │ ├── CodeGeneration.java │ └── SpringBootMybatisplusApplicationTests.java ├── spring-boot-nacos-server ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── example │ │ └── springbootnacosserver │ │ ├── SpringBootNacosServerApplication.java │ │ ├── controller │ │ └── MyNacosController.java │ │ └── feign │ │ └── MyClient.java │ └── resources │ └── application.yml ├── spring-boot-nacos ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── example │ │ └── springbootnacos │ │ ├── SpringBootNacosApplication.java │ │ ├── config │ │ ├── NacosConfig.java │ │ ├── ProviderRibbonConfig.java │ │ └── RibbonConfig.java │ │ └── controller │ │ └── MyNacosController.java │ └── resources │ ├── application.properties │ ├── application.yml │ └── bootstrap.properties ├── spring-boot-neo4j └── src │ └── main │ ├── java │ └── com │ │ └── example │ │ └── springbootneo4j │ │ ├── config │ │ └── Neo4jConfig.java │ │ ├── dao │ │ └── NeoRepository.java │ │ └── seeder │ │ └── runSeeder.java │ └── resources │ ├── application-dev.yml │ └── application.yml ├── spring-boot-netty-client ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── example │ │ ├── springbootnettyclient │ │ ├── SpringBootNettyClientApplication.java │ │ └── netty │ │ │ ├── ClientHandlerInitilizer.java │ │ │ ├── MarshallingCodeCFactory.java │ │ │ ├── MyProtocolDecoder.java │ │ │ ├── MyProtocolEncoder.java │ │ │ ├── NettyClient.java │ │ │ ├── NettyClientHandler.java │ │ │ └── NettyParams.java │ │ └── springbootnettyserver │ │ └── pojo │ │ ├── HeartBeatInfo.java │ │ └── MyProtocolBean.java │ └── resources │ └── application.properties ├── spring-boot-netty-server ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── example │ │ └── springbootnettyserver │ │ ├── SpringBootNettyServerApplication.java │ │ ├── netty │ │ ├── MarshallingCodeCFactory.java │ │ ├── MyProtocolDecoder.java │ │ ├── MyProtocolEncoder.java │ │ ├── NettyServer.java │ │ ├── NettyServerHandler.java │ │ ├── NettyServerHandlerInitializer.java │ │ └── ServerIdleStateHandler.java │ │ └── pojo │ │ ├── HeartBeatInfo.java │ │ └── MyProtocolBean.java │ └── resources │ └── application.properties ├── spring-boot-package-war ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── Application.java │ │ │ ├── ServletInitializer.java │ │ │ └── controller │ │ │ └── HelloWorldController.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── neo │ ├── ApplicationTests.java │ └── controller │ ├── HelloTests.java │ └── HelloWorldControlerTests.java ├── spring-boot-rabbitmq ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── Application.java │ │ │ ├── model │ │ │ └── User.java │ │ │ └── rabbit │ │ │ ├── FanoutRabbitConfig.java │ │ │ ├── RabbitConfig.java │ │ │ ├── TopicRabbitConfig.java │ │ │ ├── fanout │ │ │ ├── FanoutReceiverA.java │ │ │ ├── FanoutReceiverB.java │ │ │ ├── FanoutReceiverC.java │ │ │ └── FanoutSender.java │ │ │ ├── hello │ │ │ ├── HelloReceiver.java │ │ │ └── HelloSender.java │ │ │ ├── many │ │ │ ├── NeoReceiver1.java │ │ │ ├── NeoReceiver2.java │ │ │ ├── NeoSender.java │ │ │ └── NeoSender2.java │ │ │ ├── object │ │ │ ├── ObjectReceiver.java │ │ │ └── ObjectSender.java │ │ │ └── topic │ │ │ ├── TopicReceiver.java │ │ │ ├── TopicReceiver2.java │ │ │ └── TopicSender.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── neo │ ├── ApplicationTests.java │ └── rabbitmq │ ├── FanoutTest.java │ ├── HelloTest.java │ ├── ManyTest.java │ ├── ObjectTest.java │ └── TopicTest.java ├── spring-boot-redis ├── pom.xml ├── spring-boot-redis.iml ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── neo │ │ │ │ ├── RedisApplication.java │ │ │ │ ├── config │ │ │ │ └── RedisConfig.java │ │ │ │ ├── model │ │ │ │ ├── RedisModel.java │ │ │ │ └── User.java │ │ │ │ ├── service │ │ │ │ ├── IRedisService.java │ │ │ │ └── Impl │ │ │ │ │ └── RedisServiceImpl.java │ │ │ │ ├── util │ │ │ │ └── RedisUtil.java │ │ │ │ └── web │ │ │ │ └── TestController.java │ │ └── resources │ │ │ ├── application.properties │ │ │ └── application.yml │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ ├── RedisApplicationTests.java │ │ └── TestRedis.java └── target │ ├── classes │ ├── application.properties │ ├── application.yml │ └── com │ │ └── neo │ │ ├── RedisApplication.class │ │ ├── config │ │ └── RedisConfig.class │ │ ├── model │ │ ├── RedisModel.class │ │ └── User.class │ │ ├── service │ │ ├── IRedisService.class │ │ └── Impl │ │ │ └── RedisServiceImpl.class │ │ ├── util │ │ └── RedisUtil.class │ │ └── web │ │ └── TestController.class │ └── test-classes │ └── com │ └── neo │ ├── RedisApplicationTests.class │ └── TestRedis.class ├── spring-boot-scheduler ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── Application.java │ │ │ └── task │ │ │ ├── Scheduler2Task.java │ │ │ └── SchedulerTask.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── neo │ └── ApplicationTests.java ├── spring-boot-sentinel ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── example │ │ └── springbootsentinel │ │ ├── SpringBootSentinelApplication.java │ │ ├── config │ │ └── SentinelConfig.java │ │ └── controller │ │ └── experimentController.java │ └── resources │ └── application.yml ├── spring-boot-shiro ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── SpringBootShiroApplication.java │ │ │ ├── config │ │ │ ├── MyShiroRealm.java │ │ │ └── ShiroConfig.java │ │ │ ├── dao │ │ │ └── UserInfoDao.java │ │ │ ├── entity │ │ │ ├── SysPermission.java │ │ │ ├── SysRole.java │ │ │ └── UserInfo.java │ │ │ ├── sevice │ │ │ ├── UserInfoService.java │ │ │ └── impl │ │ │ │ └── UserInfoServiceImpl.java │ │ │ └── web │ │ │ ├── HomeController.java │ │ │ └── UserInfoController.java │ └── resources │ │ ├── application.yml │ │ ├── database │ │ └── import.sql │ │ └── templates │ │ ├── 403.html │ │ ├── index.html │ │ ├── login.html │ │ ├── userInfo.html │ │ ├── userInfoAdd.html │ │ └── userInfoDel.html │ └── test │ └── java │ └── com │ └── neo │ └── SpringBootShiroApplicationTests.java ├── spring-boot-thymeleaf ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── neo │ │ └── thymeleaf │ │ ├── HelloController.java │ │ └── ThymeleafApplication.java │ └── resources │ ├── application.properties │ └── templates │ └── hello.html ├── spring-boot-tk_mybatis-multi-mysql ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── springboottk_mybatismultimysql │ │ │ ├── SpringBootTkMybatisMultiMysqlApplication.java │ │ │ ├── config │ │ │ ├── DataSourceConfig.java │ │ │ └── SecondSourceConfig.java │ │ │ ├── controller │ │ │ ├── AuditResultController.java │ │ │ ├── AuobjectController.java │ │ │ └── BaseController.java │ │ │ ├── dao │ │ │ ├── IMapper.java │ │ │ ├── firstdao │ │ │ │ └── AuobjectMapper.java │ │ │ └── secondDao │ │ │ │ └── AuditResultDao.java │ │ │ ├── entity │ │ │ ├── Auobject.java │ │ │ └── Column.java │ │ │ ├── service │ │ │ ├── AuditResultService.java │ │ │ └── AuobjectService.java │ │ │ └── util │ │ │ ├── CommonMapperUtil.java │ │ │ ├── ConvertUtils.java │ │ │ ├── DateUtils.java │ │ │ ├── Page.java │ │ │ ├── PropertyFilter.java │ │ │ ├── ReflectionUtils.java │ │ │ └── ServletUtils.java │ └── resources │ │ ├── application.properties │ │ ├── application.yml │ │ ├── generator │ │ └── generatorConfig.xml │ │ ├── mapper │ │ └── AuobjectMapper.xml │ │ ├── mybatis_config.xml │ │ ├── secondmapper │ │ └── AuditResultMapper.xml │ │ └── sql │ │ ├── au_object.sql │ │ └── daa-audit-result.sql │ └── test │ └── java │ └── com │ └── example │ └── springboottk_mybatismultimysql │ └── SpringBootTkMybatisMultiMysqlApplicationTests.java ├── spring-boot-web-thymeleaf ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── ThymeleafApplication.java │ │ │ ├── controller │ │ │ └── MessageController.java │ │ │ ├── model │ │ │ └── Message.java │ │ │ └── repository │ │ │ ├── InMemoryMessageRepository.java │ │ │ └── MessageRepository.java │ └── resources │ │ ├── application.properties │ │ ├── logback.xml │ │ ├── static │ │ ├── css │ │ │ └── bootstrap.min.css │ │ └── favicon.ico │ │ └── templates │ │ ├── fragments.html │ │ └── messages │ │ ├── form.html │ │ ├── list.html │ │ └── view.html │ └── test │ └── java │ └── com │ └── neo │ ├── MessageControllerWebTests.java │ └── ThymeleafApplicationTests.java ├── spring-boot-web ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── WebApplication.java │ │ │ ├── WebConfiguration.java │ │ │ ├── model │ │ │ └── User.java │ │ │ ├── repository │ │ │ └── UserRepository.java │ │ │ ├── util │ │ │ └── NeoProperties.java │ │ │ └── web │ │ │ ├── HelloController.java │ │ │ ├── ThymeleafController.java │ │ │ └── UserController.java │ └── resources │ │ ├── application.properties │ │ ├── static │ │ ├── css │ │ │ └── starter.css │ │ └── images │ │ │ └── favicon.png │ │ └── templates │ │ ├── hello.html │ │ └── layout.html │ └── test │ └── java │ └── com │ └── neo │ ├── WebApplicationTests.java │ ├── model │ └── UserRepositoryTests.java │ └── web │ ├── HelloControlerTests.java │ └── ProPertiesTest.java ├── spring-boot-webflux ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── WebFluxApplication.java │ │ │ └── web │ │ │ └── HelloController.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── neo │ ├── HelloTests.java │ └── WebFluxApplicationTests.java └── spring-boot-websocket ├── Vue ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ └── index.html ├── src │ ├── App.vue │ ├── assets │ │ └── logo.png │ ├── components │ │ └── HelloWorld.vue │ └── main.js └── vue.config.js ├── pom.xml └── src └── main └── java └── com └── example └── springwebsocket ├── SpringwebsocketApplication.java ├── config ├── CorsConfig.java ├── WebSocket.java └── WebSocketConfig.java ├── controller └── WebSocketXdxController.java └── service └── WebSocketXdxService.java /README.md: -------------------------------------------------------------------------------- 1 | # springboot-gatherdemo 2 | springboot常用各类Demo整合,以纯洁的微笑大佬的demo为基础进行进一步整合。 3 | 4 | 大佬的例子,请移步https://github.com/ityouknow/spring-boot-examples 受益良多。 5 | 6 | 7 | -------------------------------------------------------------------------------- /dockercompose-springboot-mysql-nginx/app/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /dockercompose-springboot-mysql-nginx/app/src/main/java/com/neo/ComposeApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ComposeApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ComposeApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /dockercompose-springboot-mysql-nginx/app/src/main/java/com/neo/controller/VisitorController.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import com.neo.entity.Visitor; 4 | import com.neo.repository.VisitorRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | 11 | @RestController 12 | public class VisitorController { 13 | 14 | @Autowired 15 | private VisitorRepository repository; 16 | 17 | @RequestMapping("/") 18 | public String index(HttpServletRequest request) { 19 | String ip=request.getRemoteAddr(); 20 | Visitor visitor=repository.findByIp(ip); 21 | if(visitor==null){ 22 | visitor=new Visitor(); 23 | visitor.setIp(ip); 24 | visitor.setTimes(1); 25 | }else { 26 | visitor.setTimes(visitor.getTimes()+1); 27 | } 28 | repository.save(visitor); 29 | return "I have been seen ip "+visitor.getIp()+" "+visitor.getTimes()+" times."; 30 | } 31 | } -------------------------------------------------------------------------------- /dockercompose-springboot-mysql-nginx/app/src/main/java/com/neo/entity/Visitor.java: -------------------------------------------------------------------------------- 1 | package com.neo.entity; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.Id; 7 | 8 | @Entity 9 | public class Visitor { 10 | @Id 11 | @GeneratedValue 12 | private long id; 13 | @Column(nullable = false) 14 | private long times; 15 | @Column(nullable = false) 16 | private String ip; 17 | 18 | public long getId() { 19 | return id; 20 | } 21 | 22 | public void setId(long id) { 23 | this.id = id; 24 | } 25 | 26 | public long getTimes() { 27 | return times; 28 | } 29 | 30 | public void setTimes(long times) { 31 | this.times = times; 32 | } 33 | 34 | public String getIp() { 35 | return ip; 36 | } 37 | 38 | public void setIp(String ip) { 39 | this.ip = ip; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dockercompose-springboot-mysql-nginx/app/src/main/java/com/neo/repository/VisitorRepository.java: -------------------------------------------------------------------------------- 1 | package com.neo.repository; 2 | 3 | import com.neo.entity.Visitor; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface VisitorRepository extends JpaRepository { 7 | Visitor findByIp(String ip); 8 | } 9 | -------------------------------------------------------------------------------- /dockercompose-springboot-mysql-nginx/app/src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test 2 | spring.datasource.username=root 3 | spring.datasource.password=root 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver -------------------------------------------------------------------------------- /dockercompose-springboot-mysql-nginx/app/src/main/resources/application-docker.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://mysql:3306/test 2 | spring.datasource.username=root 3 | spring.datasource.password=root 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver -------------------------------------------------------------------------------- /dockercompose-springboot-mysql-nginx/app/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jpa.properties.hibernate.hbm2ddl.auto=update 2 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect 3 | spring.jpa.show-sql=true 4 | 5 | spring.profiles.active=dev -------------------------------------------------------------------------------- /dockercompose-springboot-mysql-nginx/app/src/test/java/com/neo/ComposeApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | @RunWith(SpringRunner.class) 10 | @SpringBootTest 11 | public class ComposeApplicationTests { 12 | 13 | @Test 14 | public void contextLoads() { 15 | System.out.println("Hello Spring Boot Docker Compose!"); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /dockercompose-springboot-mysql-nginx/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | nginx: 4 | container_name: v-nginx 5 | image: nginx:1.13 6 | restart: always 7 | ports: 8 | - 80:80 9 | - 443:443 10 | volumes: 11 | - ./nginx/conf.d:/etc/nginx/conf.d 12 | 13 | mysql: 14 | container_name: v-mysql 15 | image: mysql/mysql-server:5.7 16 | environment: 17 | MYSQL_DATABASE: test 18 | MYSQL_ROOT_PASSWORD: root 19 | MYSQL_ROOT_HOST: '%' 20 | ports: 21 | - "3306:3306" 22 | restart: always 23 | 24 | app: 25 | restart: always 26 | build: ./app 27 | working_dir: /app 28 | volumes: 29 | - ./app:/app 30 | - ~/.m2:/root/.m2 31 | expose: 32 | - "8080" 33 | depends_on: 34 | - nginx 35 | - mysql 36 | command: mvn clean spring-boot:run -Dspring-boot.run.profiles=docker -------------------------------------------------------------------------------- /dockercompose-springboot-mysql-nginx/nginx/conf.d/app.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | charset utf-8; 4 | access_log off; 5 | 6 | location / { 7 | proxy_pass http://app:8080; 8 | proxy_set_header Host $host:$server_port; 9 | proxy_set_header X-Forwarded-Host $server_name; 10 | proxy_set_header X-Real-IP $remote_addr; 11 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 12 | } 13 | 14 | location /static { 15 | access_log off; 16 | expires 30d; 17 | 18 | alias /app/static; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-actuator/src/main/java/com/neo/ActuatorApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ActuatorApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ActuatorApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-actuator/src/main/java/com/neo/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloController { 8 | 9 | @RequestMapping("/hello") 10 | public String index() { 11 | return "Hello World"; 12 | } 13 | } -------------------------------------------------------------------------------- /spring-boot-actuator/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | management: 4 | security: 5 | enabled: false #关掉安全认证 6 | port: 8088 #管理端口调整成8088 7 | context-path: /monitor #actuator的访问路径 8 | endpoints: 9 | shutdown: 10 | enabled: true 11 | 12 | info: 13 | app: 14 | name: spring-boot-actuator 15 | version: 1.0.0 -------------------------------------------------------------------------------- /spring-boot-actuator/src/test/java/com/neo/ActuatorApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | @RunWith(SpringRunner.class) 10 | @SpringBootTest 11 | public class ActuatorApplicationTests { 12 | 13 | @Test 14 | public void contextLoads() { 15 | System.out.println("hello word"); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-actuator/src/test/java/com/neo/controller/HelloTests.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.http.MediaType; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | import org.springframework.test.web.servlet.MockMvc; 10 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; 11 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 12 | 13 | import static org.hamcrest.Matchers.equalTo; 14 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; 15 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 16 | 17 | @RunWith(SpringRunner.class) 18 | @SpringBootTest 19 | public class HelloTests { 20 | 21 | 22 | private MockMvc mvc; 23 | 24 | @Before 25 | public void setUp() throws Exception { 26 | mvc = MockMvcBuilders.standaloneSetup(new HelloController()).build(); 27 | } 28 | 29 | @Test 30 | public void getHello() throws Exception { 31 | mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON)) 32 | .andExpect(status().isOk()) 33 | .andExpect(content().string(equalTo("Hello World"))); 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /spring-boot-actuator/src/test/java/com/neo/controller/HelloWorldControlerTests.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.http.MediaType; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | import org.springframework.test.web.servlet.MockMvc; 10 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; 11 | import org.springframework.test.web.servlet.result.MockMvcResultHandlers; 12 | import org.springframework.test.web.servlet.result.MockMvcResultMatchers; 13 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 14 | 15 | @RunWith(SpringRunner.class) 16 | @SpringBootTest 17 | public class HelloWorldControlerTests { 18 | 19 | private MockMvc mvc; 20 | 21 | @Before 22 | public void setUp() throws Exception { 23 | mvc = MockMvcBuilders.standaloneSetup(new HelloController()).build(); 24 | } 25 | 26 | @Test 27 | public void getHello() throws Exception { 28 | mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON)) 29 | .andExpect(MockMvcResultMatchers.status().isOk()) 30 | .andDo(MockMvcResultHandlers.print()) 31 | .andReturn(); 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /spring-boot-admin-simple/spring-boot-admin-client/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.neo 7 | spring-boot-admin-simple 8 | 1.0.0.BUILD-SNAPSHOT 9 | 10 | spring-boot-admin-client 11 | jar 12 | 13 | 14 | 15 | de.codecentric 16 | spring-boot-admin-starter-client 17 | 1.5.6 18 | 19 | 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-maven-plugin 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /spring-boot-admin-simple/spring-boot-admin-client/src/main/java/com/neo/AdminClientApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class AdminClientApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(AdminClientApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-admin-simple/spring-boot-admin-client/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8001 2 | 3 | spring.boot.admin.url=http://localhost:8000 4 | management.security.enabled=false 5 | -------------------------------------------------------------------------------- /spring-boot-admin-simple/spring-boot-admin-client/src/test/java/com/neo/AdminClientApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class AdminClientApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-admin-simple/spring-boot-admin-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.neo 7 | spring-boot-admin-simple 8 | 1.0.0.BUILD-SNAPSHOT 9 | 10 | spring-boot-admin-server 11 | jar 12 | 13 | 14 | 15 | de.codecentric 16 | spring-boot-admin-server 17 | 1.5.6 18 | 19 | 20 | de.codecentric 21 | spring-boot-admin-server-ui 22 | 1.5.6 23 | 24 | 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-maven-plugin 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /spring-boot-admin-simple/spring-boot-admin-server/src/main/java/com/neo/AdminServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import de.codecentric.boot.admin.config.EnableAdminServer; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | @EnableAutoConfiguration 10 | @EnableAdminServer 11 | public class AdminServerApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(AdminServerApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-admin-simple/spring-boot-admin-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8000 2 | 3 | -------------------------------------------------------------------------------- /spring-boot-admin-simple/spring-boot-admin-server/src/test/java/com/neo/AdminServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class AdminServerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-banner/src/main/java/com/neo/banner/BannerApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo.banner; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class BannerApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(BannerApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-banner/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-banner/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-banner/src/main/resources/banner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-banner/src/main/resources/banner.gif -------------------------------------------------------------------------------- /spring-boot-banner/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | .__ .__ .__ .__ .___ 2 | | |__ ____ | | | | ____ __ _ _____________| | __| _/ 3 | | | \_/ __ \| | | | / _ \ \ \/ \/ / _ \_ __ \ | / __ | 4 | | Y \ ___/| |_| |_( <_> ) \ ( <_> ) | \/ |__/ /_/ | 5 | |___| /\___ >____/____/\____/ \/\_/ \____/|__| |____/\____ | 6 | \/ \/ \/ -------------------------------------------------------------------------------- /spring-boot-commandLineRunner/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | spring-boot-commandLineRunner 8 | 2.0.0 9 | jar 10 | 11 | Spring Boot banner 12 | Spring Boot and commandLineRunner demo 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.0.RELEASE 18 | 19 | 20 | 21 | UTF-8 22 | UTF-8 23 | 1.8 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-web 30 | 31 | 32 | 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-maven-plugin 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /spring-boot-commandLineRunner/src/main/java/com/neo/CommandLineRunnerApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.CommandLineRunner; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | public class CommandLineRunnerApplication { 9 | 10 | public static void main(String[] args) { 11 | System.out.println("The service to start."); 12 | SpringApplication.run(CommandLineRunnerApplication.class, args); 13 | System.out.println("The service has started."); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-commandLineRunner/src/main/java/com/neo/runner/OrderRunner1.java: -------------------------------------------------------------------------------- 1 | package com.neo.runner; 2 | 3 | import org.springframework.boot.CommandLineRunner; 4 | import org.springframework.core.annotation.Order; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | @Order(1) 9 | public class OrderRunner1 implements CommandLineRunner { 10 | 11 | @Override 12 | public void run(String... args) throws Exception { 13 | System.out.println("The OrderRunner1 start to initialize ..."); 14 | } 15 | } -------------------------------------------------------------------------------- /spring-boot-commandLineRunner/src/main/java/com/neo/runner/OrderRunner2.java: -------------------------------------------------------------------------------- 1 | package com.neo.runner; 2 | 3 | import org.springframework.boot.CommandLineRunner; 4 | import org.springframework.core.annotation.Order; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | @Order(2) 9 | public class OrderRunner2 implements CommandLineRunner { 10 | 11 | @Override 12 | public void run(String... args) throws Exception { 13 | System.out.println("The OrderRunner2 start to initialize ..."); 14 | } 15 | } -------------------------------------------------------------------------------- /spring-boot-commandLineRunner/src/main/java/com/neo/runner/Runner.java: -------------------------------------------------------------------------------- 1 | package com.neo.runner; 2 | 3 | import org.springframework.boot.CommandLineRunner; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class Runner implements CommandLineRunner { 8 | 9 | @Override 10 | public void run(String... args) throws Exception { 11 | System.out.println("The Runner start to initialize ..."); 12 | } 13 | } -------------------------------------------------------------------------------- /spring-boot-commandLineRunner/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-commandLineRunner/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-docker/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jdk-alpine 2 | VOLUME /tmp 3 | ADD spring-boot-docker-1.0.jar app.jar 4 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] -------------------------------------------------------------------------------- /spring-boot-docker/src/main/java/com/neo/DockerApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DockerApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DockerApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-docker/src/main/java/com/neo/controller/DockerController.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class DockerController { 8 | 9 | @RequestMapping("/") 10 | public String index() { 11 | return "Hello Docker!"; 12 | } 13 | } -------------------------------------------------------------------------------- /spring-boot-docker/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-docker/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-docker/src/test/java/com/neo/DockerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | @RunWith(SpringRunner.class) 10 | @SpringBootTest 11 | public class DockerApplicationTests { 12 | 13 | @Test 14 | public void contextLoads() { 15 | System.out.println("hello docker"); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch/src/main/java/com/example/elastic/ElasticApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.elastic; 2 | 3 | import com.example.elastic.service.ElasticService; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.ConfigurableApplicationContext; 7 | 8 | @SpringBootApplication 9 | public class ElasticApplication { 10 | 11 | public static void main(String[] args) { 12 | ConfigurableApplicationContext context = SpringApplication.run(ElasticApplication.class, args); 13 | ElasticService service = (ElasticService) context.getBean("elasticService"); 14 | Thread thread = new Thread(service); 15 | thread.start(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch/src/main/java/com/example/elastic/controller/ElasticController.java: -------------------------------------------------------------------------------- 1 | package com.example.elastic.controller; 2 | 3 | import com.example.elastic.service.ElasticService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestMethod; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import java.io.IOException; 10 | 11 | @RestController 12 | public class ElasticController { 13 | 14 | @Autowired 15 | private ElasticService service; 16 | 17 | @RequestMapping(value = "/ttt",method = RequestMethod.GET) 18 | public boolean test() throws IOException { 19 | return service.IndexExists(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 7777 3 | tomcat: 4 | uri-encoding: utf-8 5 | # servlet: 6 | # context-path: /@project.artifactId@ 7 | 8 | # elasticsearch 9 | # 9200端口是用来让HTTP REST API来访问ElasticSearch,而9300端口是传输层监听的默认端口 10 | spring: 11 | data: 12 | elasticsearch: 13 | cluster-nodes: 10.20.4.167 14 | cluster-port: 9200 15 | username: elastic 16 | password: 123456 17 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/java/com/neo/FastDFSApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.apache.coyote.http11.AbstractHttp11Protocol; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer; 7 | import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; 8 | import org.springframework.context.annotation.Bean; 9 | 10 | @SpringBootApplication 11 | public class FastDFSApplication { 12 | 13 | public static void main(String[] args) throws Exception { 14 | SpringApplication.run(FastDFSApplication.class, args); 15 | } 16 | 17 | //Tomcat large file upload connection reset 18 | @Bean 19 | public TomcatEmbeddedServletContainerFactory tomcatEmbedded() { 20 | TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory(); 21 | tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> { 22 | if ((connector.getProtocolHandler() instanceof AbstractHttp11Protocol)) { 23 | //-1 means unlimited 24 | ((AbstractHttp11Protocol) connector.getProtocolHandler()).setMaxSwallowSize(-1); 25 | } 26 | }); 27 | return tomcat; 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/java/com/neo/controller/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import org.springframework.web.bind.annotation.ControllerAdvice; 4 | import org.springframework.web.bind.annotation.ExceptionHandler; 5 | import org.springframework.web.multipart.MultipartException; 6 | import org.springframework.web.servlet.mvc.support.RedirectAttributes; 7 | 8 | @ControllerAdvice 9 | public class GlobalExceptionHandler { 10 | 11 | //https://jira.spring.io/browse/SPR-14651 12 | //4.3.5 supports RedirectAttributes redirectAttributes 13 | @ExceptionHandler(MultipartException.class) 14 | public String handleError1(MultipartException e, RedirectAttributes redirectAttributes) { 15 | 16 | redirectAttributes.addFlashAttribute("message", e.getCause().getMessage()); 17 | return "redirect:/uploadStatus"; 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/java/com/neo/fastdfs/FastDFSFile.java: -------------------------------------------------------------------------------- 1 | package com.neo.fastdfs; 2 | 3 | public class FastDFSFile { 4 | private String name; 5 | 6 | private byte[] content; 7 | 8 | private String ext; 9 | 10 | private String md5; 11 | 12 | private String author; 13 | 14 | public FastDFSFile(String name, byte[] content, String ext, String height, 15 | String width, String author) { 16 | super(); 17 | this.name = name; 18 | this.content = content; 19 | this.ext = ext; 20 | this.author = author; 21 | } 22 | 23 | public FastDFSFile(String name, byte[] content, String ext) { 24 | super(); 25 | this.name = name; 26 | this.content = content; 27 | this.ext = ext; 28 | 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public void setName(String name) { 36 | this.name = name; 37 | } 38 | 39 | public byte[] getContent() { 40 | return content; 41 | } 42 | 43 | public void setContent(byte[] content) { 44 | this.content = content; 45 | } 46 | 47 | public String getExt() { 48 | return ext; 49 | } 50 | 51 | public void setExt(String ext) { 52 | this.ext = ext; 53 | } 54 | 55 | public String getMd5() { 56 | return md5; 57 | } 58 | 59 | public void setMd5(String md5) { 60 | this.md5 = md5; 61 | } 62 | 63 | public String getAuthor() { 64 | return author; 65 | } 66 | 67 | public void setAuthor(String author) { 68 | this.author = author; 69 | } 70 | } -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#common-application-properties 2 | #search multipart 3 | spring.http.multipart.max-file-size=10MB 4 | spring.http.multipart.max-request-size=10MB 5 | 6 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/resources/fdfs_client.conf: -------------------------------------------------------------------------------- 1 | connect_timeout = 60 2 | network_timeout = 60 3 | charset = UTF-8 4 | http.tracker_http_port = 8080 5 | http.anti_steal_token = no 6 | http.secret_key = 123456 7 | 8 | tracker_server = 192.168.53.85:22122 9 | tracker_server = 192.168.53.86:22122 10 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/resources/templates/upload.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Spring Boot file upload example

6 | 7 |
8 |

9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-fastDFS/src/main/resources/templates/uploadStatus.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Spring Boot - Upload Status

6 | 7 |
8 |

9 |

10 | 11 |
12 |

13 |

14 | 15 | 16 | -------------------------------------------------------------------------------- /spring-boot-file-upload/src/main/java/com/neo/FileUploadWebApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.apache.coyote.http11.AbstractHttp11Protocol; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer; 7 | import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; 8 | import org.springframework.context.annotation.Bean; 9 | 10 | @SpringBootApplication 11 | public class FileUploadWebApplication { 12 | 13 | public static void main(String[] args) throws Exception { 14 | SpringApplication.run(FileUploadWebApplication.class, args); 15 | } 16 | 17 | //Tomcat large file upload connection reset 18 | @Bean 19 | public TomcatEmbeddedServletContainerFactory tomcatEmbedded() { 20 | TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory(); 21 | tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> { 22 | if ((connector.getProtocolHandler() instanceof AbstractHttp11Protocol)) { 23 | //-1 means unlimited 24 | ((AbstractHttp11Protocol) connector.getProtocolHandler()).setMaxSwallowSize(-1); 25 | } 26 | }); 27 | return tomcat; 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /spring-boot-file-upload/src/main/java/com/neo/controller/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import org.springframework.web.bind.annotation.ControllerAdvice; 4 | import org.springframework.web.bind.annotation.ExceptionHandler; 5 | import org.springframework.web.multipart.MultipartException; 6 | import org.springframework.web.servlet.mvc.support.RedirectAttributes; 7 | 8 | @ControllerAdvice 9 | public class GlobalExceptionHandler { 10 | 11 | //https://jira.spring.io/browse/SPR-14651 12 | //4.3.5 supports RedirectAttributes redirectAttributes 13 | @ExceptionHandler(MultipartException.class) 14 | public String handleError1(MultipartException e, RedirectAttributes redirectAttributes) { 15 | redirectAttributes.addFlashAttribute("message", e.getCause().getMessage()); 16 | return "redirect:/uploadStatus"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-file-upload/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#common-application-properties 2 | #search multipart 3 | spring.http.multipart.max-file-size=10MB 4 | spring.http.multipart.max-request-size=10MB 5 | 6 | #spring.http.multipart.enabled=true #\u9ED8\u8BA4\u652F\u6301\u6587\u4EF6\u4E0A\u4F20. 7 | #spring.http.multipart.file-size-threshold=0 #\u652F\u6301\u6587\u4EF6\u5199\u5165\u78C1\u76D8. 8 | #spring.http.multipart.location= # \u4E0A\u4F20\u6587\u4EF6\u7684\u4E34\u65F6\u76EE\u5F55 9 | #spring.http.multipart.max-file-size=1Mb # \u6700\u5927\u652F\u6301\u6587\u4EF6\u5927\u5C0F 10 | #spring.http.multipart.max-request-size=10Mb # \u6700\u5927\u652F\u6301\u8BF7\u6C42\u5927\u5C0F 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-file-upload/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /spring-boot-file-upload/src/main/resources/templates/from_file.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-file-upload/src/main/resources/templates/from_file.html -------------------------------------------------------------------------------- /spring-boot-file-upload/src/main/resources/templates/upload.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Spring Boot file upload example

6 | 7 |
8 |

9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-file-upload/src/main/resources/templates/uploadStatus.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Spring Boot - Upload Status

6 | 7 |
8 |

9 |

10 | 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/example/springboothbase/SpringBootHbaseApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.springboothbase; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootHbaseApplication { 8 | 9 | public static void main(String[] args) { 10 | System.out.println("welcome to my world"); 11 | SpringApplication.run(SpringBootHbaseApplication.class, args); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/example/springboothbase/bean/HBaseBean.java: -------------------------------------------------------------------------------- 1 | package com.example.springboothbase.bean; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | 7 | @Getter 8 | @Setter 9 | @ToString 10 | public class HBaseBean { 11 | 12 | public HBaseBean( ) { 13 | } 14 | 15 | 16 | 17 | /** 18 | * hbase中的rowKey 19 | */ 20 | private String rowKey; 21 | 22 | /** 23 | * hbase中的列族 24 | */ 25 | private String columnFamily; 26 | 27 | 28 | /** 29 | * hbase 列字段名 30 | */ 31 | private String columnQualifier; 32 | 33 | /** 34 | * 时间戳 35 | */ 36 | private Long timeStamp; 37 | 38 | /** 39 | * 类型 40 | */ 41 | private String type; 42 | 43 | 44 | /** 45 | * 值 46 | */ 47 | private String value; 48 | 49 | } -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/java/com/example/springboothbase/entity/Student.java: -------------------------------------------------------------------------------- 1 | package com.example.springboothbase.entity; 2 | 3 | /** 4 | * @author Arvin 5 | */ 6 | public class Student { 7 | private String id; 8 | private String name; 9 | private String age; 10 | 11 | public String getId() { 12 | return id; 13 | } 14 | 15 | public void setId(String id) { 16 | this.id = id; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public String getAge() { 28 | return age; 29 | } 30 | 31 | public void setAge(String age) { 32 | this.age = age; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "Student{" + 38 | "id='" + id + '\'' + 39 | ", name='" + name + '\'' + 40 | ", age=" + age + 41 | '}'; 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | application: 2 | hbase: 3 | config: 4 | hbase.zookeeper.quorum: 192.168.0.137 5 | hbase.zookeeper.property.clientPort: 2181 6 | extract-family-name: dw_starsearch_web_content_xpath_test 7 | extract-table-name: web_info 8 | kafka: 9 | topics: spider_content_prod_queue_sina_mil 10 | error-topic: spider_content_error_queue 11 | -------------------------------------------------------------------------------- /spring-boot-hbase/src/main/resources/hbase.properties: -------------------------------------------------------------------------------- 1 | hbase.zookeeper.quorum = 192.168.247.131 2 | hbase.zookeeper.property.clientPort = 2181 3 | zookeeper.znode.paren = /hbase 4 | -------------------------------------------------------------------------------- /spring-boot-helloWorld/src/main/java/com/neo/Application.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | public static void main(String[] args) { 9 | SpringApplication.run(Application.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-helloWorld/src/main/java/com/neo/controller/HelloWorldController.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloWorldController { 8 | 9 | @RequestMapping("/hello") 10 | public String index() { 11 | return "Hello World"; 12 | } 13 | } -------------------------------------------------------------------------------- /spring-boot-helloWorld/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-helloWorld/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-helloWorld/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | jasypt: 2 | encryptor: 3 | #这里可以理解成是加解密的时候使用的密钥 4 | password: JUEH848*&F(feuis -------------------------------------------------------------------------------- /spring-boot-helloWorld/src/test/java/com/neo/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | @RunWith(SpringRunner.class) 10 | @SpringBootTest 11 | public class ApplicationTests { 12 | 13 | @Test 14 | public void contextLoads() { 15 | System.out.println("hello word"); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-helloWorld/src/test/java/com/neo/TupleTest.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import com.neo.util.TupleUtils; 4 | import org.javatuples.Triplet; 5 | import org.junit.Test; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | public class TupleTest { 11 | 12 | 13 | @Test 14 | public void test() { 15 | List> roleList = new ArrayList>(); 16 | 17 | /* 18 | 三元组,存储数据:对应实体类字节码文件、数据表主键名称、数据表毕业院校字段名称 19 | */ 20 | Triplet studentTriplet = TupleUtils.with(String.class, "sid", "graduate"); 21 | Triplet teacherTriplet = TupleUtils.with(Object.class, "tid", "graduate"); 22 | Triplet programmerTriplet = TupleUtils.with(TupleUtils.class, "id", "graduate"); 23 | 24 | roleList.add(studentTriplet); 25 | roleList.add(teacherTriplet); 26 | roleList.add(programmerTriplet); 27 | 28 | for (Triplet triplet : roleList) { 29 | System.out.println(triplet); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-jpa-thymeleaf-curd/src/main/java/com/neo/JpaThymeleafApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.builder.SpringApplicationBuilder; 6 | import org.springframework.boot.web.support.SpringBootServletInitializer; 7 | 8 | 9 | @SpringBootApplication 10 | public class JpaThymeleafApplication extends SpringBootServletInitializer { 11 | @Override 12 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 13 | return application.sources(JpaThymeleafApplication.class); 14 | } 15 | 16 | public static void main(String[] args) throws Exception { 17 | SpringApplication.run(JpaThymeleafApplication.class, args); 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /spring-boot-jpa-thymeleaf-curd/src/main/java/com/neo/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.neo.entity; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.Id; 7 | 8 | @Entity 9 | public class User { 10 | @Id 11 | @GeneratedValue 12 | private long id; 13 | @Column(nullable = false, unique = true) 14 | private String userName; 15 | @Column(nullable = false) 16 | private String password; 17 | @Column(nullable = false) 18 | private int age; 19 | 20 | public long getId() { 21 | return id; 22 | } 23 | 24 | public User setId(long id) { 25 | this.id = id; 26 | return this; 27 | } 28 | 29 | public String getUserName() { 30 | return userName; 31 | } 32 | 33 | public User setUserName(String userName) { 34 | this.userName = userName; 35 | return this; 36 | } 37 | 38 | public String getPassword() { 39 | return password; 40 | } 41 | 42 | public User setPassword(String password) { 43 | this.password = password; 44 | return this; 45 | } 46 | 47 | public int getAge() { 48 | return age; 49 | } 50 | 51 | public User setAge(int age) { 52 | this.age = age; 53 | return this; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /spring-boot-jpa-thymeleaf-curd/src/main/java/com/neo/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.neo.repository; 2 | 3 | import com.neo.entity.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface UserRepository extends JpaRepository { 7 | 8 | User findById(long id); 9 | 10 | Long deleteById(Long id); 11 | } -------------------------------------------------------------------------------- /spring-boot-jpa-thymeleaf-curd/src/main/java/com/neo/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.neo.service; 2 | 3 | import com.neo.entity.User; 4 | 5 | import java.util.List; 6 | 7 | public interface UserService { 8 | 9 | public List getUserList(); 10 | 11 | public User findUserById(long id); 12 | 13 | public void save(User user); 14 | 15 | public void edit(User user); 16 | 17 | public void delete(long id); 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-jpa-thymeleaf-curd/src/main/java/com/neo/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.neo.service.impl; 2 | 3 | import com.neo.entity.User; 4 | import com.neo.repository.UserRepository; 5 | import com.neo.service.UserService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | @Service 13 | public class UserServiceImpl implements UserService{ 14 | 15 | @Autowired 16 | private UserRepository userRepository; 17 | 18 | @Override 19 | public List getUserList() { 20 | return userRepository.findAll(); 21 | } 22 | 23 | @Override 24 | public User findUserById(long id) { 25 | return userRepository.findById(id); 26 | } 27 | 28 | @Override 29 | public void save(User user) { 30 | userRepository.save(user); 31 | } 32 | 33 | @Override 34 | public void edit(User user) { 35 | userRepository.save(user); 36 | } 37 | 38 | @Override 39 | public void delete(long id) { 40 | userRepository.delete(id); 41 | } 42 | } 43 | 44 | 45 | -------------------------------------------------------------------------------- /spring-boot-jpa-thymeleaf-curd/src/main/java/com/neo/web/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.neo.web; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @Controller 9 | public class HelloController { 10 | 11 | @RequestMapping("/hello") 12 | public String hello(Model model, @RequestParam(value="name", required=false, defaultValue="World") String name) { 13 | model.addAttribute("name", name); 14 | return "hello"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-jpa-thymeleaf-curd/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://127.0.0.1/test?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=true 2 | spring.datasource.username=root 3 | spring.datasource.password=root 4 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 5 | 6 | spring.jpa.properties.hibernate.hbm2ddl.auto=update 7 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect 8 | spring.jpa.show-sql= true 9 | 10 | spring.thymeleaf.cache=false -------------------------------------------------------------------------------- /spring-boot-jpa-thymeleaf-curd/src/main/resources/templates/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello Thymeleaf! 6 | 7 | 8 |

9 | 10 | -------------------------------------------------------------------------------- /spring-boot-jpa-thymeleaf-curd/src/main/resources/templates/user/list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | userList 6 | 7 | 8 | 9 |
10 |

用户列表

11 |

12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
#User NamePasswordAgeEditDelete
1neoOtto6editdelete
35 |
36 |
37 |
38 | add 39 |
40 |
41 | 42 | 43 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/java/com/example/demo/domain/KafkaConsumer.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.domain; 2 | 3 | import cn.hutool.json.JSONUtil; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.apache.kafka.clients.consumer.ConsumerRecord; 6 | import org.springframework.kafka.annotation.KafkaListener; 7 | import org.springframework.kafka.support.Acknowledgment; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | @Component 14 | @Slf4j 15 | public class KafkaConsumer { 16 | 17 | @KafkaListener(topicPattern = "${spring.kafka.topics.file}") 18 | public void processNewsMessage(ConsumerRecord record) { 19 | String msg = record.value(); 20 | // System.out.println("msg"); 21 | Map data = JSONUtil.toBean(msg, new cn.hutool.core.lang.TypeReference>() { 22 | }, true); 23 | String spiderId = data.get("spiderId").toString(); 24 | System.out.println(spiderId); 25 | // try { 26 | // Map data = JSONUtil.toBean(msg, new cn.hutool.core.lang.TypeReference>() { 27 | // }, true); 28 | // } catch (Exception e) { 29 | // log.error("covert data error,topic:{}, offset:{}", record.topic(), record.offset(), e); 30 | // } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-kafka/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # elasticsearch 2 | # 9200端口是用来让HTTP REST API来访问ElasticSearch,而9300端口是传输层监听的默认端口 3 | spring: 4 | kafka: 5 | bootstrap-servers: 192.168.0.63:9092,192.168.0.64:9092,192.168.0.65:9092 6 | producer: 7 | # 发生错误后,消息重发的次数。 8 | retries: 1 9 | #当有多个消息需要被发送到同一个分区时,生产者会把它们放在同一个批次里。该参数指定了一个批次可以使用的内存大小,按照字节数计算。 10 | batch-size: 16384 11 | # 设置生产者内存缓冲区的大 12 | buffer-memory: 33554432 13 | # 键的序列化方式 14 | key-serializer: org.apache.kafka.common.serialization.StringSerializer 15 | # 值的序列化方式 16 | value-serializer: org.apache.kafka.common.serialization.StringSerializer 17 | # acks=0 : 生产者在成功写入消息之前不会等待任何来自服务器的响应。 18 | # acks=1 : 只要集群的首领节点收到消息,生产者就会收到一个来自服务器成功响应。 19 | # acks=all :只有当所有参与复制的节点全部收到消息时,生产者才会收到一个来自服务器的成功响应。 20 | acks: 1 21 | consumer: 22 | group-id: spider-ocr-recognition-group 23 | max-poll-records: 1000 24 | auto-commit-interval: 5000 25 | enable-auto-commit: true 26 | auto-offset-reset: latest 27 | heartbeat-interval: 3000 28 | topics: 29 | file: spider_file_record_queue 30 | orc-file: spider_ocr_file_queue -------------------------------------------------------------------------------- /spring-boot-mail/src/main/java/com/neo/Application.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableScheduling; 6 | 7 | @SpringBootApplication 8 | public class Application { 9 | 10 | public static void main(String[] args) { 11 | SpringApplication.run(Application.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-mail/src/main/java/com/neo/service/MailService.java: -------------------------------------------------------------------------------- 1 | package com.neo.service; 2 | 3 | /** 4 | * Created by summer on 2017/5/4. 5 | */ 6 | public interface MailService { 7 | 8 | public void sendSimpleMail(String to, String subject, String content); 9 | 10 | public void sendHtmlMail(String to, String subject, String content); 11 | 12 | public void sendAttachmentsMail(String to, String subject, String content, String filePath); 13 | 14 | public void sendInlineResourceMail(String to, String subject, String content, String rscPath, String rscId); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-mail/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spirng-boot-mail 2 | 3 | spring.mail.host=smtp.163.com 4 | spring.mail.username=xxoo@xxoo.com 5 | spring.mail.password=xxoo 6 | spring.mail.default-encoding=UTF-8 7 | 8 | mail.fromMail.addr=xxoo@xxoo.com 9 | 10 | -------------------------------------------------------------------------------- /spring-boot-mail/src/main/resources/templates/emailTemplate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 您好,这是验证邮件,请点击下面的链接完成验证,
9 | 激活账号 10 | 11 | -------------------------------------------------------------------------------- /spring-boot-mail/src/test/java/com/neo/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-manual-kafka/src/main/java/com/example/springbootmanualkafka/SpringBootManualKafkaApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootmanualkafka; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootManualKafkaApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootManualKafkaApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-manual-kafka/src/main/java/com/example/springbootmanualkafka/demain/TopicManualPartition.java: -------------------------------------------------------------------------------- 1 | //package com.example.springbootmanualkafka.demain; 2 | // 3 | //import org.springframework.kafka.annotation.PartitionOffset; 4 | //import org.springframework.kafka.annotation.TopicPartition; 5 | // 6 | //import java.lang.annotation.Annotation; 7 | // 8 | //public class TopicManualPartition implements TopicPartition { 9 | // 10 | // String topic; 11 | // 12 | // String[] partitions; 13 | // 14 | // public TopicManualPartition(String topic, int partition) { 15 | // this.topic = topic; 16 | // this.partitions[0] = String.valueOf(partition); 17 | // } 18 | // 19 | // @Override 20 | // public String topic() { 21 | // return topic; 22 | // } 23 | // 24 | // @Override 25 | // public String[] partitions() { 26 | // return partitions; 27 | // } 28 | // 29 | // @Override 30 | // public PartitionOffset[] partitionOffsets() { 31 | // return new PartitionOffset[0]; 32 | // } 33 | // 34 | // @Override 35 | // public Class annotationType() { 36 | // return null; 37 | // } 38 | //} 39 | -------------------------------------------------------------------------------- /spring-boot-manual-kafka/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | #spring: 2 | # kafka: 3 | # bootstrap-servers: 192.168.0.63:9092,192.168.0.64:9092,192.168.0.65:9092 4 | # producer: 5 | # # 发生错误后,消息重发的次数。 6 | # retries: 1 7 | # #当有多个消息需要被发送到同一个分区时,生产者会把它们放在同一个批次里。该参数指定了一个批次可以使用的内存大小,按照字节数计算。 8 | # batch-size: 16384 9 | # # 设置生产者内存缓冲区的大 10 | # buffer-memory: 33554432 11 | # # 键的序列化方式 12 | # key-serializer: org.apache.kafka.common.serialization.StringSerializer 13 | # # 值的序列化方式 14 | # value-serializer: org.apache.kafka.common.serialization.StringSerializer 15 | # # acks=0 : 生产者在成功写入消息之前不会等待任何来自服务器的响应。 16 | # # acks=1 : 只要集群的首领节点收到消息,生产者就会收到一个来自服务器成功响应。 17 | # # acks=all :只有当所有参与复制的节点全部收到消息时,生产者才会收到一个来自服务器的成功响应。 18 | # acks: 1 19 | # consumer: 20 | # group-id: spider-ocr-recognition-group 21 | # max-poll-records: 1000 22 | # auto-commit-interval: 5000 23 | # enable-auto-commit: true 24 | # auto-offset-reset: latest 25 | # heartbeat-interval: 3000 26 | # topics: 27 | # file: spider_file_record_queue 28 | # orc-file: spider_ocr_file_queue -------------------------------------------------------------------------------- /spring-boot-memcache-spymemcached/src/main/java/com/neo/MemcacheApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class MemcacheApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(MemcacheApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-memcache-spymemcached/src/main/java/com/neo/config/MemcacheSource.java: -------------------------------------------------------------------------------- 1 | package com.neo.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties(prefix = "memcache") 8 | public class MemcacheSource { 9 | 10 | private String ip; 11 | 12 | private int port; 13 | 14 | public String getIp() { 15 | return ip; 16 | } 17 | 18 | public void setIp(String ip) { 19 | this.ip = ip; 20 | } 21 | 22 | public int getPort() { 23 | return port; 24 | } 25 | 26 | public void setPort(int port) { 27 | this.port = port; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-memcache-spymemcached/src/main/java/com/neo/config/MemcachedRunner.java: -------------------------------------------------------------------------------- 1 | package com.neo.config; 2 | 3 | import net.spy.memcached.MemcachedClient; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.stereotype.Component; 8 | 9 | import javax.annotation.Resource; 10 | import java.io.IOException; 11 | import java.net.InetSocketAddress; 12 | 13 | @Component 14 | public class MemcachedRunner implements CommandLineRunner { 15 | protected Logger logger = LoggerFactory.getLogger(this.getClass()); 16 | 17 | @Resource 18 | private MemcacheSource memcacheSource; 19 | 20 | private MemcachedClient client = null; 21 | 22 | @Override 23 | public void run(String... args) throws Exception { 24 | try { 25 | client = new MemcachedClient(new InetSocketAddress(memcacheSource.getIp(),memcacheSource.getPort())); 26 | } catch (IOException e) { 27 | logger.error("inint MemcachedClient failed ",e); 28 | } 29 | } 30 | 31 | public MemcachedClient getClient() { 32 | return client; 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /spring-boot-memcache-spymemcached/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | memcache.ip=192.168.0.161 2 | memcache.port=11211 -------------------------------------------------------------------------------- /spring-boot-memcache-spymemcached/src/test/java/com/neo/MemcacheApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class MemcacheApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-memcache-spymemcached/src/test/java/com/neo/RepositoryTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import com.neo.config.MemcachedRunner; 4 | import net.spy.memcached.MemcachedClient; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | import javax.annotation.Resource; 11 | 12 | @RunWith(SpringRunner.class) 13 | @SpringBootTest 14 | public class RepositoryTests { 15 | 16 | @Resource 17 | private MemcachedRunner memcachedRunner; 18 | 19 | @Test 20 | public void testSetGet() { 21 | MemcachedClient memcachedClient = memcachedRunner.getClient(); 22 | memcachedClient.set("testkey",1000,"666666"); 23 | System.out.println("*********** "+memcachedClient.get("testkey").toString()); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/neo/Application.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableScheduling; 6 | 7 | @SpringBootApplication 8 | public class Application { 9 | 10 | public static void main(String[] args) { 11 | SpringApplication.run(Application.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/neo/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.neo.dao; 2 | 3 | import com.neo.entity.UserEntity; 4 | 5 | /** 6 | * Created by summer on 2017/5/5. 7 | */ 8 | public interface UserDao { 9 | 10 | public void saveUser(UserEntity user); 11 | 12 | public UserEntity findUserByUserName(String userName); 13 | 14 | public int updateUser(UserEntity user); 15 | 16 | public void deleteUserById(Long id); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/java/com/neo/entity/UserEntity.java: -------------------------------------------------------------------------------- 1 | package com.neo.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by summer on 2017/5/5. 7 | */ 8 | public class UserEntity implements Serializable { 9 | private static final long serialVersionUID = -3258839839160856613L; 10 | private Long id; 11 | private String userName; 12 | private String passWord; 13 | 14 | public Long getId() { 15 | return id; 16 | } 17 | 18 | public void setId(Long id) { 19 | this.id = id; 20 | } 21 | 22 | public String getUserName() { 23 | return userName; 24 | } 25 | 26 | public void setUserName(String userName) { 27 | this.userName = userName; 28 | } 29 | 30 | public String getPassWord() { 31 | return passWord; 32 | } 33 | 34 | public void setPassWord(String passWord) { 35 | this.passWord = passWord; 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return "UserEntity{" + 41 | "id=" + id + 42 | ", userName='" + userName + '\'' + 43 | ", passWord='" + passWord + '\'' + 44 | '}'; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spirng-boot-mongodb 2 | 3 | spring.data.mongodb.uri=mongodb://192.168.9.61:20000/test 4 | 5 | 6 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/test/java/com/neo/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-mongodb/src/test/java/com/neo/dao/UserDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.neo.dao; 2 | 3 | import com.neo.entity.UserEntity; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | /** 11 | * Created by summer on 2017/5/5. 12 | */ 13 | @RunWith(SpringRunner.class) 14 | @SpringBootTest 15 | public class UserDaoTest { 16 | 17 | @Autowired 18 | private UserDao userDao; 19 | 20 | @Test 21 | public void testSaveUser() throws Exception { 22 | UserEntity user=new UserEntity(); 23 | user.setId(2l); 24 | user.setUserName("小明"); 25 | user.setPassWord("fffooo123"); 26 | userDao.saveUser(user); 27 | } 28 | 29 | @Test 30 | public void findUserByUserName(){ 31 | UserEntity user= userDao.findUserByUserName("小明"); 32 | System.out.println("user is "+user); 33 | } 34 | 35 | @Test 36 | public void updateUser(){ 37 | UserEntity user=new UserEntity(); 38 | user.setId(2l); 39 | user.setUserName("天空"); 40 | user.setPassWord("fffxxxx"); 41 | userDao.updateUser(user); 42 | } 43 | 44 | @Test 45 | public void deleteUserById(){ 46 | userDao.deleteUserById(1l); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /spring-boot-multi-mongodb/src/main/java/com/neo/Application.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import com.neo.config.props.MultipleMongoProperties; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; 8 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 9 | import org.springframework.scheduling.annotation.EnableScheduling; 10 | 11 | @EnableConfigurationProperties(MultipleMongoProperties.class) 12 | @SpringBootApplication(exclude = MongoAutoConfiguration.class) 13 | public class Application { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(Application.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-multi-mongodb/src/main/java/com/neo/config/PrimaryMongoConfig.java: -------------------------------------------------------------------------------- 1 | package com.neo.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; 5 | 6 | /** 7 | * @author neo 8 | */ 9 | @Configuration 10 | @EnableMongoRepositories(basePackages = "com.neo.model.repository.primary", 11 | mongoTemplateRef = PrimaryMongoConfig.MONGO_TEMPLATE) 12 | public class PrimaryMongoConfig { 13 | 14 | protected static final String MONGO_TEMPLATE = "primaryMongoTemplate"; 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-multi-mongodb/src/main/java/com/neo/config/SecondaryMongoConfig.java: -------------------------------------------------------------------------------- 1 | package com.neo.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; 5 | 6 | /** 7 | * @author neo 8 | */ 9 | @Configuration 10 | @EnableMongoRepositories(basePackages = "com.neo.model.repository.secondary", 11 | mongoTemplateRef = SecondaryMongoConfig.MONGO_TEMPLATE) 12 | public class SecondaryMongoConfig { 13 | 14 | protected static final String MONGO_TEMPLATE = "secondaryMongoTemplate"; 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-multi-mongodb/src/main/java/com/neo/config/props/MultipleMongoProperties.java: -------------------------------------------------------------------------------- 1 | package com.neo.config.props; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.autoconfigure.mongo.MongoProperties; 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | 7 | /** 8 | * @author neo 9 | */ 10 | @Data 11 | @ConfigurationProperties(prefix = "mongodb") 12 | public class MultipleMongoProperties { 13 | 14 | private MongoProperties primary = new MongoProperties(); 15 | private MongoProperties secondary = new MongoProperties(); 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-multi-mongodb/src/main/java/com/neo/model/repository/primary/PrimaryMongoObject.java: -------------------------------------------------------------------------------- 1 | package com.neo.model.repository.primary; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import org.springframework.data.annotation.Id; 7 | import org.springframework.data.mongodb.core.mapping.Document; 8 | 9 | /** 10 | * @author neo 11 | */ 12 | @Data 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @Document(collection = "first_mongo") 16 | public class PrimaryMongoObject { 17 | 18 | @Id 19 | private String id; 20 | 21 | private String value; 22 | 23 | @Override 24 | public String toString() { 25 | return "PrimaryMongoObject{" + "id='" + id + '\'' + ", value='" + value + '\'' 26 | + '}'; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-multi-mongodb/src/main/java/com/neo/model/repository/primary/PrimaryRepository.java: -------------------------------------------------------------------------------- 1 | package com.neo.model.repository.primary; 2 | 3 | import org.springframework.data.mongodb.repository.MongoRepository; 4 | 5 | /** 6 | * @author neo 7 | */ 8 | public interface PrimaryRepository extends MongoRepository { 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-multi-mongodb/src/main/java/com/neo/model/repository/secondary/SecondaryMongoObject.java: -------------------------------------------------------------------------------- 1 | package com.neo.model.repository.secondary; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import org.springframework.data.annotation.Id; 7 | import org.springframework.data.mongodb.core.mapping.Document; 8 | 9 | /** 10 | * @author neo 11 | */ 12 | @Data 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @Document(collection = "second_mongo") 16 | public class SecondaryMongoObject { 17 | 18 | @Id 19 | private String id; 20 | 21 | private String value; 22 | 23 | 24 | @Override 25 | public String toString() { 26 | return "SecondaryMongoObject{" + "id='" + id + '\'' + ", value='" + value + '\'' 27 | + '}'; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-multi-mongodb/src/main/java/com/neo/model/repository/secondary/SecondaryRepository.java: -------------------------------------------------------------------------------- 1 | package com.neo.model.repository.secondary; 2 | 3 | import org.springframework.data.mongodb.repository.MongoRepository; 4 | 5 | /** 6 | * @author neo 7 | */ 8 | public interface SecondaryRepository extends MongoRepository { 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-multi-mongodb/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | mongodb: 2 | primary: 3 | host: 192.168.9.60 4 | port: 20000 5 | database: test 6 | secondary: 7 | host: 192.168.9.61 8 | port: 20000 9 | database: test1 -------------------------------------------------------------------------------- /spring-boot-multi-mongodb/src/test/java/com/neo/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-mybatis-annotation-mulidatasource/src/main/java/com/neo/Application.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | public class Application { 9 | 10 | public static void main(String[] args) { 11 | SpringApplication.run(Application.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-mybatis-annotation-mulidatasource/src/main/java/com/neo/enums/UserSexEnum.java: -------------------------------------------------------------------------------- 1 | package com.neo.enums; 2 | 3 | public enum UserSexEnum { 4 | MAN, WOMAN 5 | } 6 | -------------------------------------------------------------------------------- /spring-boot-mybatis-annotation-mulidatasource/src/main/java/com/neo/mapper/test1/User1Mapper.java: -------------------------------------------------------------------------------- 1 | package com.neo.mapper.test1; 2 | 3 | import com.neo.entity.UserEntity; 4 | import com.neo.enums.UserSexEnum; 5 | import org.apache.ibatis.annotations.*; 6 | 7 | import java.util.List; 8 | 9 | public interface User1Mapper { 10 | 11 | 12 | @Select("SELECT * FROM users") 13 | @Results({ 14 | @Result(property = "userSex", column = "user_sex", javaType = UserSexEnum.class), 15 | @Result(property = "nickName", column = "nick_name") 16 | }) 17 | List getAll(); 18 | 19 | @Select("SELECT * FROM users WHERE id = #{id}") 20 | @Results({ 21 | @Result(property = "userSex", column = "user_sex", javaType = UserSexEnum.class), 22 | @Result(property = "nickName", column = "nick_name") 23 | }) 24 | UserEntity getOne(Long id); 25 | 26 | @Insert("INSERT INTO users(userName,passWord,user_sex) VALUES(#{userName}, #{passWord}, #{userSex})") 27 | void insert(UserEntity user); 28 | 29 | @Update("UPDATE users SET userName=#{userName},nick_name=#{nickName} WHERE id =#{id}") 30 | void update(UserEntity user); 31 | 32 | @Delete("DELETE FROM users WHERE id =#{id}") 33 | void delete(Long id); 34 | 35 | } -------------------------------------------------------------------------------- /spring-boot-mybatis-annotation-mulidatasource/src/main/java/com/neo/mapper/test2/User2Mapper.java: -------------------------------------------------------------------------------- 1 | package com.neo.mapper.test2; 2 | 3 | import java.util.List; 4 | 5 | import com.neo.entity.UserEntity; 6 | import com.neo.enums.UserSexEnum; 7 | import org.apache.ibatis.annotations.*; 8 | 9 | public interface User2Mapper { 10 | 11 | 12 | @Select("SELECT * FROM users") 13 | @Results({ 14 | @Result(property = "userSex", column = "user_sex", javaType = UserSexEnum.class), 15 | @Result(property = "nickName", column = "nick_name") 16 | }) 17 | List getAll(); 18 | 19 | @Select("SELECT * FROM users WHERE id = #{id}") 20 | @Results({ 21 | @Result(property = "userSex", column = "user_sex", javaType = UserSexEnum.class), 22 | @Result(property = "nickName", column = "nick_name") 23 | }) 24 | UserEntity getOne(Long id); 25 | 26 | @Insert("INSERT INTO users(userName,passWord,user_sex) VALUES(#{userName}, #{passWord}, #{userSex})") 27 | void insert(UserEntity user); 28 | 29 | @Update("UPDATE users SET userName=#{userName},nick_name=#{nickName} WHERE id =#{id}") 30 | void update(UserEntity user); 31 | 32 | @Delete("DELETE FROM users WHERE id =#{id}") 33 | void delete(Long id); 34 | 35 | } -------------------------------------------------------------------------------- /spring-boot-mybatis-annotation-mulidatasource/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | mybatis.type-aliases-package=com.neo.entity 2 | 3 | spring.datasource.test1.driverClassName = com.mysql.jdbc.Driver 4 | spring.datasource.test1.url = jdbc:mysql://localhost:3306/test1?useUnicode=true&characterEncoding=utf-8 5 | spring.datasource.test1.username = root 6 | spring.datasource.test1.password = root 7 | 8 | 9 | spring.datasource.test2.driverClassName = com.mysql.jdbc.Driver 10 | spring.datasource.test2.url = jdbc:mysql://localhost:3306/test2?useUnicode=true&characterEncoding=utf-8 11 | spring.datasource.test2.username = root 12 | spring.datasource.test2.password = root 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-mybatis-annotation-mulidatasource/src/test/java/com/neo/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-mybatis-annotation/src/main/java/com/neo/Application.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @MapperScan("com.neo.mapper") 9 | public class Application { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(Application.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-mybatis-annotation/src/main/java/com/neo/enums/UserSexEnum.java: -------------------------------------------------------------------------------- 1 | package com.neo.enums; 2 | 3 | public enum UserSexEnum { 4 | MAN, WOMAN 5 | } 6 | -------------------------------------------------------------------------------- /spring-boot-mybatis-annotation/src/main/java/com/neo/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.neo.mapper; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Delete; 6 | import org.apache.ibatis.annotations.Insert; 7 | import org.apache.ibatis.annotations.Result; 8 | import org.apache.ibatis.annotations.Results; 9 | import org.apache.ibatis.annotations.Select; 10 | import org.apache.ibatis.annotations.Update; 11 | 12 | import com.neo.entity.UserEntity; 13 | import com.neo.enums.UserSexEnum; 14 | 15 | public interface UserMapper { 16 | 17 | @Select("SELECT * FROM users") 18 | @Results({ 19 | @Result(property = "userSex", column = "user_sex", javaType = UserSexEnum.class), 20 | @Result(property = "nickName", column = "nick_name") 21 | }) 22 | List getAll(); 23 | 24 | @Select("SELECT * FROM users WHERE id = #{id}") 25 | @Results({ 26 | @Result(property = "userSex", column = "user_sex", javaType = UserSexEnum.class), 27 | @Result(property = "nickName", column = "nick_name") 28 | }) 29 | UserEntity getOne(Long id); 30 | 31 | @Insert("INSERT INTO users(userName,passWord,user_sex) VALUES(#{userName}, #{passWord}, #{userSex})") 32 | void insert(UserEntity user); 33 | 34 | @Update("UPDATE users SET userName=#{userName},nick_name=#{nickName} WHERE id =#{id}") 35 | void update(UserEntity user); 36 | 37 | @Delete("DELETE FROM users WHERE id =#{id}") 38 | void delete(Long id); 39 | 40 | } -------------------------------------------------------------------------------- /spring-boot-mybatis-annotation/src/main/java/com/neo/web/UserController.java: -------------------------------------------------------------------------------- 1 | package com.neo.web; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | import com.neo.entity.UserEntity; 11 | import com.neo.mapper.UserMapper; 12 | 13 | @RestController 14 | public class UserController { 15 | 16 | @Autowired 17 | private UserMapper userMapper; 18 | 19 | @RequestMapping("/getUsers") 20 | public List getUsers() { 21 | List users=userMapper.getAll(); 22 | return users; 23 | } 24 | 25 | @RequestMapping("/getUser") 26 | public UserEntity getUser(Long id) { 27 | UserEntity user=userMapper.getOne(id); 28 | return user; 29 | } 30 | 31 | @RequestMapping("/add") 32 | public void save(UserEntity user) { 33 | userMapper.insert(user); 34 | } 35 | 36 | @RequestMapping(value="update") 37 | public void update(UserEntity user) { 38 | userMapper.update(user); 39 | } 40 | 41 | @RequestMapping(value="/delete/{id}") 42 | public void delete(@PathVariable("id") Long id) { 43 | userMapper.delete(id); 44 | } 45 | 46 | 47 | } -------------------------------------------------------------------------------- /spring-boot-mybatis-annotation/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | mybatis.type-aliases-package=com.neo.entity 2 | 3 | spring.datasource.driverClassName = com.mysql.jdbc.Driver 4 | spring.datasource.url = jdbc:mysql://localhost:3306/test1?useUnicode=true&characterEncoding=utf-8 5 | spring.datasource.username = root 6 | spring.datasource.password = root 7 | -------------------------------------------------------------------------------- /spring-boot-mybatis-annotation/src/test/java/com/neo/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-mybatis-annotation/users.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : 本地 5 | Source Server Version : 50505 6 | Source Host : localhost:3306 7 | Source Database : test1 8 | 9 | Target Server Type : MYSQL 10 | Target Server Version : 50505 11 | File Encoding : 65001 12 | 13 | Date: 2016-11-05 21:17:33 14 | */ 15 | 16 | SET FOREIGN_KEY_CHECKS=0; 17 | 18 | -- ---------------------------- 19 | -- Table structure for `users` 20 | -- ---------------------------- 21 | DROP TABLE IF EXISTS `users`; 22 | CREATE TABLE `users` ( 23 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id', 24 | `userName` varchar(32) DEFAULT NULL COMMENT '用户名', 25 | `passWord` varchar(32) DEFAULT NULL COMMENT '密码', 26 | `user_sex` varchar(32) DEFAULT NULL, 27 | `nick_name` varchar(32) DEFAULT NULL, 28 | PRIMARY KEY (`id`) 29 | ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8; 30 | 31 | -------------------------------------------------------------------------------- /spring-boot-mybatis-mulidatasource/src/main/java/com/neo/Application.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | public class Application { 9 | 10 | public static void main(String[] args) { 11 | SpringApplication.run(Application.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-mybatis-mulidatasource/src/main/java/com/neo/enums/UserSexEnum.java: -------------------------------------------------------------------------------- 1 | package com.neo.enums; 2 | 3 | public enum UserSexEnum { 4 | MAN, WOMAN 5 | } 6 | -------------------------------------------------------------------------------- /spring-boot-mybatis-mulidatasource/src/main/java/com/neo/mapper/test1/User1Mapper.java: -------------------------------------------------------------------------------- 1 | package com.neo.mapper.test1; 2 | 3 | import com.neo.entity.UserEntity; 4 | 5 | import java.util.List; 6 | 7 | public interface User1Mapper { 8 | 9 | List getAll(); 10 | 11 | UserEntity getOne(Long id); 12 | 13 | void insert(UserEntity user); 14 | 15 | void update(UserEntity user); 16 | 17 | void delete(Long id); 18 | 19 | } -------------------------------------------------------------------------------- /spring-boot-mybatis-mulidatasource/src/main/java/com/neo/mapper/test2/User2Mapper.java: -------------------------------------------------------------------------------- 1 | package com.neo.mapper.test2; 2 | 3 | import java.util.List; 4 | 5 | import com.neo.entity.UserEntity; 6 | 7 | public interface User2Mapper { 8 | 9 | List getAll(); 10 | 11 | UserEntity getOne(Long id); 12 | 13 | void insert(UserEntity user); 14 | 15 | void update(UserEntity user); 16 | 17 | void delete(Long id); 18 | 19 | } -------------------------------------------------------------------------------- /spring-boot-mybatis-mulidatasource/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | mybatis.config-locations=classpath:mybatis/mybatis-config.xml 2 | 3 | spring.datasource.test1.driverClassName = com.mysql.jdbc.Driver 4 | spring.datasource.test1.url = jdbc:mysql://localhost:3306/test1?useUnicode=true&characterEncoding=utf-8 5 | spring.datasource.test1.username = root 6 | spring.datasource.test1.password = root 7 | 8 | 9 | spring.datasource.test2.driverClassName = com.mysql.jdbc.Driver 10 | spring.datasource.test2.url = jdbc:mysql://localhost:3306/test2?useUnicode=true&characterEncoding=utf-8 11 | spring.datasource.test2.username = root 12 | spring.datasource.test2.password = root 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-mybatis-mulidatasource/src/main/resources/mybatis/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-mybatis-mulidatasource/src/test/java/com/neo/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-mybatis-mulidatasource/users.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : 本地 5 | Source Server Version : 50505 6 | Source Host : localhost:3306 7 | Source Database : test1 8 | 9 | Target Server Type : MYSQL 10 | Target Server Version : 50505 11 | File Encoding : 65001 12 | 13 | Date: 2016-11-05 21:17:33 14 | */ 15 | 16 | SET FOREIGN_KEY_CHECKS=0; 17 | 18 | -- ---------------------------- 19 | -- Table structure for `users` 20 | -- ---------------------------- 21 | DROP TABLE IF EXISTS `users`; 22 | CREATE TABLE `users` ( 23 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id', 24 | `userName` varchar(32) DEFAULT NULL COMMENT '用户名', 25 | `passWord` varchar(32) DEFAULT NULL COMMENT '密码', 26 | `user_sex` varchar(32) DEFAULT NULL, 27 | `nick_name` varchar(32) DEFAULT NULL, 28 | PRIMARY KEY (`id`) 29 | ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8; 30 | 31 | -------------------------------------------------------------------------------- /spring-boot-mybatis-xml/src/main/java/com/neo/Application.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @MapperScan("com.neo.mapper") 9 | public class Application { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(Application.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-mybatis-xml/src/main/java/com/neo/enums/UserSexEnum.java: -------------------------------------------------------------------------------- 1 | package com.neo.enums; 2 | 3 | public enum UserSexEnum { 4 | MAN, WOMAN 5 | } 6 | -------------------------------------------------------------------------------- /spring-boot-mybatis-xml/src/main/java/com/neo/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.neo.mapper; 2 | 3 | import java.util.List; 4 | 5 | import com.neo.entity.UserEntity; 6 | 7 | public interface UserMapper { 8 | 9 | List getAll(); 10 | 11 | UserEntity getOne(Long id); 12 | 13 | void insert(UserEntity user); 14 | 15 | void update(UserEntity user); 16 | 17 | void delete(Long id); 18 | 19 | } -------------------------------------------------------------------------------- /spring-boot-mybatis-xml/src/main/java/com/neo/web/UserController.java: -------------------------------------------------------------------------------- 1 | package com.neo.web; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | import com.neo.entity.UserEntity; 11 | import com.neo.mapper.UserMapper; 12 | 13 | @RestController 14 | public class UserController { 15 | 16 | @Autowired 17 | private UserMapper userMapper; 18 | 19 | @RequestMapping("/getUsers") 20 | public List getUsers() { 21 | List users=userMapper.getAll(); 22 | return users; 23 | } 24 | 25 | @RequestMapping("/getUser") 26 | public UserEntity getUser(Long id) { 27 | UserEntity user=userMapper.getOne(id); 28 | return user; 29 | } 30 | 31 | @RequestMapping("/add") 32 | public void save(UserEntity user) { 33 | userMapper.insert(user); 34 | } 35 | 36 | @RequestMapping(value="update") 37 | public void update(UserEntity user) { 38 | userMapper.update(user); 39 | } 40 | 41 | @RequestMapping(value="/delete/{id}") 42 | public void delete(@PathVariable("id") Long id) { 43 | userMapper.delete(id); 44 | } 45 | 46 | 47 | } -------------------------------------------------------------------------------- /spring-boot-mybatis-xml/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | mybatis.config-locations=classpath:mybatis/mybatis-config.xml 2 | mybatis.mapper-locations=classpath:mybatis/mapper/*.xml 3 | mybatis.type-aliases-package=com.neo.entity 4 | 5 | spring.datasource.driverClassName = com.mysql.jdbc.Driver 6 | spring.datasource.url = jdbc:mysql://localhost:3306/test1?useUnicode=true&characterEncoding=utf-8 7 | spring.datasource.username = root 8 | spring.datasource.password = root 9 | -------------------------------------------------------------------------------- /spring-boot-mybatis-xml/src/main/resources/mybatis/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-mybatis-xml/src/test/java/com/neo/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-mybatis-xml/src/test/java/com/neo/web/UserControllerTest.java: -------------------------------------------------------------------------------- 1 | package com.neo.web; 2 | 3 | 4 | 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.http.MediaType; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | import org.springframework.test.web.servlet.MockMvc; 13 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; 14 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 15 | import org.springframework.web.context.WebApplicationContext; 16 | 17 | import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; 18 | 19 | @RunWith(SpringRunner.class) 20 | @SpringBootTest 21 | public class UserControllerTest { 22 | @Autowired 23 | private WebApplicationContext wac; 24 | private MockMvc mockMvc; 25 | 26 | @Before 27 | public void setUp() throws Exception { 28 | mockMvc = MockMvcBuilders.webAppContextSetup(wac).build(); //初始化MockMvc对象 29 | } 30 | 31 | @Test 32 | public void getUsers() throws Exception { 33 | mockMvc.perform(MockMvcRequestBuilders.post("/getUsers") 34 | .accept(MediaType.APPLICATION_JSON_UTF8)).andDo(print()); 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /spring-boot-mybatis-xml/users.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : 本地 5 | Source Server Version : 50505 6 | Source Host : localhost:3306 7 | Source Database : test1 8 | 9 | Target Server Type : MYSQL 10 | Target Server Version : 50505 11 | File Encoding : 65001 12 | 13 | Date: 2016-11-05 21:17:33 14 | */ 15 | 16 | SET FOREIGN_KEY_CHECKS=0; 17 | 18 | -- ---------------------------- 19 | -- Table structure for `users` 20 | -- ---------------------------- 21 | DROP TABLE IF EXISTS `users`; 22 | CREATE TABLE `users` ( 23 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id', 24 | `userName` varchar(32) DEFAULT NULL COMMENT '用户名', 25 | `passWord` varchar(32) DEFAULT NULL COMMENT '密码', 26 | `user_sex` varchar(32) DEFAULT NULL, 27 | `nick_name` varchar(32) DEFAULT NULL, 28 | PRIMARY KEY (`id`) 29 | ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8; 30 | 31 | -------------------------------------------------------------------------------- /spring-boot-mybatisplus/src/main/java/com/example/springbootmybatisplus/SpringBootMybatisplusApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootmybatisplus; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 7 | 8 | //@MapperScan("com.example.springbootmybatisplus.dao*") 9 | @SpringBootApplication() 10 | public class SpringBootMybatisplusApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(SpringBootMybatisplusApplication.class, args); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-mybatisplus/src/main/java/com/example/springbootmybatisplus/config/MybatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootmybatisplus.config; 2 | 3 | import com.baomidou.mybatisplus.plugins.PaginationInterceptor; 4 | import org.mybatis.spring.annotation.MapperScan; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | //@MapperScan("com.example.springbootmybatisplus.dao.*") 10 | public class MybatisPlusConfig { 11 | /** 12 | * 分页插件 13 | * @return 14 | */ 15 | @Bean 16 | public PaginationInterceptor paginationInterceptor() { 17 | PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); 18 | // 开启 PageHelper 的支持 19 | paginationInterceptor.setLocalPage(true); 20 | return paginationInterceptor; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-mybatisplus/src/main/java/com/example/springbootmybatisplus/controller/AuObjectController.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootmybatisplus.controller; 2 | 3 | 4 | import com.baomidou.mybatisplus.mapper.EntityWrapper; 5 | import com.baomidou.mybatisplus.mapper.Wrapper; 6 | import com.baomidou.mybatisplus.plugins.Page; 7 | import com.example.springbootmybatisplus.model.AuObject; 8 | import com.example.springbootmybatisplus.service.impl.AuObjectServiceImpl; 9 | import org.springframework.beans.BeanUtils; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | 13 | import org.springframework.stereotype.Controller; 14 | import org.springframework.web.bind.annotation.RequestMethod; 15 | import org.springframework.web.bind.annotation.RestController; 16 | 17 | import java.util.List; 18 | 19 | /** 20 | *

21 | * 审计对象 前端控制器 22 | *

23 | * 24 | * @author null123 25 | * @since 2019-03-08 26 | */ 27 | @RestController 28 | @RequestMapping("/test") 29 | public class AuObjectController { 30 | 31 | @Autowired 32 | private AuObjectServiceImpl auObjectService; 33 | 34 | @RequestMapping(value = "/list",method = RequestMethod.GET) 35 | private Page selectList(){ 36 | return auObjectService.selectAuObjectList(); 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /spring-boot-mybatisplus/src/main/java/com/example/springbootmybatisplus/dao/AuObjectMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootmybatisplus.dao; 2 | 3 | import com.example.springbootmybatisplus.model.AuObject; 4 | import com.baomidou.mybatisplus.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.springframework.stereotype.Repository; 7 | 8 | /** 9 | *

10 | * 审计对象 Mapper 接口 11 | *

12 | * 13 | * @author null123 14 | * @since 2019-03-08 15 | */ 16 | @Mapper 17 | @Repository 18 | public interface AuObjectMapper extends BaseMapper { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-mybatisplus/src/main/java/com/example/springbootmybatisplus/mapper/AuObjectMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /spring-boot-mybatisplus/src/main/java/com/example/springbootmybatisplus/service/AuObjectService.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootmybatisplus.service; 2 | 3 | import com.baomidou.mybatisplus.plugins.Page; 4 | import com.example.springbootmybatisplus.model.AuObject; 5 | import com.baomidou.mybatisplus.service.IService; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | *

11 | * 审计对象 服务类 12 | *

13 | * 14 | * @author null123 15 | * @since 2019-03-08 16 | */ 17 | public interface AuObjectService extends IService { 18 | 19 | public Page selectAuObjectList(); 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-mybatisplus/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-mybatisplus/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8881 3 | spring: 4 | datasource: 5 | # 数据源基本配置 6 | username: lsmsp 7 | password: 860IzvOLj!P2%jfa 8 | driver-class-name: com.mysql.jdbc.Driver 9 | url: jdbc:mysql://10.20.4.161:3306/daa-audit?useUnicode=true&characterEncoding=utf8 10 | type: com.alibaba.druid.pool.DruidDataSource 11 | # 数据源其他配置 12 | initialSize: 5 13 | minIdle: 5 14 | maxActive: 20 15 | maxWait: 60000 16 | timeBetweenEvictionRunsMillis: 60000 17 | minEvictableIdleTimeMillis: 300000 18 | validationQuery: SELECT 1 FROM DUAL 19 | testWhileIdle: true 20 | testOnBorrow: false 21 | testOnReturn: false 22 | poolPreparedStatements: true 23 | # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙 24 | filters: stat 25 | maxPoolPreparedStatementPerConnectionSize: 20 26 | useGlobalDataSourceStat: true 27 | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500 28 | 29 | 30 | #mybatis: 31 | # 指定全局配置文件位置 32 | # config-location: classpath:mybatis_config.xml 33 | # 指定sql映射文件位置 34 | # mapper-locations: classpath:mapper/*.xml 35 | 36 | -------------------------------------------------------------------------------- /spring-boot-mybatisplus/src/test/java/com/example/springbootmybatisplus/SpringBootMybatisplusApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootmybatisplus; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootMybatisplusApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-nacos-server/src/main/java/com/example/springbootnacosserver/SpringBootNacosServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnacosserver; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 7 | import org.springframework.cloud.openfeign.EnableFeignClients; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.web.client.RestTemplate; 10 | 11 | @SpringBootApplication 12 | @EnableDiscoveryClient 13 | @EnableFeignClients 14 | public class SpringBootNacosServerApplication { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(SpringBootNacosServerApplication.class, args); 18 | } 19 | 20 | @LoadBalanced 21 | @Bean 22 | public RestTemplate restTemplate() { 23 | return new RestTemplate(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-nacos-server/src/main/java/com/example/springbootnacosserver/feign/MyClient.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnacosserver.feign; 2 | 3 | 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.stereotype.Service; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | 8 | @Service 9 | @FeignClient(value = "my-nacos-client") 10 | public interface MyClient { 11 | 12 | @GetMapping(value = "/na/test") 13 | public String getClient(); 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-nacos-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8886 3 | spring: 4 | application: 5 | name: my-nacos-server 6 | cloud: 7 | nacos: 8 | discovery: 9 | enabled: true 10 | service: ${spring.application.name} 11 | server-addr: 192.168.70.130:8882 12 | config: 13 | server-addr: 192.168.70.130:8882 14 | file-extension: yml 15 | 16 | ribbon: 17 | eager-load: 18 | enabled: true 19 | clients: my_nacos_client #饥饿加载的服务名 20 | ConnectTimeout: 3000 21 | ReadTimeout: 60000 22 | MaxAutoRetries: 1 23 | MaxAutoRetriesNextServer: 1 24 | OkToRetryOnAllOperations: true 25 | NFLoadBalancerRuleClassName: com.netflix.loadbalancer.RandomRule 26 | 27 | #Ribbon的超时 28 | #ribbon.ConnectTimeout=3000 29 | # ribbon.ReadTimeout=60000 30 | # #对第一次请求的服务的重试次数 31 | # ribbon.MaxAutoRetries=1 32 | # #要重试的下一个服务的最大数量(不包括第一个服务) 33 | # ribbon.MaxAutoRetriesNextServer=1 34 | # #无论是请求超时或者socket read timeout都进行重试 35 | # ribbon.OkToRetryOnAllOperations=true 36 | # #默认随机策略 37 | # ribbon.NFLoadBalancerRuleClassName=com.netflix.loadbalancer.RandomRule 38 | -------------------------------------------------------------------------------- /spring-boot-nacos/src/main/java/com/example/springbootnacos/SpringBootNacosApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnacos; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @SpringBootApplication 8 | @EnableDiscoveryClient 9 | //@NacosPropertySource(dataId = "WARE_ID", autoRefreshed = true) 10 | public class SpringBootNacosApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(SpringBootNacosApplication.class, args); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-nacos/src/main/java/com/example/springbootnacos/config/NacosConfig.java: -------------------------------------------------------------------------------- 1 | //package com.example.springbootnacos.config; 2 | // 3 | //import com.alibaba.nacos.api.annotation.NacosInjected; 4 | //import com.alibaba.nacos.api.exception.NacosException; 5 | //import com.alibaba.nacos.api.naming.NamingService; 6 | //import org.springframework.beans.factory.annotation.Value; 7 | //import org.springframework.context.annotation.Configuration; 8 | //import javax.annotation.PostConstruct; 9 | //@Configuration 10 | //public class NacosConfig { 11 | // @Value("${server.port}") 12 | // private int serverPort; 13 | // @Value("${spring.application.name}") 14 | // private String applicationName; 15 | // @NacosInjected 16 | // private NamingService namingService; 17 | // @PostConstruct 18 | // public void registerInstance() throws NacosException { 19 | // namingService.registerInstance(applicationName, "127.0.0.1", serverPort); 20 | // } 21 | //} -------------------------------------------------------------------------------- /spring-boot-nacos/src/main/java/com/example/springbootnacos/config/ProviderRibbonConfig.java: -------------------------------------------------------------------------------- 1 | //package com.example.springbootnacos.config; 2 | // 3 | //import com.netflix.loadbalancer.BestAvailableRule; 4 | //import com.netflix.loadbalancer.IRule; 5 | //import org.springframework.context.annotation.Bean; 6 | //import org.springframework.context.annotation.Configuration; 7 | // 8 | // 9 | ////Ribbon更细力度的配置,可以针对不同服务设置Load Balance策略 10 | //@Configuration 11 | //public class ProviderRibbonConfig { 12 | // 13 | // //BestAvailableRule策略用来选取最少并发量请求的服务器 14 | // @Bean 15 | // public IRule ribbonRule(){ 16 | // return new BestAvailableRule(); 17 | // } 18 | //} 19 | -------------------------------------------------------------------------------- /spring-boot-nacos/src/main/java/com/example/springbootnacos/config/RibbonConfig.java: -------------------------------------------------------------------------------- 1 | //package com.example.springbootnacos.config; 2 | // 3 | //import org.springframework.cloud.client.loadbalancer.LoadBalanced; 4 | //import org.springframework.cloud.netflix.ribbon.RibbonClient; 5 | //import org.springframework.cloud.netflix.ribbon.RibbonClients; 6 | //import org.springframework.context.annotation.Bean; 7 | //import org.springframework.context.annotation.Configuration; 8 | //import org.springframework.web.client.RestTemplate; 9 | // 10 | // 11 | // 12 | //@Configuration 13 | ////RibbonClients可以配置多个服务策略 14 | //@RibbonClients({ 15 | // //Ribbon更细力度的配置,可以针对不同服务设置Load Balance策略 16 | // @RibbonClient(name = "nacos-provider-service", configuration = ProviderRibbonConfig.class) 17 | //}) 18 | //public class RibbonConfig { 19 | // 20 | // //使用RestTemplate进行rest操作的时候,会自动使用负载均衡策略,它内部会在RestTemplate中加入LoadBalancerInterceptor这个拦截器,这个拦截器的作用就是使用负载均衡。 21 | // //默认情况下会采用轮询策 22 | // @LoadBalanced 23 | // @Bean 24 | // public RestTemplate restTemplate() { 25 | // return new RestTemplate(); 26 | // } 27 | //} 28 | -------------------------------------------------------------------------------- /spring-boot-nacos/src/main/java/com/example/springbootnacos/controller/MyNacosController.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnacos.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | @RequestMapping("na") 9 | //@RefreshScope 10 | public class MyNacosController { 11 | 12 | @GetMapping("/test") 13 | public String getNacInfo(){ 14 | return "welcome to my world"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-nacos/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #spring.profiles.active=dev 2 | #spring.application.name=nacos-provider-service 3 | #server.port=8081 -------------------------------------------------------------------------------- /spring-boot-nacos/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8883 3 | spring: 4 | application: 5 | name: my-nacos-client 6 | cloud: 7 | nacos: 8 | discovery: 9 | enabled: true 10 | service: ${spring.application.name} 11 | server-addr: 192.168.70.130:8882 12 | config: 13 | server-addr: 192.168.70.130:8882 14 | file-extension: yml 15 | 16 | ribbon: 17 | eager-load: 18 | enabled: true 19 | clients: my_nacos_client #饥饿加载的服务名 20 | ConnectTimeout: 3000 21 | ReadTimeout: 60000 22 | MaxAutoRetries: 1 23 | MaxAutoRetriesNextServer: 1 24 | OkToRetryOnAllOperations: true 25 | NFLoadBalancerRuleClassName: com.netflix.loadbalancer.RandomRule 26 | 27 | #Ribbon的超时 28 | #ribbon.ConnectTimeout=3000 29 | # ribbon.ReadTimeout=60000 30 | # #对第一次请求的服务的重试次数 31 | # ribbon.MaxAutoRetries=1 32 | # #要重试的下一个服务的最大数量(不包括第一个服务) 33 | # ribbon.MaxAutoRetriesNextServer=1 34 | # #无论是请求超时或者socket read timeout都进行重试 35 | # ribbon.OkToRetryOnAllOperations=true 36 | # #默认随机策略 37 | # ribbon.NFLoadBalancerRuleClassName=com.netflix.loadbalancer.RandomRule 38 | -------------------------------------------------------------------------------- /spring-boot-nacos/src/main/resources/bootstrap.properties: -------------------------------------------------------------------------------- 1 | ##Nacos注册中心地址 2 | #spring.cloud.nacos.discovery.server-addr=192.168.0.149:8882 3 | ##命名当前服务名称 4 | #spring.cloud.nacos.discovery.service=${spring.application.name} 5 | #spring.cloud.nacos.discovery.enabled=true -------------------------------------------------------------------------------- /spring-boot-neo4j/src/main/java/com/example/springbootneo4j/config/Neo4jConfig.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootneo4j.config; 2 | 3 | import org.neo4j.driver.v1.AuthTokens; 4 | import org.neo4j.driver.v1.Driver; 5 | import org.neo4j.driver.v1.GraphDatabase; 6 | import org.neo4j.driver.v1.Session; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.transaction.annotation.EnableTransactionManagement; 11 | 12 | @Configuration 13 | @EnableTransactionManagement 14 | public class Neo4jConfig { 15 | 16 | @Value("${spring.data.neo4j.uri}") 17 | private String url; 18 | 19 | @Value("${spring.data.neo4j.username}") 20 | private String username; 21 | 22 | @Value("${spring.data.neo4j.password}") 23 | private String password; 24 | 25 | @Bean(name = "session") 26 | public Session neo4jSession() { 27 | Driver driver = GraphDatabase.driver(url, AuthTokens.basic(username, password)); 28 | return driver.session(); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /spring-boot-neo4j/src/main/java/com/example/springbootneo4j/seeder/runSeeder.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootneo4j.seeder; 2 | 3 | import com.example.springbootneo4j.dao.NeoRepository; 4 | import com.sun.prism.shader.Solid_TextureYV12_AlphaTest_Loader; 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.stereotype.Service; 7 | 8 | import javax.annotation.Resource; 9 | 10 | @Service 11 | public class runSeeder implements CommandLineRunner { 12 | 13 | @Resource 14 | private NeoRepository neoRepository; 15 | 16 | @Override 17 | public void run(String... args) throws Exception { 18 | // new Thread(()->{ 19 | // neoRepository.listSyncNeoNode(25000,50000); 20 | // }).start(); 21 | // new Thread(()->{ 22 | // neoRepository.listSyncNeoNode(75001,50000); 23 | // }).start(); 24 | // new Thread(()->{ 25 | // neoRepository.listSyncNeoNode(125001,50000); 26 | // }).start(); 27 | // new Thread(()->{ 28 | // neoRepository.listSyncNeoNode(175001,50000); 29 | // }).start(); 30 | // new Thread(()->{ 31 | // neoRepository.listSyncNeoNode(225001,50000); 32 | // }).start(); 33 | // 34 | neoRepository.executeLabelAdd(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot-neo4j/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | data: 3 | neo4j: 4 | uri: bolt://192.168.0.149:13334 5 | username: neo4j 6 | password: 123456 7 | open-in-view: true -------------------------------------------------------------------------------- /spring-boot-neo4j/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: 'dev' 4 | http: 5 | encoding: 6 | charset: utf-8 7 | -------------------------------------------------------------------------------- /spring-boot-netty-client/src/main/java/com/example/springbootnettyclient/SpringBootNettyClientApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnettyclient; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootNettyClientApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootNettyClientApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-netty-client/src/main/java/com/example/springbootnettyclient/netty/ClientHandlerInitilizer.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnettyclient.netty; 2 | 3 | import io.netty.channel.Channel; 4 | import io.netty.channel.ChannelInitializer; 5 | 6 | public class ClientHandlerInitilizer extends ChannelInitializer { 7 | 8 | private static final int MAX_FRAME_LENGTH = 1024 * 1024; //最大长度 9 | private static final int LENGTH_FIELD_LENGTH = 4; //长度字段所占的字节数 10 | private static final int LENGTH_FIELD_OFFSET = 2; //长度偏移 11 | private static final int LENGTH_ADJUSTMENT = 0; 12 | private static final int INITIAL_BYTES_TO_STRIP = 0; 13 | 14 | @Override 15 | protected void initChannel(Channel ch) throws Exception { 16 | ch.pipeline() 17 | // .addLast(MarshallingCodeCFactory.buildMarshallingEncoder()) 18 | // .addLast(MarshallingCodeCFactory.buildMarshallingDecoder()) 19 | .addLast(new MyProtocolDecoder(MAX_FRAME_LENGTH,LENGTH_FIELD_OFFSET,LENGTH_FIELD_LENGTH,LENGTH_ADJUSTMENT,INITIAL_BYTES_TO_STRIP,false)) 20 | .addLast(new MyProtocolEncoder()) 21 | .addLast(new NettyClientHandler()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-netty-client/src/main/java/com/example/springbootnettyclient/netty/MyProtocolEncoder.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnettyclient.netty; 2 | 3 | import com.example.springbootnettyserver.pojo.MyProtocolBean; 4 | import io.netty.buffer.ByteBuf; 5 | import io.netty.channel.ChannelHandlerContext; 6 | import io.netty.handler.codec.MessageToByteEncoder; 7 | 8 | import java.nio.charset.Charset; 9 | 10 | public class MyProtocolEncoder extends MessageToByteEncoder { 11 | 12 | @Override 13 | protected void encode(ChannelHandlerContext ctx, MyProtocolBean msg, ByteBuf out) throws Exception { 14 | if(msg == null){ 15 | throw new Exception("msg is null"); 16 | } 17 | out.writeByte(msg.getType()); 18 | out.writeByte(msg.getFlag()); 19 | out.writeInt(msg.getLength()); 20 | out.writeBytes(msg.getContent().getBytes(Charset.forName("UTF-8"))); 21 | } 22 | } -------------------------------------------------------------------------------- /spring-boot-netty-client/src/main/java/com/example/springbootnettyclient/netty/NettyParams.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnettyclient.netty; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.stereotype.Component; 5 | 6 | /** 7 | * @author LSD 8 | * @date 2020/11/26 19:30 9 | */ 10 | @Component 11 | public class NettyParams { 12 | 13 | 14 | public static int port; 15 | 16 | public static String host; 17 | 18 | @Value("${netty.port}") 19 | public void setPort(int port) { 20 | this.port = port; 21 | } 22 | 23 | @Value("${netty.host}") 24 | public void setHost(String host) { 25 | this.host = host; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-netty-client/src/main/java/com/example/springbootnettyserver/pojo/HeartBeatInfo.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnettyserver.pojo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class HeartBeatInfo implements Serializable { 9 | 10 | private static final long serialVersionUID = 5634457841495229433L; 11 | 12 | private String name; 13 | private Integer status; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-netty-client/src/main/java/com/example/springbootnettyserver/pojo/MyProtocolBean.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnettyserver.pojo; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class MyProtocolBean { 7 | //类型 系统编号 0xA 表示A系统,0xB 表示B系统 8 | private byte type; 9 | //信息标志 0xA 表示心跳包 0xC 表示超时包 0xC 业务信息包 10 | private byte flag; 11 | //内容长度 12 | private int length; 13 | //内容 14 | private String content; 15 | 16 | public MyProtocolBean(byte flag, byte type, int length, String content) { 17 | this.flag = flag; 18 | this.type = type; 19 | this.length = length; 20 | this.content = content; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /spring-boot-netty-client/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | netty.port=9000 2 | netty.host=127.0.0.1 -------------------------------------------------------------------------------- /spring-boot-netty-server/src/main/java/com/example/springbootnettyserver/SpringBootNettyServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnettyserver; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootNettyServerApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootNettyServerApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-netty-server/src/main/java/com/example/springbootnettyserver/netty/MyProtocolEncoder.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnettyserver.netty; 2 | 3 | import com.example.springbootnettyserver.pojo.MyProtocolBean; 4 | import io.netty.buffer.ByteBuf; 5 | import io.netty.channel.ChannelHandlerContext; 6 | import io.netty.handler.codec.MessageToByteEncoder; 7 | 8 | import java.nio.charset.Charset; 9 | 10 | public class MyProtocolEncoder extends MessageToByteEncoder { 11 | 12 | @Override 13 | protected void encode(ChannelHandlerContext ctx, MyProtocolBean msg, ByteBuf out) throws Exception { 14 | if(msg == null){ 15 | throw new Exception("msg is null"); 16 | } 17 | out.writeByte(msg.getType()); 18 | out.writeByte(msg.getFlag()); 19 | out.writeInt(msg.getLength()); 20 | out.writeBytes(msg.getContent().getBytes(Charset.forName("UTF-8"))); 21 | } 22 | } -------------------------------------------------------------------------------- /spring-boot-netty-server/src/main/java/com/example/springbootnettyserver/netty/NettyServerHandlerInitializer.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnettyserver.netty; 2 | 3 | import io.netty.channel.Channel; 4 | import io.netty.channel.ChannelInitializer; 5 | 6 | /** 7 | * @author LSD 8 | * @date 2020/11/26 10:50 9 | */ 10 | public class NettyServerHandlerInitializer extends ChannelInitializer { 11 | 12 | private static final int MAX_FRAME_LENGTH = 1024 * 1024; //最大长度 13 | private static final int LENGTH_FIELD_LENGTH = 4; //长度字段所占的字节数 14 | private static final int LENGTH_FIELD_OFFSET = 2; //长度偏移 15 | private static final int LENGTH_ADJUSTMENT = 0; 16 | private static final int INITIAL_BYTES_TO_STRIP = 0; 17 | 18 | @Override 19 | protected void initChannel(Channel ch) throws Exception { 20 | ch.pipeline() 21 | //空闲检测 22 | // .addLast(MarshallingCodeCFactory.buildMarshallingDecoder()) 23 | // .addLast(MarshallingCodeCFactory.buildMarshallingEncoder()) 24 | .addLast(new MyProtocolDecoder(MAX_FRAME_LENGTH,LENGTH_FIELD_OFFSET,LENGTH_FIELD_LENGTH,LENGTH_ADJUSTMENT,INITIAL_BYTES_TO_STRIP,false)) 25 | .addLast(new MyProtocolEncoder()) 26 | .addLast(new ServerIdleStateHandler()) 27 | .addLast(new NettyServerHandler()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-netty-server/src/main/java/com/example/springbootnettyserver/netty/ServerIdleStateHandler.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnettyserver.netty; 2 | 3 | import com.example.springbootnettyserver.pojo.HeartBeatInfo; 4 | import com.example.springbootnettyserver.pojo.MyProtocolBean; 5 | import io.netty.channel.ChannelHandlerContext; 6 | import io.netty.handler.timeout.IdleStateEvent; 7 | import io.netty.handler.timeout.IdleStateHandler; 8 | import lombok.extern.slf4j.Slf4j; 9 | 10 | import java.util.concurrent.TimeUnit; 11 | 12 | /** 13 | * 空闲检测 14 | * 15 | * @author pjmike 16 | * @create 2018-10-25 16:21 17 | */ 18 | @Slf4j 19 | public class ServerIdleStateHandler extends IdleStateHandler { 20 | /** 21 | * 设置空闲检测时间为 30s 22 | */ 23 | private static final int READER_IDLE_TIME = 10; 24 | public ServerIdleStateHandler() { 25 | super(READER_IDLE_TIME, 0, 0, TimeUnit.SECONDS); 26 | } 27 | 28 | @Override 29 | protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) throws Exception { 30 | log.info("{} 秒内没有读取到数据,发送心跳包", READER_IDLE_TIME); 31 | String message = "come on baby!!!"; 32 | ctx.writeAndFlush(new MyProtocolBean((byte)0xA,(byte)0xA,message.getBytes().length, message)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-netty-server/src/main/java/com/example/springbootnettyserver/pojo/HeartBeatInfo.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnettyserver.pojo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class HeartBeatInfo implements Serializable { 9 | 10 | private static final long serialVersionUID = 5634457841495229433L; 11 | 12 | private String name; 13 | private Integer status; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-netty-server/src/main/java/com/example/springbootnettyserver/pojo/MyProtocolBean.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootnettyserver.pojo; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class MyProtocolBean { 7 | //类型 系统编号 0xA 表示A系统,0xB 表示B系统 8 | private byte type; 9 | //信息标志 0xA 表示心跳包 0xC 表示超时包 0xC 业务信息包 10 | private byte flag; 11 | //内容长度 12 | private int length; 13 | //内容 14 | private String content; 15 | 16 | public MyProtocolBean(byte flag, byte type, int length, String content) { 17 | this.flag = flag; 18 | this.type = type; 19 | this.length = length; 20 | this.content = content; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /spring-boot-netty-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | netty.port=9000 2 | netty.host=127.0.0.1 3 | -------------------------------------------------------------------------------- /spring-boot-package-war/src/main/java/com/neo/Application.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-package-war/src/main/java/com/neo/ServletInitializer.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.builder.SpringApplicationBuilder; 4 | import org.springframework.boot.context.web.SpringBootServletInitializer; 5 | 6 | /** 7 | * Created by summer on 2017/5/8. 8 | */ 9 | public class ServletInitializer extends SpringBootServletInitializer { 10 | @Override 11 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 12 | return application.sources(Application.class); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-package-war/src/main/java/com/neo/controller/HelloWorldController.java: -------------------------------------------------------------------------------- 1 | package com.neo.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloWorldController { 8 | 9 | @RequestMapping("/hello") 10 | public String index() { 11 | return "Hello World xx"; 12 | } 13 | } -------------------------------------------------------------------------------- /spring-boot-package-war/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-package-war/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-package-war/src/test/java/com/neo/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.SpringApplicationConfiguration; 6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 7 | 8 | @RunWith(SpringJUnit4ClassRunner.class) 9 | @SpringApplicationConfiguration(classes = Application.class) 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/Application.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/model/User.java: -------------------------------------------------------------------------------- 1 | package com.neo.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by summer on 2016/11/29. 7 | */ 8 | public class User implements Serializable{ 9 | 10 | private String name; 11 | 12 | private String pass; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public void setName(String name) { 19 | this.name = name; 20 | } 21 | 22 | public String getPass() { 23 | return pass; 24 | } 25 | 26 | public void setPass(String pass) { 27 | this.pass = pass; 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return "User{" + 33 | "name='" + name + '\'' + 34 | ", pass='" + pass + '\'' + 35 | '}'; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/RabbitConfig.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit; 2 | 3 | import org.springframework.amqp.core.Queue; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | 8 | @Configuration 9 | public class RabbitConfig { 10 | 11 | @Bean 12 | public Queue helloQueue() { 13 | return new Queue("hello"); 14 | } 15 | 16 | @Bean 17 | public Queue neoQueue() { 18 | return new Queue("neo"); 19 | } 20 | 21 | @Bean 22 | public Queue objectQueue() { 23 | return new Queue("object"); 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/TopicRabbitConfig.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit; 2 | 3 | import org.springframework.amqp.core.Binding; 4 | import org.springframework.amqp.core.BindingBuilder; 5 | import org.springframework.amqp.core.Queue; 6 | import org.springframework.amqp.core.TopicExchange; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | 11 | @Configuration 12 | public class TopicRabbitConfig { 13 | 14 | final static String message = "topic.message"; 15 | final static String messages = "topic.messages"; 16 | 17 | @Bean 18 | public Queue queueMessage() { 19 | return new Queue(TopicRabbitConfig.message); 20 | } 21 | 22 | @Bean 23 | public Queue queueMessages() { 24 | return new Queue(TopicRabbitConfig.messages); 25 | } 26 | 27 | @Bean 28 | TopicExchange exchange() { 29 | return new TopicExchange("topicExchange"); 30 | } 31 | 32 | @Bean 33 | Binding bindingExchangeMessage(Queue queueMessage, TopicExchange exchange) { 34 | return BindingBuilder.bind(queueMessage).to(exchange).with("topic.message"); 35 | } 36 | 37 | @Bean 38 | Binding bindingExchangeMessages(Queue queueMessages, TopicExchange exchange) { 39 | return BindingBuilder.bind(queueMessages).to(exchange).with("topic.#"); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/fanout/FanoutReceiverA.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit.fanout; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 4 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | @RabbitListener(queues = "fanout.A") 9 | public class FanoutReceiverA { 10 | 11 | @RabbitHandler 12 | public void process(String message) { 13 | System.out.println("fanout Receiver A : " + message); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/fanout/FanoutReceiverB.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit.fanout; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 4 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | @RabbitListener(queues = "fanout.B") 9 | public class FanoutReceiverB { 10 | 11 | @RabbitHandler 12 | public void process(String message) { 13 | System.out.println("fanout Receiver B: " + message); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/fanout/FanoutReceiverC.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit.fanout; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 4 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | @RabbitListener(queues = "fanout.C") 9 | public class FanoutReceiverC { 10 | 11 | @RabbitHandler 12 | public void process(String message) { 13 | System.out.println("fanout Receiver C: " + message); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/fanout/FanoutSender.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit.fanout; 2 | 3 | import org.springframework.amqp.core.AmqpTemplate; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class FanoutSender { 9 | 10 | @Autowired 11 | private AmqpTemplate rabbitTemplate; 12 | 13 | public void send() { 14 | String context = "hi, fanout msg "; 15 | System.out.println("Sender : " + context); 16 | this.rabbitTemplate.convertAndSend("fanoutExchange","", context); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/hello/HelloReceiver.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit.hello; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 4 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 5 | import org.springframework.cache.annotation.Cacheable; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.Date; 9 | 10 | @Component 11 | @RabbitListener(queues = "hello") 12 | public class HelloReceiver { 13 | 14 | @RabbitHandler 15 | public void process(String hello) { 16 | System.out.println("Receiver : " + hello); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/hello/HelloSender.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit.hello; 2 | 3 | import org.springframework.amqp.core.AmqpTemplate; 4 | import org.springframework.amqp.rabbit.core.RabbitTemplate; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.Date; 9 | 10 | @Component 11 | public class HelloSender { 12 | 13 | @Autowired 14 | private AmqpTemplate rabbitTemplate; 15 | 16 | public void send() { 17 | String context = "hello " + new Date(); 18 | System.out.println("Sender : " + context); 19 | this.rabbitTemplate.convertAndSend("hello", context); 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/many/NeoReceiver1.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit.many; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 4 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | @RabbitListener(queues = "neo") 9 | public class NeoReceiver1 { 10 | 11 | @RabbitHandler 12 | public void process(String neo) { 13 | System.out.println("Receiver 1: " + neo); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/many/NeoReceiver2.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit.many; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 4 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | @RabbitListener(queues = "neo") 9 | public class NeoReceiver2 { 10 | 11 | @RabbitHandler 12 | public void process(String neo) { 13 | System.out.println("Receiver 2: " + neo); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/many/NeoSender.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit.many; 2 | 3 | import org.springframework.amqp.core.AmqpTemplate; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class NeoSender { 9 | 10 | @Autowired 11 | private AmqpTemplate rabbitTemplate; 12 | 13 | public void send(int i) { 14 | String context = "spirng boot neo queue"+" ****** "+i; 15 | System.out.println("Sender1 : " + context); 16 | this.rabbitTemplate.convertAndSend("neo", context); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/many/NeoSender2.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit.many; 2 | 3 | import org.springframework.amqp.core.AmqpTemplate; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class NeoSender2 { 9 | 10 | @Autowired 11 | private AmqpTemplate rabbitTemplate; 12 | 13 | public void send(int i) { 14 | String context = "spirng boot neo queue"+" ****** "+i; 15 | System.out.println("Sender2 : " + context); 16 | this.rabbitTemplate.convertAndSend("neo", context); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/object/ObjectReceiver.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit.object; 2 | 3 | import com.neo.model.User; 4 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 5 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | @RabbitListener(queues = "object") 10 | public class ObjectReceiver { 11 | 12 | @RabbitHandler 13 | public void process(User user) { 14 | System.out.println("Receiver object : " + user); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/object/ObjectSender.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit.object; 2 | 3 | import com.neo.model.User; 4 | import org.springframework.amqp.core.AmqpTemplate; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.Date; 9 | 10 | @Component 11 | public class ObjectSender { 12 | 13 | @Autowired 14 | private AmqpTemplate rabbitTemplate; 15 | 16 | public void send(User user) { 17 | System.out.println("Sender object: " + user.toString()); 18 | this.rabbitTemplate.convertAndSend("object", user); 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/topic/TopicReceiver.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit.topic; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 4 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | @RabbitListener(queues = "topic.message") 9 | public class TopicReceiver { 10 | 11 | @RabbitHandler 12 | public void process(String message) { 13 | System.out.println("Topic Receiver1 : " + message); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/topic/TopicReceiver2.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit.topic; 2 | 3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler; 4 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | @RabbitListener(queues = "topic.messages") 9 | public class TopicReceiver2 { 10 | 11 | @RabbitHandler 12 | public void process(String message) { 13 | System.out.println("Topic Receiver2 : " + message); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/topic/TopicSender.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbit.topic; 2 | 3 | import org.springframework.amqp.core.AmqpTemplate; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.Date; 8 | 9 | @Component 10 | public class TopicSender { 11 | 12 | @Autowired 13 | private AmqpTemplate rabbitTemplate; 14 | 15 | public void send() { 16 | String context = "hi, i am message all"; 17 | System.out.println("Sender : " + context); 18 | this.rabbitTemplate.convertAndSend("topicExchange", "topic.1", context); 19 | } 20 | 21 | public void send1() { 22 | String context = "hi, i am message 1"; 23 | System.out.println("Sender : " + context); 24 | this.rabbitTemplate.convertAndSend("topicExchange", "topic.message", context); 25 | } 26 | 27 | public void send2() { 28 | String context = "hi, i am messages 2"; 29 | System.out.println("Sender : " + context); 30 | this.rabbitTemplate.convertAndSend("topicExchange", "topic.messages", context); 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spirng-boot-rabbitmq-example 2 | 3 | spring.rabbitmq.host=192.168.0.86 4 | spring.rabbitmq.port=5672 5 | spring.rabbitmq.username=admin 6 | spring.rabbitmq.password=123456 7 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/test/java/com/neo/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/test/java/com/neo/rabbitmq/FanoutTest.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbitmq; 2 | 3 | import com.neo.rabbit.fanout.FanoutSender; 4 | import com.neo.rabbit.topic.TopicSender; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | @RunWith(SpringRunner.class) 12 | @SpringBootTest 13 | public class FanoutTest { 14 | 15 | @Autowired 16 | private FanoutSender sender; 17 | 18 | @Test 19 | public void fanoutSender() throws Exception { 20 | sender.send(); 21 | } 22 | 23 | 24 | } -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/test/java/com/neo/rabbitmq/HelloTest.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbitmq; 2 | 3 | import com.neo.rabbit.hello.HelloSender; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | @RunWith(SpringRunner.class) 11 | @SpringBootTest 12 | public class HelloTest { 13 | 14 | @Autowired 15 | private HelloSender helloSender; 16 | 17 | @Test 18 | public void hello() throws Exception { 19 | helloSender.send(); 20 | } 21 | 22 | 23 | } -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/test/java/com/neo/rabbitmq/ManyTest.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbitmq; 2 | 3 | import com.neo.rabbit.many.NeoSender; 4 | import com.neo.rabbit.many.NeoSender2; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | @RunWith(SpringRunner.class) 12 | @SpringBootTest 13 | public class ManyTest { 14 | @Autowired 15 | private NeoSender neoSender; 16 | 17 | @Autowired 18 | private NeoSender2 neoSender2; 19 | 20 | @Test 21 | public void oneToMany() throws Exception { 22 | for (int i=0;i<100;i++){ 23 | neoSender.send(i); 24 | } 25 | } 26 | 27 | @Test 28 | public void manyToMany() throws Exception { 29 | for (int i=0;i<100;i++){ 30 | neoSender.send(i); 31 | neoSender2.send(i); 32 | } 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/test/java/com/neo/rabbitmq/ObjectTest.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbitmq; 2 | 3 | import com.neo.model.User; 4 | import com.neo.rabbit.object.ObjectSender; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | @RunWith(SpringRunner.class) 12 | @SpringBootTest 13 | public class ObjectTest { 14 | 15 | @Autowired 16 | private ObjectSender sender; 17 | 18 | @Test 19 | public void sendOject() throws Exception { 20 | User user=new User(); 21 | user.setName("neo"); 22 | user.setPass("123456"); 23 | sender.send(user); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/test/java/com/neo/rabbitmq/TopicTest.java: -------------------------------------------------------------------------------- 1 | package com.neo.rabbitmq; 2 | 3 | import com.neo.rabbit.topic.TopicSender; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | @RunWith(SpringRunner.class) 11 | @SpringBootTest 12 | public class TopicTest { 13 | 14 | @Autowired 15 | private TopicSender sender; 16 | 17 | @Test 18 | public void topic() throws Exception { 19 | sender.send(); 20 | } 21 | 22 | @Test 23 | public void topic1() throws Exception { 24 | sender.send1(); 25 | } 26 | 27 | @Test 28 | public void topic2() throws Exception { 29 | sender.send2(); 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /spring-boot-redis/src/main/java/com/neo/RedisApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | public class RedisApplication { 9 | 10 | public static void main(String[] args) { 11 | 12 | System.getProperties().put("projectName","springApp"); 13 | SpringApplication.run(RedisApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-redis/src/main/java/com/neo/model/RedisModel.java: -------------------------------------------------------------------------------- 1 | package com.neo.model; 2 | import java.io.Serializable; 3 | 4 | public class RedisModel implements Serializable { 5 | private String redisKey;//redis中的key 6 | private String name;//姓名 7 | private String tel;//电话 8 | private String address;//住址 9 | 10 | public String getRedisKey() { 11 | return redisKey; 12 | } 13 | 14 | public void setRedisKey(String redisKey) { 15 | this.redisKey = redisKey; 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public void setName(String name) { 23 | this.name = name; 24 | } 25 | 26 | public String getTel() { 27 | return tel; 28 | } 29 | 30 | public void setTel(String tel) { 31 | this.tel = tel; 32 | } 33 | 34 | public String getAddress() { 35 | return address; 36 | } 37 | 38 | public void setAddress(String address) { 39 | this.address = address; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-redis/src/main/java/com/neo/service/Impl/RedisServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.neo.service.Impl; 2 | 3 | import com.neo.model.RedisModel; 4 | import com.neo.service.IRedisService; 5 | import org.springframework.stereotype.Service; 6 | 7 | 8 | /** 9 | * Created by Administrator on 2017/3/1 16:00. 10 | */ 11 | @Service 12 | public class RedisServiceImpl extends IRedisService { 13 | private static final String REDIS_KEY = "TEST_REDIS_KEY"; 14 | 15 | @Override 16 | protected String getRedisKey() { 17 | return this.REDIS_KEY; 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /spring-boot-redis/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | ##redis 2 | #spring.redis.hostName=127.0.0.1 3 | #spring.redis.port=6379 4 | #spring.redis.pool.maxActive=100 5 | #spring.redis.pool.maxWait=100 6 | #spring.redis.pool.maxIdle=20 7 | #spring.redis.pool.minIdle=10 8 | #spring.redis.timeout=0 -------------------------------------------------------------------------------- /spring-boot-redis/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # redis配置,以下有默认配置的也可以使用默认配置 2 | spring: 3 | redis: 4 | host: 192.168.164.142 5 | port: 6379 6 | password: 123456 7 | pool: 8 | max-active: 100 9 | max-wait: 100 10 | max-idle: 20 11 | min-idle: 10 12 | timeout: 300 13 | -------------------------------------------------------------------------------- /spring-boot-redis/src/test/java/com/neo/RedisApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | @RunWith(SpringRunner.class) 10 | @SpringBootTest 11 | public class RedisApplicationTests { 12 | 13 | @Test 14 | public void contextLoads() { 15 | System.out.println("hello web"); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-redis/target/classes/application.properties: -------------------------------------------------------------------------------- 1 | ##redis 2 | #spring.redis.hostName=127.0.0.1 3 | #spring.redis.port=6379 4 | #spring.redis.pool.maxActive=100 5 | #spring.redis.pool.maxWait=100 6 | #spring.redis.pool.maxIdle=20 7 | #spring.redis.pool.minIdle=10 8 | #spring.redis.timeout=0 -------------------------------------------------------------------------------- /spring-boot-redis/target/classes/application.yml: -------------------------------------------------------------------------------- 1 | # redis配置,以下有默认配置的也可以使用默认配置 2 | spring: 3 | redis: 4 | host: 192.168.164.142 5 | port: 6379 6 | password: 123456 7 | pool: 8 | max-active: 100 9 | max-wait: 100 10 | max-idle: 20 11 | min-idle: 10 12 | timeout: 300 13 | -------------------------------------------------------------------------------- /spring-boot-redis/target/classes/com/neo/RedisApplication.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-redis/target/classes/com/neo/RedisApplication.class -------------------------------------------------------------------------------- /spring-boot-redis/target/classes/com/neo/config/RedisConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-redis/target/classes/com/neo/config/RedisConfig.class -------------------------------------------------------------------------------- /spring-boot-redis/target/classes/com/neo/model/RedisModel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-redis/target/classes/com/neo/model/RedisModel.class -------------------------------------------------------------------------------- /spring-boot-redis/target/classes/com/neo/model/User.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-redis/target/classes/com/neo/model/User.class -------------------------------------------------------------------------------- /spring-boot-redis/target/classes/com/neo/service/IRedisService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-redis/target/classes/com/neo/service/IRedisService.class -------------------------------------------------------------------------------- /spring-boot-redis/target/classes/com/neo/service/Impl/RedisServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-redis/target/classes/com/neo/service/Impl/RedisServiceImpl.class -------------------------------------------------------------------------------- /spring-boot-redis/target/classes/com/neo/util/RedisUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-redis/target/classes/com/neo/util/RedisUtil.class -------------------------------------------------------------------------------- /spring-boot-redis/target/classes/com/neo/web/TestController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-redis/target/classes/com/neo/web/TestController.class -------------------------------------------------------------------------------- /spring-boot-redis/target/test-classes/com/neo/RedisApplicationTests.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-redis/target/test-classes/com/neo/RedisApplicationTests.class -------------------------------------------------------------------------------- /spring-boot-redis/target/test-classes/com/neo/TestRedis.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-redis/target/test-classes/com/neo/TestRedis.class -------------------------------------------------------------------------------- /spring-boot-scheduler/src/main/java/com/neo/Application.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableScheduling; 6 | 7 | @SpringBootApplication 8 | @EnableScheduling 9 | public class Application { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(Application.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-scheduler/src/main/java/com/neo/task/Scheduler2Task.java: -------------------------------------------------------------------------------- 1 | package com.neo.task; 2 | 3 | import org.springframework.scheduling.annotation.Scheduled; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.text.SimpleDateFormat; 7 | import java.util.Date; 8 | 9 | /** 10 | * Created by summer on 2016/12/1. 11 | */ 12 | 13 | @Component 14 | public class Scheduler2Task { 15 | 16 | private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); 17 | 18 | @Scheduled(fixedRate = 6000) 19 | public void reportCurrentTime() { 20 | System.out.println("现在时间:" + dateFormat.format(new Date())); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-scheduler/src/main/java/com/neo/task/SchedulerTask.java: -------------------------------------------------------------------------------- 1 | package com.neo.task; 2 | 3 | import org.springframework.scheduling.annotation.Scheduled; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * Created by summer on 2016/12/1. 10 | */ 11 | 12 | @Component 13 | public class SchedulerTask { 14 | 15 | private int count=0; 16 | 17 | @Scheduled(cron="*/6 * * * * ?") 18 | private void process(){ 19 | System.out.println("this is scheduler task runing "+(count++)); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-scheduler/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spirng-boot-scheduler 2 | 3 | -------------------------------------------------------------------------------- /spring-boot-scheduler/src/test/java/com/neo/ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-sentinel/src/main/java/com/example/springbootsentinel/SpringBootSentinelApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.springbootsentinel; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootSentinelApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootSentinelApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-sentinel/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: sentinelserver 4 | # cloud: 5 | # sentinel: 6 | # transport: 7 | # dashboard: localhost:8080 8 | # heartbeat-interval-ms: 500 9 | # eager: true -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/neo/SpringBootShiroApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootShiroApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootShiroApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/neo/dao/UserInfoDao.java: -------------------------------------------------------------------------------- 1 | package com.neo.dao; 2 | 3 | import com.neo.entity.UserInfo; 4 | import org.springframework.data.repository.CrudRepository; 5 | 6 | public interface UserInfoDao extends CrudRepository { 7 | /**通过username查找用户信息;*/ 8 | public UserInfo findByUsername(String username); 9 | } -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/neo/sevice/UserInfoService.java: -------------------------------------------------------------------------------- 1 | package com.neo.sevice; 2 | 3 | import com.neo.entity.UserInfo; 4 | 5 | public interface UserInfoService { 6 | /**通过username查找用户信息;*/ 7 | public UserInfo findByUsername(String username); 8 | } -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/neo/sevice/impl/UserInfoServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.neo.sevice.impl; 2 | 3 | import com.neo.dao.UserInfoDao; 4 | import com.neo.entity.UserInfo; 5 | import com.neo.sevice.UserInfoService; 6 | import org.springframework.stereotype.Service; 7 | 8 | import javax.annotation.Resource; 9 | 10 | @Service 11 | public class UserInfoServiceImpl implements UserInfoService { 12 | @Resource 13 | private UserInfoDao userInfoDao; 14 | @Override 15 | public UserInfo findByUsername(String username) { 16 | System.out.println("UserInfoServiceImpl.findByUsername()"); 17 | return userInfoDao.findByUsername(username); 18 | } 19 | } -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/neo/web/UserInfoController.java: -------------------------------------------------------------------------------- 1 | package com.neo.web; 2 | 3 | import org.apache.shiro.authz.annotation.RequiresPermissions; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | @Controller 8 | @RequestMapping("/userInfo") 9 | public class UserInfoController { 10 | 11 | /** 12 | * 用户查询. 13 | * @return 14 | */ 15 | @RequestMapping("/userList") 16 | @RequiresPermissions("userInfo:view")//权限管理; 17 | public String userInfo(){ 18 | return "userInfo"; 19 | } 20 | 21 | /** 22 | * 用户添加; 23 | * @return 24 | */ 25 | @RequestMapping("/userAdd") 26 | @RequiresPermissions("userInfo:add")//权限管理; 27 | public String userInfoAdd(){ 28 | return "userInfoAdd"; 29 | } 30 | 31 | /** 32 | * 用户删除; 33 | * @return 34 | */ 35 | @RequestMapping("/userDel") 36 | @RequiresPermissions("userInfo:del")//权限管理; 37 | public String userDel(){ 38 | return "userInfoDel"; 39 | } 40 | } -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | url: jdbc:mysql://localhost:3306/test 4 | username: root 5 | password: root 6 | #schema: database/import.sql 7 | #sql-script-encoding: utf-8 8 | driver-class-name: com.mysql.jdbc.Driver 9 | 10 | jpa: 11 | database: mysql 12 | show-sql: true 13 | hibernate: 14 | ddl-auto: update 15 | naming: 16 | strategy: org.hibernate.cfg.DefaultComponentSafeNamingStrategy 17 | properties: 18 | hibernate: 19 | dialect: org.hibernate.dialect.MySQL5Dialect 20 | 21 | thymeleaf: 22 | cache: false 23 | mode: LEGACYHTML5 -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/resources/database/import.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO `user_info` (`uid`,`username`,`name`,`password`,`salt`,`state`) VALUES ('1', 'admin', '管理员', 'd3c59d25033dbf980d29554025c23a75', '8d78869f470951332959580424d4bf4f', 0); 2 | INSERT INTO `sys_permission` (`id`,`available`,`name`,`parent_id`,`parent_ids`,`permission`,`resource_type`,`url`) VALUES (1,0,'用户管理',0,'0/','userInfo:view','menu','userInfo/userList'); 3 | INSERT INTO `sys_permission` (`id`,`available`,`name`,`parent_id`,`parent_ids`,`permission`,`resource_type`,`url`) VALUES (2,0,'用户添加',1,'0/1','userInfo:add','button','userInfo/userAdd'); 4 | INSERT INTO `sys_permission` (`id`,`available`,`name`,`parent_id`,`parent_ids`,`permission`,`resource_type`,`url`) VALUES (3,0,'用户删除',1,'0/1','userInfo:del','button','userInfo/userDel'); 5 | INSERT INTO `sys_role` (`id`,`available`,`description`,`role`) VALUES (1,0,'管理员','admin'); 6 | INSERT INTO `sys_role` (`id`,`available`,`description`,`role`) VALUES (2,0,'VIP会员','vip'); 7 | INSERT INTO `sys_role` (`id`,`available`,`description`,`role`) VALUES (3,1,'test','test'); 8 | INSERT INTO `sys_role_permission` VALUES ('1', '1'); 9 | INSERT INTO `sys_role_permission` (`permission_id`,`role_id`) VALUES (1,1); 10 | INSERT INTO `sys_role_permission` (`permission_id`,`role_id`) VALUES (2,1); 11 | INSERT INTO `sys_role_permission` (`permission_id`,`role_id`) VALUES (3,2); 12 | INSERT INTO `sys_user_role` (`role_id`,`uid`) VALUES (1,1); -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/resources/templates/403.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 403 6 | 7 | 8 |

403没有权限

9 | 10 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | index 6 | 7 | 8 |

index

9 | 10 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/resources/templates/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Login 6 | 7 | 8 | 错误信息:

9 |
10 |

账号:

11 |

密码:

12 |

13 |
14 | 15 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/resources/templates/userInfo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UserInfo 6 | 7 | 8 |

用户查询界面

9 | 10 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/resources/templates/userInfoAdd.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Add 6 | 7 | 8 |

用户添加界面

9 | 10 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/resources/templates/userInfoDel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Del 6 | 7 | 8 |

用户删除界面

9 | 10 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/test/java/com/neo/SpringBootShiroApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootShiroApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | spring-boot-thymeleaf 5 | spring-boot-thymeleaf 6 | spring-boot-thymeleaf 7 | 8 | org.springframework.boot 9 | spring-boot-starter-parent 10 | 1.5.6.RELEASE 11 | 12 | 13 | 14 | 1.8 15 | 16 | 17 | 18 | 19 | org.springframework.boot 20 | spring-boot-starter-web 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-thymeleaf 25 | 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-maven-plugin 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/src/main/java/com/neo/thymeleaf/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.neo.thymeleaf; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @Controller 9 | public class HelloController { 10 | @RequestMapping("/hello") 11 | public String hello(Model model, @RequestParam(value="name", required=false, defaultValue="World") String name) { 12 | model.addAttribute("name", name); 13 | return "hello"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/src/main/java/com/neo/thymeleaf/ThymeleafApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo.thymeleaf; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.builder.SpringApplicationBuilder; 6 | import org.springframework.boot.web.support.SpringBootServletInitializer; 7 | 8 | 9 | @SpringBootApplication 10 | public class ThymeleafApplication extends SpringBootServletInitializer { 11 | @Override 12 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 13 | return application.sources(ThymeleafApplication.class); 14 | } 15 | 16 | public static void main(String[] args) throws Exception { 17 | SpringApplication.run(ThymeleafApplication.class, args); 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.thymeleaf.cache: false -------------------------------------------------------------------------------- /spring-boot-thymeleaf/src/main/resources/templates/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello Thymeleaf! 6 | 7 | 8 |

9 | 10 | -------------------------------------------------------------------------------- /spring-boot-tk_mybatis-multi-mysql/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /nbbuild/ 22 | /dist/ 23 | /nbdist/ 24 | /.nb-gradle/ 25 | /build/ 26 | -------------------------------------------------------------------------------- /spring-boot-tk_mybatis-multi-mysql/src/main/java/com/example/springboottk_mybatismultimysql/SpringBootTkMybatisMultiMysqlApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.springboottk_mybatismultimysql; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootTkMybatisMultiMysqlApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootTkMybatisMultiMysqlApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-tk_mybatis-multi-mysql/src/main/java/com/example/springboottk_mybatismultimysql/controller/AuditResultController.java: -------------------------------------------------------------------------------- 1 | package com.example.springboottk_mybatismultimysql.controller; 2 | 3 | 4 | import com.example.springboottk_mybatismultimysql.service.AuditResultService; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import java.util.List; 14 | 15 | @CrossOrigin 16 | @RestController 17 | @RequestMapping(value = "/auditResult") 18 | public class AuditResultController extends BaseController { 19 | 20 | @Autowired 21 | private AuditResultService auditResultService; 22 | 23 | protected Logger logger = LoggerFactory.getLogger(this.getClass()); 24 | 25 | @RequestMapping(value = "/tableNames",method = RequestMethod.GET) 26 | public List getTableNames(){ 27 | List list = auditResultService.getAllTableNames(); 28 | logger.info("获取表名列表成功"); 29 | return list; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-tk_mybatis-multi-mysql/src/main/java/com/example/springboottk_mybatismultimysql/controller/AuobjectController.java: -------------------------------------------------------------------------------- 1 | package com.example.springboottk_mybatismultimysql.controller; 2 | 3 | 4 | import com.example.springboottk_mybatismultimysql.entity.Auobject; 5 | import com.example.springboottk_mybatismultimysql.service.AuobjectService; 6 | import com.example.springboottk_mybatismultimysql.util.Page; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | @CrossOrigin 13 | @RestController 14 | @RequestMapping(value = "/auobject") 15 | public class AuobjectController extends BaseController { 16 | 17 | protected Logger logger = LoggerFactory.getLogger(this.getClass()); 18 | 19 | @Autowired 20 | private AuobjectService auobjectService; 21 | 22 | public Page page = new Page<>(1000); 23 | 24 | @RequestMapping(value = "/{id}",method = RequestMethod.GET) 25 | public Auobject oneInfoAuobjectTemplate(@PathVariable Long id){ 26 | Auobject auobject = auobjectService.ListObject(id); 27 | return auobject; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-tk_mybatis-multi-mysql/src/main/java/com/example/springboottk_mybatismultimysql/dao/IMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.springboottk_mybatismultimysql.dao; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | public interface IMapper extends Mapper, MySqlMapper { 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-tk_mybatis-multi-mysql/src/main/java/com/example/springboottk_mybatismultimysql/dao/firstdao/AuobjectMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.springboottk_mybatismultimysql.dao.firstdao; 2 | 3 | import com.example.springboottk_mybatismultimysql.dao.IMapper; 4 | import com.example.springboottk_mybatismultimysql.entity.Auobject; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Mapper 9 | @Repository 10 | public interface AuobjectMapper extends IMapper { 11 | 12 | // public Auobject auobjectInfo(Auobject auobject); 13 | 14 | } -------------------------------------------------------------------------------- /spring-boot-tk_mybatis-multi-mysql/src/main/java/com/example/springboottk_mybatismultimysql/dao/secondDao/AuditResultDao.java: -------------------------------------------------------------------------------- 1 | package com.example.springboottk_mybatismultimysql.dao.secondDao; 2 | 3 | import com.example.springboottk_mybatismultimysql.dao.IMapper; 4 | import com.example.springboottk_mybatismultimysql.entity.Column; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.List; 9 | 10 | @Mapper 11 | @Repository 12 | public interface AuditResultDao extends IMapper { 13 | 14 | public List listAllTables(); 15 | 16 | public List getColumns(String tableName); 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-tk_mybatis-multi-mysql/src/main/java/com/example/springboottk_mybatismultimysql/entity/Column.java: -------------------------------------------------------------------------------- 1 | package com.example.springboottk_mybatismultimysql.entity; 2 | 3 | public class Column { 4 | 5 | private String name; 6 | private String type; 7 | private String columnKey; //PRI是主键 8 | private String extra; //auto_increment 自增 9 | 10 | public String getName() { 11 | return name; 12 | } 13 | 14 | public void setName(String name) { 15 | this.name = name; 16 | } 17 | 18 | public String getType() { 19 | return type; 20 | } 21 | 22 | public void setType(String type) { 23 | this.type = type; 24 | } 25 | 26 | public String getColumnKey() { 27 | return columnKey; 28 | } 29 | 30 | public void setColumnKey(String columnKey) { 31 | this.columnKey = columnKey; 32 | } 33 | 34 | public String getExtra() { 35 | return extra; 36 | } 37 | 38 | public void setExtra(String extra) { 39 | this.extra = extra; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-boot-tk_mybatis-multi-mysql/src/main/java/com/example/springboottk_mybatismultimysql/service/AuditResultService.java: -------------------------------------------------------------------------------- 1 | package com.example.springboottk_mybatismultimysql.service; 2 | 3 | import com.example.springboottk_mybatismultimysql.dao.secondDao.AuditResultDao; 4 | import com.example.springboottk_mybatismultimysql.entity.Column; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.HashMap; 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | @Service 15 | public class AuditResultService { 16 | 17 | private static Logger logger = LoggerFactory.getLogger(AuditResultService.class); 18 | @Autowired 19 | private AuditResultDao auditResultDao; 20 | 21 | //不展示的列 22 | private String[] filterColumns = {"id"}; 23 | //默认的列名对应 24 | private Map defaultColumnNameMap = new HashMap<>(); 25 | 26 | { 27 | defaultColumnNameMap.put("inserttime", "采集时间"); 28 | } 29 | 30 | public List getAllTableNames() { 31 | // auditResultDao.selectAll(); 32 | return auditResultDao.listAllTables(); 33 | } 34 | 35 | public List getColumns(String tableName) { 36 | return auditResultDao.getColumns(tableName); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-boot-tk_mybatis-multi-mysql/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spring-boot-tk_mybatis-multi-mysql/src/main/resources/mapper/AuobjectMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /spring-boot-tk_mybatis-multi-mysql/src/main/resources/mybatis_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /spring-boot-tk_mybatis-multi-mysql/src/main/resources/secondmapper/AuditResultMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 26 | -------------------------------------------------------------------------------- /spring-boot-tk_mybatis-multi-mysql/src/test/java/com/example/springboottk_mybatismultimysql/SpringBootTkMybatisMultiMysqlApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.springboottk_mybatismultimysql; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringBootTkMybatisMultiMysqlApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-web-thymeleaf/src/main/java/com/neo/model/Message.java: -------------------------------------------------------------------------------- 1 | package com.neo.model; 2 | 3 | import java.util.Calendar; 4 | 5 | import javax.validation.constraints.NotEmpty; 6 | 7 | 8 | public class Message { 9 | 10 | private Long id; 11 | 12 | @NotEmpty(message = "Text is required.") 13 | private String text; 14 | 15 | @NotEmpty(message = "Summary is required.") 16 | private String summary; 17 | 18 | private Calendar created = Calendar.getInstance(); 19 | 20 | public Long getId() { 21 | return this.id; 22 | } 23 | 24 | public void setId(Long id) { 25 | this.id = id; 26 | } 27 | 28 | public Calendar getCreated() { 29 | return this.created; 30 | } 31 | 32 | public void setCreated(Calendar created) { 33 | this.created = created; 34 | } 35 | 36 | public String getText() { 37 | return this.text; 38 | } 39 | 40 | public void setText(String text) { 41 | this.text = text; 42 | } 43 | 44 | public String getSummary() { 45 | return this.summary; 46 | } 47 | 48 | public void setSummary(String summary) { 49 | this.summary = summary; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /spring-boot-web-thymeleaf/src/main/java/com/neo/repository/InMemoryMessageRepository.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package com.neo.repository; 4 | 5 | import com.neo.model.Message; 6 | 7 | import java.util.concurrent.ConcurrentHashMap; 8 | import java.util.concurrent.ConcurrentMap; 9 | import java.util.concurrent.atomic.AtomicLong; 10 | 11 | 12 | public class InMemoryMessageRepository implements MessageRepository { 13 | 14 | private static AtomicLong counter = new AtomicLong(); 15 | 16 | private final ConcurrentMap messages = new ConcurrentHashMap<>(); 17 | 18 | @Override 19 | public Iterable findAll() { 20 | return this.messages.values(); 21 | } 22 | 23 | @Override 24 | public Message save(Message message) { 25 | Long id = message.getId(); 26 | if (id == null) { 27 | id = counter.incrementAndGet(); 28 | message.setId(id); 29 | } 30 | this.messages.put(id, message); 31 | return message; 32 | } 33 | 34 | @Override 35 | public Message findMessage(Long id) { 36 | return this.messages.get(id); 37 | } 38 | 39 | @Override 40 | public void deleteMessage(Long id) { 41 | this.messages.remove(id); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /spring-boot-web-thymeleaf/src/main/java/com/neo/repository/MessageRepository.java: -------------------------------------------------------------------------------- 1 | 2 | package com.neo.repository; 3 | 4 | import com.neo.model.Message; 5 | 6 | public interface MessageRepository { 7 | 8 | Iterable findAll(); 9 | 10 | Message save(Message message); 11 | 12 | Message findMessage(Long id); 13 | 14 | void deleteMessage(Long id); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-web-thymeleaf/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Allow Thymeleaf templates to be reloaded at dev time 2 | spring.thymeleaf.cache: false 3 | server.tomcat.access_log_enabled: true 4 | server.tomcat.basedir: target/tomcat -------------------------------------------------------------------------------- /spring-boot-web-thymeleaf/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /spring-boot-web-thymeleaf/src/main/resources/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-web-thymeleaf/src/main/resources/static/favicon.ico -------------------------------------------------------------------------------- /spring-boot-web-thymeleaf/src/main/resources/templates/fragments.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Fragments 5 | 7 | 8 | 9 |

10 | 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /spring-boot-web-thymeleaf/src/main/resources/templates/messages/list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Messages : View all 5 | 6 | 7 |
8 |
9 |
10 | Create Message 11 |
12 |

Messages : View all

13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 31 | 32 | 33 |
IDCreatedSummary
No messages
1July 11, 28 | 2012 2:17:16 PM CDT The summary
34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /spring-boot-web-thymeleaf/src/main/resources/templates/messages/view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Messages : View 5 | 6 | 7 |
8 |
9 |
10 | Messages 11 |
12 |

Messages : View

13 |
14 |
Some Success message 15 |
16 |
17 |
18 |

123 - A short summary...

19 |
July 11, 2012 2:17:16 PM CDT
20 |

A detailed message that is longer than the summary.

21 | delete 22 | modify 23 |
24 |
25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /spring-boot-web/src/main/java/com/neo/WebApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class WebApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(WebApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-web/src/main/java/com/neo/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.neo.repository; 2 | 3 | import com.neo.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface UserRepository extends JpaRepository { 7 | 8 | User findByUserName(String userName); 9 | 10 | User findByUserNameOrEmail(String username, String email); 11 | 12 | } -------------------------------------------------------------------------------- /spring-boot-web/src/main/java/com/neo/util/NeoProperties.java: -------------------------------------------------------------------------------- 1 | package com.neo.util; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class NeoProperties { 8 | 9 | @Value("${com.neo.title}") 10 | private String title; 11 | @Value("${com.neo.description}") 12 | private String description; 13 | public String getTitle() { 14 | return title; 15 | } 16 | public void setTitle(String title) { 17 | this.title = title; 18 | } 19 | public String getDescription() { 20 | return description; 21 | } 22 | public void setDescription(String description) { 23 | this.description = description; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /spring-boot-web/src/main/java/com/neo/web/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.neo.web; 2 | 3 | import java.util.Locale; 4 | import java.util.UUID; 5 | 6 | import javax.servlet.http.HttpSession; 7 | 8 | import com.neo.model.User; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | @RestController 14 | public class HelloController { 15 | 16 | @RequestMapping("/hello") 17 | public String hello(Locale locale, Model model) { 18 | return "Hello World"; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /spring-boot-web/src/main/java/com/neo/web/ThymeleafController.java: -------------------------------------------------------------------------------- 1 | package com.neo.web; 2 | 3 | import java.text.DateFormat; 4 | import java.util.Date; 5 | import java.util.Locale; 6 | 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | 11 | @Controller 12 | public class ThymeleafController { 13 | 14 | @RequestMapping("/hi") 15 | public String hello(Locale locale, Model model) { 16 | model.addAttribute("greeting", "Hello!"); 17 | 18 | Date date = new Date(); 19 | DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); 20 | String formattedDate = dateFormat.format(date); 21 | model.addAttribute("currentTime", formattedDate); 22 | 23 | return "hello"; 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /spring-boot-web/src/main/java/com/neo/web/UserController.java: -------------------------------------------------------------------------------- 1 | package com.neo.web; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import com.neo.model.User; 10 | import com.neo.repository.UserRepository; 11 | 12 | @RestController 13 | public class UserController { 14 | 15 | @Autowired 16 | private UserRepository userRepository; 17 | 18 | @RequestMapping("/getUser") 19 | public User getUser() { 20 | User user=userRepository.findByUserName("aa"); 21 | System.out.println("若下面没出现“无缓存的时候调用”字样且能打印出数据表示测试成功"); 22 | return user; 23 | } 24 | 25 | @RequestMapping("/getUsers") 26 | public List getUsers() { 27 | List users=userRepository.findAll(); 28 | System.out.println("若下面没出现“无缓存的时候调用”字样且能打印出数据表示测试成功"); 29 | return users; 30 | } 31 | } -------------------------------------------------------------------------------- /spring-boot-web/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true 2 | spring.datasource.username=root 3 | spring.datasource.password=root 4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 5 | 6 | spring.jpa.properties.hibernate.hbm2ddl.auto=create 7 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect 8 | #sql\u8F93\u51FA 9 | spring.jpa.show-sql=true 10 | #format\u4E00\u4E0Bsql\u8FDB\u884C\u8F93\u51FA 11 | spring.jpa.properties.hibernate.format_sql=true 12 | 13 | com.neo.title=\u7EAF\u6D01\u7684\u5FAE\u7B11 14 | com.neo.description=\u5206\u4EAB\u751F\u6D3B\u548C\u6280\u672F -------------------------------------------------------------------------------- /spring-boot-web/src/main/resources/static/css/starter.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | } 4 | 5 | .starter-template { 6 | padding: 40px 15px; 7 | text-align: center; 8 | } -------------------------------------------------------------------------------- /spring-boot-web/src/main/resources/static/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-web/src/main/resources/static/images/favicon.png -------------------------------------------------------------------------------- /spring-boot-web/src/main/resources/templates/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
(navbar)
6 | 7 |
8 |
9 |

Spring MVC / Thymeleaf / Bootstrap

10 |

(greeting)

11 |

The current time is (time)

12 |
13 |
14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /spring-boot-web/src/test/java/com/neo/WebApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | @RunWith(SpringRunner.class) 10 | @SpringBootTest 11 | public class WebApplicationTests { 12 | 13 | @Test 14 | public void contextLoads() { 15 | System.out.println("hello web"); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-web/src/test/java/com/neo/web/ProPertiesTest.java: -------------------------------------------------------------------------------- 1 | package com.neo.web; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | 12 | import com.neo.util.NeoProperties; 13 | import org.springframework.test.context.junit4.SpringRunner; 14 | 15 | @RunWith(SpringRunner.class) 16 | @SpringBootTest 17 | public class ProPertiesTest { 18 | 19 | @Autowired 20 | private NeoProperties neoProperties; 21 | 22 | @Test 23 | public void getHello() throws Exception { 24 | System.out.println(neoProperties.getTitle()); 25 | Assert.assertEquals(neoProperties.getTitle(), "纯洁的微笑"); 26 | Assert.assertEquals(neoProperties.getDescription(), "分享生活和技术"); 27 | } 28 | 29 | @Test 30 | public void testMap() throws Exception { 31 | Map orderMinTime=new HashMap(); 32 | long xx=orderMinTime.get("123"); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /spring-boot-webflux/src/main/java/com/neo/WebFluxApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class WebFluxApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(WebFluxApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-webflux/src/main/java/com/neo/web/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.neo.web; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | import reactor.core.publisher.Mono; 6 | 7 | @RestController 8 | public class HelloController { 9 | 10 | @GetMapping("/hello") 11 | public Mono hello() { 12 | return Mono.just("Welcome to reactive world ~"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-webflux/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-webflux/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-boot-webflux/src/test/java/com/neo/HelloTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import com.neo.web.HelloController; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | import org.springframework.test.web.reactive.server.WebTestClient; 10 | 11 | @RunWith(SpringRunner.class) 12 | @WebFluxTest(controllers = HelloController.class) 13 | public class HelloTests { 14 | @Autowired 15 | WebTestClient client; 16 | 17 | @Test 18 | public void getHello() { 19 | client.get().uri("/hello").exchange().expectStatus().isOk(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-webflux/src/test/java/com/neo/WebFluxApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class WebFluxApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-websocket/Vue/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw? 22 | -------------------------------------------------------------------------------- /spring-boot-websocket/Vue/README.md: -------------------------------------------------------------------------------- 1 | # websocket 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Customize configuration 19 | See [Configuration Reference](https://cli.vuejs.org/config/). 20 | -------------------------------------------------------------------------------- /spring-boot-websocket/Vue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "websocket", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build" 8 | }, 9 | "dependencies": { 10 | "vue": "^2.6.10" 11 | }, 12 | "devDependencies": { 13 | "@vue/cli-service": "^4.1.0", 14 | "vue-template-compiler": "^2.6.10" 15 | }, 16 | "browserslist": [ 17 | "> 1%", 18 | "last 2 versions" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /spring-boot-websocket/Vue/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-websocket/Vue/public/favicon.ico -------------------------------------------------------------------------------- /spring-boot-websocket/Vue/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | websocket 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /spring-boot-websocket/Vue/src/App.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 18 | 19 | 29 | -------------------------------------------------------------------------------- /spring-boot-websocket/Vue/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viviandavid/springboot-gatherdemo/ea150e45f7fefd19a8f7f233d68ea3b802e7d463/spring-boot-websocket/Vue/src/assets/logo.png -------------------------------------------------------------------------------- /spring-boot-websocket/Vue/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | 4 | Vue.config.productionTip = false 5 | 6 | new Vue({ 7 | render: function (h) { return h(App) }, 8 | }).$mount('#app') 9 | -------------------------------------------------------------------------------- /spring-boot-websocket/Vue/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | devServer: { 3 | port: 8887, // 端口号 4 | } 5 | }; -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/java/com/example/springwebsocket/SpringwebsocketApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.springwebsocket; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringwebsocketApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringwebsocketApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/java/com/example/springwebsocket/config/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package com.example.springwebsocket.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.socket.server.standard.ServerEndpointExporter; 6 | 7 | @Configuration 8 | public class WebSocketConfig { 9 | @Bean 10 | public ServerEndpointExporter serverEndpointExporter() { 11 | return new ServerEndpointExporter(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/java/com/example/springwebsocket/controller/WebSocketXdxController.java: -------------------------------------------------------------------------------- 1 | package com.example.springwebsocket.controller; 2 | 3 | import com.example.springwebsocket.service.WebSocketXdxService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | public class WebSocketXdxController { 10 | 11 | @Autowired 12 | private WebSocketXdxService webSocketXdxService; 13 | /** 14 | * 15 | * @param shipId 16 | * @return 17 | */ 18 | @GetMapping("/xdx/text") 19 | public Object xdxTest(String shipId) throws InterruptedException { 20 | return webSocketXdxService.xdxTest(shipId); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-websocket/src/main/java/com/example/springwebsocket/service/WebSocketXdxService.java: -------------------------------------------------------------------------------- 1 | package com.example.springwebsocket.service; 2 | 3 | import com.example.springwebsocket.config.WebSocket; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | @Service 11 | public class WebSocketXdxService { 12 | 13 | 14 | @Autowired 15 | private WebSocket webSocket; 16 | 17 | 18 | public Object xdxTest(String shipId) throws InterruptedException { 19 | for (int i = 0; i < 10; i++){ 20 | Thread.sleep(1000); 21 | webSocket.sendTextMessage(shipId, "thread"+i); 22 | } 23 | return null; 24 | } 25 | } 26 | --------------------------------------------------------------------------------