File tree Expand file tree Collapse file tree
src/main/java/com/greglturnquist/learningspringboot Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,16 +39,13 @@ repositories {
3939}
4040
4141// tag::deps[]
42- ext[' thymeleaf-spring5.version' ] = ' 3.0.7-SNAPSHOT'
43-
4442dependencies {
45- compile(' org.springframework.boot:spring-boot-starter-data-jpa ' )
43+ compile(' org.springframework.boot:spring-boot-starter-data-mongodb-reactive ' )
4644 compile(' org.springframework.boot:spring-boot-starter-thymeleaf' )
47- compile(' org.springframework.boot:spring-boot-starter-web' )
48- compile(' org.springframework:spring-messaging' )
45+ compile(' org.springframework.boot:spring-boot-starter-webflux' )
4946
5047 compile(' org.projectlombok:lombok' )
51- runtime( ' com.h2database:h2 ' )
48+ compile( ' de.flapdoodle.embed:de.flapdoodle.embed.mongo ' )
5249 testCompile(' org.springframework.boot:spring-boot-starter-test' )
5350}
5451// end::deps[]
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11package com .greglturnquist .learningspringboot ;
22
3- import javax .persistence .Entity ;
4- import javax .persistence .GeneratedValue ;
5- import javax .persistence .Id ;
6-
73import lombok .Data ;
84
5+ import org .springframework .data .annotation .Id ;
6+ import org .springframework .data .mongodb .core .mapping .Document ;
7+
98@ Data
10- @ Entity
9+ @ Document
1110public class Chapter {
1211
13- @ Id @ GeneratedValue
14- private Long id ;
15-
12+ @ Id
13+ private String id ;
1614 private String name ;
1715
18- private Chapter () {
19- // No one but JPA uses this.
20- }
21-
2216 public Chapter (String name ) {
2317 this .name = name ;
2418 }
Original file line number Diff line number Diff line change 11package com .greglturnquist .learningspringboot ;
22
3+ import reactor .core .publisher .Flux ;
4+
35import org .springframework .web .bind .annotation .GetMapping ;
46import org .springframework .web .bind .annotation .RestController ;
57
@@ -13,7 +15,7 @@ public ChapterController(ChapterRepository repository) {
1315 }
1416
1517 @ GetMapping ("/chapters" )
16- public Iterable <Chapter > listing () {
18+ public Flux <Chapter > listing () {
1719 return repository .findAll ();
1820 }
1921}
Original file line number Diff line number Diff line change 11package com .greglturnquist .learningspringboot ;
22
3- import org .springframework .data .repository .CrudRepository ;
3+ import org .springframework .data .repository .reactive . ReactiveCrudRepository ;
44
55public interface ChapterRepository
6- extends CrudRepository <Chapter , Long > {
6+ extends ReactiveCrudRepository <Chapter , String > {
77
88}
Original file line number Diff line number Diff line change 11package com .greglturnquist .learningspringboot ;
22
3+ import reactor .core .publisher .Flux ;
4+
35import org .springframework .boot .CommandLineRunner ;
46import org .springframework .context .annotation .Bean ;
57import org .springframework .context .annotation .Configuration ;
@@ -10,12 +12,12 @@ public class LoadDatabase {
1012 @ Bean
1113 CommandLineRunner init (ChapterRepository repository ) {
1214 return args -> {
13- repository . save (
14- new Chapter ("Quick start with Java" ));
15- repository . save (
16- new Chapter ("Reactive Web with Spring Boot " ));
17- repository . save (
18- new Chapter ( "...and more!" ) );
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 );
1921 };
2022 }
2123
Original file line number Diff line number Diff line change 1- # Sun May 14 20:03:28 CDT 2017
1+ # Fri Jul 28 13:37:07 BST 2017
22distributionBase =GRADLE_USER_HOME
33distributionPath =wrapper/dists
44zipStoreBase =GRADLE_USER_HOME
55zipStorePath =wrapper/dists
6- distributionUrl =https\://services.gradle.org/distributions/gradle-3.4 -bin.zip
6+ distributionUrl =https\://services.gradle.org/distributions/gradle-4.0.2 -bin.zip
You can’t perform that action at this time.
0 commit comments