File tree Expand file tree Collapse file tree 9 files changed +24
-288
lines changed
src/main/java/com/greglturnquist/learningspringboot Expand file tree Collapse file tree 9 files changed +24
-288
lines changed Original file line number Diff line number Diff line change @@ -39,16 +39,13 @@ repositories {
39
39
}
40
40
41
41
// tag::deps[]
42
- ext[' thymeleaf-spring5.version' ] = ' 3.0.7-SNAPSHOT'
43
-
44
42
dependencies {
45
- compile(' org.springframework.boot:spring-boot-starter-data-jpa ' )
43
+ compile(' org.springframework.boot:spring-boot-starter-data-mongodb-reactive ' )
46
44
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' )
49
46
50
47
compile(' org.projectlombok:lombok' )
51
- runtime( ' com.h2database:h2 ' )
48
+ compile( ' de.flapdoodle.embed:de.flapdoodle.embed.mongo ' )
52
49
testCompile(' org.springframework.boot:spring-boot-starter-test' )
53
50
}
54
51
// 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 1
1
package com .greglturnquist .learningspringboot ;
2
2
3
- import javax .persistence .Entity ;
4
- import javax .persistence .GeneratedValue ;
5
- import javax .persistence .Id ;
6
-
7
3
import lombok .Data ;
8
4
5
+ import org .springframework .data .annotation .Id ;
6
+ import org .springframework .data .mongodb .core .mapping .Document ;
7
+
9
8
@ Data
10
- @ Entity
9
+ @ Document
11
10
public class Chapter {
12
11
13
- @ Id @ GeneratedValue
14
- private Long id ;
15
-
12
+ @ Id
13
+ private String id ;
16
14
private String name ;
17
15
18
- private Chapter () {
19
- // No one but JPA uses this.
20
- }
21
-
22
16
public Chapter (String name ) {
23
17
this .name = name ;
24
18
}
Original file line number Diff line number Diff line change 1
1
package com .greglturnquist .learningspringboot ;
2
2
3
+ import reactor .core .publisher .Flux ;
4
+
3
5
import org .springframework .web .bind .annotation .GetMapping ;
4
6
import org .springframework .web .bind .annotation .RestController ;
5
7
@@ -13,7 +15,7 @@ public ChapterController(ChapterRepository repository) {
13
15
}
14
16
15
17
@ GetMapping ("/chapters" )
16
- public Iterable <Chapter > listing () {
18
+ public Flux <Chapter > listing () {
17
19
return repository .findAll ();
18
20
}
19
21
}
Original file line number Diff line number Diff line change 1
1
package com .greglturnquist .learningspringboot ;
2
2
3
- import org .springframework .data .repository .CrudRepository ;
3
+ import org .springframework .data .repository .reactive . ReactiveCrudRepository ;
4
4
5
5
public interface ChapterRepository
6
- extends CrudRepository <Chapter , Long > {
6
+ extends ReactiveCrudRepository <Chapter , String > {
7
7
8
8
}
Original file line number Diff line number Diff line change 1
1
package com .greglturnquist .learningspringboot ;
2
2
3
+ import reactor .core .publisher .Flux ;
4
+
3
5
import org .springframework .boot .CommandLineRunner ;
4
6
import org .springframework .context .annotation .Bean ;
5
7
import org .springframework .context .annotation .Configuration ;
@@ -10,12 +12,12 @@ public class LoadDatabase {
10
12
@ Bean
11
13
CommandLineRunner init (ChapterRepository repository ) {
12
14
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 );
19
21
};
20
22
}
21
23
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
2
2
distributionBase =GRADLE_USER_HOME
3
3
distributionPath =wrapper/dists
4
4
zipStoreBase =GRADLE_USER_HOME
5
5
zipStorePath =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