├── .gitattributes ├── .gitignore ├── Chapter01 ├── .bowerrc ├── .gitignore └── part1 │ ├── build.gradle │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ ├── Chapter.java │ │ │ ├── ChapterController.java │ │ │ ├── ChapterRepository.java │ │ │ ├── HomeController.java │ │ │ ├── LearningSpringBootApplication.java │ │ │ └── LoadDatabase.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── greglturnquist │ └── learningspringboot │ └── LearningSpringBootApplicationTests.java ├── Chapter02 ├── part1 │ ├── .gitignore │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ ├── ApiController.java │ │ │ │ ├── HomeController.java │ │ │ │ ├── Image.java │ │ │ │ ├── ImageService.java │ │ │ │ └── LearningSpringBootApplication.java │ │ └── resources │ │ │ ├── application.properties │ │ │ ├── static │ │ │ └── main.css │ │ │ └── templates │ │ │ └── index.html │ │ └── test │ │ └── java │ │ └── com │ │ └── greglturnquist │ │ └── learningspringboot │ │ └── ExampleTests.java └── part2 │ ├── .gitignore │ ├── build.gradle │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ ├── ApiController.java │ │ │ ├── HomeController.java │ │ │ ├── Image.java │ │ │ ├── ImageService.java │ │ │ └── LearningSpringBootApplication.java │ └── resources │ │ ├── application.yml │ │ ├── static │ │ └── main.css │ │ └── templates │ │ └── index.html │ └── test │ └── java │ └── com │ └── greglturnquist │ └── learningspringboot │ ├── BlockingImageService.java │ └── ExampleTests.java ├── Chapter03 ├── part1 │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ ├── ApiController.java │ │ │ │ ├── HomeController.java │ │ │ │ ├── Image.java │ │ │ │ ├── ImageRepository.java │ │ │ │ ├── ImageService.java │ │ │ │ ├── InitDatabase.java │ │ │ │ └── LearningSpringBootApplication.java │ │ └── resources │ │ │ ├── application.properties │ │ │ ├── static │ │ │ └── main.css │ │ │ └── templates │ │ │ └── index.html │ │ └── test │ │ └── java │ │ └── com │ │ └── greglturnquist │ │ └── learningspringboot │ │ ├── Employee.java │ │ ├── EmployeeRepository.java │ │ ├── ImageServiceTests.java │ │ └── QueryTests.java └── part2 │ ├── build.gradle │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ ├── ApiController.java │ │ │ ├── HomeController.java │ │ │ ├── Image.java │ │ │ ├── ImageRepository.java │ │ │ ├── ImageService.java │ │ │ ├── InitDatabase.java │ │ │ └── LearningSpringBootApplication.java │ └── resources │ │ ├── application.properties │ │ ├── static │ │ └── main.css │ │ └── templates │ │ └── index.html │ └── test │ └── java │ └── com │ └── greglturnquist │ └── learningspringboot │ ├── Employee.java │ ├── EmployeeRepository.java │ ├── ImageServiceTests.java │ └── QueryTests.java ├── Chapter04 ├── part1 │ ├── build.gradle │ ├── ext │ │ └── chromedriver │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ ├── ApiController.java │ │ │ │ ├── HomeController.java │ │ │ │ ├── Image.java │ │ │ │ ├── ImageRepository.java │ │ │ │ ├── ImageService.java │ │ │ │ ├── InitDatabase.java │ │ │ │ └── LearningSpringBootApplication.java │ │ └── resources │ │ │ ├── application.properties │ │ │ ├── static │ │ │ └── main.css │ │ │ └── templates │ │ │ └── index.html │ │ └── test │ │ └── java │ │ └── com │ │ └── greglturnquist │ │ └── learningspringboot │ │ ├── EmbeddedImageRepositoryTests.java │ │ ├── EndToEndTests.java │ │ ├── HomeControllerTests.java │ │ ├── ImageServiceTests.java │ │ ├── ImageTests.java │ │ └── LiveImageRepositoryTests.java └── part2 │ ├── build.gradle │ ├── ext │ └── chromedriver │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ ├── ApiController.java │ │ │ ├── HomeController.java │ │ │ ├── Image.java │ │ │ ├── ImageRepository.java │ │ │ ├── ImageService.java │ │ │ ├── InitDatabase.java │ │ │ ├── LearningSpringBootApplication.java │ │ │ └── webdriver │ │ │ ├── ChromeDriverFactory.java │ │ │ ├── FirefoxDriverFactory.java │ │ │ ├── SafariDriverFactory.java │ │ │ ├── WebDriverAutoConfiguration.java │ │ │ └── WebDriverConfigurationProperties.java │ └── resources │ │ ├── application.properties │ │ ├── static │ │ └── main.css │ │ └── templates │ │ └── index.html │ └── test │ └── java │ └── com │ └── greglturnquist │ └── learningspringboot │ ├── EmbeddedImageRepositoryTests.java │ ├── EndToEndTests.java │ ├── HomeControllerTests.java │ ├── ImageServiceTests.java │ ├── ImageTests.java │ ├── LiveImageRepositoryTests.java │ └── webdriver │ └── WebDriverAutoConfigurationTests.java ├── Chapter05 ├── part1 │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ ├── HomeController.java │ │ │ │ ├── Image.java │ │ │ │ ├── ImageRepository.java │ │ │ │ ├── ImageService.java │ │ │ │ ├── InitDatabase.java │ │ │ │ └── LearningSpringBootApplication.java │ │ └── resources │ │ │ ├── application.properties │ │ │ ├── static │ │ │ └── main.css │ │ │ └── templates │ │ │ └── index.html │ │ └── test │ │ └── java │ │ └── com │ │ └── greglturnquist │ │ └── learningspringboot │ │ └── LearningSpringBootApplicationTests.java └── part2 │ ├── build.gradle │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ ├── HomeController.java │ │ │ ├── Image.java │ │ │ ├── ImageRepository.java │ │ │ ├── ImageService.java │ │ │ ├── InitDatabase.java │ │ │ ├── LearningSpringBootApplication.java │ │ │ └── LearningSpringBootHealthIndicator.java │ └── resources │ │ ├── application.properties │ │ ├── static │ │ └── main.css │ │ └── templates │ │ └── index.html │ └── test │ └── java │ └── com │ └── greglturnquist │ └── learningspringboot │ └── LearningSpringBootApplicationTests.java ├── Chapter06 ├── part1 │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ ├── HomeController.java │ │ │ ├── LearningSpringBootApplication.java │ │ │ ├── comments │ │ │ ├── Comment.java │ │ │ ├── CommentController.java │ │ │ ├── CommentService.java │ │ │ └── CommentWriterRepository.java │ │ │ ├── images │ │ │ ├── Comment.java │ │ │ ├── CommentReaderRepository.java │ │ │ ├── Image.java │ │ │ ├── ImageRepository.java │ │ │ ├── ImageService.java │ │ │ └── InitDatabase.java │ │ │ └── ops │ │ │ └── LearningSpringBootHealthIndicator.java │ │ └── resources │ │ ├── application.properties │ │ ├── static │ │ └── main.css │ │ └── templates │ │ └── index.html ├── part2 │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ ├── CommentSimulator.java │ │ │ ├── HomeController.java │ │ │ ├── LearningSpringBootApplication.java │ │ │ ├── comments │ │ │ ├── Comment.java │ │ │ ├── CommentController.java │ │ │ ├── CommentService.java │ │ │ └── CommentWriterRepository.java │ │ │ ├── images │ │ │ ├── Comment.java │ │ │ ├── CommentReaderRepository.java │ │ │ ├── Image.java │ │ │ ├── ImageRepository.java │ │ │ ├── ImageService.java │ │ │ └── InitDatabase.java │ │ │ └── ops │ │ │ └── LearningSpringBootHealthIndicator.java │ │ └── resources │ │ ├── application.properties │ │ ├── static │ │ └── main.css │ │ └── templates │ │ └── index.html └── part3 │ ├── build.gradle │ └── src │ └── main │ ├── java │ └── com │ │ └── greglturnquist │ │ └── learningspringboot │ │ ├── CommentSimulator.java │ │ ├── HomeController.java │ │ ├── LearningSpringBootApplication.java │ │ ├── comments │ │ ├── Comment.java │ │ ├── CommentController.java │ │ ├── CommentService.java │ │ ├── CommentWriterRepository.java │ │ └── CustomProcessor.java │ │ ├── images │ │ ├── Comment.java │ │ ├── CommentReaderRepository.java │ │ ├── Image.java │ │ ├── ImageRepository.java │ │ ├── ImageService.java │ │ └── InitDatabase.java │ │ └── ops │ │ └── LearningSpringBootHealthIndicator.java │ └── resources │ ├── application.yml │ ├── static │ └── main.css │ └── templates │ └── index.html ├── Chapter07 ├── part1 │ ├── comments │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ └── comments │ │ │ │ ├── Comment.java │ │ │ │ ├── CommentController.java │ │ │ │ ├── CommentRepository.java │ │ │ │ ├── CommentService.java │ │ │ │ └── LearningSpringBootCommentsApplication.java │ │ │ └── resources │ │ │ └── application.yml │ ├── eureka-server │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ └── LearningSpringBootEurekaServerApplication.java │ │ │ └── resources │ │ │ └── application.yml │ └── images │ │ ├── build.gradle │ │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ ├── CommentSimulator.java │ │ │ ├── HomeController.java │ │ │ ├── LearningSpringBootImagesApplication.java │ │ │ ├── images │ │ │ ├── Comment.java │ │ │ ├── CommentController.java │ │ │ ├── Config.java │ │ │ ├── Image.java │ │ │ ├── ImageRepository.java │ │ │ ├── ImageService.java │ │ │ ├── InitDatabase.java │ │ │ └── UploadController.java │ │ │ └── ops │ │ │ └── LearningSpringBootHealthIndicator.java │ │ └── resources │ │ ├── application.yml │ │ ├── static │ │ └── main.css │ │ └── templates │ │ └── index.html ├── part2 │ ├── comments │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ └── comments │ │ │ │ ├── Comment.java │ │ │ │ ├── CommentController.java │ │ │ │ ├── CommentRepository.java │ │ │ │ ├── CommentService.java │ │ │ │ └── LearningSpringBootCommentsApplication.java │ │ │ └── resources │ │ │ └── application.yml │ ├── eureka-server │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ └── LearningSpringBootEurekaServerApplication.java │ │ │ └── resources │ │ │ └── application.yml │ ├── hystrix-dashboard │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ └── LearningSpringBootHystrixDashboard.java │ │ │ └── resources │ │ │ └── application.yml │ └── images │ │ ├── build.gradle │ │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ ├── CommentSimulator.java │ │ │ ├── HomeController.java │ │ │ ├── LearningSpringBootImagesApplication.java │ │ │ ├── images │ │ │ ├── Comment.java │ │ │ ├── CommentController.java │ │ │ ├── CommentHelper.java │ │ │ ├── Config.java │ │ │ ├── Image.java │ │ │ ├── ImageRepository.java │ │ │ ├── ImageService.java │ │ │ ├── InitDatabase.java │ │ │ └── UploadController.java │ │ │ └── ops │ │ │ └── LearningSpringBootHealthIndicator.java │ │ └── resources │ │ ├── application.yml │ │ ├── static │ │ └── main.css │ │ └── templates │ │ └── index.html └── part3 │ ├── comments │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── comments │ │ │ ├── Comment.java │ │ │ ├── CommentController.java │ │ │ ├── CommentRepository.java │ │ │ ├── CommentService.java │ │ │ └── LearningSpringBootCommentsApplication.java │ │ └── resources │ │ └── bootstrap.yml │ ├── config-server │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── LearningSpringBootConfigServer.java │ │ └── resources │ │ └── application.yml │ ├── eureka-server │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── LearningSpringBootEurekaServerApplication.java │ │ └── resources │ │ └── bootstrap.yml │ ├── hystrix-dashboard │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── LearningSpringBootHystrixDashboard.java │ │ └── resources │ │ └── bootstrap.yml │ └── images │ ├── build.gradle │ └── src │ └── main │ ├── java │ └── com │ │ └── greglturnquist │ │ └── learningspringboot │ │ ├── CommentSimulator.java │ │ ├── HomeController.java │ │ ├── LearningSpringBootImagesApplication.java │ │ ├── images │ │ ├── Comment.java │ │ ├── CommentController.java │ │ ├── CommentHelper.java │ │ ├── Config.java │ │ ├── Image.java │ │ ├── ImageRepository.java │ │ ├── ImageService.java │ │ ├── InitDatabase.java │ │ └── UploadController.java │ │ └── ops │ │ └── LearningSpringBootHealthIndicator.java │ └── resources │ ├── bootstrap.yml │ ├── static │ └── main.css │ └── templates │ └── index.html ├── Chapter08 ├── part1 │ ├── chat │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ └── chat │ │ │ │ ├── Comment.java │ │ │ │ ├── CommentService.java │ │ │ │ ├── LearningSpringBootChatApplication.java │ │ │ │ └── WebSocketConfig.java │ │ │ └── resources │ │ │ ├── application.properties │ │ │ └── bootstrap.yml │ ├── comments │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ └── comments │ │ │ │ ├── Comment.java │ │ │ │ ├── CommentController.java │ │ │ │ ├── CommentRepository.java │ │ │ │ ├── CommentService.java │ │ │ │ └── LearningSpringBootCommentsApplication.java │ │ │ └── resources │ │ │ └── bootstrap.yml │ ├── config-server │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ └── LearningSpringBootConfigServer.java │ │ │ └── resources │ │ │ └── application.yml │ ├── eureka-server │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ └── LearningSpringBootEurekaServerApplication.java │ │ │ └── resources │ │ │ └── bootstrap.yml │ ├── hystrix-dashboard │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ └── LearningSpringBootHystrixDashboard.java │ │ │ └── resources │ │ │ └── bootstrap.yml │ └── images │ │ ├── build.gradle │ │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ ├── CommentSimulator.java │ │ │ ├── HomeController.java │ │ │ ├── LearningSpringBootImagesApplication.java │ │ │ ├── images │ │ │ ├── Comment.java │ │ │ ├── CommentController.java │ │ │ ├── CommentHelper.java │ │ │ ├── Config.java │ │ │ ├── Image.java │ │ │ ├── ImageRepository.java │ │ │ ├── ImageService.java │ │ │ ├── InitDatabase.java │ │ │ └── UploadController.java │ │ │ └── ops │ │ │ └── LearningSpringBootHealthIndicator.java │ │ └── resources │ │ ├── application.properties │ │ ├── bootstrap.yml │ │ ├── static │ │ └── main.css │ │ └── templates │ │ └── index.html ├── part2 │ ├── chat │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ └── chat │ │ │ │ ├── ChatServiceStreams.java │ │ │ │ ├── Comment.java │ │ │ │ ├── CommentService.java │ │ │ │ ├── InboundChatService.java │ │ │ │ ├── LearningSpringBootChatApplication.java │ │ │ │ ├── OutboundChatService.java │ │ │ │ └── WebSocketConfig.java │ │ │ └── resources │ │ │ └── bootstrap.yml │ ├── comments │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ └── comments │ │ │ │ ├── Comment.java │ │ │ │ ├── CommentController.java │ │ │ │ ├── CommentRepository.java │ │ │ │ ├── CommentService.java │ │ │ │ └── LearningSpringBootCommentsApplication.java │ │ │ └── resources │ │ │ └── bootstrap.yml │ ├── config-server │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ └── LearningSpringBootConfigServer.java │ │ │ └── resources │ │ │ └── application.yml │ ├── eureka-server │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ └── LearningSpringBootEurekaServerApplication.java │ │ │ └── resources │ │ │ └── bootstrap.yml │ ├── hystrix-dashboard │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── greglturnquist │ │ │ │ └── learningspringboot │ │ │ │ └── LearningSpringBootHystrixDashboard.java │ │ │ └── resources │ │ │ └── bootstrap.yml │ └── images │ │ ├── build.gradle │ │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ ├── CommentSimulator.java │ │ │ ├── HomeController.java │ │ │ ├── LearningSpringBootImagesApplication.java │ │ │ ├── images │ │ │ ├── Comment.java │ │ │ ├── CommentController.java │ │ │ ├── CommentHelper.java │ │ │ ├── Config.java │ │ │ ├── Image.java │ │ │ ├── ImageRepository.java │ │ │ ├── ImageService.java │ │ │ ├── InitDatabase.java │ │ │ └── UploadController.java │ │ │ └── ops │ │ │ └── LearningSpringBootHealthIndicator.java │ │ └── resources │ │ ├── bootstrap.yml │ │ ├── static │ │ └── main.css │ │ └── templates │ │ └── index.html └── part3 │ ├── chat │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── chat │ │ │ ├── ChatServiceStreams.java │ │ │ ├── Comment.java │ │ │ ├── CommentService.java │ │ │ ├── InboundChatService.java │ │ │ ├── LearningSpringBootChatApplication.java │ │ │ ├── OutboundChatService.java │ │ │ ├── UserParsingHandshakeHandler.java │ │ │ └── WebSocketConfig.java │ │ └── resources │ │ └── bootstrap.yml │ ├── comments │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── comments │ │ │ ├── Comment.java │ │ │ ├── CommentController.java │ │ │ ├── CommentRepository.java │ │ │ ├── CommentService.java │ │ │ └── LearningSpringBootCommentsApplication.java │ │ └── resources │ │ └── bootstrap.yml │ ├── config-server │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── LearningSpringBootConfigServer.java │ │ └── resources │ │ └── application.yml │ ├── eureka-server │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── LearningSpringBootEurekaServerApplication.java │ │ └── resources │ │ └── bootstrap.yml │ ├── hystrix-dashboard │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── LearningSpringBootHystrixDashboard.java │ │ └── resources │ │ └── bootstrap.yml │ └── images │ ├── build.gradle │ └── src │ └── main │ ├── java │ └── com │ │ └── greglturnquist │ │ └── learningspringboot │ │ ├── CommentSimulator.java │ │ ├── HomeController.java │ │ ├── LearningSpringBootImagesApplication.java │ │ ├── images │ │ ├── Comment.java │ │ ├── CommentController.java │ │ ├── CommentHelper.java │ │ ├── Config.java │ │ ├── Image.java │ │ ├── ImageRepository.java │ │ ├── ImageService.java │ │ ├── InitDatabase.java │ │ └── UploadController.java │ │ └── ops │ │ └── LearningSpringBootHealthIndicator.java │ └── resources │ ├── bootstrap.yml │ ├── static │ └── main.css │ └── templates │ └── index.html ├── Chapter09 └── part1 │ ├── chat │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── chat │ │ │ ├── AuthorizedWebSocketHandler.java │ │ │ ├── ChatServiceStreams.java │ │ │ ├── Comment.java │ │ │ ├── CommentService.java │ │ │ ├── GatewayConfig.java │ │ │ ├── HomeController.java │ │ │ ├── InboundChatService.java │ │ │ ├── InitUsers.java │ │ │ ├── LearningSpringBootChatApplication.java │ │ │ ├── OutboundChatService.java │ │ │ ├── SecurityConfiguration.java │ │ │ ├── SessionConfig.java │ │ │ ├── SpringDataUserDetailsRepository.java │ │ │ ├── User.java │ │ │ ├── UserRepository.java │ │ │ └── WebSocketConfig.java │ │ └── resources │ │ ├── bootstrap.yml │ │ └── templates │ │ └── index.html │ ├── comments │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── comments │ │ │ ├── Comment.java │ │ │ ├── CommentController.java │ │ │ ├── CommentRepository.java │ │ │ ├── CommentService.java │ │ │ ├── LearningSpringBootCommentsApplication.java │ │ │ ├── SecurityConfiguration.java │ │ │ └── SessionConfig.java │ │ └── resources │ │ └── bootstrap.yml │ ├── config-server │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── LearningSpringBootConfigServer.java │ │ └── resources │ │ └── application.yml │ ├── eureka-server │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── LearningSpringBootEurekaServerApplication.java │ │ └── resources │ │ └── bootstrap.yml │ ├── hystrix-dashboard │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── LearningSpringBootHystrixDashboard.java │ │ └── resources │ │ └── bootstrap.yml │ └── images │ ├── build.gradle │ └── src │ └── main │ ├── java │ └── com │ │ └── greglturnquist │ │ └── learningspringboot │ │ ├── Authorization.java │ │ ├── CommentSimulator.java │ │ ├── HomeController.java │ │ ├── ImagesConfiguration.java │ │ ├── LearningSpringBootImagesApplication.java │ │ ├── SecurityConfiguration.java │ │ ├── SecurityDialect.java │ │ ├── SecurityDialectPostProcessor.java │ │ ├── SecurityExpressionObjectFactory.java │ │ ├── SessionConfig.java │ │ ├── images │ │ ├── Comment.java │ │ ├── CommentController.java │ │ ├── CommentHelper.java │ │ ├── Config.java │ │ ├── Image.java │ │ ├── ImageRepository.java │ │ ├── ImageService.java │ │ ├── InitDatabase.java │ │ └── UploadController.java │ │ └── ops │ │ └── LearningSpringBootHealthIndicator.java │ └── resources │ ├── bootstrap.yml │ ├── static │ └── main.css │ └── templates │ └── index.html ├── Chapter10 └── part1 │ ├── chat │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── chat │ │ │ ├── AuthorizedWebSocketHandler.java │ │ │ ├── ChatConfigProperties.java │ │ │ ├── ChatController.java │ │ │ ├── ChatServiceStreams.java │ │ │ ├── Comment.java │ │ │ ├── CommentService.java │ │ │ ├── GatewayConfig.java │ │ │ ├── HomeController.java │ │ │ ├── InboundChatService.java │ │ │ ├── LearningSpringBootChatApplication.java │ │ │ ├── OutboundChatService.java │ │ │ ├── SecurityConfiguration.java │ │ │ ├── SessionConfig.java │ │ │ ├── SpringDataUserDetailsRepository.java │ │ │ ├── User.java │ │ │ ├── UserRepository.java │ │ │ └── WebSocketConfig.java │ │ └── resources │ │ ├── bootstrap.yml │ │ └── templates │ │ └── index.html │ ├── clean.sh │ ├── comments │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── comments │ │ │ ├── Comment.java │ │ │ ├── CommentController.java │ │ │ ├── CommentRepository.java │ │ │ ├── CommentService.java │ │ │ ├── LearningSpringBootCommentsApplication.java │ │ │ ├── SecurityConfiguration.java │ │ │ └── SessionConfig.java │ │ └── resources │ │ └── bootstrap.yml │ ├── config-server │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── LearningSpringBootConfigServer.java │ │ └── resources │ │ └── application.yml │ ├── config.sh │ ├── deploy.sh │ ├── eureka-server │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── LearningSpringBootEurekaServerApplication.java │ │ └── resources │ │ └── bootstrap.yml │ ├── hystrix-dashboard │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ └── LearningSpringBootHystrixDashboard.java │ │ └── resources │ │ └── bootstrap.yml │ ├── images │ ├── build.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── greglturnquist │ │ │ └── learningspringboot │ │ │ ├── Authorization.java │ │ │ ├── CommentSimulator.java │ │ │ ├── HomeController.java │ │ │ ├── ImagesConfiguration.java │ │ │ ├── LearningSpringBootImagesApplication.java │ │ │ ├── SecurityConfiguration.java │ │ │ ├── SecurityDialect.java │ │ │ ├── SecurityDialectPostProcessor.java │ │ │ ├── SecurityExpressionObjectFactory.java │ │ │ ├── SessionConfig.java │ │ │ ├── images │ │ │ ├── Comment.java │ │ │ ├── CommentController.java │ │ │ ├── CommentHelper.java │ │ │ ├── Config.java │ │ │ ├── Image.java │ │ │ ├── ImageRepository.java │ │ │ ├── ImageService.java │ │ │ ├── InitDatabase.java │ │ │ └── UploadController.java │ │ │ └── ops │ │ │ └── LearningSpringBootHealthIndicator.java │ │ └── resources │ │ ├── bootstrap.yml │ │ ├── static │ │ └── main.css │ │ └── templates │ │ └── index.html │ └── restart.sh ├── LICENSE ├── README.md ├── build.bash ├── ci.bash ├── ext └── chromedriver ├── gradle └── wrapper │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /Chapter01/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "public/" 3 | } 4 | -------------------------------------------------------------------------------- /Chapter01/.gitignore: -------------------------------------------------------------------------------- 1 | public 2 | -------------------------------------------------------------------------------- /Chapter01/part1/src/main/java/com/greglturnquist/learningspringboot/Chapter.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import lombok.Data; 4 | 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.mongodb.core.mapping.Document; 7 | 8 | @Data 9 | @Document 10 | public class Chapter { 11 | 12 | @Id 13 | private String id; 14 | private String name; 15 | 16 | public Chapter(String name) { 17 | this.name = name; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Chapter01/part1/src/main/java/com/greglturnquist/learningspringboot/ChapterController.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import reactor.core.publisher.Flux; 4 | 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | public class ChapterController { 10 | 11 | private final ChapterRepository repository; 12 | 13 | public ChapterController(ChapterRepository repository) { 14 | this.repository = repository; 15 | } 16 | 17 | @GetMapping("/chapters") 18 | public Flux listing() { 19 | return repository.findAll(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Chapter01/part1/src/main/java/com/greglturnquist/learningspringboot/ChapterRepository.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 4 | 5 | public interface ChapterRepository 6 | extends ReactiveCrudRepository { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /Chapter01/part1/src/main/java/com/greglturnquist/learningspringboot/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RequestParam; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class HomeController { 9 | 10 | @GetMapping 11 | public String greeting(@RequestParam(required = false, 12 | defaultValue = "") String name) { 13 | return name.equals("") 14 | ? "Hey!" 15 | : "Hey, " + name + "!"; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Chapter01/part1/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class LearningSpringBootApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run( 11 | LearningSpringBootApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Chapter01/part1/src/main/java/com/greglturnquist/learningspringboot/LoadDatabase.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import reactor.core.publisher.Flux; 4 | 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | @Configuration 10 | public class LoadDatabase { 11 | 12 | @Bean 13 | CommandLineRunner init(ChapterRepository repository) { 14 | return args -> { 15 | Flux.just( 16 | new Chapter("Quick Start with Java"), 17 | new Chapter("Reactive Web with Spring Boot"), 18 | new Chapter("...and more!")) 19 | .flatMap(repository::save) 20 | .subscribe(System.out::println); 21 | }; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Chapter01/part1/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Override the port Tomcat listens on 2 | server.port=9000 3 | 4 | # Customize log levels 5 | logging.level.com.greglturnquist=DEBUG -------------------------------------------------------------------------------- /Chapter01/part1/src/test/java/com/greglturnquist/learningspringboot/LearningSpringBootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 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 LearningSpringBootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Chapter02/part1/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | nbproject/private/ 21 | build/ 22 | nbbuild/ 23 | dist/ 24 | nbdist/ 25 | .nb-gradle/ -------------------------------------------------------------------------------- /Chapter02/part1/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | // tag::versions[] 3 | ext { 4 | springBootVersion = '2.0.0.M5' 5 | } 6 | // end::versions[] 7 | repositories { 8 | mavenCentral() 9 | maven { url "https://repo.spring.io/snapshot" } 10 | maven { url "https://repo.spring.io/milestone" } 11 | } 12 | dependencies { 13 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 14 | } 15 | } 16 | 17 | apply plugin: 'java' 18 | apply plugin: 'eclipse' 19 | apply plugin: 'org.springframework.boot' 20 | apply plugin: 'io.spring.dependency-management' 21 | 22 | jar { 23 | baseName = 'learning-spring-boot' 24 | version = '0.0.1-SNAPSHOT' 25 | } 26 | 27 | sourceCompatibility = 1.8 28 | 29 | repositories { 30 | mavenCentral() 31 | maven { url "https://repo.spring.io/snapshot" } 32 | maven { url "https://repo.spring.io/milestone" } 33 | maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } 34 | } 35 | 36 | // tag::deps[] 37 | dependencies { 38 | compile('org.springframework.boot:spring-boot-starter-webflux') 39 | compile("org.springframework.boot:spring-boot-starter-thymeleaf") 40 | compile('org.synchronoss.cloud:nio-multipart-parser') 41 | compile('org.projectlombok:lombok') 42 | testCompile('org.springframework.boot:spring-boot-starter-test') 43 | } 44 | // end::deps[] 45 | -------------------------------------------------------------------------------- /Chapter02/part1/src/main/java/com/greglturnquist/learningspringboot/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import lombok.Data; 19 | import lombok.NoArgsConstructor; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | @Data 26 | @NoArgsConstructor 27 | public class Image { 28 | 29 | private String id; 30 | private String name; 31 | 32 | public Image(String id, String name) { 33 | this.id = id; 34 | this.name = name; 35 | } 36 | } 37 | // end::code[] 38 | -------------------------------------------------------------------------------- /Chapter02/part1/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | @SpringBootApplication 9 | public class LearningSpringBootApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(LearningSpringBootApplication.class, args); 13 | } 14 | 15 | @Bean 16 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 17 | return new HiddenHttpMethodFilter(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Chapter02/part1/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Learning-Spring-Boot-2.0-Second-Edition/fe67fc2effc10783a3232b59434ad5c69b497323/Chapter02/part1/src/main/resources/application.properties -------------------------------------------------------------------------------- /Chapter02/part1/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter02/part2/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | nbproject/private/ 21 | build/ 22 | nbbuild/ 23 | dist/ 24 | nbdist/ 25 | .nb-gradle/ -------------------------------------------------------------------------------- /Chapter02/part2/src/main/java/com/greglturnquist/learningspringboot/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import lombok.Data; 19 | import lombok.NoArgsConstructor; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | @Data 26 | @NoArgsConstructor 27 | public class Image { 28 | 29 | private int id; 30 | private String name; 31 | 32 | public Image(int id, String name) { 33 | this.id = id; 34 | this.name = name; 35 | } 36 | } 37 | // end::code[] -------------------------------------------------------------------------------- /Chapter02/part2/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | // tag::code[] 9 | @SpringBootApplication 10 | public class LearningSpringBootApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run( 14 | LearningSpringBootApplication.class, args); 15 | } 16 | 17 | @Bean 18 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 19 | return new HiddenHttpMethodFilter(); 20 | } 21 | 22 | } 23 | // end::code[] -------------------------------------------------------------------------------- /Chapter02/part2/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | logging: 2 | level: 3 | io: 4 | netty: DEBUG 5 | reactor: DEBUG -------------------------------------------------------------------------------- /Chapter02/part2/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | -------------------------------------------------------------------------------- /Chapter03/part1/src/main/java/com/greglturnquist/learningspringboot/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import lombok.Data; 19 | 20 | import org.springframework.data.annotation.Id; 21 | import org.springframework.data.mongodb.core.mapping.Document; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | @Data 28 | @Document 29 | public class Image { 30 | 31 | @Id final private String id; 32 | final private String name; 33 | } 34 | // end::code[] 35 | -------------------------------------------------------------------------------- /Chapter03/part1/src/main/java/com/greglturnquist/learningspringboot/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 19 | import reactor.core.publisher.Mono; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | // end::code[] 31 | -------------------------------------------------------------------------------- /Chapter03/part1/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | @SpringBootApplication 9 | public class LearningSpringBootApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(LearningSpringBootApplication.class, args); 13 | } 14 | 15 | @Bean 16 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 17 | return new HiddenHttpMethodFilter(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Chapter03/part1/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # tag::logging[] 2 | logging.level.com.greglturnquist=DEBUG 3 | logging.level.org.springframework.data=TRACE 4 | logging.level.reactor.core=TRACE 5 | logging.level.reactor.util=TRACE 6 | # end::logging[] -------------------------------------------------------------------------------- /Chapter03/part1/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter03/part1/src/test/java/com/greglturnquist/learningspringboot/Employee.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import lombok.Data; 19 | import org.springframework.data.annotation.Id; 20 | import org.springframework.data.mongodb.core.mapping.Document; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | @Data 27 | @Document 28 | public class Employee { 29 | 30 | @Id private String id; 31 | private String firstName; 32 | private String lastName; 33 | private String role; 34 | } 35 | // end::code[] -------------------------------------------------------------------------------- /Chapter03/part1/src/test/java/com/greglturnquist/learningspringboot/EmployeeRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.data.repository.query.ReactiveQueryByExampleExecutor; 19 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | public interface EmployeeRepository extends 26 | ReactiveCrudRepository, 27 | ReactiveQueryByExampleExecutor { 28 | 29 | } 30 | // end::code[] 31 | -------------------------------------------------------------------------------- /Chapter03/part2/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.0.0.M5' 4 | } 5 | repositories { 6 | mavenCentral() 7 | maven { url "https://repo.spring.io/snapshot" } 8 | maven { url "https://repo.spring.io/milestone" } 9 | } 10 | dependencies { 11 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 12 | } 13 | } 14 | 15 | apply plugin: 'java' 16 | apply plugin: 'eclipse' 17 | apply plugin: 'org.springframework.boot' 18 | apply plugin: 'io.spring.dependency-management' 19 | 20 | jar { 21 | baseName = 'learning-spring-boot' 22 | version = '0.0.1-SNAPSHOT' 23 | } 24 | sourceCompatibility = 1.8 25 | targetCompatibility = 1.8 26 | 27 | repositories { 28 | mavenCentral() 29 | maven { url "https://repo.spring.io/snapshot" } 30 | maven { url "https://repo.spring.io/milestone" } 31 | maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } 32 | } 33 | 34 | dependencies { 35 | compile('org.springframework.boot:spring-boot-starter-webflux') 36 | compile('org.synchronoss.cloud:nio-multipart-parser') 37 | compile('org.springframework.boot:spring-boot-starter-data-mongodb-reactive') 38 | compile("org.springframework.boot:spring-boot-starter-thymeleaf") 39 | compile('org.projectlombok:lombok') 40 | testCompile('org.springframework.boot:spring-boot-starter-test') 41 | testCompile("io.projectreactor:reactor-test") 42 | } 43 | -------------------------------------------------------------------------------- /Chapter03/part2/src/main/java/com/greglturnquist/learningspringboot/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import lombok.Data; 19 | import lombok.NoArgsConstructor; 20 | import org.springframework.data.annotation.Id; 21 | import org.springframework.data.mongodb.core.mapping.Document; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | @Data 28 | @Document 29 | public class Image { 30 | 31 | @Id final private String id; 32 | final private String name; 33 | } 34 | // end::code[] 35 | -------------------------------------------------------------------------------- /Chapter03/part2/src/main/java/com/greglturnquist/learningspringboot/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 19 | import reactor.core.publisher.Mono; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | // end::code[] 31 | -------------------------------------------------------------------------------- /Chapter03/part2/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | @SpringBootApplication 9 | public class LearningSpringBootApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(LearningSpringBootApplication.class, args); 13 | } 14 | 15 | @Bean 16 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 17 | return new HiddenHttpMethodFilter(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Chapter03/part2/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # tag::logging[] 2 | logging.level.com.greglturnquist=DEBUG 3 | logging.level.org.springframework.data=TRACE 4 | logging.level.reactor.core=TRACE 5 | logging.level.reactor.util=TRACE 6 | # end::logging[] -------------------------------------------------------------------------------- /Chapter03/part2/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter03/part2/src/test/java/com/greglturnquist/learningspringboot/Employee.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import lombok.Data; 19 | import org.springframework.data.annotation.Id; 20 | import org.springframework.data.mongodb.core.mapping.Document; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | @Data 27 | @Document 28 | public class Employee { 29 | 30 | @Id private String id; 31 | private String firstName; 32 | private String lastName; 33 | private String role; 34 | } 35 | // end::code[] -------------------------------------------------------------------------------- /Chapter03/part2/src/test/java/com/greglturnquist/learningspringboot/EmployeeRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.data.repository.query.ReactiveQueryByExampleExecutor; 19 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | public interface EmployeeRepository extends 26 | ReactiveCrudRepository, 27 | ReactiveQueryByExampleExecutor { 28 | 29 | } 30 | // end::code[] 31 | -------------------------------------------------------------------------------- /Chapter04/part1/ext/chromedriver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Learning-Spring-Boot-2.0-Second-Edition/fe67fc2effc10783a3232b59434ad5c69b497323/Chapter04/part1/ext/chromedriver -------------------------------------------------------------------------------- /Chapter04/part1/src/main/java/com/greglturnquist/learningspringboot/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import lombok.Data; 19 | import org.springframework.data.annotation.Id; 20 | import org.springframework.data.mongodb.core.mapping.Document; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | @Data 27 | @Document 28 | public class Image { 29 | 30 | @Id final private String id; 31 | final private String name; 32 | } 33 | // end::code[] 34 | -------------------------------------------------------------------------------- /Chapter04/part1/src/main/java/com/greglturnquist/learningspringboot/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 19 | import reactor.core.publisher.Mono; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | // end::code[] 31 | -------------------------------------------------------------------------------- /Chapter04/part1/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | @SpringBootApplication 9 | public class LearningSpringBootApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(LearningSpringBootApplication.class, args); 13 | } 14 | 15 | @Bean 16 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 17 | return new HiddenHttpMethodFilter(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Chapter04/part1/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # tag::logging[] 2 | logging.level.reactor.core=TRACE 3 | logging.level.reactor.util=TRACE 4 | logging.level.org.springframework=TRACE 5 | # end::logging[] -------------------------------------------------------------------------------- /Chapter04/part1/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter04/part1/src/test/java/com/greglturnquist/learningspringboot/ImageTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.junit.Test; 19 | 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | public class ImageTests { 27 | 28 | @Test 29 | public void imagesManagedByLombokShouldWork() { 30 | Image image = new Image("id", "file-name.jpg"); 31 | 32 | assertThat(image.getId()).isEqualTo("id"); 33 | assertThat(image.getName()).isEqualTo("file-name.jpg"); 34 | } 35 | 36 | } 37 | // end::code[] -------------------------------------------------------------------------------- /Chapter04/part2/ext/chromedriver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Learning-Spring-Boot-2.0-Second-Edition/fe67fc2effc10783a3232b59434ad5c69b497323/Chapter04/part2/ext/chromedriver -------------------------------------------------------------------------------- /Chapter04/part2/src/main/java/com/greglturnquist/learningspringboot/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import lombok.Data; 19 | import org.springframework.data.annotation.Id; 20 | import org.springframework.data.mongodb.core.mapping.Document; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | @Data 27 | @Document 28 | public class Image { 29 | 30 | @Id final private String id; 31 | final private String name; 32 | } 33 | // end::code[] 34 | -------------------------------------------------------------------------------- /Chapter04/part2/src/main/java/com/greglturnquist/learningspringboot/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 19 | import reactor.core.publisher.Mono; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | // end::code[] 31 | -------------------------------------------------------------------------------- /Chapter04/part2/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | @SpringBootApplication 9 | public class LearningSpringBootApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(LearningSpringBootApplication.class, args); 13 | } 14 | 15 | // tag::hidden-http-method-filter[] 16 | @Bean 17 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 18 | return new HiddenHttpMethodFilter(); 19 | } 20 | // end::hidden-http-method-filter[] 21 | } 22 | -------------------------------------------------------------------------------- /Chapter04/part2/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # tag::logging[] 2 | logging.level.reactor.core=TRACE 3 | logging.level.reactor.util=TRACE 4 | logging.level.org.springframework.web=TRACE 5 | # end::logging[] -------------------------------------------------------------------------------- /Chapter04/part2/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter04/part2/src/test/java/com/greglturnquist/learningspringboot/ImageTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.junit.Test; 19 | 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | public class ImageTests { 27 | 28 | @Test 29 | public void imagesManagedByLombokShouldWork() { 30 | Image image = new Image("id", "file-name.jpg"); 31 | 32 | assertThat(image.getId()).isEqualTo("id"); 33 | assertThat(image.getName()).isEqualTo("file-name.jpg"); 34 | } 35 | 36 | } 37 | // end::code[] -------------------------------------------------------------------------------- /Chapter05/part1/src/main/java/com/greglturnquist/learningspringboot/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import lombok.Data; 19 | 20 | import org.springframework.data.annotation.Id; 21 | import org.springframework.data.mongodb.core.mapping.Document; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | @Data 27 | @Document 28 | public class Image { 29 | 30 | @Id final private String id; 31 | final private String name; 32 | } 33 | -------------------------------------------------------------------------------- /Chapter05/part1/src/main/java/com/greglturnquist/learningspringboot/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | -------------------------------------------------------------------------------- /Chapter05/part1/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | @SpringBootApplication 9 | public class LearningSpringBootApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(LearningSpringBootApplication.class, args); 13 | } 14 | 15 | @Bean 16 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 17 | return new HiddenHttpMethodFilter(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Chapter05/part1/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.devtools.restart.poll-interval=4000 -------------------------------------------------------------------------------- /Chapter05/part1/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter05/part1/src/test/java/com/greglturnquist/learningspringboot/LearningSpringBootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 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 LearningSpringBootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Chapter05/part2/src/main/java/com/greglturnquist/learningspringboot/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import lombok.Data; 19 | 20 | import org.springframework.data.annotation.Id; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | @Data 26 | public class Image { 27 | 28 | @Id 29 | private String id; 30 | 31 | private String name; 32 | 33 | public Image(String id, String name) { 34 | this.name = name; 35 | } 36 | 37 | public String getId() { 38 | return this.id; 39 | } 40 | 41 | public String getName() { 42 | return this.name; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Chapter05/part2/src/main/java/com/greglturnquist/learningspringboot/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | -------------------------------------------------------------------------------- /Chapter05/part2/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | @SpringBootApplication 9 | public class LearningSpringBootApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(LearningSpringBootApplication.class, args); 13 | } 14 | 15 | @Bean 16 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 17 | return new HiddenHttpMethodFilter(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Chapter05/part2/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.devtools.remote.secret=learning-spring-boot 2 | endpoints.default.web.enabled=true -------------------------------------------------------------------------------- /Chapter05/part2/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter05/part2/src/test/java/com/greglturnquist/learningspringboot/LearningSpringBootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 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 LearningSpringBootApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Chapter06/part1/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | @SpringBootApplication 9 | public class LearningSpringBootApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(LearningSpringBootApplication.class, args); 13 | } 14 | 15 | @Bean 16 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 17 | return new HiddenHttpMethodFilter(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Chapter06/part1/src/main/java/com/greglturnquist/learningspringboot/comments/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.comments; 18 | 19 | import lombok.Data; 20 | 21 | import org.springframework.data.annotation.Id; 22 | import org.springframework.data.mongodb.core.mapping.Document; 23 | 24 | @Data 25 | @Document 26 | public class Comment { 27 | 28 | @Id private String id; 29 | private String imageId; 30 | private String comment; 31 | } 32 | // end::code[] -------------------------------------------------------------------------------- /Chapter06/part1/src/main/java/com/greglturnquist/learningspringboot/comments/CommentWriterRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | import org.springframework.data.repository.Repository; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | public interface CommentWriterRepository 27 | extends Repository { 28 | 29 | Mono save(Comment newComment); 30 | 31 | // Needed to support save() 32 | Mono findById(String id); 33 | } 34 | // end::code[] 35 | -------------------------------------------------------------------------------- /Chapter06/part1/src/main/java/com/greglturnquist/learningspringboot/images/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.images; 18 | 19 | import lombok.Data; 20 | 21 | import org.springframework.data.annotation.Id; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | 30 | } 31 | // end::code[] -------------------------------------------------------------------------------- /Chapter06/part1/src/main/java/com/greglturnquist/learningspringboot/images/CommentReaderRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import reactor.core.publisher.Flux; 19 | 20 | import org.springframework.data.repository.Repository; 21 | 22 | // tag::code[] 23 | public interface CommentReaderRepository 24 | extends Repository { 25 | 26 | Flux findByImageId(String imageId); 27 | } 28 | // end::code[] 29 | -------------------------------------------------------------------------------- /Chapter06/part1/src/main/java/com/greglturnquist/learningspringboot/images/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import lombok.Data; 19 | 20 | import org.springframework.data.annotation.Id; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | @Data 26 | public class Image { 27 | 28 | @Id 29 | private String id; 30 | 31 | private String name; 32 | 33 | public Image(String id, String name) { 34 | this.name = name; 35 | } 36 | 37 | public String getId() { 38 | return this.id; 39 | } 40 | 41 | public String getName() { 42 | return this.name; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Chapter06/part1/src/main/java/com/greglturnquist/learningspringboot/images/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | -------------------------------------------------------------------------------- /Chapter06/part1/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Learning-Spring-Boot-2.0-Second-Edition/fe67fc2effc10783a3232b59434ad5c69b497323/Chapter06/part1/src/main/resources/application.properties -------------------------------------------------------------------------------- /Chapter06/part1/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter06/part2/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | @SpringBootApplication 9 | public class LearningSpringBootApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(LearningSpringBootApplication.class, args); 13 | } 14 | 15 | @Bean 16 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 17 | return new HiddenHttpMethodFilter(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Chapter06/part2/src/main/java/com/greglturnquist/learningspringboot/comments/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.comments; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | } 30 | // end::code[] -------------------------------------------------------------------------------- /Chapter06/part2/src/main/java/com/greglturnquist/learningspringboot/comments/CommentWriterRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | import org.springframework.data.repository.Repository; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | public interface CommentWriterRepository 27 | extends Repository { 28 | 29 | Mono save(Comment newComment); 30 | 31 | // Needed to support save() 32 | Mono findById(String id); 33 | 34 | Mono deleteAll(); 35 | } 36 | // end::code[] 37 | -------------------------------------------------------------------------------- /Chapter06/part2/src/main/java/com/greglturnquist/learningspringboot/images/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.images; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | 30 | } 31 | // end::code[] -------------------------------------------------------------------------------- /Chapter06/part2/src/main/java/com/greglturnquist/learningspringboot/images/CommentReaderRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.images; 18 | 19 | import reactor.core.publisher.Flux; 20 | 21 | import org.springframework.data.repository.Repository; 22 | 23 | public interface CommentReaderRepository 24 | extends Repository { 25 | 26 | Flux findByImageId(String imageId); 27 | } 28 | // end::code[] 29 | -------------------------------------------------------------------------------- /Chapter06/part2/src/main/java/com/greglturnquist/learningspringboot/images/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import lombok.Data; 19 | 20 | import org.springframework.data.annotation.Id; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | @Data 26 | public class Image { 27 | 28 | @Id 29 | private String id; 30 | 31 | private String name; 32 | 33 | public Image(String id, String name) { 34 | this.name = name; 35 | } 36 | 37 | public String getId() { 38 | return this.id; 39 | } 40 | 41 | public String getName() { 42 | return this.name; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Chapter06/part2/src/main/java/com/greglturnquist/learningspringboot/images/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | -------------------------------------------------------------------------------- /Chapter06/part2/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.http.multipart.max-file-size=10MB 2 | 3 | endpoints.default.web.enabled=true -------------------------------------------------------------------------------- /Chapter06/part2/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter06/part3/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator; 4 | 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 9 | 10 | // tag::code[] 11 | @SpringBootApplication 12 | public class LearningSpringBootApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(LearningSpringBootApplication.class, args); 16 | } 17 | 18 | @Bean 19 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 20 | return new HiddenHttpMethodFilter(); 21 | } 22 | 23 | @Bean 24 | ParameterMessageInterpolator parameterMessageInterpolator() { 25 | return new ParameterMessageInterpolator(); 26 | } 27 | } 28 | // end::code[] -------------------------------------------------------------------------------- /Chapter06/part3/src/main/java/com/greglturnquist/learningspringboot/comments/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.comments; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | } 30 | // end::code[] -------------------------------------------------------------------------------- /Chapter06/part3/src/main/java/com/greglturnquist/learningspringboot/comments/CommentWriterRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import reactor.core.publisher.Flux; 19 | import reactor.core.publisher.Mono; 20 | 21 | import org.springframework.data.repository.Repository; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | public interface CommentWriterRepository 28 | extends Repository { 29 | 30 | Flux saveAll(Flux newComment); 31 | 32 | // Needed to support save() 33 | Mono findById(String id); 34 | 35 | Mono deleteAll(); 36 | } 37 | // end::code[] 38 | -------------------------------------------------------------------------------- /Chapter06/part3/src/main/java/com/greglturnquist/learningspringboot/images/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.images; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | 30 | } 31 | // end::code[] -------------------------------------------------------------------------------- /Chapter06/part3/src/main/java/com/greglturnquist/learningspringboot/images/CommentReaderRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.images; 18 | 19 | import reactor.core.publisher.Flux; 20 | 21 | import org.springframework.data.repository.Repository; 22 | 23 | public interface CommentReaderRepository 24 | extends Repository { 25 | 26 | Flux findByImageId(String imageId); 27 | } 28 | // end::code[] 29 | -------------------------------------------------------------------------------- /Chapter06/part3/src/main/java/com/greglturnquist/learningspringboot/images/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import lombok.Data; 19 | 20 | import org.springframework.data.annotation.Id; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | @Data 26 | public class Image { 27 | 28 | @Id 29 | private String id; 30 | 31 | private String name; 32 | 33 | public Image(String id, String name) { 34 | this.name = name; 35 | } 36 | 37 | public String getId() { 38 | return this.id; 39 | } 40 | 41 | public String getName() { 42 | return this.name; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Chapter06/part3/src/main/java/com/greglturnquist/learningspringboot/images/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | -------------------------------------------------------------------------------- /Chapter06/part3/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # tag::settings[] 2 | spring: 3 | cloud: 4 | stream: 5 | bindings: 6 | input: 7 | destination: learning-spring-boot-comments 8 | group: learning-spring-boot 9 | output: 10 | destination: learning-spring-boot-comments 11 | group: learning-spring-boot 12 | # end::settings[] 13 | # tag::logs[] 14 | logging: 15 | level: 16 | org: 17 | springframework: 18 | cloud: DEBUG 19 | integration: DEBUG 20 | # end::logs[] -------------------------------------------------------------------------------- /Chapter06/part3/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter07/part1/comments/src/main/java/com/greglturnquist/learningspringboot/comments/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.comments; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | } 30 | // end::code[] -------------------------------------------------------------------------------- /Chapter07/part1/comments/src/main/java/com/greglturnquist/learningspringboot/comments/CommentRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import reactor.core.publisher.Flux; 19 | import reactor.core.publisher.Mono; 20 | 21 | import org.springframework.data.repository.Repository; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | public interface CommentRepository 28 | extends Repository { 29 | 30 | Flux findByImageId(String imageId); 31 | 32 | Flux saveAll(Flux newComment); 33 | 34 | // Required to support save() 35 | Mono findById(String id); 36 | 37 | Mono deleteAll(); 38 | } 39 | // end::code[] 40 | -------------------------------------------------------------------------------- /Chapter07/part1/comments/src/main/java/com/greglturnquist/learningspringboot/comments/LearningSpringBootCommentsApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.cloud.client.SpringCloudApplication; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | @SpringCloudApplication 26 | public class LearningSpringBootCommentsApplication { 27 | 28 | public static void main(String[] args) { 29 | SpringApplication.run( 30 | LearningSpringBootCommentsApplication.class); 31 | } 32 | } 33 | // end::code[] 34 | -------------------------------------------------------------------------------- /Chapter07/part1/comments/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9000 3 | 4 | spring: 5 | cloud: 6 | stream: 7 | bindings: 8 | input: 9 | destination: learning-spring-boot 10 | group: comments 11 | content-type: application/json 12 | output: 13 | destination: learning-spring-boot 14 | application: 15 | name: comments -------------------------------------------------------------------------------- /Chapter07/part1/eureka-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8761 3 | 4 | eureka: 5 | instance: 6 | hostname: localhost 7 | client: 8 | registerWithEureka: false 9 | fetchRegistry: false 10 | serviceUrl: 11 | defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ -------------------------------------------------------------------------------- /Chapter07/part1/images/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootImagesApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | // tag::code[] 9 | @SpringCloudApplication 10 | public class LearningSpringBootImagesApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run( 14 | LearningSpringBootImagesApplication.class, args); 15 | } 16 | 17 | @Bean 18 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 19 | return new HiddenHttpMethodFilter(); 20 | } 21 | 22 | } 23 | // end::code[] -------------------------------------------------------------------------------- /Chapter07/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.images; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | 30 | } 31 | // end::code[] -------------------------------------------------------------------------------- /Chapter07/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 19 | import org.springframework.context.annotation.Bean; 20 | import org.springframework.context.annotation.Configuration; 21 | import org.springframework.web.client.RestTemplate; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | @Configuration 28 | public class Config { 29 | 30 | @Bean 31 | @LoadBalanced 32 | RestTemplate restTemplate() { 33 | return new RestTemplate(); 34 | } 35 | } 36 | // end::code[] 37 | -------------------------------------------------------------------------------- /Chapter07/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import lombok.Data; 19 | 20 | import org.springframework.data.annotation.Id; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | @Data 26 | public class Image { 27 | 28 | @Id 29 | private String id; 30 | 31 | private String name; 32 | 33 | public Image(String id, String name) { 34 | this.name = name; 35 | } 36 | 37 | public String getId() { 38 | return this.id; 39 | } 40 | 41 | public String getName() { 42 | return this.name; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Chapter07/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | -------------------------------------------------------------------------------- /Chapter07/part1/images/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | client: 3 | serviceUrl: 4 | defaultZone: http://localhost:8761/eureka/ 5 | 6 | spring: 7 | http: 8 | multipart: 9 | max-file-size: 10MB 10 | cloud: 11 | stream: 12 | bindings: 13 | input: 14 | destination: learning-spring-boot 15 | output: 16 | destination: learning-spring-boot 17 | group: comments 18 | content-type: application/json 19 | application: 20 | name: images -------------------------------------------------------------------------------- /Chapter07/part1/images/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter07/part2/comments/src/main/java/com/greglturnquist/learningspringboot/comments/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.comments; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | } 30 | // end::code[] -------------------------------------------------------------------------------- /Chapter07/part2/comments/src/main/java/com/greglturnquist/learningspringboot/comments/CommentRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import reactor.core.publisher.Flux; 19 | import reactor.core.publisher.Mono; 20 | 21 | import org.springframework.data.repository.Repository; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | public interface CommentRepository 28 | extends Repository { 29 | 30 | Flux findByImageId(String imageId); 31 | 32 | Flux saveAll(Flux newComment); 33 | 34 | // Required to support save() 35 | Mono findById(String id); 36 | 37 | Mono deleteAll(); 38 | } 39 | // end::code[] 40 | -------------------------------------------------------------------------------- /Chapter07/part2/comments/src/main/java/com/greglturnquist/learningspringboot/comments/LearningSpringBootCommentsApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.cloud.client.SpringCloudApplication; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | @SpringCloudApplication 26 | public class LearningSpringBootCommentsApplication { 27 | 28 | public static void main(String[] args) { 29 | SpringApplication.run( 30 | LearningSpringBootCommentsApplication.class); 31 | } 32 | } 33 | // end::code[] 34 | -------------------------------------------------------------------------------- /Chapter07/part2/comments/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 9000 3 | 4 | spring: 5 | cloud: 6 | stream: 7 | bindings: 8 | input: 9 | destination: learning-spring-boot 10 | group: comments 11 | content-type: application/json 12 | output: 13 | destination: learning-spring-boot 14 | application: 15 | name: comments 16 | 17 | -------------------------------------------------------------------------------- /Chapter07/part2/eureka-server/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.0.0.M5' 4 | springCloudVersion = 'Finchley.M3' 5 | } 6 | repositories { 7 | mavenCentral() 8 | maven { url "https://repo.spring.io/snapshot" } 9 | maven { url "https://repo.spring.io/milestone" } 10 | } 11 | dependencies { 12 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 13 | } 14 | } 15 | 16 | plugins { 17 | // tag::gradle-git[] 18 | id "com.gorylenko.gradle-git-properties" version "1.4.17" 19 | // end::gradle-git[] 20 | } 21 | 22 | apply plugin: 'java' 23 | apply plugin: 'eclipse' 24 | apply plugin: 'org.springframework.boot' 25 | apply plugin: 'io.spring.dependency-management' 26 | 27 | sourceCompatibility = 1.8 28 | targetCompatibility = 1.8 29 | 30 | repositories { 31 | mavenCentral() 32 | maven { url "https://repo.spring.io/snapshot" } 33 | maven { url "https://repo.spring.io/milestone" } 34 | } 35 | 36 | jar { 37 | baseName = 'learning-spring-boot-eureka-server' 38 | version = '0.0.1-SNAPSHOT' 39 | } 40 | 41 | // tag::code[] 42 | dependencies { 43 | compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-server') 44 | } 45 | 46 | dependencyManagement { 47 | imports { 48 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" 49 | } 50 | } 51 | // end::code[] -------------------------------------------------------------------------------- /Chapter07/part2/eureka-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8761 3 | 4 | eureka: 5 | instance: 6 | hostname: localhost 7 | client: 8 | registerWithEureka: false 9 | fetchRegistry: false 10 | serviceUrl: 11 | defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ -------------------------------------------------------------------------------- /Chapter07/part2/hystrix-dashboard/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootHystrixDashboard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | @SpringBootApplication 27 | @EnableHystrixDashboard 28 | public class LearningSpringBootHystrixDashboard { 29 | 30 | public static void main(String[] args) { 31 | SpringApplication.run( 32 | LearningSpringBootHystrixDashboard.class); 33 | } 34 | } 35 | // end::code[] -------------------------------------------------------------------------------- /Chapter07/part2/hystrix-dashboard/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 7979 3 | -------------------------------------------------------------------------------- /Chapter07/part2/images/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootImagesApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | // tag::code[] 9 | @SpringCloudApplication 10 | public class LearningSpringBootImagesApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run( 14 | LearningSpringBootImagesApplication.class, args); 15 | } 16 | 17 | @Bean 18 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 19 | return new HiddenHttpMethodFilter(); 20 | } 21 | } 22 | // end::code[] -------------------------------------------------------------------------------- /Chapter07/part2/images/src/main/java/com/greglturnquist/learningspringboot/images/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.images; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | 30 | } 31 | // end::code[] -------------------------------------------------------------------------------- /Chapter07/part2/images/src/main/java/com/greglturnquist/learningspringboot/images/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 19 | import org.springframework.context.annotation.Bean; 20 | import org.springframework.context.annotation.Configuration; 21 | import org.springframework.web.client.RestTemplate; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | @Configuration 28 | public class Config { 29 | 30 | @Bean 31 | @LoadBalanced 32 | RestTemplate restTemplate() { 33 | return new RestTemplate(); 34 | } 35 | } 36 | // end::code[] 37 | -------------------------------------------------------------------------------- /Chapter07/part2/images/src/main/java/com/greglturnquist/learningspringboot/images/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import lombok.Data; 19 | 20 | import org.springframework.data.annotation.Id; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | @Data 26 | public class Image { 27 | 28 | @Id 29 | private String id; 30 | 31 | private String name; 32 | 33 | public Image(String id, String name) { 34 | this.name = name; 35 | } 36 | 37 | public String getId() { 38 | return this.id; 39 | } 40 | 41 | public String getName() { 42 | return this.name; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Chapter07/part2/images/src/main/java/com/greglturnquist/learningspringboot/images/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | -------------------------------------------------------------------------------- /Chapter07/part2/images/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | client: 3 | serviceUrl: 4 | defaultZone: http://localhost:8761/eureka/ 5 | 6 | spring: 7 | http: 8 | multipart: 9 | max-file-size: 10MB 10 | cloud: 11 | stream: 12 | bindings: 13 | input: 14 | destination: learning-spring-boot 15 | output: 16 | destination: learning-spring-boot 17 | group: comments 18 | content-type: application/json 19 | application: 20 | name: images -------------------------------------------------------------------------------- /Chapter07/part2/images/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter07/part3/comments/src/main/java/com/greglturnquist/learningspringboot/comments/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.comments; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | } 30 | // end::code[] -------------------------------------------------------------------------------- /Chapter07/part3/comments/src/main/java/com/greglturnquist/learningspringboot/comments/CommentRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import reactor.core.publisher.Flux; 19 | import reactor.core.publisher.Mono; 20 | 21 | import org.springframework.data.repository.Repository; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | public interface CommentRepository 28 | extends Repository { 29 | 30 | Flux findByImageId(String imageId); 31 | 32 | Flux saveAll(Flux newComment); 33 | 34 | // Required to support save() 35 | Mono findById(String id); 36 | 37 | Mono deleteAll(); 38 | } 39 | // end::code[] 40 | -------------------------------------------------------------------------------- /Chapter07/part3/comments/src/main/java/com/greglturnquist/learningspringboot/comments/LearningSpringBootCommentsApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.cloud.client.SpringCloudApplication; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | @SpringCloudApplication 26 | public class LearningSpringBootCommentsApplication { 27 | 28 | public static void main(String[] args) { 29 | SpringApplication.run( 30 | LearningSpringBootCommentsApplication.class); 31 | } 32 | } 33 | // end::code[] 34 | -------------------------------------------------------------------------------- /Chapter07/part3/comments/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: comments -------------------------------------------------------------------------------- /Chapter07/part3/config-server/build.gradle: -------------------------------------------------------------------------------- 1 | // tag::versions[] 2 | buildscript { 3 | ext { 4 | springBootVersion = '2.0.0.M5' 5 | springCloudVersion = 'Finchley.M3' 6 | } 7 | // end::versions[] 8 | repositories { 9 | mavenCentral() 10 | maven { url "https://repo.spring.io/snapshot" } 11 | maven { url "https://repo.spring.io/milestone" } 12 | } 13 | dependencies { 14 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 15 | } 16 | } 17 | 18 | plugins { 19 | // tag::gradle-git[] 20 | id "com.gorylenko.gradle-git-properties" version "1.4.17" 21 | // end::gradle-git[] 22 | } 23 | 24 | apply plugin: 'java' 25 | apply plugin: 'eclipse' 26 | apply plugin: 'org.springframework.boot' 27 | apply plugin: 'io.spring.dependency-management' 28 | 29 | sourceCompatibility = 1.8 30 | targetCompatibility = 1.8 31 | 32 | repositories { 33 | mavenCentral() 34 | maven { url "https://repo.spring.io/snapshot" } 35 | maven { url "https://repo.spring.io/milestone" } 36 | } 37 | 38 | jar { 39 | baseName = 'learning-spring-boot-eureka-server' 40 | version = '0.0.1-SNAPSHOT' 41 | } 42 | 43 | // tag::code[] 44 | dependencies { 45 | compile('org.springframework.cloud:spring-cloud-config-server') 46 | } 47 | 48 | dependencyManagement { 49 | imports { 50 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" 51 | } 52 | } 53 | // end::code[] -------------------------------------------------------------------------------- /Chapter07/part3/config-server/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootConfigServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.cloud.config.server.EnableConfigServer; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | @SpringBootApplication 27 | @EnableConfigServer 28 | public class LearningSpringBootConfigServer { 29 | 30 | public static void main(String[] args) { 31 | SpringApplication.run( 32 | LearningSpringBootConfigServer.class, args); 33 | } 34 | } 35 | // end::code[] 36 | -------------------------------------------------------------------------------- /Chapter07/part3/config-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8888 3 | 4 | spring: 5 | cloud: 6 | config: 7 | server: 8 | git: 9 | uri: https://github.com/gregturn/learning-spring-boot-config-repo 10 | -------------------------------------------------------------------------------- /Chapter07/part3/eureka-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: eureka -------------------------------------------------------------------------------- /Chapter07/part3/hystrix-dashboard/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootHystrixDashboard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | @SpringBootApplication 27 | @EnableHystrixDashboard 28 | public class LearningSpringBootHystrixDashboard { 29 | 30 | public static void main(String[] args) { 31 | SpringApplication.run( 32 | LearningSpringBootHystrixDashboard.class); 33 | } 34 | } 35 | // end::code[] -------------------------------------------------------------------------------- /Chapter07/part3/hystrix-dashboard/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: hystrix-dashboard -------------------------------------------------------------------------------- /Chapter07/part3/images/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootImagesApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | // tag::code[] 9 | @SpringCloudApplication 10 | public class LearningSpringBootImagesApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run( 14 | LearningSpringBootImagesApplication.class, args); 15 | } 16 | 17 | @Bean 18 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 19 | return new HiddenHttpMethodFilter(); 20 | } 21 | 22 | } 23 | // end::code[] -------------------------------------------------------------------------------- /Chapter07/part3/images/src/main/java/com/greglturnquist/learningspringboot/images/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.images; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | 30 | } 31 | // end::code[] -------------------------------------------------------------------------------- /Chapter07/part3/images/src/main/java/com/greglturnquist/learningspringboot/images/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 19 | import org.springframework.context.annotation.Bean; 20 | import org.springframework.context.annotation.Configuration; 21 | import org.springframework.web.client.RestTemplate; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | @Configuration 28 | public class Config { 29 | 30 | @Bean 31 | @LoadBalanced 32 | RestTemplate restTemplate() { 33 | return new RestTemplate(); 34 | } 35 | } 36 | // end::code[] 37 | -------------------------------------------------------------------------------- /Chapter07/part3/images/src/main/java/com/greglturnquist/learningspringboot/images/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import lombok.Data; 19 | 20 | import org.springframework.data.annotation.Id; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | @Data 26 | public class Image { 27 | 28 | @Id 29 | private String id; 30 | 31 | private String name; 32 | 33 | public Image(String id, String name) { 34 | this.name = name; 35 | } 36 | 37 | public String getId() { 38 | return this.id; 39 | } 40 | 41 | public String getName() { 42 | return this.name; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Chapter07/part3/images/src/main/java/com/greglturnquist/learningspringboot/images/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | -------------------------------------------------------------------------------- /Chapter07/part3/images/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: images -------------------------------------------------------------------------------- /Chapter07/part3/images/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter08/part1/chat/src/main/java/com/greglturnquist/learningspringboot/chat/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.chat; 17 | 18 | import lombok.Data; 19 | 20 | /** 21 | * @author Greg Turnquist 22 | */ 23 | // tag::code[] 24 | @Data 25 | public class Comment { 26 | 27 | private String id; 28 | private String imageId; 29 | private String comment; 30 | } 31 | // end::code[] 32 | -------------------------------------------------------------------------------- /Chapter08/part1/chat/src/main/java/com/greglturnquist/learningspringboot/chat/LearningSpringBootChatApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot.chat; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 6 | 7 | // tag::code[] 8 | @SpringBootApplication 9 | @EnableEurekaClient 10 | public class LearningSpringBootChatApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run( 14 | LearningSpringBootChatApplication.class, args); 15 | } 16 | } 17 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part1/chat/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.reactor.core=TRACE 2 | logging.level.reactor.util=TRACE 3 | -------------------------------------------------------------------------------- /Chapter08/part1/chat/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: chat 4 | -------------------------------------------------------------------------------- /Chapter08/part1/comments/src/main/java/com/greglturnquist/learningspringboot/comments/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.comments; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | } 30 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part1/comments/src/main/java/com/greglturnquist/learningspringboot/comments/CommentRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import reactor.core.publisher.Flux; 19 | import reactor.core.publisher.Mono; 20 | 21 | import org.springframework.data.repository.Repository; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | public interface CommentRepository 28 | extends Repository { 29 | 30 | Flux findByImageId(String imageId); 31 | 32 | Flux saveAll(Flux newComment); 33 | 34 | // Required to support save() 35 | Mono findById(String id); 36 | 37 | Mono deleteAll(); 38 | } 39 | // end::code[] 40 | -------------------------------------------------------------------------------- /Chapter08/part1/comments/src/main/java/com/greglturnquist/learningspringboot/comments/LearningSpringBootCommentsApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.cloud.client.SpringCloudApplication; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | @SpringCloudApplication 26 | public class LearningSpringBootCommentsApplication { 27 | 28 | public static void main(String[] args) { 29 | SpringApplication.run( 30 | LearningSpringBootCommentsApplication.class); 31 | } 32 | } 33 | // end::code[] 34 | -------------------------------------------------------------------------------- /Chapter08/part1/comments/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: comments -------------------------------------------------------------------------------- /Chapter08/part1/config-server/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.0.0.M5' 4 | springCloudVersion = 'Finchley.M3' 5 | } 6 | repositories { 7 | mavenCentral() 8 | maven { url "https://repo.spring.io/snapshot" } 9 | maven { url "https://repo.spring.io/milestone" } 10 | } 11 | dependencies { 12 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 13 | } 14 | } 15 | 16 | plugins { 17 | // tag::gradle-git[] 18 | id "com.gorylenko.gradle-git-properties" version "1.4.17" 19 | // end::gradle-git[] 20 | } 21 | 22 | apply plugin: 'java' 23 | apply plugin: 'eclipse' 24 | apply plugin: 'org.springframework.boot' 25 | apply plugin: 'io.spring.dependency-management' 26 | 27 | sourceCompatibility = 1.8 28 | targetCompatibility = 1.8 29 | 30 | repositories { 31 | mavenCentral() 32 | maven { url "https://repo.spring.io/snapshot" } 33 | maven { url "https://repo.spring.io/milestone" } 34 | } 35 | 36 | jar { 37 | baseName = 'learning-spring-boot-eureka-server' 38 | version = '0.0.1-SNAPSHOT' 39 | } 40 | 41 | // tag::code[] 42 | dependencies { 43 | compile('org.springframework.cloud:spring-cloud-config-server') 44 | } 45 | 46 | dependencyManagement { 47 | imports { 48 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" 49 | } 50 | } 51 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part1/config-server/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootConfigServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.cloud.config.server.EnableConfigServer; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | @SpringBootApplication 27 | @EnableConfigServer 28 | public class LearningSpringBootConfigServer { 29 | 30 | public static void main(String[] args) { 31 | SpringApplication.run( 32 | LearningSpringBootConfigServer.class, args); 33 | } 34 | } 35 | // end::code[] 36 | -------------------------------------------------------------------------------- /Chapter08/part1/config-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8888 3 | 4 | spring: 5 | cloud: 6 | config: 7 | server: 8 | git: 9 | uri: https://github.com/gregturn/learning-spring-boot-config-repo 10 | -------------------------------------------------------------------------------- /Chapter08/part1/eureka-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: eureka -------------------------------------------------------------------------------- /Chapter08/part1/hystrix-dashboard/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootHystrixDashboard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | @SpringBootApplication 27 | @EnableHystrixDashboard 28 | public class LearningSpringBootHystrixDashboard { 29 | 30 | public static void main(String[] args) { 31 | SpringApplication.run( 32 | LearningSpringBootHystrixDashboard.class); 33 | } 34 | } 35 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part1/hystrix-dashboard/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: hystrix-dashboard -------------------------------------------------------------------------------- /Chapter08/part1/images/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootImagesApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | // tag::code[] 9 | @SpringCloudApplication 10 | public class LearningSpringBootImagesApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run( 14 | LearningSpringBootImagesApplication.class, args); 15 | } 16 | 17 | @Bean 18 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 19 | return new HiddenHttpMethodFilter(); 20 | } 21 | } 22 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.images; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | 30 | } 31 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 19 | import org.springframework.context.annotation.Bean; 20 | import org.springframework.context.annotation.Configuration; 21 | import org.springframework.web.client.RestTemplate; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | @Configuration 28 | public class Config { 29 | 30 | @Bean 31 | @LoadBalanced 32 | RestTemplate restTemplate() { 33 | return new RestTemplate(); 34 | } 35 | } 36 | // end::code[] 37 | -------------------------------------------------------------------------------- /Chapter08/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import lombok.Data; 19 | 20 | import org.springframework.data.annotation.Id; 21 | import org.springframework.data.mongodb.core.mapping.Document; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | @Data 27 | @Document 28 | public class Image { 29 | 30 | @Id private final String id; 31 | private final String name; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Chapter08/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | -------------------------------------------------------------------------------- /Chapter08/part1/images/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.reactor.core=TRACE 2 | logging.level.reactor.util=TRACE 3 | logging.level.org.springframework=TRACE 4 | -------------------------------------------------------------------------------- /Chapter08/part1/images/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: images -------------------------------------------------------------------------------- /Chapter08/part1/images/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter08/part2/chat/src/main/java/com/greglturnquist/learningspringboot/chat/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.chat; 17 | 18 | import lombok.Data; 19 | 20 | /** 21 | * @author Greg Turnquist 22 | */ 23 | @Data 24 | public class Comment { 25 | 26 | private String id; 27 | private String imageId; 28 | private String comment; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Chapter08/part2/chat/src/main/java/com/greglturnquist/learningspringboot/chat/LearningSpringBootChatApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot.chat; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | 6 | // tag::code[] 7 | //@SpringCloudApplication 8 | @SpringCloudApplication 9 | public class LearningSpringBootChatApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run( 13 | LearningSpringBootChatApplication.class, args); 14 | } 15 | } 16 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part2/chat/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: chat 4 | -------------------------------------------------------------------------------- /Chapter08/part2/comments/src/main/java/com/greglturnquist/learningspringboot/comments/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.comments; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | } 30 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part2/comments/src/main/java/com/greglturnquist/learningspringboot/comments/CommentRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import reactor.core.publisher.Flux; 19 | import reactor.core.publisher.Mono; 20 | 21 | import org.springframework.data.repository.Repository; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | public interface CommentRepository 28 | extends Repository { 29 | 30 | Flux findByImageId(String imageId); 31 | 32 | Flux saveAll(Flux newComment); 33 | 34 | // Required to support save() 35 | Mono findById(String id); 36 | 37 | Mono deleteAll(); 38 | } 39 | // end::code[] 40 | -------------------------------------------------------------------------------- /Chapter08/part2/comments/src/main/java/com/greglturnquist/learningspringboot/comments/LearningSpringBootCommentsApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.cloud.client.SpringCloudApplication; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | @SpringCloudApplication 26 | public class LearningSpringBootCommentsApplication { 27 | 28 | public static void main(String[] args) { 29 | SpringApplication.run( 30 | LearningSpringBootCommentsApplication.class); 31 | } 32 | } 33 | // end::code[] 34 | -------------------------------------------------------------------------------- /Chapter08/part2/comments/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: comments -------------------------------------------------------------------------------- /Chapter08/part2/config-server/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.0.0.M5' 4 | springCloudVersion = 'Finchley.M3' 5 | } 6 | repositories { 7 | mavenCentral() 8 | maven { url "https://repo.spring.io/snapshot" } 9 | maven { url "https://repo.spring.io/milestone" } 10 | } 11 | dependencies { 12 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 13 | } 14 | } 15 | 16 | plugins { 17 | // tag::gradle-git[] 18 | id "com.gorylenko.gradle-git-properties" version "1.4.17" 19 | // end::gradle-git[] 20 | } 21 | 22 | apply plugin: 'java' 23 | apply plugin: 'eclipse' 24 | apply plugin: 'org.springframework.boot' 25 | apply plugin: 'io.spring.dependency-management' 26 | 27 | sourceCompatibility = 1.8 28 | targetCompatibility = 1.8 29 | 30 | repositories { 31 | mavenCentral() 32 | maven { url "https://repo.spring.io/snapshot" } 33 | maven { url "https://repo.spring.io/milestone" } 34 | } 35 | 36 | jar { 37 | baseName = 'learning-spring-boot-eureka-server' 38 | version = '0.0.1-SNAPSHOT' 39 | } 40 | 41 | // tag::code[] 42 | dependencies { 43 | compile('org.springframework.cloud:spring-cloud-config-server') 44 | } 45 | 46 | dependencyManagement { 47 | imports { 48 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" 49 | } 50 | } 51 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part2/config-server/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootConfigServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.cloud.config.server.EnableConfigServer; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | @SpringBootApplication 27 | @EnableConfigServer 28 | public class LearningSpringBootConfigServer { 29 | 30 | public static void main(String[] args) { 31 | SpringApplication.run( 32 | LearningSpringBootConfigServer.class, args); 33 | } 34 | } 35 | // end::code[] 36 | -------------------------------------------------------------------------------- /Chapter08/part2/config-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8888 3 | 4 | spring: 5 | cloud: 6 | config: 7 | server: 8 | git: 9 | uri: https://github.com/gregturn/learning-spring-boot-config-repo 10 | -------------------------------------------------------------------------------- /Chapter08/part2/eureka-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: eureka -------------------------------------------------------------------------------- /Chapter08/part2/hystrix-dashboard/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootHystrixDashboard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | @SpringBootApplication 27 | @EnableHystrixDashboard 28 | public class LearningSpringBootHystrixDashboard { 29 | 30 | public static void main(String[] args) { 31 | SpringApplication.run( 32 | LearningSpringBootHystrixDashboard.class); 33 | } 34 | } 35 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part2/hystrix-dashboard/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: hystrix-dashboard -------------------------------------------------------------------------------- /Chapter08/part2/images/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootImagesApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | // tag::code[] 9 | @SpringCloudApplication 10 | public class LearningSpringBootImagesApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run( 14 | LearningSpringBootImagesApplication.class, args); 15 | } 16 | 17 | @Bean 18 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 19 | return new HiddenHttpMethodFilter(); 20 | } 21 | } 22 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part2/images/src/main/java/com/greglturnquist/learningspringboot/images/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.images; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | 30 | } 31 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part2/images/src/main/java/com/greglturnquist/learningspringboot/images/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 19 | import org.springframework.context.annotation.Bean; 20 | import org.springframework.context.annotation.Configuration; 21 | import org.springframework.web.client.RestTemplate; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | @Configuration 28 | public class Config { 29 | 30 | @Bean 31 | @LoadBalanced 32 | RestTemplate restTemplate() { 33 | return new RestTemplate(); 34 | } 35 | } 36 | // end::code[] 37 | -------------------------------------------------------------------------------- /Chapter08/part2/images/src/main/java/com/greglturnquist/learningspringboot/images/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import lombok.Data; 19 | 20 | import org.springframework.data.annotation.Id; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | @Data 26 | public class Image { 27 | 28 | @Id 29 | private String id; 30 | 31 | private String name; 32 | 33 | public Image(String id, String name) { 34 | this.name = name; 35 | } 36 | 37 | public String getId() { 38 | return this.id; 39 | } 40 | 41 | public String getName() { 42 | return this.name; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Chapter08/part2/images/src/main/java/com/greglturnquist/learningspringboot/images/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | -------------------------------------------------------------------------------- /Chapter08/part2/images/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: images -------------------------------------------------------------------------------- /Chapter08/part2/images/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter08/part3/chat/src/main/java/com/greglturnquist/learningspringboot/chat/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.chat; 17 | 18 | import lombok.Data; 19 | 20 | /** 21 | * @author Greg Turnquist 22 | */ 23 | @Data 24 | public class Comment { 25 | 26 | private String id; 27 | private String imageId; 28 | private String comment; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Chapter08/part3/chat/src/main/java/com/greglturnquist/learningspringboot/chat/LearningSpringBootChatApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot.chat; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | 6 | // tag::code[] 7 | //@SpringCloudApplication 8 | @SpringCloudApplication 9 | public class LearningSpringBootChatApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run( 13 | LearningSpringBootChatApplication.class, args); 14 | } 15 | } 16 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part3/chat/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: chat 4 | -------------------------------------------------------------------------------- /Chapter08/part3/comments/src/main/java/com/greglturnquist/learningspringboot/comments/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.comments; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | } 30 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part3/comments/src/main/java/com/greglturnquist/learningspringboot/comments/CommentRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import reactor.core.publisher.Flux; 19 | import reactor.core.publisher.Mono; 20 | 21 | import org.springframework.data.repository.Repository; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | public interface CommentRepository 28 | extends Repository { 29 | 30 | Flux findByImageId(String imageId); 31 | 32 | Flux saveAll(Flux newComment); 33 | 34 | // Required to support save() 35 | Mono findById(String id); 36 | 37 | Mono deleteAll(); 38 | } 39 | // end::code[] 40 | -------------------------------------------------------------------------------- /Chapter08/part3/comments/src/main/java/com/greglturnquist/learningspringboot/comments/LearningSpringBootCommentsApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.cloud.client.SpringCloudApplication; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | @SpringCloudApplication 26 | public class LearningSpringBootCommentsApplication { 27 | 28 | public static void main(String[] args) { 29 | SpringApplication.run( 30 | LearningSpringBootCommentsApplication.class); 31 | } 32 | } 33 | // end::code[] 34 | -------------------------------------------------------------------------------- /Chapter08/part3/comments/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: comments -------------------------------------------------------------------------------- /Chapter08/part3/config-server/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.0.0.M5' 4 | springCloudVersion = 'Finchley.M3' 5 | } 6 | repositories { 7 | mavenCentral() 8 | maven { url "https://repo.spring.io/snapshot" } 9 | maven { url "https://repo.spring.io/milestone" } 10 | } 11 | dependencies { 12 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 13 | } 14 | } 15 | 16 | plugins { 17 | // tag::gradle-git[] 18 | id "com.gorylenko.gradle-git-properties" version "1.4.17" 19 | // end::gradle-git[] 20 | } 21 | 22 | apply plugin: 'java' 23 | apply plugin: 'eclipse' 24 | apply plugin: 'org.springframework.boot' 25 | apply plugin: 'io.spring.dependency-management' 26 | 27 | sourceCompatibility = 1.8 28 | targetCompatibility = 1.8 29 | 30 | repositories { 31 | mavenCentral() 32 | maven { url "https://repo.spring.io/snapshot" } 33 | maven { url "https://repo.spring.io/milestone" } 34 | } 35 | 36 | jar { 37 | baseName = 'learning-spring-boot-eureka-server' 38 | version = '0.0.1-SNAPSHOT' 39 | } 40 | 41 | // tag::code[] 42 | dependencies { 43 | compile('org.springframework.cloud:spring-cloud-config-server') 44 | } 45 | 46 | dependencyManagement { 47 | imports { 48 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" 49 | } 50 | } 51 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part3/config-server/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootConfigServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.cloud.config.server.EnableConfigServer; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | @SpringBootApplication 27 | @EnableConfigServer 28 | public class LearningSpringBootConfigServer { 29 | 30 | public static void main(String[] args) { 31 | SpringApplication.run( 32 | LearningSpringBootConfigServer.class, args); 33 | } 34 | } 35 | // end::code[] 36 | -------------------------------------------------------------------------------- /Chapter08/part3/config-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8888 3 | 4 | spring: 5 | cloud: 6 | config: 7 | server: 8 | git: 9 | uri: https://github.com/gregturn/learning-spring-boot-config-repo 10 | -------------------------------------------------------------------------------- /Chapter08/part3/eureka-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: eureka -------------------------------------------------------------------------------- /Chapter08/part3/hystrix-dashboard/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: hystrix-dashboard -------------------------------------------------------------------------------- /Chapter08/part3/images/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootImagesApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | // tag::code[] 9 | @SpringCloudApplication 10 | public class LearningSpringBootImagesApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run( 14 | LearningSpringBootImagesApplication.class, args); 15 | } 16 | 17 | @Bean 18 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 19 | return new HiddenHttpMethodFilter(); 20 | } 21 | } 22 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part3/images/src/main/java/com/greglturnquist/learningspringboot/images/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.images; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | 30 | } 31 | // end::code[] -------------------------------------------------------------------------------- /Chapter08/part3/images/src/main/java/com/greglturnquist/learningspringboot/images/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 19 | import org.springframework.context.annotation.Bean; 20 | import org.springframework.context.annotation.Configuration; 21 | import org.springframework.web.client.RestTemplate; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | @Configuration 28 | public class Config { 29 | 30 | @Bean 31 | @LoadBalanced 32 | RestTemplate restTemplate() { 33 | return new RestTemplate(); 34 | } 35 | } 36 | // end::code[] 37 | -------------------------------------------------------------------------------- /Chapter08/part3/images/src/main/java/com/greglturnquist/learningspringboot/images/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import lombok.Data; 19 | 20 | import org.springframework.data.annotation.Id; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | @Data 26 | public class Image { 27 | 28 | @Id 29 | private String id; 30 | 31 | private String name; 32 | 33 | public Image(String id, String name) { 34 | this.name = name; 35 | } 36 | 37 | public String getId() { 38 | return this.id; 39 | } 40 | 41 | public String getName() { 42 | return this.name; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Chapter08/part3/images/src/main/java/com/greglturnquist/learningspringboot/images/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | -------------------------------------------------------------------------------- /Chapter08/part3/images/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: images -------------------------------------------------------------------------------- /Chapter08/part3/images/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter09/part1/chat/src/main/java/com/greglturnquist/learningspringboot/chat/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.chat; 17 | 18 | import lombok.Data; 19 | 20 | /** 21 | * @author Greg Turnquist 22 | */ 23 | @Data 24 | public class Comment { 25 | 26 | private String id; 27 | private String imageId; 28 | private String comment; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Chapter09/part1/chat/src/main/java/com/greglturnquist/learningspringboot/chat/LearningSpringBootChatApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot.chat; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | // tag::code[] 9 | @SpringCloudApplication 10 | public class LearningSpringBootChatApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run( 14 | LearningSpringBootChatApplication.class, args); 15 | } 16 | 17 | @Bean 18 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 19 | return new HiddenHttpMethodFilter(); 20 | } 21 | } 22 | // end::code[] -------------------------------------------------------------------------------- /Chapter09/part1/chat/src/main/java/com/greglturnquist/learningspringboot/chat/SessionConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.chat; 17 | 18 | import org.springframework.session.data.mongo.config.annotation.web.reactive.EnableMongoWebSession; 19 | 20 | /** 21 | * @author Greg Turnquist 22 | */ 23 | // tag::code[] 24 | @EnableMongoWebSession 25 | public class SessionConfig { 26 | 27 | } 28 | // end::code[] -------------------------------------------------------------------------------- /Chapter09/part1/chat/src/main/java/com/greglturnquist/learningspringboot/chat/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.chat; 17 | 18 | import lombok.AllArgsConstructor; 19 | import lombok.Data; 20 | import lombok.NoArgsConstructor; 21 | import org.springframework.data.annotation.Id; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | @Data 28 | @AllArgsConstructor 29 | @NoArgsConstructor 30 | public class User { 31 | 32 | @Id private String id; 33 | private String username; 34 | private String password; 35 | private String[] roles; 36 | } 37 | // end::code[] -------------------------------------------------------------------------------- /Chapter09/part1/chat/src/main/java/com/greglturnquist/learningspringboot/chat/UserRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.chat; 17 | 18 | import reactor.core.publisher.Mono; 19 | import org.springframework.data.repository.Repository; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | public interface UserRepository 26 | extends Repository { 27 | 28 | Mono findByUsername(String username); 29 | } 30 | // end::code[] -------------------------------------------------------------------------------- /Chapter09/part1/chat/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: chat 4 | cloud: 5 | config: 6 | label: session 7 | password: password -------------------------------------------------------------------------------- /Chapter09/part1/comments/src/main/java/com/greglturnquist/learningspringboot/comments/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.comments; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | } 30 | // end::code[] -------------------------------------------------------------------------------- /Chapter09/part1/comments/src/main/java/com/greglturnquist/learningspringboot/comments/CommentRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import reactor.core.publisher.Flux; 19 | import reactor.core.publisher.Mono; 20 | 21 | import org.springframework.data.repository.Repository; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | public interface CommentRepository 28 | extends Repository { 29 | 30 | Flux findByImageId(String imageId); 31 | 32 | Flux saveAll(Flux newComment); 33 | 34 | // Required to support save() 35 | Mono findById(String id); 36 | 37 | Mono deleteAll(); 38 | } 39 | // end::code[] 40 | -------------------------------------------------------------------------------- /Chapter09/part1/comments/src/main/java/com/greglturnquist/learningspringboot/comments/LearningSpringBootCommentsApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.cloud.client.SpringCloudApplication; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | @SpringCloudApplication 26 | public class LearningSpringBootCommentsApplication { 27 | 28 | public static void main(String[] args) { 29 | SpringApplication.run( 30 | LearningSpringBootCommentsApplication.class); 31 | } 32 | } 33 | // end::code[] 34 | -------------------------------------------------------------------------------- /Chapter09/part1/comments/src/main/java/com/greglturnquist/learningspringboot/comments/SessionConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import org.springframework.session.data.mongo.config.annotation.web.reactive.EnableMongoWebSession; 19 | 20 | /** 21 | * @author Greg Turnquist 22 | */ 23 | // tag::code[] 24 | @EnableMongoWebSession 25 | public class SessionConfig { 26 | 27 | } 28 | // end::code[] -------------------------------------------------------------------------------- /Chapter09/part1/comments/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: comments 4 | cloud: 5 | config: 6 | label: session 7 | password: password -------------------------------------------------------------------------------- /Chapter09/part1/config-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8888 3 | 4 | spring: 5 | cloud: 6 | config: 7 | server: 8 | git: 9 | uri: https://github.com/gregturn/learning-spring-boot-config-repo 10 | 11 | # tag::secured[] 12 | security: 13 | user: 14 | password: password 15 | # tag::secured[] 16 | -------------------------------------------------------------------------------- /Chapter09/part1/eureka-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | # tag::secured-config-server[] 2 | spring: 3 | application: 4 | name: eureka 5 | cloud: 6 | config: 7 | label: session 8 | password: password 9 | # end::secured-config-server[] 10 | -------------------------------------------------------------------------------- /Chapter09/part1/hystrix-dashboard/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: hystrix-dashboard 4 | cloud: 5 | config: 6 | label: session 7 | password: password -------------------------------------------------------------------------------- /Chapter09/part1/images/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootImagesApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import reactor.core.publisher.Hooks; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.reactor.core.ReactorCoreProperties; 7 | import org.springframework.cloud.client.SpringCloudApplication; 8 | 9 | // tag::code[] 10 | @SpringCloudApplication 11 | public class LearningSpringBootImagesApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run( 15 | LearningSpringBootImagesApplication.class, args); 16 | } 17 | 18 | @Autowired 19 | protected void initialize(ReactorCoreProperties properties) { 20 | if (properties.getStacktraceMode().isEnabled()) { 21 | Hooks.onOperatorDebug(); 22 | } 23 | } 24 | } 25 | // end::code[] -------------------------------------------------------------------------------- /Chapter09/part1/images/src/main/java/com/greglturnquist/learningspringboot/SessionConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.session.data.mongo.config.annotation.web.reactive.EnableMongoWebSession; 19 | 20 | /** 21 | * @author Greg Turnquist 22 | */ 23 | // tag::code[] 24 | @EnableMongoWebSession 25 | public class SessionConfig { 26 | 27 | } 28 | // end::code[] 29 | -------------------------------------------------------------------------------- /Chapter09/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.images; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | 30 | } 31 | // end::code[] -------------------------------------------------------------------------------- /Chapter09/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 19 | import org.springframework.context.annotation.Bean; 20 | import org.springframework.context.annotation.Configuration; 21 | import org.springframework.web.client.RestTemplate; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | @Configuration 28 | public class Config { 29 | 30 | @Bean 31 | @LoadBalanced 32 | RestTemplate restTemplate() { 33 | return new RestTemplate(); 34 | } 35 | } 36 | // end::code[] 37 | -------------------------------------------------------------------------------- /Chapter09/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import lombok.AllArgsConstructor; 19 | import lombok.Data; 20 | 21 | import org.springframework.data.annotation.Id; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | @Data 28 | @AllArgsConstructor 29 | public class Image { 30 | 31 | @Id private String id; 32 | private String name; 33 | private String owner; 34 | } 35 | // end::code[] 36 | -------------------------------------------------------------------------------- /Chapter09/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | -------------------------------------------------------------------------------- /Chapter09/part1/images/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: images 4 | cloud: 5 | config: 6 | label: session 7 | password: password -------------------------------------------------------------------------------- /Chapter09/part1/images/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter10/part1/chat/src/main/java/com/greglturnquist/learningspringboot/chat/ChatConfigProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.chat; 17 | 18 | import lombok.Data; 19 | import org.springframework.beans.factory.annotation.Value; 20 | import org.springframework.boot.context.properties.ConfigurationProperties; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | // tag::code[] 26 | @Data 27 | @ConfigurationProperties(prefix = "lsb") 28 | public class ChatConfigProperties { 29 | 30 | @Value("https://${vcap.application.uris[0]}") 31 | private String origin; 32 | 33 | } 34 | // end::code[] 35 | -------------------------------------------------------------------------------- /Chapter10/part1/chat/src/main/java/com/greglturnquist/learningspringboot/chat/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.chat; 17 | 18 | import lombok.Data; 19 | 20 | /** 21 | * @author Greg Turnquist 22 | */ 23 | @Data 24 | public class Comment { 25 | 26 | private String id; 27 | private String imageId; 28 | private String comment; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Chapter10/part1/chat/src/main/java/com/greglturnquist/learningspringboot/chat/LearningSpringBootChatApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot.chat; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.filter.reactive.HiddenHttpMethodFilter; 7 | 8 | // tag::code[] 9 | @SpringCloudApplication 10 | public class LearningSpringBootChatApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run( 14 | LearningSpringBootChatApplication.class, args); 15 | } 16 | 17 | @Bean 18 | HiddenHttpMethodFilter hiddenHttpMethodFilter() { 19 | return new HiddenHttpMethodFilter(); 20 | } 21 | } 22 | // end::code[] -------------------------------------------------------------------------------- /Chapter10/part1/chat/src/main/java/com/greglturnquist/learningspringboot/chat/SessionConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.chat; 17 | 18 | import org.springframework.session.data.mongo.config.annotation.web.reactive.EnableMongoWebSession; 19 | 20 | /** 21 | * @author Greg Turnquist 22 | */ 23 | // tag::code[] 24 | @EnableMongoWebSession 25 | public class SessionConfig { 26 | 27 | } 28 | // end::code[] -------------------------------------------------------------------------------- /Chapter10/part1/chat/src/main/java/com/greglturnquist/learningspringboot/chat/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.chat; 17 | 18 | import org.springframework.data.annotation.Id; 19 | 20 | import lombok.AllArgsConstructor; 21 | import lombok.Data; 22 | import lombok.NoArgsConstructor; 23 | 24 | /** 25 | * @author Greg Turnquist 26 | */ 27 | // tag::code[] 28 | @Data 29 | @AllArgsConstructor 30 | @NoArgsConstructor 31 | public class User { 32 | 33 | @Id private String id; 34 | private String username; 35 | private String password; 36 | private String[] roles; 37 | } 38 | // end::code[] -------------------------------------------------------------------------------- /Chapter10/part1/chat/src/main/java/com/greglturnquist/learningspringboot/chat/UserRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.chat; 17 | 18 | import reactor.core.publisher.Mono; 19 | import org.springframework.data.repository.Repository; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | public interface UserRepository 26 | extends Repository { 27 | 28 | Mono findByUsername(String username); 29 | } 30 | // end::code[] -------------------------------------------------------------------------------- /Chapter10/part1/chat/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: chat 4 | cloud: 5 | config: 6 | label: session 7 | password: password 8 | -------------------------------------------------------------------------------- /Chapter10/part1/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cf delete -f learning-spring-boot-config-server & 4 | cf delete -f learning-spring-boot-eureka-server & 5 | cf delete -f learning-spring-boot & 6 | cf delete -f learning-spring-boot-comments & 7 | cf delete -f learning-spring-boot-images & 8 | cf delete -f learning-spring-boot-hystrix-dashboard & 9 | -------------------------------------------------------------------------------- /Chapter10/part1/comments/src/main/java/com/greglturnquist/learningspringboot/comments/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.comments; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | } 30 | // end::code[] -------------------------------------------------------------------------------- /Chapter10/part1/comments/src/main/java/com/greglturnquist/learningspringboot/comments/CommentRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import reactor.core.publisher.Flux; 19 | import reactor.core.publisher.Mono; 20 | 21 | import org.springframework.data.repository.Repository; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | public interface CommentRepository 28 | extends Repository { 29 | 30 | Flux findByImageId(String imageId); 31 | 32 | Flux saveAll(Flux newComment); 33 | 34 | // Required to support save() 35 | Mono findById(String id); 36 | 37 | Mono deleteAll(); 38 | } 39 | // end::code[] 40 | -------------------------------------------------------------------------------- /Chapter10/part1/comments/src/main/java/com/greglturnquist/learningspringboot/comments/LearningSpringBootCommentsApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.cloud.client.SpringCloudApplication; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | */ 24 | // tag::code[] 25 | @SpringCloudApplication 26 | public class LearningSpringBootCommentsApplication { 27 | 28 | public static void main(String[] args) { 29 | SpringApplication.run( 30 | LearningSpringBootCommentsApplication.class); 31 | } 32 | } 33 | // end::code[] 34 | -------------------------------------------------------------------------------- /Chapter10/part1/comments/src/main/java/com/greglturnquist/learningspringboot/comments/SessionConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.comments; 17 | 18 | import org.springframework.session.data.mongo.config.annotation.web.reactive.EnableMongoWebSession; 19 | 20 | /** 21 | * @author Greg Turnquist 22 | */ 23 | // tag::code[] 24 | @EnableMongoWebSession 25 | public class SessionConfig { 26 | 27 | } 28 | // end::code[] -------------------------------------------------------------------------------- /Chapter10/part1/comments/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: comments 4 | cloud: 5 | config: 6 | label: session 7 | password: password -------------------------------------------------------------------------------- /Chapter10/part1/config-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8888 3 | 4 | spring: 5 | cloud: 6 | config: 7 | server: 8 | git: 9 | uri: https://github.com/gregturn/learning-spring-boot-config-repo 10 | -------------------------------------------------------------------------------- /Chapter10/part1/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cf push learning-spring-boot-config-server -p config-server/build/libs/learning-spring-boot-config-server-0.0.1-SNAPSHOT.jar & 4 | cf push learning-spring-boot-eureka-server -p eureka-server/build/libs/learning-spring-boot-eureka-server-0.0.1-SNAPSHOT.jar & 5 | cf push learning-spring-boot -p chat/build/libs/learning-spring-boot-chat-0.0.1-SNAPSHOT.jar & 6 | cf push learning-spring-boot-comments -p comments/build/libs/learning-spring-boot-comments-0.0.1-SNAPSHOT.jar & 7 | cf push learning-spring-boot-images -p images/build/libs/learning-spring-boot-images-0.0.1-SNAPSHOT.jar & 8 | cf push learning-spring-boot-hystrix-dashboard -p hystrix-dashboard/build/libs/learning-spring-boot-hystrix-dashboard-0.0.1-SNAPSHOT.jar & 9 | -------------------------------------------------------------------------------- /Chapter10/part1/eureka-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | # tag::secured-config-server[] 2 | spring: 3 | application: 4 | name: eureka 5 | cloud: 6 | config: 7 | label: session 8 | password: password 9 | # end::secured-config-server[] 10 | -------------------------------------------------------------------------------- /Chapter10/part1/hystrix-dashboard/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: hystrix-dashboard 4 | cloud: 5 | config: 6 | label: session 7 | password: password -------------------------------------------------------------------------------- /Chapter10/part1/images/src/main/java/com/greglturnquist/learningspringboot/LearningSpringBootImagesApplication.java: -------------------------------------------------------------------------------- 1 | package com.greglturnquist.learningspringboot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.cloud.client.SpringCloudApplication; 5 | 6 | // tag::code[] 7 | @SpringCloudApplication 8 | public class LearningSpringBootImagesApplication { 9 | 10 | public static void main(String[] args) { 11 | SpringApplication.run( 12 | LearningSpringBootImagesApplication.class, args); 13 | } 14 | } 15 | // end::code[] -------------------------------------------------------------------------------- /Chapter10/part1/images/src/main/java/com/greglturnquist/learningspringboot/SessionConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot; 17 | 18 | import org.springframework.session.data.mongo.config.annotation.web.reactive.EnableMongoWebSession; 19 | 20 | /** 21 | * @author Greg Turnquist 22 | */ 23 | // tag::code[] 24 | @EnableMongoWebSession 25 | public class SessionConfig { 26 | 27 | } 28 | // end::code[] 29 | -------------------------------------------------------------------------------- /Chapter10/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | // tag::code[] 17 | package com.greglturnquist.learningspringboot.images; 18 | 19 | import org.springframework.data.annotation.Id; 20 | 21 | import lombok.Data; 22 | 23 | @Data 24 | public class Comment { 25 | 26 | @Id private String id; 27 | private String imageId; 28 | private String comment; 29 | 30 | } 31 | // end::code[] -------------------------------------------------------------------------------- /Chapter10/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 19 | import org.springframework.context.annotation.Bean; 20 | import org.springframework.context.annotation.Configuration; 21 | import org.springframework.web.client.RestTemplate; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | @Configuration 28 | public class Config { 29 | 30 | @Bean 31 | @LoadBalanced 32 | RestTemplate restTemplate() { 33 | return new RestTemplate(); 34 | } 35 | } 36 | // end::code[] 37 | -------------------------------------------------------------------------------- /Chapter10/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import org.springframework.data.annotation.Id; 19 | 20 | import lombok.AllArgsConstructor; 21 | import lombok.Data; 22 | 23 | /** 24 | * @author Greg Turnquist 25 | */ 26 | // tag::code[] 27 | @Data 28 | @AllArgsConstructor 29 | public class Image { 30 | 31 | @Id private String id; 32 | private String name; 33 | private String owner; 34 | } 35 | // end::code[] 36 | -------------------------------------------------------------------------------- /Chapter10/part1/images/src/main/java/com/greglturnquist/learningspringboot/images/ImageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.greglturnquist.learningspringboot.images; 17 | 18 | import reactor.core.publisher.Mono; 19 | 20 | import org.springframework.data.repository.reactive.ReactiveCrudRepository; 21 | 22 | /** 23 | * @author Greg Turnquist 24 | */ 25 | public interface ImageRepository 26 | extends ReactiveCrudRepository { 27 | 28 | Mono findByName(String name); 29 | } 30 | -------------------------------------------------------------------------------- /Chapter10/part1/images/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: images 4 | cloud: 5 | config: 6 | label: session 7 | password: password -------------------------------------------------------------------------------- /Chapter10/part1/images/src/main/resources/static/main.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | td, th { 6 | border: 1px solid #999; 7 | padding: 0.5rem; 8 | text-align: left; 9 | } 10 | 11 | .thumbnail { 12 | max-width: 75px; 13 | max-height: 75px; 14 | } 15 | 16 | .flash { 17 | background-color: lightcoral; 18 | padding: 1em; 19 | } -------------------------------------------------------------------------------- /Chapter10/part1/restart.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cf restart learning-spring-boot-config-server 4 | 5 | sleep 10 6 | 7 | cf restart learning-spring-boot-eureka-server & 8 | cf restart learning-spring-boot & 9 | cf restart learning-spring-boot-comments & 10 | cf restart learning-spring-boot-images & -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Packt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /build.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pushd `dirname $1` 4 | #gradle wrapper 5 | #./gradlew clean compileJava 6 | gradle clean compileJava 7 | popd 8 | -------------------------------------------------------------------------------- /ci.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | find . -name build.gradle -exec ./build.bash {} \; -print 4 | -------------------------------------------------------------------------------- /ext/chromedriver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Learning-Spring-Boot-2.0-Second-Edition/fe67fc2effc10783a3232b59434ad5c69b497323/ext/chromedriver -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jul 28 13:37:07 BST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip 7 | --------------------------------------------------------------------------------