├── .gitignore ├── spring-boot-banner ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ ├── banner.gif │ │ └── banner.txt │ │ └── java │ │ └── com │ │ └── neo │ │ └── banner │ │ └── BannerApplication.java └── pom.xml ├── spring-boot-docker └── src │ ├── main │ ├── resources │ │ └── application.properties │ ├── docker │ │ └── Dockerfile │ └── java │ │ └── com │ │ └── neo │ │ ├── DockerApplication.java │ │ └── controller │ │ └── DockerController.java │ └── test │ └── java │ └── com │ └── neo │ └── DockerApplicationTests.java ├── spring-boot-hello ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── neo │ │ │ ├── HelloApplication.java │ │ │ └── controller │ │ │ └── HelloController.java │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ └── HelloApplicationTests.java └── pom.xml ├── spring-boot-webflux └── src │ ├── main │ ├── resources │ │ └── application.properties │ └── java │ │ └── com │ │ └── neo │ │ ├── WebFluxApplication.java │ │ └── web │ │ └── HelloController.java │ └── test │ └── java │ └── com │ └── neo │ ├── WebFluxApplicationTests.java │ └── HelloTests.java ├── spring-boot-helloWorld └── src │ ├── main │ ├── resources │ │ └── application.properties │ └── java │ │ └── com │ │ └── neo │ │ ├── Application.java │ │ └── controller │ │ └── HelloWorldController.java │ └── test │ └── java │ └── com │ └── neo │ ├── ApplicationTests.java │ └── controller │ ├── HelloWorldControlerTests.java │ └── HelloTests.java ├── spring-boot-package-war └── src │ ├── main │ ├── resources │ │ └── application.properties │ └── java │ │ └── com │ │ └── neo │ │ ├── Application.java │ │ ├── controller │ │ └── HelloWorldController.java │ │ └── ServletInitializer.java │ └── test │ └── java │ └── com │ └── neo │ └── ApplicationTests.java ├── dockercompose-springboot-mysql-nginx ├── app │ ├── Dockerfile │ └── src │ │ ├── main │ │ ├── resources │ │ │ ├── application-docker.properties │ │ │ ├── application-dev.properties │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── neo │ │ │ ├── repository │ │ │ └── VisitorRepository.java │ │ │ ├── ComposeApplication.java │ │ │ ├── entity │ │ │ └── Visitor.java │ │ │ └── controller │ │ │ └── VisitorController.java │ │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ └── ComposeApplicationTests.java ├── nginx │ └── conf.d │ │ └── app.conf └── docker-compose.yaml ├── spring-boot-commandLineRunner ├── src │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── neo │ │ ├── runner │ │ ├── Runner.java │ │ ├── OrderRunner1.java │ │ └── OrderRunner2.java │ │ └── CommandLineRunnerApplication.java └── pom.xml ├── spring-boot-thymeleaf ├── spring-boot-thymeleaf │ └── src │ │ ├── main │ │ ├── resources │ │ │ ├── application.properties │ │ │ └── templates │ │ │ │ ├── hello.html │ │ │ │ ├── if.html │ │ │ │ ├── switch.html │ │ │ │ ├── eq.html │ │ │ │ ├── string.html │ │ │ │ ├── list.html │ │ │ │ └── url.html │ │ └── java │ │ │ └── com │ │ │ └── neo │ │ │ ├── ThymeleafApplication.java │ │ │ ├── web │ │ │ └── HelloController.java │ │ │ └── model │ │ │ └── User.java │ │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ └── ThymeleafApplicationTests.java └── spring-boot-thymeleaf-layout │ └── src │ ├── main │ ├── resources │ │ ├── application.properties │ │ └── templates │ │ │ ├── layout │ │ │ ├── left.html │ │ │ ├── footer.html │ │ │ ├── header.html │ │ │ └── copyright.html │ │ │ ├── index.html │ │ │ ├── home.html │ │ │ ├── fragment.html │ │ │ ├── layout.html │ │ │ └── base.html │ └── java │ │ └── com │ │ └── neo │ │ ├── TLayoutApplication.java │ │ └── web │ │ └── IndexController.java │ └── test │ └── java │ └── com │ └── neo │ └── TLayoutApplicationTests.java ├── spring-boot-admin-simple ├── spring-boot-admin-server │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── application.properties │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── neo │ │ │ │ └── AdminServerApplication.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── neo │ │ │ └── AdminServerApplicationTests.java │ └── pom.xml └── spring-boot-admin-client │ ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── neo │ │ │ └── AdminClientApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ └── AdminClientApplicationTests.java │ └── pom.xml ├── spring-boot-scheduler ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── neo │ │ │ ├── SchedulerApplication.java │ │ │ └── task │ │ │ ├── SchedulerTask.java │ │ │ └── Scheduler2Task.java │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ └── SchedulerApplicationTests.java └── pom.xml ├── spring-boot-package └── src │ ├── main │ ├── resources │ │ ├── application-dev.properties │ │ ├── application-pro.properties │ │ └── application-test.properties │ └── java │ │ └── com │ │ └── neo │ │ ├── controller │ │ └── HelloController.java │ │ └── PackageApplication.java │ └── test │ └── java │ └── com │ └── neo │ ├── PackageApplicationTests.java │ └── controller │ ├── HelloWorldControlerTests.java │ └── HelloTests.java ├── spring-boot-memcache-spymemcached └── src │ ├── main │ ├── resources │ │ └── application.properties │ └── java │ │ └── com │ │ └── neo │ │ ├── MemcacheApplication.java │ │ └── config │ │ ├── MemcacheSource.java │ │ └── MemcachedRunner.java │ └── test │ └── java │ └── com │ └── neo │ ├── MemcacheApplicationTests.java │ └── RepositoryTests.java ├── spring-boot-swagger └── src │ ├── main │ ├── resources │ │ ├── application.properties │ │ └── logback.xml │ └── java │ │ └── com │ │ └── neo │ │ ├── SwaggerApplication.java │ │ ├── repository │ │ └── MessageRepository.java │ │ ├── model │ │ ├── User.java │ │ └── Message.java │ │ └── config │ │ └── SwaggerConfig.java │ └── test │ └── java │ └── com │ └── neo │ └── SwaggerApplicationTests.java ├── spring-boot-mybatis ├── spring-boot-mybatis-xml │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── neo │ │ │ │ │ ├── enums │ │ │ │ │ └── UserSexEnum.java │ │ │ │ │ ├── mapper │ │ │ │ │ └── UserMapper.java │ │ │ │ │ ├── MybatisXmlApplication.java │ │ │ │ │ └── web │ │ │ │ │ └── UserController.java │ │ │ └── resources │ │ │ │ ├── application.properties │ │ │ │ └── mybatis │ │ │ │ └── mybatis-config.xml │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── neo │ │ │ ├── MybatisXmlApplicationTests.java │ │ │ ├── web │ │ │ └── UserControllerTest.java │ │ │ └── mapper │ │ │ └── UserMapperTest.java │ └── users.sql ├── spring-boot-mybatis-annotation │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── neo │ │ │ │ │ ├── enums │ │ │ │ │ └── UserSexEnum.java │ │ │ │ │ ├── MybatisAnnotationApplication.java │ │ │ │ │ ├── web │ │ │ │ │ └── UserController.java │ │ │ │ │ └── mapper │ │ │ │ │ └── UserMapper.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── neo │ │ │ ├── MybatisAnnotationApplicationTests.java │ │ │ └── mapper │ │ │ └── UserMapperTest.java │ └── users.sql ├── spring-boot-mybatis-xml-mulidatasource │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── neo │ │ │ │ │ ├── enums │ │ │ │ │ └── UserSexEnum.java │ │ │ │ │ ├── mapper │ │ │ │ │ ├── test1 │ │ │ │ │ │ └── User1Mapper.java │ │ │ │ │ └── test2 │ │ │ │ │ │ └── User2Mapper.java │ │ │ │ │ ├── MXMApplication.java │ │ │ │ │ └── web │ │ │ │ │ └── UserController.java │ │ │ └── resources │ │ │ │ ├── mybatis │ │ │ │ └── mybatis-config.xml │ │ │ │ └── application.properties │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── neo │ │ │ └── MXMApplicationTests.java │ └── users.sql └── spring-boot-mybatis-annotation-mulidatasource │ ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── neo │ │ │ │ ├── enums │ │ │ │ └── UserSexEnum.java │ │ │ │ ├── MAMApplication.java │ │ │ │ ├── mapper │ │ │ │ ├── test1 │ │ │ │ │ └── User1Mapper.java │ │ │ │ └── test2 │ │ │ │ │ └── User2Mapper.java │ │ │ │ └── web │ │ │ │ └── UserController.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ └── MAMApplicationTests.java │ └── users.sql ├── spring-boot-elasticsearch ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── neo │ │ │ ├── service │ │ │ └── CustomersInterface.java │ │ │ ├── ElasticsearchApplication.java │ │ │ └── repository │ │ │ └── CustomerRepository.java │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ └── ElasticsearchApplicationTests.java └── pom.xml ├── spring-boot-web └── src │ ├── main │ ├── resources │ │ ├── static │ │ │ ├── css │ │ │ │ └── starter.css │ │ │ └── images │ │ │ │ └── favicon.png │ │ ├── templates │ │ │ └── hello.html │ │ └── application.properties │ └── java │ │ └── com │ │ └── neo │ │ ├── WebApplication.java │ │ ├── repository │ │ └── UserRepository.java │ │ ├── web │ │ ├── HelloController.java │ │ ├── ThymeleafController.java │ │ └── UserController.java │ │ └── util │ │ └── NeoProperties.java │ └── test │ └── java │ └── com │ └── neo │ ├── WebApplicationTests.java │ ├── web │ └── ProPertiesTest.java │ └── model │ └── UserRepositoryTests.java ├── spring-boot-web-thymeleaf ├── src │ └── main │ │ ├── resources │ │ ├── static │ │ │ └── favicon.ico │ │ ├── application.properties │ │ ├── logback.xml │ │ └── templates │ │ │ ├── fragments.html │ │ │ └── messages │ │ │ ├── list.html │ │ │ ├── view.html │ │ │ └── form.html │ │ └── java │ │ └── com │ │ └── neo │ │ ├── repository │ │ ├── MessageRepository.java │ │ └── InMemoryMessageRepository.java │ │ └── model │ │ └── Message.java └── pom.xml ├── spring-boot-mongodb ├── spring-boot-mongodb │ └── src │ │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── neo │ │ │ ├── MongoDBApplication.java │ │ │ ├── repository │ │ │ └── UserRepository.java │ │ │ └── model │ │ │ └── User.java │ │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ ├── MongoDBApplicationTests.java │ │ └── repository │ │ └── UserRepositoryTest.java └── spring-boot-multi-mongodb │ ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── neo │ │ │ ├── repository │ │ │ ├── primary │ │ │ │ └── PrimaryRepository.java │ │ │ └── secondary │ │ │ │ └── SecondaryRepository.java │ │ │ ├── MultiMongodbApplication.java │ │ │ ├── config │ │ │ ├── props │ │ │ │ └── MultipleMongoProperties.java │ │ │ ├── PrimaryMongoConfig.java │ │ │ └── SecondaryMongoConfig.java │ │ │ └── model │ │ │ └── User.java │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ └── MultiMongodbApplicationTests.java │ └── pom.xml ├── spring-boot-file-upload └── src │ └── main │ ├── resources │ ├── templates │ │ ├── from_file.html │ │ ├── uploadStatus.html │ │ └── upload.html │ ├── application.properties │ └── logback.xml │ └── java │ └── com │ └── neo │ ├── controller │ └── GlobalExceptionHandler.java │ └── FileUploadWebApplication.java ├── spring-boot-shiro └── src │ ├── main │ ├── resources │ │ ├── templates │ │ │ ├── 403.html │ │ │ ├── index.html │ │ │ ├── userInfo.html │ │ │ ├── userInfoAdd.html │ │ │ ├── userInfoDel.html │ │ │ └── login.html │ │ ├── application.yml │ │ └── database │ │ │ └── import.sql │ └── java │ │ └── com │ │ └── neo │ │ ├── sevice │ │ ├── UserInfoService.java │ │ └── impl │ │ │ └── UserInfoServiceImpl.java │ │ ├── dao │ │ └── UserInfoDao.java │ │ ├── ShiroApplication.java │ │ └── web │ │ └── UserInfoController.java │ └── test │ └── java │ └── com │ └── neo │ └── ShiroApplicationTests.java ├── spring-boot-jpa ├── spring-boot-jpa │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── neo │ │ │ │ ├── model │ │ │ │ ├── UserInfo.java │ │ │ │ └── Address.java │ │ │ │ ├── repository │ │ │ │ ├── AddressRepository.java │ │ │ │ ├── UserDetailRepository.java │ │ │ │ └── UserRepository.java │ │ │ │ ├── service │ │ │ │ └── UserDetailService.java │ │ │ │ ├── JpaApplication.java │ │ │ │ └── param │ │ │ │ └── UserDetailParam.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ ├── JpaApplicationTests.java │ │ └── repository │ │ └── JpaSpecificationTests.java └── spring-boot-multi-Jpa │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── neo │ │ │ ├── MultiJpaApplication.java │ │ │ └── repository │ │ │ ├── test1 │ │ │ └── UserTest1Repository.java │ │ │ └── test2 │ │ │ └── UserTest2Repository.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── neo │ └── MultiJpaApplicationTests.java ├── spring-boot-rabbitmq ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── neo │ │ │ ├── RabbitMQApplication.java │ │ │ ├── rabbit │ │ │ ├── many │ │ │ │ ├── NeoReceiver1.java │ │ │ │ ├── NeoReceiver2.java │ │ │ │ ├── NeoSender.java │ │ │ │ └── NeoSender2.java │ │ │ ├── fanout │ │ │ │ ├── FanoutReceiverB.java │ │ │ │ ├── FanoutReceiverC.java │ │ │ │ ├── FanoutReceiverA.java │ │ │ │ └── FanoutSender.java │ │ │ ├── topic │ │ │ │ ├── TopicReceiver.java │ │ │ │ ├── TopicReceiver2.java │ │ │ │ └── TopicSender.java │ │ │ ├── object │ │ │ │ ├── ObjectReceiver.java │ │ │ │ └── ObjectSender.java │ │ │ ├── hello │ │ │ │ ├── HelloReceiver.java │ │ │ │ └── HelloSender.java │ │ │ ├── RabbitConfig.java │ │ │ ├── TopicRabbitConfig.java │ │ │ └── FanoutRabbitConfig.java │ │ │ └── model │ │ │ └── User.java │ └── test │ │ └── java │ │ └── com │ │ └── neo │ │ ├── RabbitMQApplicationTests.java │ │ └── rabbitmq │ │ ├── HelloTest.java │ │ ├── FanoutTest.java │ │ ├── ObjectTest.java │ │ ├── TopicTest.java │ │ └── ManyTest.java └── pom.xml ├── spring-boot-fastDFS └── src │ └── main │ ├── resources │ ├── application.properties │ ├── fdfs_client.conf │ ├── templates │ │ ├── uploadStatus.html │ │ └── upload.html │ └── logback.xml │ └── java │ └── com │ └── neo │ ├── controller │ └── GlobalExceptionHandler.java │ ├── FastDFSApplication.java │ └── fastdfs │ └── FastDFSFile.java ├── spring-boot-mail └── src │ ├── main │ ├── resources │ │ ├── application.properties │ │ └── templates │ │ │ └── emailTemplate.html │ └── java │ │ └── com │ │ └── neo │ │ ├── MailApplication.java │ │ └── service │ │ └── MailService.java │ └── test │ └── java │ └── com │ └── neo │ └── MailApplicationTests.java ├── spring-boot-jpa-thymeleaf-curd └── src │ └── main │ ├── resources │ ├── templates │ │ ├── hello.html │ │ └── user │ │ │ └── list.html │ └── application.properties │ └── java │ └── com │ └── neo │ ├── repository │ └── UserRepository.java │ ├── service │ ├── UserService.java │ └── impl │ │ └── UserServiceImpl.java │ ├── web │ └── HelloController.java │ ├── JpaThymeleafApplication.java │ └── model │ └── User.java ├── spring-boot-actuator └── src │ ├── main │ ├── resources │ │ └── application.properties │ └── java │ │ └── com │ │ └── neo │ │ ├── ActuatorApplication.java │ │ └── controller │ │ └── HelloController.java │ └── test │ └── java │ └── com │ └── neo │ ├── ActuatorApplicationTests.java │ └── controller │ ├── HelloWorldControlerTests.java │ └── HelloTests.java └── spring-boot-redis └── src ├── main ├── java │ └── com │ │ └── neo │ │ ├── config │ │ ├── SessionConfig.java │ │ └── RedisConfig.java │ │ ├── RedisApplication.java │ │ └── web │ │ └── UserController.java └── resources │ └── application.properties └── test └── java └── com └── neo └── RedisApplicationTests.java /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | target/ 3 | *.iml 4 | 5 | -------------------------------------------------------------------------------- /spring-boot-banner/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-boot-docker/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-boot-hello/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-boot-webflux/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-boot-helloWorld/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-boot-package-war/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dockercompose-springboot-mysql-nginx/app/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.5-jdk-8 -------------------------------------------------------------------------------- /spring-boot-commandLineRunner/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.thymeleaf.cache=false -------------------------------------------------------------------------------- /spring-boot-admin-simple/spring-boot-admin-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8000 2 | 3 | -------------------------------------------------------------------------------- /spring-boot-scheduler/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spirng-boot-scheduler 2 | 3 | -------------------------------------------------------------------------------- /spring-boot-package/src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | info.app.name=spring-boot-test 2 | info.app.version= 1.0.0 -------------------------------------------------------------------------------- /spring-boot-package/src/main/resources/application-pro.properties: -------------------------------------------------------------------------------- 1 | info.app.name=spring-boot-pro 2 | info.app.version= 1.0.0 -------------------------------------------------------------------------------- /spring-boot-package/src/main/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | info.app.name=spring-boot-uat 2 | info.app.version= 1.0.0 -------------------------------------------------------------------------------- /spring-boot-memcache-spymemcached/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | memcache.ip=192.168.0.161 2 | memcache.port=11211 -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.io.swagger.models.parameters.AbstractSerializableParameter=error -------------------------------------------------------------------------------- /spring-boot-banner/src/main/resources/banner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awesome-interview/spring-boot-examples/master/spring-boot-banner/src/main/resources/banner.gif -------------------------------------------------------------------------------- /spring-boot-mybatis/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-elasticsearch/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.data.elasticsearch.cluster-name=es-mongodb 2 | spring.data.elasticsearch.cluster-nodes=192.168.0.53:9300 -------------------------------------------------------------------------------- /spring-boot-mybatis/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-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-mybatis/spring-boot-mybatis-xml-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/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-web/src/main/resources/static/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awesome-interview/spring-boot-examples/master/spring-boot-web/src/main/resources/static/images/favicon.png -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | com.neo.title=\u7EAF\u6D01\u7684\u5FAE\u7B11 2 | com.neo.description=\u5206\u4EAB\u751F\u6D3B\u548C\u6280\u672F -------------------------------------------------------------------------------- /spring-boot-web-thymeleaf/src/main/resources/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awesome-interview/spring-boot-examples/master/spring-boot-web-thymeleaf/src/main/resources/static/favicon.ico -------------------------------------------------------------------------------- /spring-boot-mongodb/spring-boot-mongodb/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spring-boot-mongodb 2 | 3 | spring.data.mongodb.uri=mongodb://192.168.0.75:20000/test 4 | 5 | 6 | -------------------------------------------------------------------------------- /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-file-upload/src/main/resources/templates/from_file.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awesome-interview/spring-boot-examples/master/spring-boot-file-upload/src/main/resources/templates/from_file.html -------------------------------------------------------------------------------- /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-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-jpa/spring-boot-jpa/src/main/java/com/neo/model/UserInfo.java: -------------------------------------------------------------------------------- 1 | package com.neo.model; 2 | 3 | public interface UserInfo { 4 | String getUserName(); 5 | String getEmail(); 6 | String getHobby(); 7 | String getIntroduction(); 8 | } -------------------------------------------------------------------------------- /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-rabbitmq/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spring-boot-rabbitmq 2 | 3 | spring.rabbitmq.host=192.168.0.56 4 | spring.rabbitmq.port=5672 5 | spring.rabbitmq.username=zzq 6 | spring.rabbitmq.password=zzq 7 | -------------------------------------------------------------------------------- /spring-boot-admin-simple/spring-boot-admin-client/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8001 2 | 3 | spring.application.name=Admin Client 4 | spring.boot.admin.client.url=http://localhost:8000 5 | management.endpoints.web.exposure.include=* -------------------------------------------------------------------------------- /spring-boot-swagger/src/test/java/com/neo/SwaggerApplicationTests.java: -------------------------------------------------------------------------------- 1 | 2 | package com.neo; 3 | 4 | 5 | 6 | import org.junit.Test; 7 | 8 | public class SwaggerApplicationTests { 9 | 10 | @Test 11 | public void test() { 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/neo/sevice/UserInfoService.java: -------------------------------------------------------------------------------- 1 | package com.neo.sevice; 2 | 3 | import com.neo.model.UserInfo; 4 | 5 | public interface UserInfoService { 6 | /**通过username查找用户信息;*/ 7 | public UserInfo findByUsername(String username); 8 | } -------------------------------------------------------------------------------- /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-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.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 -------------------------------------------------------------------------------- /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.servlet.multipart.max-file-size=10MB 4 | spring.servlet.multipart.max-request-size=10MB -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /spring-boot-web-thymeleaf/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /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.servlet.http.multipart.max-file-size=10MB 4 | spring.servlet.http.multipart.max-request-size=10MB 5 | 6 | -------------------------------------------------------------------------------- /spring-boot-jpa/spring-boot-jpa/src/main/java/com/neo/repository/AddressRepository.java: -------------------------------------------------------------------------------- 1 | package com.neo.repository; 2 | 3 | import com.neo.model.Address; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface AddressRepository extends JpaRepository { 7 | } -------------------------------------------------------------------------------- /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-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-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-jpa-thymeleaf-curd/src/main/resources/templates/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello Thymeleaf! 6 | 7 | 8 |

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

Hello World

9 | 10 | -------------------------------------------------------------------------------- /spring-boot-mongodb/spring-boot-multi-mongodb/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spring-boot-multi-mongodb 2 | 3 | mongodb.primary.uri=mongodb://192.168.0.75:20000 4 | mongodb.primary.database=primary 5 | mongodb.secondary.uri=mongodb://192.168.0.75:20000 6 | mongodb.secondary.database=secondary 7 | 8 | 9 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/neo/dao/UserInfoDao.java: -------------------------------------------------------------------------------- 1 | package com.neo.dao; 2 | 3 | import com.neo.model.UserInfo; 4 | import org.springframework.data.repository.CrudRepository; 5 | 6 | public interface UserInfoDao extends CrudRepository { 7 | /**通过username查找用户信息;*/ 8 | public UserInfo findByUsername(String username); 9 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch/src/main/java/com/neo/service/CustomersInterface.java: -------------------------------------------------------------------------------- 1 | package com.neo.service; 2 | 3 | import com.neo.model.Customer; 4 | 5 | import java.util.List; 6 | 7 | public interface CustomersInterface { 8 | 9 | public List searchCity(Integer pageNumber, Integer pageSize, String searchContent); 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-actuator/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | info.app.name=spring-boot-actuator 2 | info.app.version= 1.0.0 3 | info.app.test=test 4 | 5 | management.endpoints.web.exposure.include=* 6 | management.endpoint.health.show-details=always 7 | #management.endpoints.web.base-path=/manage 8 | 9 | management.endpoint.shutdown.enabled=true 10 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/left.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | left 6 | 7 | 8 | 9 |

我是 左侧

10 |
11 | 12 | -------------------------------------------------------------------------------- /spring-boot-jpa-thymeleaf-curd/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 findById(long id); 9 | 10 | void deleteById(Long id); 11 | } -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | footer 6 | 7 | 8 |
9 |

我是 尾部

10 |
11 | 12 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | header 6 | 7 | 8 |
9 |

我是 头部

10 |
11 | 12 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/copyright.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 9 | © 2018 10 | 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-mongodb/spring-boot-multi-mongodb/src/main/java/com/neo/repository/primary/PrimaryRepository.java: -------------------------------------------------------------------------------- 1 | package com.neo.repository.primary; 2 | 3 | import com.neo.model.User; 4 | import org.springframework.data.mongodb.repository.MongoRepository; 5 | 6 | /** 7 | * @author neo 8 | */ 9 | public interface PrimaryRepository extends MongoRepository { 10 | } 11 | -------------------------------------------------------------------------------- /spring-boot-redis/src/main/java/com/neo/config/SessionConfig.java: -------------------------------------------------------------------------------- 1 | package com.neo.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; 5 | 6 | @Configuration 7 | @EnableRedisHttpSession(maxInactiveIntervalInSeconds = 86400*30) 8 | public class SessionConfig { 9 | } -------------------------------------------------------------------------------- /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-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-mongodb/spring-boot-multi-mongodb/src/main/java/com/neo/repository/secondary/SecondaryRepository.java: -------------------------------------------------------------------------------- 1 | package com.neo.repository.secondary; 2 | 3 | import com.neo.model.User; 4 | import org.springframework.data.mongodb.repository.MongoRepository; 5 | 6 | /** 7 | * @author neo 8 | */ 9 | public interface SecondaryRepository extends MongoRepository { 10 | } 11 | -------------------------------------------------------------------------------- /spring-boot-mybatis/spring-boot-mybatis-annotation/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | mybatis.type-aliases-package=com.neo.model 2 | 3 | spring.datasource.url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true 4 | spring.datasource.username=root 5 | spring.datasource.password=root 6 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -------------------------------------------------------------------------------- /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 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-mybatis/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.model.User; 6 | 7 | public interface UserMapper { 8 | 9 | List getAll(); 10 | 11 | User getOne(Long id); 12 | 13 | void insert(User user); 14 | 15 | void update(User user); 16 | 17 | void delete(Long id); 18 | 19 | } -------------------------------------------------------------------------------- /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-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-mail/src/main/java/com/neo/MailApplication.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 MailApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(MailApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /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-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-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-hello/src/main/java/com/neo/HelloApplication.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 HelloApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(HelloApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-mail/src/main/resources/templates/emailTemplate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 您好,这是验证邮件,请点击下面的链接完成验证,
9 | 激活账号 10 | 11 | -------------------------------------------------------------------------------- /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.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class RedisApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(RedisApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/java/com/neo/ShiroApplication.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 ShiroApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ShiroApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Index 6 | 7 | 8 |
9 |
10 | 11 | -------------------------------------------------------------------------------- /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-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-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-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-rabbitmq/src/main/java/com/neo/RabbitMQApplication.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 RabbitMQApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(RabbitMQApplication.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-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-hello/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("/") 10 | public String index() { 11 | return "Hello Spring Boot 2.0!"; 12 | } 13 | } -------------------------------------------------------------------------------- /spring-boot-package/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-mybatis/spring-boot-mybatis-xml-mulidatasource/src/main/java/com/neo/mapper/test1/User1Mapper.java: -------------------------------------------------------------------------------- 1 | package com.neo.mapper.test1; 2 | 3 | import com.neo.model.User; 4 | 5 | import java.util.List; 6 | 7 | public interface User1Mapper { 8 | 9 | List getAll(); 10 | 11 | User getOne(Long id); 12 | 13 | void insert(User user); 14 | 15 | void update(User user); 16 | 17 | void delete(Long id); 18 | 19 | } -------------------------------------------------------------------------------- /spring-boot-mybatis/spring-boot-mybatis-xml-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.model.User; 6 | 7 | public interface User2Mapper { 8 | 9 | List getAll(); 10 | 11 | User getOne(Long id); 12 | 13 | void insert(User user); 14 | 15 | void update(User user); 16 | 17 | void delete(Long id); 18 | 19 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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-jpa/spring-boot-multi-Jpa/src/main/java/com/neo/MultiJpaApplication.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 MultiJpaApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(MultiJpaApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /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-mongodb/spring-boot-mongodb/src/main/java/com/neo/MongoDBApplication.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 MongoDBApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(MongoDBApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/java/com/neo/SwaggerApplication.java: -------------------------------------------------------------------------------- 1 | 2 | package com.neo; 3 | 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | 8 | @SpringBootApplication 9 | public class SwaggerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SwaggerApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Home 5 | 6 | 7 |
8 |

个性化的内容

9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch/src/main/java/com/neo/ElasticsearchApplication.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 ElasticsearchApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ElasticsearchApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /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-mybatis/spring-boot-mybatis-xml-mulidatasource/src/main/java/com/neo/MXMApplication.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 MXMApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(MXMApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /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-jpa/spring-boot-jpa/src/main/java/com/neo/service/UserDetailService.java: -------------------------------------------------------------------------------- 1 | package com.neo.service; 2 | 3 | import com.neo.model.UserDetail; 4 | import com.neo.param.UserDetailParam; 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | 8 | public interface UserDetailService { 9 | public Page findByCondition(UserDetailParam detailParam, Pageable pageable); 10 | } 11 | -------------------------------------------------------------------------------- /spring-boot-mybatis/spring-boot-mybatis-annotation-mulidatasource/src/main/java/com/neo/MAMApplication.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 MAMApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(MAMApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/ThymeleafApplication.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 ThymeleafApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ThymeleafApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-mongodb/spring-boot-multi-mongodb/src/main/java/com/neo/MultiMongodbApplication.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 MultiMongodbApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(MultiMongodbApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/java/com/neo/TLayoutApplication.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 TLayoutApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(TLayoutApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/fragment.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Fragment - Page 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /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-jpa-thymeleaf-curd/src/main/java/com/neo/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.neo.service; 2 | 3 | import com.neo.model.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-shiro/src/test/java/com/neo/ShiroApplicationTests.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 ShiroApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-banner/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | .__ .__ .__ .__ .___ 2 | | |__ ____ | | | | ____ __ _ _____________| | __| _/ 3 | | | \_/ __ \| | | | / _ \ \ \/ \/ / _ \_ __ \ | / __ | 4 | | Y \ ___/| |_| |_( <_> ) \ ( <_> ) | \/ |__/ /_/ | 5 | |___| /\___ >____/____/\____/ \/\_/ \____/|__| |____/\____ | 6 | \/ \/ \/ -------------------------------------------------------------------------------- /spring-boot-package/src/test/java/com/neo/PackageApplicationTests.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 PackageApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /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-jpa/spring-boot-jpa/src/test/java/com/neo/JpaApplicationTests.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 JpaApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-jpa/spring-boot-multi-Jpa/src/main/java/com/neo/repository/test1/UserTest1Repository.java: -------------------------------------------------------------------------------- 1 | package com.neo.repository.test1; 2 | 3 | import com.neo.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface UserTest1Repository extends JpaRepository { 7 | User findById(long id); 8 | User findByUserName(String userName); 9 | User findByUserNameOrEmail(String username, String email); 10 | } -------------------------------------------------------------------------------- /spring-boot-jpa/spring-boot-multi-Jpa/src/main/java/com/neo/repository/test2/UserTest2Repository.java: -------------------------------------------------------------------------------- 1 | package com.neo.repository.test2; 2 | 3 | import com.neo.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | 7 | public interface UserTest2Repository extends JpaRepository { 8 | User findById(long id); 9 | User findByUserName(String userName); 10 | User findByUserNameOrEmail(String username, String email); 11 | } -------------------------------------------------------------------------------- /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-mongodb/spring-boot-mongodb/src/main/java/com/neo/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.neo.repository; 2 | 3 | import com.neo.model.User; 4 | 5 | /** 6 | * Created by summer on 2017/5/5. 7 | */ 8 | public interface UserRepository { 9 | 10 | public void saveUser(User user); 11 | 12 | public User findUserByUserName(String userName); 13 | 14 | public long updateUser(User user); 15 | 16 | public void deleteUserById(Long id); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /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-jpa/spring-boot-jpa/src/main/java/com/neo/JpaApplication.java: -------------------------------------------------------------------------------- 1 | package com.neo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.domain.EntityScan; 6 | 7 | @SpringBootApplication 8 | public class JpaApplication { 9 | 10 | public static void main(String[] args) { 11 | SpringApplication.run(JpaApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /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-swagger/src/main/java/com/neo/repository/MessageRepository.java: -------------------------------------------------------------------------------- 1 | 2 | package com.neo.repository; 3 | 4 | import com.neo.model.Message; 5 | 6 | import java.util.List; 7 | 8 | public interface MessageRepository { 9 | 10 | List findAll(); 11 | 12 | Message save(Message message); 13 | 14 | Message update(Message message); 15 | 16 | Message updateText(Message message); 17 | 18 | Message findMessage(Long id); 19 | 20 | void deleteMessage(Long id); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/test/java/com/neo/TLayoutApplicationTests.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 TLayoutApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf/src/test/java/com/neo/ThymeleafApplicationTests.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 ThymeleafApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-mail/src/test/java/com/neo/MailApplicationTests.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 MailApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /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/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-rabbitmq/src/test/java/com/neo/RabbitMQApplicationTests.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 RabbitMQApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-scheduler/src/test/java/com/neo/SchedulerApplicationTests.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 SchedulerApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-mybatis/spring-boot-mybatis-xml/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | mybatis.config-location=classpath:mybatis/mybatis-config.xml 2 | mybatis.mapper-locations=classpath:mybatis/mapper/*.xml 3 | mybatis.type-aliases-package=com.neo.model 4 | 5 | spring.datasource.url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true 6 | spring.datasource.username=root 7 | spring.datasource.password=root 8 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 9 | -------------------------------------------------------------------------------- /spring-boot-scheduler/src/main/java/com/neo/SchedulerApplication.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 SchedulerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SchedulerApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-mongodb/spring-boot-mongodb/src/test/java/com/neo/MongoDBApplicationTests.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 MongoDBApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /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-mybatis/spring-boot-mybatis-xml/src/test/java/com/neo/MybatisXmlApplicationTests.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 MybatisXmlApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf/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.ModelMap; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | @Controller 8 | public class HelloController { 9 | 10 | @RequestMapping("/") 11 | public String index(ModelMap map) { 12 | map.addAttribute("message", "http://www.ityouknow.com"); 13 | return "hello"; 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/if.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example If/Unless 6 | 7 | 8 |
9 |

If/Unless

10 | home 11 |
12 | ityouknow 13 |
14 | 15 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/switch.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example switch 6 | 7 | 8 |
9 |
10 |

她是一个姑娘...

11 |

这是一个爷们!

12 | 13 |

未知性别的一个家伙。

14 |
15 |
16 | 17 | -------------------------------------------------------------------------------- /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-mybatis/spring-boot-mybatis-xml-mulidatasource/src/test/java/com/neo/MXMApplicationTests.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 MXMApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-mybatis/spring-boot-mybatis-xml/src/main/java/com/neo/MybatisXmlApplication.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 MybatisXmlApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(MybatisXmlApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /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-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/eq.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example gt eq 6 | 7 | 8 |
9 |

EQ

10 | 11 |
12 | 13 |
14 | favorites 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.cj.jdbc.Driver 5 | 6 | spring.jpa.properties.hibernate.hbm2ddl.auto=create 7 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect 8 | spring.jpa.show-sql= true 9 | 10 | spring.thymeleaf.cache=false -------------------------------------------------------------------------------- /spring-boot-mongodb/spring-boot-multi-mongodb/src/test/java/com/neo/MultiMongodbApplicationTests.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 MultiMongodbApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-mybatis/spring-boot-mybatis-annotation-mulidatasource/src/test/java/com/neo/MAMApplicationTests.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 MAMApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-mybatis/spring-boot-mybatis-annotation/src/test/java/com/neo/MybatisAnnotationApplicationTests.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 MybatisAnnotationApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | System.out.println("hello world"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-mybatis/spring-boot-mybatis-annotation/src/main/java/com/neo/MybatisAnnotationApplication.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 MybatisAnnotationApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(MybatisAnnotationApplication.class, args); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /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-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-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/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-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-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/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-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-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-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-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/string.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example String 6 | 7 | 8 |
9 |

text

10 |

neo

11 | 12 |
13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /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-hello/src/test/java/com/neo/HelloApplicationTests.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 HelloApplicationTests { 12 | 13 | @Test 14 | public void contextLoads() { 15 | System.out.println("Hello Spring Boot 2.0!"); 16 | } 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-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-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Layout 6 | 7 | 8 |
9 |
10 |
11 |
content
12 |
13 |
14 | 15 | -------------------------------------------------------------------------------- /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-elasticsearch/src/test/java/com/neo/ElasticsearchApplicationTests.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 ElasticsearchApplicationTests { 12 | 13 | @Test 14 | public void contextLoads() { 15 | System.out.println("Spring Boot Test"); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-jpa/spring-boot-multi-Jpa/src/test/java/com/neo/MultiJpaApplicationTests.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 MultiJpaApplicationTests { 12 | 13 | @Test 14 | public void contextLoads() { 15 | System.out.println("Hello MultiJpa!"); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | comm title 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /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-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-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/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 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /spring-boot-jpa/spring-boot-jpa/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 -------------------------------------------------------------------------------- /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.server.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-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-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/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-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example If/Unless 6 | 7 | 8 |
9 |

for 循环

10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
neo6213index
18 |
19 | 20 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/url.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example If/Unless 6 | 7 | 8 |
9 |

URL

10 | link1 11 |
12 | view 13 |
14 |
15 |


16 |
17 |
18 | 19 | -------------------------------------------------------------------------------- /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/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-swagger/src/main/java/com/neo/model/User.java: -------------------------------------------------------------------------------- 1 | package com.neo.model; 2 | 3 | public class User { 4 | private Long id; 5 | private String name; 6 | private int age; 7 | 8 | public Long getId() { 9 | return id; 10 | } 11 | 12 | public void setId(Long id) { 13 | this.id = id; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | 24 | public int getAge() { 25 | return age; 26 | } 27 | 28 | public void setAge(int age) { 29 | this.age = age; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot-shiro/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | url: jdbc:mysql://localhost:3306/test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true 4 | username: root 5 | password: root 6 | #schema: database/import.sql 7 | #sql-script-encoding: utf-8 8 | driver-class-name: com.mysql.cj.jdbc.Driver 9 | 10 | jpa: 11 | database: mysql 12 | show-sql: true 13 | hibernate: 14 | ddl-auto: update 15 | properties: 16 | hibernate: 17 | dialect: org.hibernate.dialect.MySQL5Dialect 18 | 19 | thymeleaf: 20 | cache: false 21 | mode: HTML -------------------------------------------------------------------------------- /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-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-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.model.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-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-mybatis/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-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-mybatis/spring-boot-mybatis-xml-mulidatasource/src/main/resources/mybatis/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 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-elasticsearch/src/main/java/com/neo/repository/CustomerRepository.java: -------------------------------------------------------------------------------- 1 | 2 | package com.neo.repository; 3 | 4 | import com.neo.model.Customer; 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; 8 | 9 | import java.util.List; 10 | 11 | 12 | public interface CustomerRepository extends ElasticsearchRepository { 13 | public List findByAddress(String address); 14 | public Customer findByUserName(String userName); 15 | public int deleteByUserName(String userName); 16 | public Page findByAddress(String address, Pageable pageable); 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /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-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-mybatis/spring-boot-mybatis-annotation-mulidatasource/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | mybatis.type-aliases-package=com.neo.model 2 | 3 | spring.datasource.test1.jdbc-url=jdbc:mysql://localhost:3306/test1?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true 4 | spring.datasource.test1.username=root 5 | spring.datasource.test1.password=root 6 | spring.datasource.test1.driver-class-name=com.mysql.cj.jdbc.Driver 7 | 8 | spring.datasource.test2.jdbc-url=jdbc:mysql://localhost:3306/test2?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true 9 | spring.datasource.test2.username=root 10 | spring.datasource.test2.password=root 11 | spring.datasource.test2.driver-class-name=com.mysql.cj.jdbc.Driver 12 | 13 | -------------------------------------------------------------------------------- /spring-boot-mybatis/spring-boot-mybatis-xml-mulidatasource/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | mybatis.config-location=classpath:mybatis/mybatis-config.xml 2 | 3 | spring.datasource.test1.jdbc-url=jdbc:mysql://localhost:3306/test1?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true 4 | spring.datasource.test1.username=root 5 | spring.datasource.test1.password=root 6 | spring.datasource.test1.driver-class-name=com.mysql.cj.jdbc.Driver 7 | 8 | spring.datasource.test2.jdbc-url=jdbc:mysql://localhost:3306/test2?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true 9 | spring.datasource.test2.username=root 10 | spring.datasource.test2.password=root 11 | spring.datasource.test2.driver-class-name=com.mysql.cj.jdbc.Driver 12 | -------------------------------------------------------------------------------- /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-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-package/src/main/java/com/neo/PackageApplication.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.servlet.support.SpringBootServletInitializer; 7 | 8 | @SpringBootApplication 9 | public class PackageApplication extends SpringBootServletInitializer { 10 | 11 | @Override 12 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 13 | return application.sources(PackageApplication.class); 14 | } 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(PackageApplication.class, args); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /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-thymeleaf/spring-boot-thymeleaf-layout/src/main/java/com/neo/web/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.neo.web; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.ModelMap; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | @Controller 8 | public class IndexController { 9 | 10 | @RequestMapping("/index") 11 | public String index() { 12 | return "index"; 13 | } 14 | 15 | @RequestMapping("/fragment") 16 | public String fragment() { 17 | return "fragment"; 18 | } 19 | 20 | @RequestMapping("/layout") 21 | public String layout() { 22 | return "layout"; 23 | } 24 | 25 | @RequestMapping("/home") 26 | public String home() { 27 | return "home"; 28 | } 29 | 30 | 31 | } -------------------------------------------------------------------------------- /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-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-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-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-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-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.servlet.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-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 | } -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /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-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-mongodb/spring-boot-multi-mongodb/src/main/java/com/neo/config/props/MultipleMongoProperties.java: -------------------------------------------------------------------------------- 1 | package com.neo.config.props; 2 | 3 | import org.springframework.boot.autoconfigure.mongo.MongoProperties; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | 6 | @ConfigurationProperties(prefix = "mongodb") 7 | public class MultipleMongoProperties { 8 | 9 | private MongoProperties primary = new MongoProperties(); 10 | private MongoProperties secondary = new MongoProperties(); 11 | 12 | public MongoProperties getPrimary() { 13 | return primary; 14 | } 15 | 16 | public void setPrimary(MongoProperties primary) { 17 | this.primary = primary; 18 | } 19 | 20 | public MongoProperties getSecondary() { 21 | return secondary; 22 | } 23 | 24 | public void setSecondary(MongoProperties secondary) { 25 | this.secondary = secondary; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-jpa/spring-boot-jpa/src/main/java/com/neo/repository/UserDetailRepository.java: -------------------------------------------------------------------------------- 1 | package com.neo.repository; 2 | 3 | import com.neo.model.User; 4 | import com.neo.model.UserDetail; 5 | import com.neo.model.UserInfo; 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 8 | import org.springframework.data.jpa.repository.Query; 9 | 10 | import java.util.List; 11 | 12 | 13 | public interface UserDetailRepository extends JpaSpecificationExecutor,JpaRepository { 14 | 15 | UserDetail findByHobby(String hobby); 16 | 17 | @Query("select u.userName as userName, u.email as email, d.introduction as introduction , d.hobby as hobby from User u , UserDetail d " + 18 | "where u.id=d.userId and d.hobby = ?1 ") 19 | List findUserInfo(String hobby); 20 | } -------------------------------------------------------------------------------- /spring-boot-mybatis/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-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-mybatis/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/spring-boot-mybatis-xml-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/spring-boot-mybatis-annotation-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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /spring-boot-jpa/spring-boot-multi-Jpa/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.primary.jdbc-url=jdbc:mysql://localhost:3306/test1?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true 2 | spring.datasource.primary.username=root 3 | spring.datasource.primary.password=root 4 | spring.datasource.primary.driver-class-name=com.mysql.cj.jdbc.Driver 5 | 6 | spring.datasource.secondary.jdbc-url=jdbc:mysql://localhost:3306/test2?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true 7 | spring.datasource.secondary.username=root 8 | spring.datasource.secondary.password=root 9 | spring.datasource.secondary.driver-class-name=com.mysql.cj.jdbc.Driver 10 | 11 | #sql\u8F93\u51FA 12 | spring.jpa.show-sql=true 13 | spring.jpa.properties.hibernate.hbm2ddl.auto=create 14 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect 15 | #format\u4E00\u4E0Bsql\u8FDB\u884C\u8F93\u51FA 16 | spring.jpa.properties.hibernate.format_sql=true 17 | -------------------------------------------------------------------------------- /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-redis/src/main/java/com/neo/web/UserController.java: -------------------------------------------------------------------------------- 1 | package com.neo.web; 2 | 3 | import org.springframework.cache.annotation.Cacheable; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | import com.neo.model.User; 8 | 9 | import javax.servlet.http.HttpSession; 10 | import java.util.UUID; 11 | 12 | @RestController 13 | public class UserController { 14 | 15 | @RequestMapping("/getUser") 16 | @Cacheable(value="user-key") 17 | public User getUser() { 18 | User user=new User("aa@126.com", "aa", "aa123456", "aa","123"); 19 | System.out.println("若下面没出现“无缓存的时候调用”字样且能打印出数据表示测试成功"); 20 | return user; 21 | } 22 | 23 | 24 | @RequestMapping("/uid") 25 | String uid(HttpSession session) { 26 | UUID uid = (UUID) session.getAttribute("uid"); 27 | if (uid == null) { 28 | uid = UUID.randomUUID(); 29 | } 30 | session.setAttribute("uid", uid); 31 | return session.getId(); 32 | } 33 | } -------------------------------------------------------------------------------- /spring-boot-redis/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # REDIS 2 | # Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09 3 | spring.redis.database=0 4 | # Redis\u670D\u52A1\u5668\u5730\u5740 5 | spring.redis.host=localhost 6 | # Redis\u670D\u52A1\u5668\u8FDE\u63A5\u7AEF\u53E3 7 | spring.redis.port=6379 8 | # Redis\u670D\u52A1\u5668\u8FDE\u63A5\u5BC6\u7801\uFF08\u9ED8\u8BA4\u4E3A\u7A7A\uFF09 9 | spring.redis.password= 10 | # \u8FDE\u63A5\u6C60\u6700\u5927\u8FDE\u63A5\u6570\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09 \u9ED8\u8BA4 8 11 | spring.redis.lettuce.pool.max-active=8 12 | # \u8FDE\u63A5\u6C60\u6700\u5927\u963B\u585E\u7B49\u5F85\u65F6\u95F4\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09 \u9ED8\u8BA4 -1 13 | spring.redis.lettuce.pool.max-wait=-1 14 | # \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5 \u9ED8\u8BA4 8 15 | spring.redis.lettuce.pool.max-idle=8 16 | # \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5 \u9ED8\u8BA4 0 17 | spring.redis.lettuce.pool.min-idle=0 18 | -------------------------------------------------------------------------------- /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-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-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/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-jpa-thymeleaf-curd/src/main/java/com/neo/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.neo.service.impl; 2 | 3 | import com.neo.model.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.List; 10 | 11 | @Service 12 | public class UserServiceImpl implements UserService{ 13 | 14 | @Autowired 15 | private UserRepository userRepository; 16 | 17 | @Override 18 | public List getUserList() { 19 | return userRepository.findAll(); 20 | } 21 | 22 | @Override 23 | public User findUserById(long id) { 24 | return userRepository.findById(id); 25 | } 26 | 27 | @Override 28 | public void save(User user) { 29 | userRepository.save(user); 30 | } 31 | 32 | @Override 33 | public void edit(User user) { 34 | userRepository.save(user); 35 | } 36 | 37 | @Override 38 | public void delete(long id) { 39 | userRepository.deleteById(id); 40 | } 41 | } 42 | 43 | 44 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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-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 | 2.1.0 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-maven-plugin 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /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-starter-server 17 | 2.1.0 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-maven-plugin 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /spring-boot-mongodb/spring-boot-multi-mongodb/src/main/java/com/neo/config/PrimaryMongoConfig.java: -------------------------------------------------------------------------------- 1 | package com.neo.config; 2 | 3 | import com.mongodb.MongoClient; 4 | import com.mongodb.MongoClientURI; 5 | import com.neo.config.props.MultipleMongoProperties; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.autoconfigure.mongo.MongoProperties; 8 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | import org.springframework.context.annotation.Primary; 12 | import org.springframework.data.mongodb.MongoDbFactory; 13 | import org.springframework.data.mongodb.core.MongoTemplate; 14 | import org.springframework.data.mongodb.core.SimpleMongoDbFactory; 15 | import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; 16 | 17 | 18 | @Configuration 19 | @EnableConfigurationProperties(MultipleMongoProperties.class) 20 | @EnableMongoRepositories(basePackages = "com.neo.repository.primary", 21 | mongoTemplateRef = "primaryMongoTemplate") 22 | public class PrimaryMongoConfig { 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-mybatis/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.model.User; 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 | User getOne(Long id); 25 | 26 | @Insert("INSERT INTO users(userName,passWord,user_sex) VALUES(#{userName}, #{passWord}, #{userSex})") 27 | void insert(User user); 28 | 29 | @Update("UPDATE users SET userName=#{userName},nick_name=#{nickName} WHERE id =#{id}") 30 | void update(User user); 31 | 32 | @Delete("DELETE FROM users WHERE id =#{id}") 33 | void delete(Long id); 34 | 35 | } -------------------------------------------------------------------------------- /spring-boot-mybatis/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.model.User; 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 | User getOne(Long id); 25 | 26 | @Insert("INSERT INTO users(userName,passWord,user_sex) VALUES(#{userName}, #{passWord}, #{userSex})") 27 | void insert(User user); 28 | 29 | @Update("UPDATE users SET userName=#{userName},nick_name=#{nickName} WHERE id =#{id}") 30 | void update(User user); 31 | 32 | @Delete("DELETE FROM users WHERE id =#{id}") 33 | void delete(Long id); 34 | 35 | } -------------------------------------------------------------------------------- /spring-boot-mongodb/spring-boot-multi-mongodb/src/main/java/com/neo/config/SecondaryMongoConfig.java: -------------------------------------------------------------------------------- 1 | package com.neo.config; 2 | 3 | import com.mongodb.MongoClient; 4 | import com.mongodb.MongoClientURI; 5 | import com.neo.config.props.MultipleMongoProperties; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Qualifier; 8 | import org.springframework.boot.autoconfigure.mongo.MongoProperties; 9 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | import org.springframework.data.mongodb.MongoDbFactory; 13 | import org.springframework.data.mongodb.core.MongoTemplate; 14 | import org.springframework.data.mongodb.core.SimpleMongoDbFactory; 15 | import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; 16 | 17 | 18 | @Configuration 19 | @EnableConfigurationProperties(MultipleMongoProperties.class) 20 | @EnableMongoRepositories(basePackages = "com.neo.repository.secondary", 21 | mongoTemplateRef = "secondaryMongoTemplate") 22 | public class SecondaryMongoConfig { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/model/User.java: -------------------------------------------------------------------------------- 1 | package com.neo.model; 2 | 3 | import org.hibernate.validator.constraints.Length; 4 | import org.hibernate.validator.constraints.NotEmpty; 5 | 6 | import javax.validation.constraints.Max; 7 | import javax.validation.constraints.Min; 8 | import javax.validation.constraints.Size; 9 | 10 | public class User { 11 | private String name; 12 | private int age; 13 | private String pass; 14 | 15 | public User(String name, int age, String pass) { 16 | this.name = name; 17 | this.age = age; 18 | this.pass = pass; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | 29 | public int getAge() { 30 | return age; 31 | } 32 | 33 | public void setAge(int age) { 34 | this.age = age; 35 | } 36 | 37 | public String getPass() { 38 | return pass; 39 | } 40 | 41 | public void setPass(String pass) { 42 | this.pass = pass; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return ("name=" + this.name + ",age=" + this.age + ",pass=" + this.pass); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /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-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.web.embedded.tomcat.TomcatConnectorCustomizer; 7 | import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; 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 TomcatServletWebServerFactory tomcatEmbedded() { 20 | TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); 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-redis/src/main/java/com/neo/config/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package com.neo.config; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | import org.springframework.cache.CacheManager; 6 | import org.springframework.cache.annotation.CachingConfigurerSupport; 7 | import org.springframework.cache.annotation.EnableCaching; 8 | import org.springframework.cache.interceptor.KeyGenerator; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | import org.springframework.data.redis.cache.RedisCacheManager; 12 | import org.springframework.data.redis.core.RedisTemplate; 13 | 14 | 15 | @Configuration 16 | @EnableCaching 17 | public class RedisConfig extends CachingConfigurerSupport{ 18 | 19 | @Bean 20 | public KeyGenerator keyGenerator() { 21 | return new KeyGenerator() { 22 | @Override 23 | public Object generate(Object target, Method method, Object... params) { 24 | StringBuilder sb = new StringBuilder(); 25 | sb.append(target.getClass().getName()); 26 | sb.append(method.getName()); 27 | for (Object obj : params) { 28 | sb.append(obj.toString()); 29 | } 30 | return sb.toString(); 31 | } 32 | }; 33 | } 34 | } -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/java/com/neo/model/Message.java: -------------------------------------------------------------------------------- 1 | package com.neo.model; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | 5 | import java.util.Calendar; 6 | import java.util.Date; 7 | 8 | import javax.validation.constraints.NotEmpty; 9 | 10 | 11 | public class Message { 12 | private Long id; 13 | @ApiModelProperty(value = "消息体") 14 | private String text; 15 | @ApiModelProperty(value = "消息总结") 16 | private String summary; 17 | private Date createDate; 18 | 19 | public Long getId() { 20 | return this.id; 21 | } 22 | 23 | public void setId(Long id) { 24 | this.id = id; 25 | } 26 | 27 | public Date getCreateDate() { 28 | return createDate; 29 | } 30 | 31 | public void setCreateDate(Date createDate) { 32 | this.createDate = createDate; 33 | } 34 | 35 | public String getText() { 36 | return this.text; 37 | } 38 | 39 | public void setText(String text) { 40 | this.text = text; 41 | } 42 | 43 | public String getSummary() { 44 | return this.summary; 45 | } 46 | 47 | public void setSummary(String summary) { 48 | this.summary = summary; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return "Message{" + 54 | "id=" + id + 55 | ", text='" + text + '\'' + 56 | ", summary='" + summary + '\'' + 57 | ", createDate=" + createDate + 58 | '}'; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /spring-boot-jpa-thymeleaf-curd/src/main/java/com/neo/model/User.java: -------------------------------------------------------------------------------- 1 | package com.neo.model; 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-mybatis/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.model.User; 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 User getUser(Long id) { 27 | User user=userMapper.getOne(id); 28 | return user; 29 | } 30 | 31 | @RequestMapping("/add") 32 | public void save(User user) { 33 | userMapper.insert(user); 34 | } 35 | 36 | @RequestMapping(value="update") 37 | public void update(User 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/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.model.User; 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 User getUser(Long id) { 27 | User user=userMapper.getOne(id); 28 | return user; 29 | } 30 | 31 | @RequestMapping("/add") 32 | public void save(User user) { 33 | userMapper.insert(user); 34 | } 35 | 36 | @RequestMapping(value="update") 37 | public void update(User 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-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.web.embedded.tomcat.TomcatConnectorCustomizer; 7 | import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; 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 TomcatServletWebServerFactory tomcatEmbedded() { 20 | TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); 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-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-mongodb/spring-boot-mongodb/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 2017/5/5. 7 | */ 8 | public class User 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-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-jpa/spring-boot-jpa/src/main/java/com/neo/model/Address.java: -------------------------------------------------------------------------------- 1 | package com.neo.model; 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 Address { 10 | 11 | @Id 12 | @GeneratedValue 13 | private Long id; 14 | @Column(nullable = false) 15 | private Long userId; 16 | private String province; 17 | private String city; 18 | private String street; 19 | 20 | public Long getId() { 21 | return id; 22 | } 23 | 24 | public void setId(Long id) { 25 | this.id = id; 26 | } 27 | 28 | public Long getUserId() { 29 | return userId; 30 | } 31 | 32 | public void setUserId(Long userId) { 33 | this.userId = userId; 34 | } 35 | 36 | public String getProvince() { 37 | return province; 38 | } 39 | 40 | public void setProvince(String province) { 41 | this.province = province; 42 | } 43 | 44 | public String getCity() { 45 | return city; 46 | } 47 | 48 | public void setCity(String city) { 49 | this.city = city; 50 | } 51 | 52 | public String getStreet() { 53 | return street; 54 | } 55 | 56 | public void setStreet(String street) { 57 | this.street = street; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /spring-boot-package/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-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-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-package/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-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-mybatis/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 com.neo.model.User; 6 | import org.apache.ibatis.annotations.Delete; 7 | import org.apache.ibatis.annotations.Insert; 8 | import org.apache.ibatis.annotations.Result; 9 | import org.apache.ibatis.annotations.Results; 10 | import org.apache.ibatis.annotations.Select; 11 | import org.apache.ibatis.annotations.Update; 12 | 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 | User getOne(Long id); 30 | 31 | @Insert("INSERT INTO users(userName,passWord,user_sex) VALUES(#{userName}, #{passWord}, #{userSex})") 32 | void insert(User user); 33 | 34 | @Update("UPDATE users SET userName=#{userName},nick_name=#{nickName} WHERE id =#{id}") 35 | void update(User user); 36 | 37 | @Delete("DELETE FROM users WHERE id =#{id}") 38 | void delete(Long id); 39 | 40 | } -------------------------------------------------------------------------------- /spring-boot-mybatis/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-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-mongodb/spring-boot-mongodb/src/test/java/com/neo/repository/UserRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package com.neo.repository; 2 | 3 | import com.neo.model.User; 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 UserRepositoryTest { 16 | 17 | @Autowired 18 | private UserRepository userDao; 19 | 20 | @Test 21 | public void testSaveUser() throws Exception { 22 | User user=new User(); 23 | user.setId(2l); 24 | user.setUserName("小明"); 25 | user.setPassWord("fffooo123"); 26 | userDao.saveUser(user); 27 | } 28 | 29 | @Test 30 | public void findUserByUserName(){ 31 | User user= userDao.findUserByUserName("小明"); 32 | System.out.println("user is "+user); 33 | } 34 | 35 | @Test 36 | public void updateUser(){ 37 | User user=new User(); 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-jpa/spring-boot-jpa/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.domain.Page; 5 | import org.springframework.data.domain.Pageable; 6 | import org.springframework.data.domain.Slice; 7 | import org.springframework.data.jpa.repository.JpaRepository; 8 | import org.springframework.data.jpa.repository.Modifying; 9 | import org.springframework.data.jpa.repository.Query; 10 | import org.springframework.transaction.annotation.Transactional; 11 | 12 | 13 | public interface UserRepository extends JpaRepository { 14 | 15 | User findByUserName(String userName); 16 | 17 | User findByUserNameOrEmail(String username, String email); 18 | 19 | @Transactional(timeout = 10) 20 | @Modifying 21 | @Query("update User set userName = ?1 where id = ?2") 22 | int modifyById(String userName, Long id); 23 | 24 | @Transactional 25 | @Modifying 26 | @Query("delete from User where id = ?1") 27 | void deleteById(Long id); 28 | 29 | @Query("select u from User u where u.email = ?1") 30 | User findByEmail(String email); 31 | 32 | @Query("select u from User u") 33 | Page findALL(Pageable pageable); 34 | 35 | Page findByNickName(String nickName, Pageable pageable); 36 | 37 | Slice findByNickNameAndEmail(String nickName, String email,Pageable pageable); 38 | 39 | 40 | } -------------------------------------------------------------------------------- /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-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-web/src/test/java/com/neo/model/UserRepositoryTests.java: -------------------------------------------------------------------------------- 1 | package com.neo.model; 2 | 3 | import java.text.DateFormat; 4 | import java.util.Date; 5 | 6 | import com.neo.repository.UserRepository; 7 | import org.junit.Assert; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | 13 | import org.springframework.test.context.junit4.SpringRunner; 14 | 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | public class UserRepositoryTests { 19 | 20 | @Autowired 21 | private UserRepository userRepository; 22 | 23 | @Test 24 | public void test() throws Exception { 25 | Date date = new Date(); 26 | DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG); 27 | String formattedDate = dateFormat.format(date); 28 | 29 | userRepository.save(new User("aa1", "aa@126.com", "aa", "aa123456",formattedDate)); 30 | userRepository.save(new User("bb2", "bb@126.com", "bb", "bb123456",formattedDate)); 31 | userRepository.save(new User("cc3", "cc@126.com", "cc", "cc123456",formattedDate)); 32 | 33 | // Assert.assertEquals(9, userRepository.findAll().size()); 34 | Assert.assertEquals("bb2", userRepository.findByUserNameOrEmail("bb", "xxx126.com").getNickName()); 35 | userRepository.delete(userRepository.findByUserName("aa")); 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /spring-boot-banner/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | spring-boot-banner 8 | 2.0.0 9 | jar 10 | 11 | Spring Boot banner 12 | A very useful project to demonstrate animated gif support in Spring Boot 2 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 30 | 31 | 32 | 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-maven-plugin 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /spring-boot-jpa/spring-boot-jpa/src/test/java/com/neo/repository/JpaSpecificationTests.java: -------------------------------------------------------------------------------- 1 | package com.neo.repository; 2 | 3 | import com.neo.model.UserDetail; 4 | import com.neo.param.UserDetailParam; 5 | import com.neo.service.UserDetailService; 6 | import com.neo.service.UserDetailServiceImpl; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.data.domain.Page; 11 | import org.springframework.data.domain.PageRequest; 12 | import org.springframework.data.domain.Pageable; 13 | import org.springframework.data.domain.Sort; 14 | import org.springframework.test.context.junit4.SpringRunner; 15 | 16 | import javax.annotation.Resource; 17 | 18 | @RunWith(SpringRunner.class) 19 | @SpringBootTest 20 | public class JpaSpecificationTests { 21 | 22 | @Resource 23 | private UserDetailService userDetailService; 24 | 25 | @Test 26 | public void testFindByCondition() { 27 | int page=0,size=10; 28 | Sort sort = new Sort(Sort.Direction.DESC, "id"); 29 | Pageable pageable = PageRequest.of(page, size, sort); 30 | UserDetailParam param=new UserDetailParam(); 31 | param.setIntroduction("程序员"); 32 | param.setMinAge(10); 33 | param.setMaxAge(30); 34 | Page page1=userDetailService.findByCondition(param,pageable); 35 | for (UserDetail userDetail:page1){ 36 | System.out.println("userDetail: "+userDetail.toString()); 37 | } 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /spring-boot-web-thymeleaf/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | spring-boot-web-thymeleaf 6 | Spring Boot Web thymeleaf Sample 7 | Spring Boot Web thymeleaf Sample 8 | 9 | 10 | org.springframework.boot 11 | spring-boot-starter-parent 12 | 2.0.0.RELEASE 13 | 14 | 15 | 16 | 17 | 18 | org.springframework.boot 19 | spring-boot-starter-web 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-thymeleaf 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-test 29 | test 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-maven-plugin 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /spring-boot-mybatis/spring-boot-mybatis-annotation-mulidatasource/src/main/java/com/neo/web/UserController.java: -------------------------------------------------------------------------------- 1 | package com.neo.web; 2 | 3 | import java.util.List; 4 | 5 | import com.neo.mapper.test1.User1Mapper; 6 | import com.neo.model.User; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import com.neo.mapper.test2.User2Mapper; 13 | 14 | @RestController 15 | public class UserController { 16 | 17 | @Autowired 18 | private User1Mapper user1Mapper; 19 | 20 | @Autowired 21 | private User2Mapper user2Mapper; 22 | 23 | @RequestMapping("/getUsers") 24 | public List getUsers() { 25 | List users=user1Mapper.getAll(); 26 | return users; 27 | } 28 | 29 | @RequestMapping("/getUser") 30 | public User getUser(Long id) { 31 | User user=user2Mapper.getOne(id); 32 | return user; 33 | } 34 | 35 | @RequestMapping("/add") 36 | public void save(User user) { 37 | user2Mapper.insert(user); 38 | } 39 | 40 | @RequestMapping(value="update") 41 | public void update(User user) { 42 | user2Mapper.update(user); 43 | } 44 | 45 | @RequestMapping(value="/delete/{id}") 46 | public void delete(@PathVariable("id") Long id) { 47 | user1Mapper.delete(id); 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /spring-boot-mybatis/spring-boot-mybatis-xml-mulidatasource/src/main/java/com/neo/web/UserController.java: -------------------------------------------------------------------------------- 1 | package com.neo.web; 2 | 3 | import java.util.List; 4 | 5 | import com.neo.mapper.test1.User1Mapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import com.neo.model.User; 12 | import com.neo.mapper.test2.User2Mapper; 13 | 14 | @RestController 15 | public class UserController { 16 | 17 | @Autowired 18 | private User1Mapper user1Mapper; 19 | 20 | @Autowired 21 | private User2Mapper user2Mapper; 22 | 23 | @RequestMapping("/getUsers") 24 | public List getUsers() { 25 | List users=user1Mapper.getAll(); 26 | return users; 27 | } 28 | 29 | @RequestMapping("/getUser") 30 | public User getUser(Long id) { 31 | User user=user2Mapper.getOne(id); 32 | return user; 33 | } 34 | 35 | @RequestMapping("/add") 36 | public void save(User user) { 37 | user2Mapper.insert(user); 38 | } 39 | 40 | @RequestMapping(value="update") 41 | public void update(User user) { 42 | user2Mapper.update(user); 43 | } 44 | 45 | @RequestMapping(value="/delete/{id}") 46 | public void delete(@PathVariable("id") Long id) { 47 | user1Mapper.delete(id); 48 | } 49 | 50 | 51 | } -------------------------------------------------------------------------------- /spring-boot-mybatis/spring-boot-mybatis-annotation/src/test/java/com/neo/mapper/UserMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.neo.mapper; 2 | 3 | import java.util.List; 4 | 5 | import com.neo.model.User; 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | 13 | import com.neo.enums.UserSexEnum; 14 | 15 | @RunWith(SpringRunner.class) 16 | @SpringBootTest 17 | public class UserMapperTest { 18 | 19 | @Autowired 20 | private UserMapper userMapper; 21 | 22 | @Test 23 | public void testInsert() throws Exception { 24 | userMapper.insert(new User("aa1", "a123456", UserSexEnum.MAN)); 25 | userMapper.insert(new User("bb1", "b123456", UserSexEnum.WOMAN)); 26 | userMapper.insert(new User("cc1", "b123456", UserSexEnum.WOMAN)); 27 | 28 | Assert.assertEquals(3, userMapper.getAll().size()); 29 | } 30 | 31 | @Test 32 | public void testQuery() throws Exception { 33 | List users = userMapper.getAll(); 34 | System.out.println(users.toString()); 35 | } 36 | 37 | 38 | @Test 39 | public void testUpdate() throws Exception { 40 | User user = userMapper.getOne(30l); 41 | System.out.println(user.toString()); 42 | user.setNickName("neo"); 43 | userMapper.update(user); 44 | Assert.assertTrue(("neo".equals(userMapper.getOne(30l).getNickName()))); 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /spring-boot-rabbitmq/src/main/java/com/neo/rabbit/FanoutRabbitConfig.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.FanoutExchange; 6 | import org.springframework.amqp.core.Queue; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | 11 | @Configuration 12 | public class FanoutRabbitConfig { 13 | 14 | @Bean 15 | public Queue AMessage() { 16 | return new Queue("fanout.A"); 17 | } 18 | 19 | @Bean 20 | public Queue BMessage() { 21 | return new Queue("fanout.B"); 22 | } 23 | 24 | @Bean 25 | public Queue CMessage() { 26 | return new Queue("fanout.C"); 27 | } 28 | 29 | @Bean 30 | FanoutExchange fanoutExchange() { 31 | return new FanoutExchange("fanoutExchange"); 32 | } 33 | 34 | @Bean 35 | Binding bindingExchangeA(Queue AMessage,FanoutExchange fanoutExchange) { 36 | return BindingBuilder.bind(AMessage).to(fanoutExchange); 37 | } 38 | 39 | @Bean 40 | Binding bindingExchangeB(Queue BMessage, FanoutExchange fanoutExchange) { 41 | return BindingBuilder.bind(BMessage).to(fanoutExchange); 42 | } 43 | 44 | @Bean 45 | Binding bindingExchangeC(Queue CMessage, FanoutExchange fanoutExchange) { 46 | return BindingBuilder.bind(CMessage).to(fanoutExchange); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /spring-boot-mongodb/spring-boot-multi-mongodb/src/main/java/com/neo/model/User.java: -------------------------------------------------------------------------------- 1 | package com.neo.model; 2 | 3 | import java.io.Serializable; 4 | 5 | 6 | public class User implements Serializable { 7 | private static final long serialVersionUID = -3258839839160856613L; 8 | private String id; 9 | private String userName; 10 | private String passWord; 11 | 12 | public User(String userName, String passWord) { 13 | this.userName = userName; 14 | this.passWord = passWord; 15 | } 16 | 17 | public String getId() { 18 | return id; 19 | } 20 | 21 | public void setId(String id) { 22 | this.id = id; 23 | } 24 | 25 | public String getUserName() { 26 | return userName; 27 | } 28 | 29 | public void setUserName(String userName) { 30 | this.userName = userName; 31 | } 32 | 33 | public String getPassWord() { 34 | return passWord; 35 | } 36 | 37 | public void setPassWord(String passWord) { 38 | this.passWord = passWord; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "User{" + 44 | "id='" + id + '\'' + 45 | ", userName='" + userName + '\'' + 46 | ", passWord='" + passWord + '\'' + 47 | '}'; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /spring-boot-hello/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.neo 7 | spring-boot-hello 8 | 1.0 9 | jar 10 | 11 | spring-boot-hello 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.0.RELEASE 18 | 19 | 20 | 21 | UTF-8 22 | 1.8 23 | 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-test 33 | test 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-maven-plugin 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /spring-boot-elasticsearch/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.neo 7 | spring-boot-elasticsearch 8 | 1.0 9 | jar 10 | 11 | spring-boot-elasticsearch 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.1.0.RELEASE 18 | 19 | 20 | 21 | UTF-8 22 | 1.8 23 | 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-data-elasticsearch 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-test 33 | test 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-maven-plugin 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /spring-boot-mongodb/spring-boot-multi-mongodb/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.neo 7 | spring-boot-multi-mongodb 8 | 1.0.0 9 | jar 10 | 11 | spring-boot-multi-mongodb 12 | Demo project for Spring Boot and multi mongodb 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.1.0.RELEASE 18 | 19 | 20 | 21 | UTF-8 22 | 1.8 23 | 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-data-mongodb 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-test 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-maven-plugin 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /spring-boot-web-thymeleaf/src/main/resources/templates/messages/form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Messages : Create 5 | 6 | 7 |
8 |
9 |
10 | Messages 11 |
12 |

Messages : Create

13 |
14 |
15 | 18 | 19 |
20 | 21 | 22 |
23 |
24 | 25 | 26 |
27 | 28 |
29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /spring-boot-helloWorld/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.mock.web.MockServletContext; 9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | import org.springframework.test.context.web.WebAppConfiguration; 12 | import org.springframework.test.web.servlet.MockMvc; 13 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; 14 | import org.springframework.test.web.servlet.result.MockMvcResultHandlers; 15 | import org.springframework.test.web.servlet.result.MockMvcResultMatchers; 16 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 17 | 18 | @RunWith(SpringRunner.class) 19 | @SpringBootTest 20 | public class HelloWorldControlerTests { 21 | 22 | private MockMvc mvc; 23 | 24 | @Before 25 | public void setUp() throws Exception { 26 | mvc = MockMvcBuilders.standaloneSetup(new HelloWorldController()).build(); 27 | } 28 | 29 | @Test 30 | public void getHello() throws Exception { 31 | mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON)) 32 | .andExpect(MockMvcResultMatchers.status().isOk()) 33 | .andDo(MockMvcResultHandlers.print()) 34 | .andReturn(); 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /spring-boot-mybatis/spring-boot-mybatis-xml/src/test/java/com/neo/mapper/UserMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.neo.mapper; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.Assert; 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.test.context.junit4.SpringRunner; 11 | 12 | import com.neo.model.User; 13 | import com.neo.enums.UserSexEnum; 14 | 15 | @RunWith(SpringRunner.class) 16 | @SpringBootTest 17 | public class UserMapperTest { 18 | 19 | @Autowired 20 | private UserMapper userMapper; 21 | 22 | @Test 23 | public void testInsert() throws Exception { 24 | userMapper.insert(new User("aa", "a123456", UserSexEnum.MAN)); 25 | userMapper.insert(new User("bb", "b123456", UserSexEnum.WOMAN)); 26 | userMapper.insert(new User("cc", "b123456", UserSexEnum.WOMAN)); 27 | 28 | Assert.assertEquals(3, userMapper.getAll().size()); 29 | } 30 | 31 | @Test 32 | public void testQuery() throws Exception { 33 | List users = userMapper.getAll(); 34 | if(users==null || users.size()==0){ 35 | System.out.println("is null"); 36 | }else{ 37 | System.out.println(users.toString()); 38 | } 39 | } 40 | 41 | 42 | @Test 43 | public void testUpdate() throws Exception { 44 | User user = userMapper.getOne(6l); 45 | System.out.println(user.toString()); 46 | user.setNickName("neo"); 47 | userMapper.update(user); 48 | Assert.assertTrue(("neo".equals(userMapper.getOne(6l).getNickName()))); 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /spring-boot-rabbitmq/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.neo 7 | spring-boot-rabbitmq 8 | 1.0.0 9 | jar 10 | 11 | spring-boot-rabbitmq 12 | Demo project for Spring Boot and rabbitmq 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.1.0.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | 1.8 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-amqp 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-test 34 | test 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-maven-plugin 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /spring-boot-scheduler/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.neo 7 | spring-boot-scheduler 8 | 1.0.0 9 | jar 10 | 11 | spring-boot-scheduler 12 | Demo project for Spring Boot and scheduler 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.1.0.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | 1.8 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-test 34 | test 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-maven-plugin 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /spring-boot-swagger/src/main/java/com/neo/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.neo.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.ApiInfoBuilder; 6 | import springfox.documentation.builders.PathSelectors; 7 | import springfox.documentation.builders.RequestHandlerSelectors; 8 | import springfox.documentation.service.ApiInfo; 9 | import springfox.documentation.service.Contact; 10 | import springfox.documentation.spi.DocumentationType; 11 | import springfox.documentation.spring.web.plugins.Docket; 12 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 13 | 14 | @Configuration 15 | @EnableSwagger2 16 | public class SwaggerConfig { 17 | 18 | @Bean 19 | public Docket api() { 20 | return new Docket(DocumentationType.SWAGGER_2) 21 | .apiInfo(apiInfo()) 22 | .select() 23 | // 自行修改为自己的包路径 24 | .apis(RequestHandlerSelectors.basePackage("com.neo.controller")) 25 | .paths(PathSelectors.any()) 26 | .build(); 27 | } 28 | 29 | private ApiInfo apiInfo() { 30 | return new ApiInfoBuilder() 31 | .title("客户管理") 32 | .description("客户管理中心 API 1.0 操作文档") 33 | //服务条款网址 34 | .termsOfServiceUrl("http://www.ityouknow.com/") 35 | .version("1.0") 36 | .contact(new Contact("纯洁的微笑", "http://www.ityouknow.com/", "ityouknow@126.com")) 37 | .build(); 38 | } 39 | } -------------------------------------------------------------------------------- /spring-boot-helloWorld/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.mock.web.MockServletContext; 9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | import org.springframework.test.context.web.WebAppConfiguration; 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 | 16 | import static org.hamcrest.Matchers.equalTo; 17 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; 18 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 19 | 20 | @RunWith(SpringRunner.class) 21 | @SpringBootTest 22 | public class HelloTests { 23 | 24 | 25 | private MockMvc mvc; 26 | 27 | @Before 28 | public void setUp() throws Exception { 29 | mvc = MockMvcBuilders.standaloneSetup(new HelloWorldController()).build(); 30 | } 31 | 32 | @Test 33 | public void getHello() throws Exception { 34 | mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON)) 35 | .andExpect(status().isOk()) 36 | .andExpect(content().string(equalTo("Hello World"))); 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /spring-boot-jpa/spring-boot-jpa/src/main/java/com/neo/param/UserDetailParam.java: -------------------------------------------------------------------------------- 1 | package com.neo.param; 2 | 3 | 4 | import com.neo.model.Address; 5 | import org.hibernate.annotations.Fetch; 6 | import org.hibernate.annotations.FetchMode; 7 | 8 | import javax.persistence.*; 9 | 10 | public class UserDetailParam { 11 | private String userId; 12 | private Integer minAge; 13 | private Integer maxAge; 14 | private String realName; 15 | private String introduction; 16 | private String city; 17 | 18 | public String getUserId() { 19 | return userId; 20 | } 21 | 22 | public void setUserId(String userId) { 23 | this.userId = userId; 24 | } 25 | 26 | public Integer getMinAge() { 27 | return minAge; 28 | } 29 | 30 | public void setMinAge(Integer minAge) { 31 | this.minAge = minAge; 32 | } 33 | 34 | public Integer getMaxAge() { 35 | return maxAge; 36 | } 37 | 38 | public void setMaxAge(Integer maxAge) { 39 | this.maxAge = maxAge; 40 | } 41 | 42 | public String getRealName() { 43 | return realName; 44 | } 45 | 46 | public void setRealName(String realName) { 47 | this.realName = realName; 48 | } 49 | 50 | public String getIntroduction() { 51 | return introduction; 52 | } 53 | 54 | public void setIntroduction(String introduction) { 55 | this.introduction = introduction; 56 | } 57 | 58 | public String getCity() { 59 | return city; 60 | } 61 | 62 | public void setCity(String city) { 63 | this.city = city; 64 | } 65 | } 66 | --------------------------------------------------------------------------------