diff --git a/README.adoc b/README.adoc
index a7fdecf..39c3e5d 100644
--- a/README.adoc
+++ b/README.adoc
@@ -1,18 +1,14 @@
:spring_version: current
-:spring_boot_version: 2.1.6.RELEASE
-:Controller: http://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/stereotype/Controller.html
-:DispatcherServlet: http://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/web/servlet/DispatcherServlet.html
-:SpringApplication: http://docs.spring.io/spring-boot/docs/{spring_boot_version}/api/org/springframework/boot/SpringApplication.html
-:ResponseBody: http://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/web/bind/annotation/ResponseBody.html
+:spring_boot_version: 2.2.2.RELEASE
:toc:
:icons: font
:source-highlighter: prettify
-:project_id: draft-gs-template
-This guide walks you through the process of creating a Spring application.
+:project_id: gs-accessing-data-r2dbc
+This guide walks you through the process of building an application that uses Spring Data R2DBC to store and retrieve data in a relational database using reactive database drivers.
== What you'll build
-You'll build a Spring application.
+You will build an application that stores `Customer` POJOs (Plain Old Java Objects) in a memory-based database.
== What you'll need
@@ -23,60 +19,179 @@ include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/
include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/how_to_complete_this_guide.adoc[]
-include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/hide-show-gradle.adoc[]
+[[scratch]]
+== Starting with Spring Initializr
-include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/hide-show-maven.adoc[]
+For all Spring applications, you should start with the https://start.spring.io[Spring
+Initializr]. The Initializr offers a fast way to pull in all the dependencies you need for
+an application and does a lot of the set up for you. This example needs the R2DBC and H2
+dependencies. The following image shows the Initializr set up for this sample project:
-include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/hide-show-sts.adoc[]
+image::images/initializr.png[]
+NOTE: The preceding image shows the Initializr with Maven chosen as the build tool. You
+can also use Gradle. It also shows values of `com.example` and `accesing-data-r2dbc` as the
+Group and Artifact, respectively. You will use those values throughout the rest of this sample.
+The following listing shows the `pom.xml` file created when you choose Maven:
+
+====
+[src,xml]
+----
+include::complete/pom.xml[]
+----
+====
+
+The following listing shows the `build.gradle` file created when you choose Gradle:
+
+====
+[src,gradle]
+----
+include::complete/build.gradle[]
+----
+====
[[initial]]
-== Create a resource controller
+== Define a Schema
+
+In this example, you store `Customer` objects, each annotated as a R2DBC entity. The
+following listing shows the SQL schema class (in `src/main/resources/schema.sql`):
+
+====
+[source,sql,indent=0]
+----
+include::complete/src/main/resources/schema.sql[]
+----
+====
+
+Here you have a `customer` table with three columns: `id`, `first_name`, and `last_name`.
+The `id` column is auto-incremented, the other columns follow the default snake case naming scheme.
+Spring Boot's auto-configuration picks up the `schema.sql` file during application startup to initialize the database schema.
+
+[[entity]]
+== Define a Simple Entity
+
+In this example, you store `Customer` objects, each annotated as a R2DBC entity. The
+following listing shows the Customer class (in
+ `src/main/java/com/example/accessingdatar2dbc/Customer.java`):
+
+====
+[source,java,indent=0]
+----
+include::complete/src/main/java/com/example/accessingdatar2dbc/Customer.java[]
+----
+====
-Create a new controller for your Spring application:
+Here you have a `Customer` class with three attributes: `id`, `firstName`, and `lastName`.
+The `Customer` class is minimally annotated. The `id` property is annotated with `@Id` so that Spring Data R2DBC can identify the primary key.
+By default, primary keys are assumed to be generated by the database on `INSERT`.
-`src/main/java/hello/GreetingController.java`
+The other two properties, `firstName` and `lastName`, are left unannotated. It is assumed
+that they are mapped to columns that share the same names as the properties themselves.
+
+The convenient `toString()` method print outs the customer's properties.
+
+
+== Create Simple Queries
+
+Spring Data R2DBC focuses on using R2DBC as underlying technology to store data in a relational database.
+Its most compelling feature is the ability to create repository implementations, at runtime, from a repository interface.
+
+To see how this works, create a repository interface that works with `Customer` entities
+as the following listing (in `src/main/java/com/example/accessingdatar2dbc/CustomerRepository.java`) shows:
+
+====
[source,java]
----
-include::complete/src/main/java/hello/GreetingController.java[]
+include::complete/src/main/java/com/example/accessingdatar2dbc/CustomerRepository.java[]
----
+====
-NOTE: The above example does not specify `GET` vs. `PUT`, `POST`, and so forth, because `@RequestMapping` maps all HTTP operations by default. Use `@RequestMapping(method=GET)` to narrow this mapping.
+`CustomerRepository` extends the `ReactiveCrudRepository` interface. The type of entity and ID that it works with, `Customer` and `Long`, are specified in the generic parameters on `ReactiveCrudRepository`.
+By extending `ReactiveCrudRepository`, `CustomerRepository` inherits several methods for working with `Customer` persistence, including methods for saving, deleting, and finding `Customer` entities using reactive types.
+Spring Data R2DBC also lets you define other query methods by annotating these with `@Query`.
+For example, `CustomerRepository` includes the `findByLastName()` method.
-== Make the application executable
+In a typical Java application, you might expect to write a class that implements `CustomerRepository`.
+However, that is what makes Spring Data R2DBC so powerful: You need not write an implementation of the repository interface.
+Spring Data R2DBC creates an implementation when you run the application.
-Although it is possible to package this service as a traditional link:/understanding/WAR[WAR] file for deployment to an external application server, the simpler approach demonstrated below creates a standalone application. You package everything in a single, executable JAR file, driven by a good old Java `main()` method. Along the way, you use Spring's support for embedding the link:/understanding/Tomcat[Tomcat] servlet container as the HTTP runtime, instead of deploying to an external instance.
+Now you can wire up this example and see what it looks like!
+== Create an Application Class
-`src/main/java/hello/Application.java`
+Spring Initializr creates a simple class for the application. The following listing shows
+the class that Initializr created for this example (in
+`src/main/java/com/example/accessingdatar2dbc/AccessingDataR2dbcApplication.java`):
+
+====
[source,java]
----
-include::complete/src/main/java/hello/Application.java[]
+include::initial/src/main/java/com/example/accessingdatar2dbc/AccessingDataR2dbcApplication.java[]
----
+====
-include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/spring-boot-application.adoc[]
+include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/spring-boot-application-new-path.adoc[]
-include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/build_an_executable_jar_subhead.adoc[]
+Now you need to modify the simple class that the Initializr created for you.
+To get output (to the console, in this example), you need to set up a logger.
+Then you need to set up some data and use it to generate output.
+The following listing shows the finished `AccessingDataR2dbcApplication` class (in `src/main/java/com/example/accessingdatar2dbc/AccessingDataR2dbcApplication.java`):
-include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/build_an_executable_jar_with_both.adoc[]
+====
+[source,java]
+----
+include::complete/src/main/java/com/example/accessingdatar2dbc/AccessingDataR2dbcApplication.java[]
+----
+====
+
+The `AccessingDataR2dbcApplication` class includes a `main()` method that puts the `CustomerRepository` through a few tests.
+First, it fetches the `CustomerRepository` from the Spring application context.
+Then it saves a handful of `Customer` objects, demonstrating the `save()` method and setting up some data to use.
+Next, it calls `findAll()` to fetch all `Customer` objects from the database.
+Then it calls `findById()` to fetch a single `Customer` by its ID.
+Finally, it calls `findByLastName()` to find all customers whose last name is "Bauer".
+R2DBC is a reactive programming technology.
+At the same time we're using it in a synchronized, imperative flow and that is why we're required to synchronize each call with a variant of the `block(…)` method.
+In a typical reactive application, the resulting `Mono` or `Flux` would represent a pipeline of operators that is handed back to a web controller or event processor that subscribes to the reactive sequence without blocking the calling thread.
-Logging output is displayed. The service should be up and running within a few seconds.
+NOTE: By default, Spring Boot enables R2DBC repository support and looks in the package (and its subpackages) where `@SpringBootApplication` is located.
+If your configuration has R2DBC repository interface definitions located in a package that is not visible, you can point out alternate packages by using `@EnableR2dbcRepositories` and its type-safe `basePackageClasses=MyRepository.class` parameter.
+include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/build_an_executable_jar_mainhead.adoc[]
-== Test the application
+include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/build_an_executable_jar_with_both.adoc[]
-Now that the application is running, you can test it.
+When you run your application, you should see output similar to the following:
+====
+----
+== Customers found with findAll():
+Customer[id=1, firstName='Jack', lastName='Bauer']
+Customer[id=2, firstName='Chloe', lastName='O'Brian']
+Customer[id=3, firstName='Kim', lastName='Bauer']
+Customer[id=4, firstName='David', lastName='Palmer']
+Customer[id=5, firstName='Michelle', lastName='Dessler']
+
+== Customer found with findOne(1L):
+Customer[id=1, firstName='Jack', lastName='Bauer']
+
+== Customer found with findByLastName('Bauer'):
+Customer[id=1, firstName='Jack', lastName='Bauer']
+Customer[id=3, firstName='Kim', lastName='Bauer']
+----
+====
== Summary
-Congratulations! You've just developed a Spring application!
+Congratulations! You have written a simple application that uses Spring Data R2DBC to save objects to and fetch them from a database, all without writing a concrete repository implementation.
+== See Also
+The following guides may also be helpful:
+* https://spring.io/guides/gs/gs-spring-data-reactive-redis[Accessing Data Reactively with Redis]
include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/footer.adoc[]
-
diff --git a/complete/build.gradle b/complete/build.gradle
index 87665e9..303dee1 100644
--- a/complete/build.gradle
+++ b/complete/build.gradle
@@ -1,32 +1,35 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE")
- }
+plugins {
+ id 'org.springframework.boot' version '2.2.2.RELEASE'
+ id 'io.spring.dependency-management' version '1.0.8.RELEASE'
+ id 'java'
}
-apply plugin: 'java'
-apply plugin: 'eclipse'
-apply plugin: 'idea'
-apply plugin: 'org.springframework.boot'
-apply plugin: 'io.spring.dependency-management'
-
-bootJar {
- baseName = 'draft-gs-template'
- version = '0.1.0'
-}
+group = 'com.example'
+version = '0.0.1-SNAPSHOT'
+sourceCompatibility = '1.8'
repositories {
- mavenCentral()
+ mavenCentral()
+ maven { url 'https://repo.spring.io/milestone' }
}
-sourceCompatibility = 1.8
-targetCompatibility = 1.8
-
dependencies {
- compile("org.springframework.boot:spring-boot-starter-web")
- testCompile("org.springframework.boot:spring-boot-starter-test")
+ implementation 'org.springframework.boot.experimental:spring-boot-starter-data-r2dbc'
+ runtimeOnly 'com.h2database:h2'
+ runtimeOnly 'io.r2dbc:r2dbc-h2'
+ testImplementation('org.springframework.boot:spring-boot-starter-test') {
+ exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
+ }
+ testImplementation 'org.springframework.boot.experimental:spring-boot-test-autoconfigure-r2dbc'
+ testImplementation 'io.projectreactor:reactor-test'
}
+dependencyManagement {
+ imports {
+ mavenBom 'org.springframework.boot.experimental:spring-boot-bom-r2dbc:0.1.0.M3'
+ }
+}
+
+test {
+ useJUnitPlatform()
+}
diff --git a/complete/gradle/wrapper/gradle-wrapper.properties b/complete/gradle/wrapper/gradle-wrapper.properties
index e038264..d0079b9 100644
--- a/complete/gradle/wrapper/gradle-wrapper.properties
+++ b/complete/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
diff --git a/complete/pom.xml b/complete/pom.xml
index bc281de..d28f719 100644
--- a/complete/pom.xml
+++ b/complete/pom.xml
@@ -4,27 +4,60 @@
4.0.0
org.springframework
- draft-gs-template
+ accessing-data-r2dbc
0.1.0
org.springframework.boot
spring-boot-starter-parent
- 2.1.6.RELEASE
+ 2.2.2.RELEASE
- org.springframework.boot
- spring-boot-starter-web
+ org.springframework.boot.experimental
+ spring-boot-starter-data-r2dbc
+
+
+ io.r2dbc
+ r2dbc-h2
+ runtime
org.springframework.boot
spring-boot-starter-test
test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+ org.springframework.boot.experimental
+ spring-boot-test-autoconfigure-r2dbc
+ test
+
+
+ io.projectreactor
+ reactor-test
+ test
+
+
+
+ org.springframework.boot.experimental
+ spring-boot-bom-r2dbc
+ 0.1.0.M3
+ pom
+ import
+
+
+
+
1.8
@@ -38,4 +71,12 @@
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+
+
diff --git a/complete/src/main/java/com/example/accessingdatar2dbc/AccessingDataR2dbcApplication.java b/complete/src/main/java/com/example/accessingdatar2dbc/AccessingDataR2dbcApplication.java
new file mode 100644
index 0000000..c1e41fe
--- /dev/null
+++ b/complete/src/main/java/com/example/accessingdatar2dbc/AccessingDataR2dbcApplication.java
@@ -0,0 +1,62 @@
+package com.example.accessingdatar2dbc;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+
+import java.time.Duration;
+import java.util.Arrays;
+
+@SpringBootApplication
+public class AccessingDataR2dbcApplication {
+
+ private static final Logger log = LoggerFactory.getLogger(AccessingDataR2dbcApplication.class);
+
+ public static void main(String[] args) {
+ SpringApplication.run(AccessingDataR2dbcApplication.class, args);
+ }
+
+ @Bean
+ public CommandLineRunner demo(CustomerRepository repository) {
+
+ return (args) -> {
+ // save a few customers
+ repository.saveAll(Arrays.asList(new Customer("Jack", "Bauer"),
+ new Customer("Chloe", "O'Brian"),
+ new Customer("Kim", "Bauer"),
+ new Customer("David", "Palmer"),
+ new Customer("Michelle", "Dessler")))
+ .blockLast(Duration.ofSeconds(10));
+
+ // fetch all customers
+ log.info("Customers found with findAll():");
+ log.info("-------------------------------");
+ repository.findAll().doOnNext(customer -> {
+ log.info(customer.toString());
+ }).blockLast(Duration.ofSeconds(10));
+
+ log.info("");
+
+ // fetch an individual customer by ID
+ repository.findById(1L).doOnNext(customer -> {
+ log.info("Customer found with findById(1L):");
+ log.info("--------------------------------");
+ log.info(customer.toString());
+ log.info("");
+ }).block(Duration.ofSeconds(10));
+
+
+ // fetch customers by last name
+ log.info("Customer found with findByLastName('Bauer'):");
+ log.info("--------------------------------------------");
+ repository.findByLastName("Bauer").doOnNext(bauer -> {
+ log.info(bauer.toString());
+ }).blockLast(Duration.ofSeconds(10));;
+ log.info("");
+ };
+ }
+
+}
diff --git a/complete/src/main/java/com/example/accessingdatar2dbc/Customer.java b/complete/src/main/java/com/example/accessingdatar2dbc/Customer.java
new file mode 100644
index 0000000..3907c92
--- /dev/null
+++ b/complete/src/main/java/com/example/accessingdatar2dbc/Customer.java
@@ -0,0 +1,41 @@
+package com.example.accessingdatar2dbc;
+
+import org.springframework.data.annotation.Id;
+
+public class Customer {
+
+ @Id
+ private Long id;
+
+ private final String firstName;
+
+ private final String lastName;
+
+ public Customer(String firstName, String lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ public Long getId() {
+ return this.id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getFirstName() {
+ return this.firstName;
+ }
+
+ public String getLastName() {
+ return this.lastName;
+ }
+
+ @Override
+ public String toString() {
+ return String.format(
+ "Customer[id=%d, firstName='%s', lastName='%s']",
+ id, firstName, lastName);
+ }
+}
diff --git a/complete/src/main/java/com/example/accessingdatar2dbc/CustomerRepository.java b/complete/src/main/java/com/example/accessingdatar2dbc/CustomerRepository.java
new file mode 100644
index 0000000..fa10545
--- /dev/null
+++ b/complete/src/main/java/com/example/accessingdatar2dbc/CustomerRepository.java
@@ -0,0 +1,13 @@
+package com.example.accessingdatar2dbc;
+
+import org.springframework.data.r2dbc.repository.Query;
+import org.springframework.data.repository.reactive.ReactiveCrudRepository;
+
+import reactor.core.publisher.Flux;
+
+public interface CustomerRepository extends ReactiveCrudRepository {
+
+ @Query("SELECT * FROM customer WHERE last_name = :lastname")
+ Flux findByLastName(String lastName);
+
+}
diff --git a/complete/src/main/java/hello/Application.java b/complete/src/main/java/hello/Application.java
deleted file mode 100644
index 5abd411..0000000
--- a/complete/src/main/java/hello/Application.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package hello;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-}
diff --git a/complete/src/main/java/hello/GreetingController.java b/complete/src/main/java/hello/GreetingController.java
deleted file mode 100644
index 3d85f1a..0000000
--- a/complete/src/main/java/hello/GreetingController.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package hello;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-@Controller
-public class GreetingController {
-
- @RequestMapping("/greeting")
- public @ResponseBody String greeting() {
- return "Hello World";
- }
-}
diff --git a/complete/src/main/resources/schema.sql b/complete/src/main/resources/schema.sql
new file mode 100644
index 0000000..5bb5fb0
--- /dev/null
+++ b/complete/src/main/resources/schema.sql
@@ -0,0 +1 @@
+CREATE TABLE customer (id SERIAL PRIMARY KEY, first_name VARCHAR(255), last_name VARCHAR(255));
diff --git a/complete/src/test/java/com/example/accessingdatar2dbc/CustomerRepositoryTests.java b/complete/src/test/java/com/example/accessingdatar2dbc/CustomerRepositoryTests.java
new file mode 100644
index 0000000..61a8d43
--- /dev/null
+++ b/complete/src/test/java/com/example/accessingdatar2dbc/CustomerRepositoryTests.java
@@ -0,0 +1,39 @@
+package com.example.accessingdatar2dbc;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.data.r2dbc.DataR2dbcTest;
+import org.springframework.data.r2dbc.core.DatabaseClient;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import reactor.core.publisher.Flux;
+import reactor.test.StepVerifier;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@ExtendWith(SpringExtension.class)
+@DataR2dbcTest
+public class CustomerRepositoryTests {
+
+ @Autowired
+ private DatabaseClient databaseClient;
+
+ @Autowired
+ private CustomerRepository customers;
+
+ @Test
+ public void testFindByLastName() {
+ Customer customer = new Customer("first", "last");
+ databaseClient.insert().into(Customer.class).using(customer).then().as(StepVerifier::create).verifyComplete();
+
+ Flux findByLastName = customers.findByLastName(customer.getLastName());
+
+
+ findByLastName.as(StepVerifier::create)
+ .assertNext(actual -> {
+ assertThat(actual.getFirstName()).isEqualTo("first");
+ assertThat(actual.getLastName()).isEqualTo("last");
+ })
+ .verifyComplete();
+ }
+}
diff --git a/complete/src/test/java/hello/GreetingControllerTest.java b/complete/src/test/java/hello/GreetingControllerTest.java
deleted file mode 100644
index 9288988..0000000
--- a/complete/src/test/java/hello/GreetingControllerTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package hello;
-
-import static org.hamcrest.Matchers.containsString;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.test.web.servlet.MockMvc;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest
-@AutoConfigureMockMvc
-public class GreetingControllerTest {
-
- @Autowired
- private MockMvc mockMvc;
-
- @Test
- public void greetingShouldReturnDefaultMessage() throws Exception {
-
- this.mockMvc.perform(get("/greeting")).andDo(print()).andExpect(status().isOk())
- .andExpect(content().string(containsString("Hello World")));
- }
-}
diff --git a/initial/build.gradle b/initial/build.gradle
index 87665e9..303dee1 100644
--- a/initial/build.gradle
+++ b/initial/build.gradle
@@ -1,32 +1,35 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE")
- }
+plugins {
+ id 'org.springframework.boot' version '2.2.2.RELEASE'
+ id 'io.spring.dependency-management' version '1.0.8.RELEASE'
+ id 'java'
}
-apply plugin: 'java'
-apply plugin: 'eclipse'
-apply plugin: 'idea'
-apply plugin: 'org.springframework.boot'
-apply plugin: 'io.spring.dependency-management'
-
-bootJar {
- baseName = 'draft-gs-template'
- version = '0.1.0'
-}
+group = 'com.example'
+version = '0.0.1-SNAPSHOT'
+sourceCompatibility = '1.8'
repositories {
- mavenCentral()
+ mavenCentral()
+ maven { url 'https://repo.spring.io/milestone' }
}
-sourceCompatibility = 1.8
-targetCompatibility = 1.8
-
dependencies {
- compile("org.springframework.boot:spring-boot-starter-web")
- testCompile("org.springframework.boot:spring-boot-starter-test")
+ implementation 'org.springframework.boot.experimental:spring-boot-starter-data-r2dbc'
+ runtimeOnly 'com.h2database:h2'
+ runtimeOnly 'io.r2dbc:r2dbc-h2'
+ testImplementation('org.springframework.boot:spring-boot-starter-test') {
+ exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
+ }
+ testImplementation 'org.springframework.boot.experimental:spring-boot-test-autoconfigure-r2dbc'
+ testImplementation 'io.projectreactor:reactor-test'
}
+dependencyManagement {
+ imports {
+ mavenBom 'org.springframework.boot.experimental:spring-boot-bom-r2dbc:0.1.0.M3'
+ }
+}
+
+test {
+ useJUnitPlatform()
+}
diff --git a/initial/gradle/wrapper/gradle-wrapper.properties b/initial/gradle/wrapper/gradle-wrapper.properties
index 07e727a..abda63d 100644
--- a/initial/gradle/wrapper/gradle-wrapper.properties
+++ b/initial/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
diff --git a/initial/pom.xml b/initial/pom.xml
index bc281de..d28f719 100644
--- a/initial/pom.xml
+++ b/initial/pom.xml
@@ -4,27 +4,60 @@
4.0.0
org.springframework
- draft-gs-template
+ accessing-data-r2dbc
0.1.0
org.springframework.boot
spring-boot-starter-parent
- 2.1.6.RELEASE
+ 2.2.2.RELEASE
- org.springframework.boot
- spring-boot-starter-web
+ org.springframework.boot.experimental
+ spring-boot-starter-data-r2dbc
+
+
+ io.r2dbc
+ r2dbc-h2
+ runtime
org.springframework.boot
spring-boot-starter-test
test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+ org.springframework.boot.experimental
+ spring-boot-test-autoconfigure-r2dbc
+ test
+
+
+ io.projectreactor
+ reactor-test
+ test
+
+
+
+ org.springframework.boot.experimental
+ spring-boot-bom-r2dbc
+ 0.1.0.M3
+ pom
+ import
+
+
+
+
1.8
@@ -38,4 +71,12 @@
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+
+
diff --git a/initial/src/main/java/com/example/accessingdatar2dbc/AccessingDataR2dbcApplication.java b/initial/src/main/java/com/example/accessingdatar2dbc/AccessingDataR2dbcApplication.java
new file mode 100644
index 0000000..ed0ac5a
--- /dev/null
+++ b/initial/src/main/java/com/example/accessingdatar2dbc/AccessingDataR2dbcApplication.java
@@ -0,0 +1,13 @@
+package com.example.accessingdatar2dbc;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class AccessingDataR2dbcApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(AccessingDataR2dbcApplication.class, args);
+ }
+
+}
diff --git a/initial/src/main/java/hello/.gitignore b/initial/src/main/java/hello/.gitignore
deleted file mode 100644
index e69de29..0000000