diff --git a/README.adoc b/README.adoc index 668d6aa..9f355e7 100644 --- a/README.adoc +++ b/README.adoc @@ -1,229 +1,251 @@ -:spring_version: current -:spring_boot_version: 2.2.2.RELEASE -:Controller: https://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/stereotype/Controller.html -:DispatcherServlet: https://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/web/servlet/DispatcherServlet.html -:SpringApplication: https://docs.spring.io/spring-boot/docs/{spring_boot_version}/api/org/springframework/boot/SpringApplication.html -:ResponseBody: https://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/web/bind/annotation/ResponseBody.html :toc: :icons: font :source-highlighter: prettify -:project_id: gs-spring-cloud-circuitbreaker -This guide walks you through the process of applying circuit breakers to potentially-failing method calls using Spring Cloud Circuit Breaker. +:project_id: gs-searching-elasticsearch +This guide walks you through the process of using https://spring.io/projects/spring-data-elasticsearch/[Spring Data Elasticsearch] to build an application that allows you to interact with Elasticsearch, a NoSQL distributed search engine. == What you'll build -You'll build a microservice application that uses the http://martinfowler.com/bliki/CircuitBreaker.html[Circuit Breaker pattern] to gracefully degrade functionality when a method call fails. Use of the Circuit Breaker pattern can allow a microservice to continue operating when a related service fails, preventing the failure from cascading and giving the failing service time to recover. - +You will store, search, and analyse `JSON` documents in Elasticsearch by using Spring Data Elasticsearch. == What you'll need :java_version: 1.8 include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/prereq_editor_jdk_buildtools.adoc[] -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/how_to_complete_this_guide.adoc[] - +- An Elasticsearch server (See <>) -[[reveal-gradle]] -[.reveal-gradle] -== Build with Gradle +include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/how_to_complete_this_guide.adoc[] [[scratch]] -[.use-gradle] -== Build with Gradle - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/build_system_intro.adoc[] +== Setting up Elasticsearch Cluster -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/create_directory_structure_hello.adoc[] +Before starting up, we need to have the Elasticsearch cluster up and running which ingests all our data and receives queries. -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/create_both_builds.adoc[] +Elasticsearch is a free and open Distributed REST based search engine. It is a JSON based store, accepts queries via Elasticsearch specific QueryDSL OR Structured Query Language (SQL). It is freely available at elastic.co/downloads/elasticsearch, download it manually or if you use a Mac, with Homebrew, by running the following command in a terminal window: -`bookstore/build.gradle` -// AsciiDoc source formatting doesn't support groovy, so using java instead -[source,java] +==== +[source,bash] ---- -include::https://raw.githubusercontent.com/spring-guides/{project_id}/main/initial/bookstore/build.gradle[] +brew tap elastic/tap ---- +==== -`reading/build.gradle` -// AsciiDoc source formatting doesn't support groovy, so using java instead -[source,java] +==== +[source,bash] ---- -include::https://raw.githubusercontent.com/spring-guides/{project_id}/main/initial/reading/build.gradle[] +brew install elastic/tap/elasticsearch-full ---- +==== -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/spring-boot-gradle-plugin.adoc[] +Once you unpack Redis, you can launch it with its default settings by running the following command: -[[reveal-maven]] -[.reveal-maven] -== Build with Maven +==== +[source,bash] +---- +elasticsearch +---- +==== -[[use-maven]] -[.use-maven] -== Build with Maven +You should see output similar to the following: -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/build_system_intro_maven.adoc[] +==== +[source,text] +---- +[o.e.n.Node] [mac.local] started +[INFO ][o.e.l.LicenseService] [mac.local] license [bdfa1fdb-bed5-4732-aac4-81010ac9b40b] mode [basic] - valid +---- +==== -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/create_directory_structure_hello.adoc[] +Further to check the version and status of the Elasticsearch server, you can call below command with cURL. -`bookstore/pom.xml` -[source,xml] +==== +[source,bash] ---- -include::https://raw.githubusercontent.com/spring-guides/{project_id}/main/initial/bookstore/pom.xml[] +curl http://localhost:9200 ---- +==== + +You should see output similar to the following: -`reading/pom.xml` -[source,xml] +==== +[source,text] ---- -include::https://raw.githubusercontent.com/spring-guides/{project_id}/main/initial/reading/pom.xml[] +{ + "name" : "Aravind-Putrevu.local", + "cluster_name" : "elasticsearch_aravindputrevu", + "cluster_uuid" : "VzGWAItpTV2dJN8tfKhKMg", + "version" : { + "number" : "7.12.1", + "build_flavor" : "default", + "build_type" : "tar", + "build_hash" : "3186837139b9c6b6d23c3200870651f10d3343b7", + "build_date" : "2021-04-20T20:56:39.040728659Z", + "build_snapshot" : false, + "lucene_version" : "8.8.0", + "minimum_wire_compatibility_version" : "6.8.0", + "minimum_index_compatibility_version" : "6.0.0-beta1" + }, + "tagline" : "You Know, for Search" +} ---- +==== -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/spring-boot-maven-plugin.adoc[] +[[initial]] +=== Starting with Spring Initializer -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/hide-show-sts.adoc[] +If you use Maven, visit the https://start.spring.io/#!type=maven-project&language=java&platformVersion=2.4.5.RELEASE&packaging=jar&jvmVersion=1.8&groupId=com.example&artifactId=indexing-data-elasticsearch&name=indexing-data-elasticsearch&description=Indexing%20data%20into%20Elasticsearch&packageName=com.example.elasticsearch&dependencies=data-elasticsearch,web[Spring Initializr] to generate a new project with the required dependency (Spring Data Elasticsearch). +The following listing shows the `pom.xml` file that is created when you choose Maven: -[[initial]] -== Set up a server microservice application +==== +[src,xml] +---- +include::complete/pom.xml[] +---- +==== -The Bookstore service will have a single endpoint. It will be accessible at `/recommended`, and will (for simplicity) return a `Mono` of `String` recommended reading list. +If you use Gradle, visit the https://start.spring.io/#!type=gradle-project&language=java&platformVersion=2.4.5.RELEASE&packaging=jar&jvmVersion=1.8&groupId=com.example&artifactId=indexing-data-elasticsearch&name=indexing-data-elasticsearch&description=Indexing%20data%20into%20Elasticsearch&packageName=com.example.elasticsearch&dependencies=data-elasticsearch,web[Spring Initializr] to generate a new project with the required dependency (Spring Data Elasticsearch). -Edit our main class, in `BookstoreApplication.java`. It should look like this: +The following listing shows the `build.gradle` file that is created when you choose Gradle: -`bookstore/src/main/java/hello/BookstoreApplication.java` -[source,java,tabsize=2] +==== +[src,java] ---- -include::complete/bookstore/src/main/java/hello/BookstoreApplication.java[] +include::complete/build.gradle[] ---- +==== -The `@RestController` annotation marks `BookstoreApplication` as a controller class, like `@Controller` does, and also ensures that `@RequestMapping` methods in this class will behave as though annotated with `@ResponseBody`. That is, the return values of `@RequestMapping` methods in this class will be automatically converted appropriately from their original types and will be written directly to the response body. +=== Manual Initialization (optional) -We're going to run this application locally alongside a client service application, so in `src/main/resources/application.properties`, set `server.port` so that the Bookstore service won't conflict with the client when we get that running. +If you want to initialize the project manually rather than use the links shown earlier, follow the steps given below: -`bookstore/src/main/resources/application.properties` -[source,properties] ----- -include::complete/bookstore/src/main/resources/application.properties[] ----- +. Navigate to https://start.spring.io. +This service pulls in all the dependencies you need for an application and does most of the setup for you. +. Choose either Gradle or Maven and the language you want to use. This guide assumes that you chose Java. +. Click *Dependencies* and select *Spring Data Elasticsearch*. +. Click *Generate*. +. Download the resulting ZIP file, which is an archive of a web application that is configured with your choices. -== Set up a client microservice application +NOTE: If your IDE has the Spring Initializr integration, you can complete this process from your IDE. -The Reading application will be our front-end (as it were) to the Bookstore application. We'll be able to view our reading list there at `/to-read`, and that reading list will be retrieved from the Bookstore service application. +== Create an Entity -`reading/src/main/java/hello/ReadingApplication.java` +Elasticsearch stores data in Indices. In this guide, we will create an entity called `Account`. The following class shows the Account class (in `src/main/java/com/example/elasticsearch/entity/Account.java`) + +==== [source,java,tabsize=2] ---- -package hello; +include::complete/src/main/java/com/example/elasticsearch/entity/Account.java[] +---- +==== -import reactor.core.publisher.Mono; +`@Document` annotation is applied at class level to declare that the mapping related information and index name of the Elasticsearch index. `VersionType` signifies the document version management. -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.reactive.function.client.WebClient; +It is important to note, understand and change default values of some fields like `versionType`. Because, you might be overriding the best defaults of Elasticsearch, therefore you need to manage the feature by yourselves. -@RestController -@SpringBootApplication -public class ReadingApplication { +`Account` class has several attributes like: `id`, `firstName`, and `lastName`, `age`, `gender` etc. Each document ingested into Elasticsearch has an `_id` field that uniquely identifies it, which is indexed so that documents can be looked up. - @RequestMapping("/to-read") - public Mono toRead() { - return WebClient.builder().build() - .get().uri("http://localhost:8090/recommended").retrieve() - .bodyToMono(String.class); - } +`@Field` denoted the type of the field in the document. You can find all the accepted field types https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html[here]. + +NOTE: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html[Official documentation] has more information on different types of Mappings and few special fields. - public static void main(String[] args) { - SpringApplication.run(ReadingApplication.class, args); - } -} ----- -To get the list from Bookstore, we're using Spring's `WebClient` class. `WebClient` makes an HTTP GET request to the Bookstore service's URL as we provide it and then returns the result as a `Mono` of `String`. (For more information on using Spring to consume a RESTful service using `WebClient`, see the https://spring.io/guides/gs/reactive-rest-service/[Building a Reactive RESTful Web Service] guide.) +== Define a Elasticsearch Repository -Add the `server.port` property to `src/main/resources/application.properties`: +Spring Data has the repository concept to manage the datastores. Spring Data Elasicsearch also has the implementation of ElasticsearchRepository. -`reading/src/main/resources/application.properties` -[source,properties] +To see how this works, create a repository interface that queries `AccountRepository` documents, as +the following listing (in + `src/main/java/com/example/accessingdatamongodb/AccountRepository.java`) shows: + +==== +[source,java,tabsize=2] ---- -include::complete/reading/src/main/resources/application.properties[] +include::complete/src/main/java/com/example/elasticsearch/AccountRepository.java[] ---- +==== -We now can access, in a browser, the `/to-read` endpoint on our Reading application, and see our reading list. Yet since we rely on the Bookstore application, if anything happens to it, or if Reading is simply unable to access Bookstore, we'll have no list and our users will get a nasty HTTP `500` error message. +TKTK write advanced queries -== Apply The Circuit Breaker Pattern -Spring Cloud's Circuit Breaker library provides an implementation of the Circuit Breaker pattern: -when we wrap a method call in a circuit breaker, Spring Cloud Circuit Breaker watches for failing -calls to that method, and if failures build up to a threshold, Spring Cloud Circuit Breaker opens -the circuit so that subsequent calls automatically fail. While the circuit is open, Spring Cloud -Circuit Breaker redirects calls to the method, and they’re passed on to our specified fallback -method. +The advantage of using Spring Data Elasticsearch to create a implementation of `ElasticsearchRepository` and add query methods with verbs like findBy. You don't need to create complete Elasticsearch implementation. -Spring Cloud Circuit Breaker supports many different circuit breaker implementations including, -Resilience4J, Hystrix, Sentinal, and Spring Retry. In this guide we will use the Resilience4J -implementation. To use this implementation we just need to add `spring-cloud-starter-circuitbreaker-reactor-resilience4j` -to our application's classpath. +Now you can wire up this application and see what it looks like! -`reading/pom.xml` -[source,xml] ----- -include::complete/reading/pom.xml[] ----- +== Create an Application Class + +Spring Initializr creates a application class. The following listing shows +the class (in +`src/main/java/com/example/elasticsearch/ElasticsearchApplication.java`): -`reading/build.gradle` -[source,groovy] +==== +[source,java,tabsize=2] ---- -include::complete/reading/build.gradle[] +include::initial/src/main/java/com/example/elasticsearch/ElasticsearchApplication.java[] ---- +==== -Spring Cloud Circuit Breaker provides an interface called `ReactiveCircuitBreakerFactory` which -we can use to create new circuit breakers for our application. An implementation of this interface -will be auto-configured based on the starter that is on your application's classpath. Lets create -a new service that uses this interface to make API calls to the Bookstore application +include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/spring-boot-application-new-path.adoc[] -`reading/src/main/java/hello/BookService.java` -[source,java] ----- -include::complete/reading/src/main/java/hello/BookService.java[] ----- +Spring Boot automatically handles those repositories as long as they are included +in the same package (or a sub-package) of your `@SpringBootApplication` class. For more +control over the registration process, you can use the `@EnableElasticsearchRepositories` +annotation. + +NOTE: By default, `@EnableElasticsearchRepositories` scans the current package for any interfaces +that extend one of Spring Data's repository interface. Alternatively, you can use `basePackageClasses=Repository.class` to instruct Spring Data Elasticsearch to scan a +different root package by type if your project layout has multiple projects and it does +not find your repositories. -The `ReactiveCircuitBreakerFactory` has a single method called `create` we can use to create new circuit -breakers. Once we have our circuit breaker all we have -to do is call `run`. Run takes a `Mono` or `Flux` and an optional -`Function`. The optional `Function` parameter acts as our fallback if anything goes wrong. In our -sample here the fallback will just return a `Mono` containing the `String` `Cloud Native Java (O'Reilly)`. +TKTK - more about queries -With our new service in place, we can update the code in `ReadingApplication` to use this new service. +Let's modify the simple class that the Spring Initializr created. Create some data and ingest it into Elasticsearch. The following listing shows the finished `ElasticsearchApplication` class (in +`src/main/java/com/example/elasticsearch/ElasticsearchApplication.java`): -`reading/src/main/java/hello/ReadingApplication.java` -[source,java] +==== +[source,java,tabsize=2] ---- -include::complete/reading/src/main/java/hello/ReadingApplication.java[] +include::complete/src/main/java/com/example/elasticsearch/ElasticsearchApplication.java[] ---- +==== +`ElasticsearchApplication` includes a `main()` method which autowires `AccountRepository` class through which we access Elasticsearch which is running locally. Using Spring Data Elasticsearch methods `save()`, `findById()`, `count()`, we have created, queried `accounts` index in Elasticsearch. -== Try it out +Note: If you have an `accounts` index in Elasticsearch, the application deleted all the documents using `deleteAll()` method. -Run both the Bookstore service and the Reading service, and then open a browser to the Reading service, at `localhost:8080/to-read`. You should see the complete recommended reading list: +Spring Data Elasticsearch uses the High level REST Client, using the `ElasticsearchRESTClientConfig`, we have configured the Elasticsearch instance. +Here is the listing which shows `ElasticsearchRESTClientConfig` class (in +`src/main/java/com/example/elasticsearch/ElasticsearchRESTClientConfig.java`): + +==== +[source,java,tabsize=2] ---- -Spring in Action (Manning), Cloud Native Java (O'Reilly), Learning Spring Boot (Packt) +include::complete/src/main/java/com/example/elasticsearch/ElasticsearchRESTClientConfig.java[] ---- +==== -Now shut down the Bookstore application. Our list source is gone, but thanks to Hystrix and Spring Cloud Netflix, we have a reliable abbreviated list to stand in the gap; you should see: +NOTE: For more information on Elasticsearch Clients and querying methods, you can refer to https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.clients[Spring Data Elasticsearch Documentation] ----- -Cloud Native Java (O'Reilly) ----- +include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/build_an_executable_jar_mainhead.adoc[] +include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/build_an_executable_jar_with_both.adoc[] == Summary -Congratulations! You've just developed a Spring application that uses the Circuit Breaker pattern to protect against cascading failures and to provide fallback behavior for potentially failing calls. - +Congratulations! You have created a Elasticsearch server and wrote a simple application that uses +Spring Data Elasticsearch to save objects, perform search, and even delete them, all without writing +a concrete repository implementation. +== See Also +The following guides may also be helpful: +* https://spring.io/guides/gs/accessing-data-jpa/[Accessing Data with JPA] +* https://spring.io/guides/gs/spring-boot/[Building Application with Spring Boot] +* https://spring.io/guides/gs/accessing-data-mysql/[Accessing data with MySQL] include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/footer.adoc[] + + diff --git a/complete/bookstore/.mvn/wrapper/maven-wrapper.jar b/complete/bookstore/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index 5fd4d50..0000000 Binary files a/complete/bookstore/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/complete/bookstore/.mvn/wrapper/maven-wrapper.properties b/complete/bookstore/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index eb91947..0000000 --- a/complete/bookstore/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1 +0,0 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip \ No newline at end of file diff --git a/complete/bookstore/build.gradle b/complete/bookstore/build.gradle deleted file mode 100644 index 11efa36..0000000 --- a/complete/bookstore/build.gradle +++ /dev/null @@ -1,45 +0,0 @@ -buildscript { - ext { - springBootVersion = '2.2.2.RELEASET' - } - repositories { - mavenCentral() - maven { url 'https://repo.spring.io/milestone' } - maven { url 'https://repo.spring.io/snapshot' } - } - dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") - } -} - -apply plugin: 'java' -apply plugin: 'eclipse' -apply plugin: 'idea' -apply plugin: 'org.springframework.boot' -apply plugin: 'io.spring.dependency-management' - -bootJar { - baseName = 'bookstore' - version = '0.0.1-SNAPSHOT' -} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -repositories { - mavenCentral() -} - - -dependencies { - compile('org.springframework.boot:spring-boot-starter-webflux') - testCompile('org.springframework.boot:spring-boot-starter-test') -} - - -eclipse { - classpath { - containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') - containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' - } -} - diff --git a/complete/bookstore/pom.xml b/complete/bookstore/pom.xml deleted file mode 100644 index 2f0a39c..0000000 --- a/complete/bookstore/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - 4.0.0 - - hello - bookstore - 0.0.1-SNAPSHOT - jar - - - org.springframework.boot - spring-boot-starter-parent - 2.2.2.RELEASE - - - - - UTF-8 - 1.8 - - - - - org.springframework.boot - spring-boot-starter-webflux - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - diff --git a/complete/bookstore/src/main/java/hello/BookstoreApplication.java b/complete/bookstore/src/main/java/hello/BookstoreApplication.java deleted file mode 100644 index 6dfa00a..0000000 --- a/complete/bookstore/src/main/java/hello/BookstoreApplication.java +++ /dev/null @@ -1,22 +0,0 @@ -package hello; - -import reactor.core.publisher.Mono; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.bind.annotation.RequestMapping; - -@RestController -@SpringBootApplication -public class BookstoreApplication { - - @RequestMapping(value = "/recommended") - public Mono readingList(){ - return Mono.just("Spring in Action (Manning), Cloud Native Java (O'Reilly), Learning Spring Boot (Packt)"); - } - - public static void main(String[] args) { - SpringApplication.run(BookstoreApplication.class, args); - } -} diff --git a/complete/bookstore/src/main/resources/application.properties b/complete/bookstore/src/main/resources/application.properties deleted file mode 100644 index f620381..0000000 --- a/complete/bookstore/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -server.port=8090 diff --git a/complete/bookstore/src/test/java/hello/BookstoreApplicationTests.java b/complete/bookstore/src/test/java/hello/BookstoreApplicationTests.java deleted file mode 100644 index 1c77fd2..0000000 --- a/complete/bookstore/src/test/java/hello/BookstoreApplicationTests.java +++ /dev/null @@ -1,26 +0,0 @@ -package hello; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.reactive.server.WebTestClient; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) -public class BookstoreApplicationTests { - - @Autowired - private WebTestClient webTestClient; - - @Test - public void recommendedTest() { - webTestClient.get().uri("/recommended").exchange() - .expectStatus().isOk() - .expectBody(String.class).value(m -> m.equals("Spring in Action (Manning), Cloud Native Java (O'Reilly), Learning Spring Boot (Packt)")); - } -} diff --git a/complete/build.gradle b/complete/build.gradle index d55d623..a7f15f9 100644 --- a/complete/build.gradle +++ b/complete/build.gradle @@ -1,32 +1,22 @@ -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:2.2.2.RELEASE") - } +plugins { + id 'org.springframework.boot' version '2.4.5' + id 'io.spring.dependency-management' version '1.0.11.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 = '11' repositories { - mavenCentral() + mavenCentral() } -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:spring-boot-starter-data-elasticsearch' + testImplementation 'org.springframework.boot:spring-boot-starter-test' } +test { + useJUnitPlatform() +} diff --git a/complete/gradle/wrapper/gradle-wrapper.jar b/complete/gradle/wrapper/gradle-wrapper.jar index f6b961f..e708b1c 100644 Binary files a/complete/gradle/wrapper/gradle-wrapper.jar and b/complete/gradle/wrapper/gradle-wrapper.jar differ diff --git a/complete/gradle/wrapper/gradle-wrapper.properties b/complete/gradle/wrapper/gradle-wrapper.properties index ae45383..7d285dd 100644 --- a/complete/gradle/wrapper/gradle-wrapper.properties +++ b/complete/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Fri May 14 13:30:07 IST 2021 +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/complete/gradlew b/complete/gradlew index cccdd3d..4f906e0 100755 --- a/complete/gradlew +++ b/complete/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 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 +# +# https://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. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -66,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -109,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -138,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/complete/gradlew.bat b/complete/gradlew.bat index f955316..ac1b06f 100644 --- a/complete/gradlew.bat +++ b/complete/gradlew.bat @@ -1,84 +1,89 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/complete/mvnw b/complete/mvnw index 02217b1..a16b543 100755 --- a/complete/mvnw +++ b/complete/mvnw @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script +# Maven Start Up Batch script # # Required ENV vars: # ------------------ @@ -54,38 +54,16 @@ case "`uname`" in CYGWIN*) cygwin=true ;; MINGW*) mingw=true;; Darwin*) darwin=true - # - # Look for the Apple JDKs first to preserve the existing behaviour, and then look - # for the new JDKs provided by Oracle. - # - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then - # - # Oracle JDKs - # - export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then - # - # Apple JDKs - # - export JAVA_HOME=`/usr/libexec/java_home` - fi - ;; + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; esac if [ -z "$JAVA_HOME" ] ; then @@ -130,13 +108,12 @@ if $cygwin ; then CLASSPATH=`cygpath --path --unix "$CLASSPATH"` fi -# For Migwn, ensure paths are in UNIX format before anything is touched +# For Mingw, ensure paths are in UNIX format before anything is touched if $mingw ; then [ -n "$M2_HOME" ] && M2_HOME="`(cd "$M2_HOME"; pwd)`" [ -n "$JAVA_HOME" ] && JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? fi if [ -z "$JAVA_HOME" ]; then @@ -184,27 +161,28 @@ fi CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` -fi - # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { - local basedir=$(pwd) - local wdir=$(pwd) + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" while [ "$wdir" != '/' ] ; do if [ -d "$wdir"/.mvn ] ; then basedir=$wdir break fi - wdir=$(cd "$wdir/.."; pwd) + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround done echo "${basedir}" } @@ -216,9 +194,108 @@ concat_lines() { fi } -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + # Provide a "standardized" way to retrieve the CLI args that will # work with both Windows and non-Windows executions. MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" @@ -230,4 +307,4 @@ exec "$JAVACMD" \ $MAVEN_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} "$@" + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/complete/mvnw.cmd b/complete/mvnw.cmd old mode 100755 new mode 100644 index 4b98b78..c8d4337 --- a/complete/mvnw.cmd +++ b/complete/mvnw.cmd @@ -18,7 +18,7 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script +@REM Maven Start Up Batch script @REM @REM Required ENV vars: @REM JAVA_HOME - location of a JDK home dir @@ -26,7 +26,7 @@ @REM Optional ENV vars @REM M2_HOME - location of maven2's installed home dir @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven @REM e.g. to debug Maven itself, use @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 @@ -35,7 +35,9 @@ @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' @echo off -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% @REM set %HOME% to equivalent of $HOME @@ -80,8 +82,6 @@ goto error :init -set MAVEN_CMD_LINE_ARGS=%* - @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". @REM Fallback to current working directory if not found. @@ -117,11 +117,48 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s :endReadAdditionalConfig SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* if ERRORLEVEL 1 goto error goto end @@ -142,4 +179,4 @@ if "%MAVEN_BATCH_PAUSE%" == "on" pause if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% -exit /B %ERROR_CODE% \ No newline at end of file +exit /B %ERROR_CODE% diff --git a/complete/pom.xml b/complete/pom.xml index af5948b..cc8f559 100644 --- a/complete/pom.xml +++ b/complete/pom.xml @@ -1,41 +1,46 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.4.5 + + + com.example + indexing-data-elasticsearch + 0.0.1-SNAPSHOT + indexing-data-elasticsearch + Indexing data into Elasticsearch + + 15 + + + + org.springframework.boot + spring-boot-starter-data-elasticsearch + - org.springframework - draft-gs-template - 0.1.0 + + org.springframework.boot + spring-boot-starter-web + - - org.springframework.boot - spring-boot-starter-parent - 2.2.2.RELEASE - + + org.springframework.boot + spring-boot-starter-test + test + + - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-test - test - - - - - 1.8 - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - + + + + org.springframework.boot + spring-boot-maven-plugin + + + diff --git a/complete/reading/.mvn/wrapper/maven-wrapper.jar b/complete/reading/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index 5fd4d50..0000000 Binary files a/complete/reading/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/complete/reading/.mvn/wrapper/maven-wrapper.properties b/complete/reading/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index eb91947..0000000 --- a/complete/reading/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1 +0,0 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip \ No newline at end of file diff --git a/complete/reading/build.gradle b/complete/reading/build.gradle deleted file mode 100644 index a5b8f38..0000000 --- a/complete/reading/build.gradle +++ /dev/null @@ -1,51 +0,0 @@ -buildscript { - ext { - springBootVersion = '2.2.2.RELEASE' - } - repositories { - mavenCentral() - maven { url 'https://repo.spring.io/milestone' } - maven { url 'https://repo.spring.io/snapshot' } - } - dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") - } -} - -apply plugin: 'java' -apply plugin: 'eclipse' -apply plugin: 'idea' -apply plugin: 'org.springframework.boot' -apply plugin: 'io.spring.dependency-management' - -bootJar { - baseName = 'reading' - version = '0.0.1-SNAPSHOT' -} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -repositories { - mavenCentral() -} - - -dependencies { - compile('org.springframework.cloud:spring-cloud-starter-circuitbreaker-reactor-resilience4j') - compile('org.springframework.boot:spring-boot-starter-webflux') - testCompile('org.springframework.boot:spring-boot-starter-test') -} - -dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-dependencies:Hoxton.SR1" - } -} - -eclipse { - classpath { - containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') - containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' - } -} - diff --git a/complete/reading/pom.xml b/complete/reading/pom.xml deleted file mode 100644 index 8a21fbe..0000000 --- a/complete/reading/pom.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - 4.0.0 - - hello - reading - 0.0.1-SNAPSHOT - jar - - - org.springframework.boot - spring-boot-starter-parent - 2.2.2.RELEASE - - - - - UTF-8 - 1.8 - - - - - org.springframework.cloud - spring-cloud-starter-circuitbreaker-reactor-resilience4j - - - org.springframework.boot - spring-boot-starter-webflux - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.cloud - spring-cloud-dependencies - Hoxton.SR1 - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - diff --git a/complete/reading/src/main/java/hello/BookService.java b/complete/reading/src/main/java/hello/BookService.java deleted file mode 100644 index 67f0b0a..0000000 --- a/complete/reading/src/main/java/hello/BookService.java +++ /dev/null @@ -1,32 +0,0 @@ -package hello; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import reactor.core.publisher.Mono; - -import org.springframework.cloud.client.circuitbreaker.ReactiveCircuitBreaker; -import org.springframework.cloud.client.circuitbreaker.ReactiveCircuitBreakerFactory; -import org.springframework.stereotype.Service; -import org.springframework.web.reactive.function.client.WebClient; - -@Service -public class BookService { - - private static final Logger LOG = LoggerFactory.getLogger(BookService.class); - - - private final WebClient webClient; - private final ReactiveCircuitBreaker readingListCircuitBreaker; - - public BookService(ReactiveCircuitBreakerFactory circuitBreakerFactory) { - this.webClient = WebClient.builder().baseUrl("http://localhost:8090").build(); - this.readingListCircuitBreaker = circuitBreakerFactory.create("recommended"); - } - - public Mono readingList() { - return readingListCircuitBreaker.run(webClient.get().uri("/recommended").retrieve().bodyToMono(String.class), throwable -> { - LOG.warn("Error making request to book service", throwable); - return Mono.just("Cloud Native Java (O'Reilly)"); - }); - } -} diff --git a/complete/reading/src/main/java/hello/ReadingApplication.java b/complete/reading/src/main/java/hello/ReadingApplication.java deleted file mode 100644 index a7fd88e..0000000 --- a/complete/reading/src/main/java/hello/ReadingApplication.java +++ /dev/null @@ -1,27 +0,0 @@ -package hello; - -import reactor.core.publisher.Mono; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.reactive.function.client.WebClient; - -@RestController -@SpringBootApplication -public class ReadingApplication { - - @Autowired - private BookService bookService; - - @RequestMapping("/to-read") - public Mono toRead() { - return bookService.readingList(); - } - - public static void main(String[] args) { - SpringApplication.run(ReadingApplication.class, args); - } -} diff --git a/complete/reading/src/main/resources/application.properties b/complete/reading/src/main/resources/application.properties deleted file mode 100644 index 4c00e40..0000000 --- a/complete/reading/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -server.port=8080 diff --git a/complete/reading/src/test/java/hello/BookServiceTests.java b/complete/reading/src/test/java/hello/BookServiceTests.java deleted file mode 100644 index 61127b9..0000000 --- a/complete/reading/src/test/java/hello/BookServiceTests.java +++ /dev/null @@ -1,32 +0,0 @@ -package hello; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.client.RestClientTest; -import org.springframework.http.MediaType; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.client.MockRestServiceServer; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; - - -@RunWith(SpringRunner.class) -@RestClientTest(BookService.class) -public class BookServiceTests { - - @Autowired - private BookService bookService; - - @Autowired - private MockRestServiceServer server; - - @Test - public void readingListTest() { - this.server.expect(requestTo("http://localhost:8090/recommended")) - .andRespond(withSuccess("books", MediaType.TEXT_PLAIN)); - assertThat(bookService.readingList()).isEqualTo("books"); - } -} diff --git a/complete/reading/src/test/java/hello/ReadingApplicationTests.java b/complete/reading/src/test/java/hello/ReadingApplicationTests.java deleted file mode 100644 index 7bfb8dc..0000000 --- a/complete/reading/src/test/java/hello/ReadingApplicationTests.java +++ /dev/null @@ -1,61 +0,0 @@ -package hello; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.http.HttpMethod; -import org.springframework.http.MediaType; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.client.MockRestServiceServer; -import org.springframework.web.client.RestTemplate; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withServerError; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; - - -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) -public class ReadingApplicationTests { - - private MockRestServiceServer server; - - @Autowired - private TestRestTemplate testRestTemplate; - - @Autowired - private RestTemplate rest; - - @Before - public void setup() { - this.server = MockRestServiceServer.createServer(rest); - } - - @After - public void teardown() { - this.server = null; - } - - @Test - public void toReadTest() { - this.server.expect(requestTo("http://localhost:8090/recommended")) - .andExpect(method(HttpMethod.GET)). - andRespond(withSuccess("books", MediaType.TEXT_PLAIN)); - String books = testRestTemplate.getForObject("/to-read", String.class); - assertThat(books).isEqualTo("books"); - } - - @Test - public void toReadFailureTest() { - this.server.expect(requestTo("http://localhost:8090/recommended")). - andExpect(method(HttpMethod.GET)).andRespond(withServerError()); - String books = testRestTemplate.getForObject("/to-read", String.class); - assertThat(books).isEqualTo("Cloud Native Java (O'Reilly)"); - } -} diff --git a/complete/settings.gradle b/complete/settings.gradle new file mode 100644 index 0000000..bd183de --- /dev/null +++ b/complete/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'indexing-data-elasticsearch' diff --git a/complete/src/main/java/com/example/elasticsearch/AccountRepository.java b/complete/src/main/java/com/example/elasticsearch/AccountRepository.java new file mode 100644 index 0000000..c996763 --- /dev/null +++ b/complete/src/main/java/com/example/elasticsearch/AccountRepository.java @@ -0,0 +1,8 @@ +package com.example.elasticsearch; + +import com.example.elasticsearch.entity.Account; +import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; + +public interface AccountRepository extends ElasticsearchRepository { + +} diff --git a/complete/src/main/java/com/example/elasticsearch/ElasticsearchApplication.java b/complete/src/main/java/com/example/elasticsearch/ElasticsearchApplication.java new file mode 100644 index 0000000..eb3def9 --- /dev/null +++ b/complete/src/main/java/com/example/elasticsearch/ElasticsearchApplication.java @@ -0,0 +1,54 @@ +package com.example.elasticsearch; + +import com.example.elasticsearch.entity.Account; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; + +import java.util.Iterator; + +@EnableElasticsearchRepositories (basePackageClasses = AccountRepository.class) +@SpringBootApplication +public class ElasticsearchApplication implements CommandLineRunner { + + @Autowired private AccountRepository accountRepository; + + public static void main(String[] args) { + SpringApplication.run(ElasticsearchApplication.class, args); + } + + @Override + public void run(String... args) throws Exception { + + //clear all the documents in the index. + { + accountRepository.deleteAll(); + } + + System.out.println("Count of documents in Accounts Index"); + System.out.println("-------------------------------"); + System.out.println(accountRepository.count()); + + accountRepository.save(new Account(5,32533.0,"Aravind","Putrevu",25,"M","800 W El Camino Real","Elastic","aravind@example.com","Sanfrancisco","CA")); + accountRepository.save(new Account(9,65537.0,"","Guduru",28,"F","800 W El Camino Real","Rubrik","siri@example.com","Sanfrancisco","CA")); + + System.out.println("Find Accounts by ID"); + System.out.println("-------------------------------"); + System.out.println(accountRepository.findById(5).get().toString()); + System.out.println("\n"); + + System.out.println("Count of documents in Accounts Index"); + System.out.println("-------------------------------"); + System.out.println(accountRepository.count()); + + System.out.println("-------------------------------"); + System.out.println("List all Accounts"); + System.out.println("-------------------------------"); + Iterator it = accountRepository.findAll().iterator(); + while (it.hasNext()) { + System.out.println(it.next().toString()); + } + } +} diff --git a/complete/src/main/java/com/example/elasticsearch/ElasticsearchRestClientConfig.java b/complete/src/main/java/com/example/elasticsearch/ElasticsearchRestClientConfig.java new file mode 100644 index 0000000..262b514 --- /dev/null +++ b/complete/src/main/java/com/example/elasticsearch/ElasticsearchRestClientConfig.java @@ -0,0 +1,27 @@ +package com.example.elasticsearch; + +import org.elasticsearch.client.RestHighLevelClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.elasticsearch.client.ClientConfiguration; +import org.springframework.data.elasticsearch.client.RestClients; +import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration; + +@Configuration +public class ElasticsearchRestClientConfig extends AbstractElasticsearchConfiguration { + + private static final Logger logger = LoggerFactory.getLogger(ElasticsearchRestClientConfig.class); + + @Override + @Bean + public RestHighLevelClient elasticsearchClient() { + + final ClientConfiguration.MaybeSecureClientConfigurationBuilder clientConfiguration = ClientConfiguration.builder() + .connectedTo("localhost:9200"); + + logger.info("Elasticsearch server [{}:{}] ssl[{}] auth[{}]"+ClientConfiguration.localhost()); + return RestClients.create(clientConfiguration.build()).rest(); + } +} diff --git a/complete/src/main/java/com/example/elasticsearch/entity/Account.java b/complete/src/main/java/com/example/elasticsearch/entity/Account.java new file mode 100644 index 0000000..95f9b8b --- /dev/null +++ b/complete/src/main/java/com/example/elasticsearch/entity/Account.java @@ -0,0 +1,54 @@ +package com.example.elasticsearch.entity; + +import org.elasticsearch.index.VersionType; +import org.springframework.data.annotation.Id; +import org.springframework.data.elasticsearch.annotations.Document; +import org.springframework.data.elasticsearch.annotations.Field; +import org.springframework.data.elasticsearch.annotations.FieldType; + +@Document(indexName = "accounts", versionType = VersionType.INTERNAL, createIndex = true) +public class Account{ + + private @Id Integer id; + private @Field(type = FieldType.Double) Double balance; + private @Field(type = FieldType.Text) String firstName; + private @Field(type = FieldType.Text)String lastName; + private @Field(type = FieldType.Integer) Integer age; + private @Field(type = FieldType.Text) String gender; + private @Field(type = FieldType.Text) String address; + private @Field(type = FieldType.Text) String employer; + private @Field(type = FieldType.Text) String email; + private @Field(type = FieldType.Text) String city; + private @Field(type = FieldType.Text) String state; + + public Account(Integer id, Double balance, String firstName, String lastName, Integer age, String gender, String address, String employer, String email, String city, String state) { + this.id = id; + this.balance = balance; + this.firstName = firstName; + this.lastName = lastName; + this.age = age; + this.gender = gender; + this.address = address; + this.employer = employer; + this.email = email; + this.city = city; + this.state = state; + } + + @Override + public String toString() { + return "Account{" + + "id=" + id + + ", balance=" + balance + + ", firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + ", age=" + age + + ", gender='" + gender + '\'' + + ", address='" + address + '\'' + + ", employer='" + employer + '\'' + + ", email='" + email + '\'' + + ", city='" + city + '\'' + + ", state='" + state + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/complete/src/main/java/hello/GreetingController.java b/complete/src/main/java/hello/GreetingController.java deleted file mode 100644 index d1c910e..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/application.properties b/complete/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/complete/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/complete/src/test/java/com/example/elasticsearch/IndexingElasticsearchApplicationTests.java b/complete/src/test/java/com/example/elasticsearch/IndexingElasticsearchApplicationTests.java new file mode 100644 index 0000000..afde6ba --- /dev/null +++ b/complete/src/test/java/com/example/elasticsearch/IndexingElasticsearchApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.elasticsearch; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class IndexingElasticsearchApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/complete/src/test/java/hello/GreetingControllerTest.java b/complete/src/test/java/hello/GreetingControllerTest.java deleted file mode 100644 index e6beb45..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 - * - * https://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/HELP.md b/initial/HELP.md new file mode 100644 index 0000000..8ff847e --- /dev/null +++ b/initial/HELP.md @@ -0,0 +1,15 @@ +# Read Me First +The following was discovered as part of building this project: + +* The original package name 'com.example.indexing-data-elasticsearch' is invalid and this project uses 'com.example.elasticsearch' instead. + +# Getting Started + +### Reference Documentation +For further reference, please consider the following sections: + +* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) +* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.4.5/maven-plugin/reference/html/) +* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.4.5/maven-plugin/reference/html/#build-image) +* [Spring Data Elasticsearch (Access+Driver)](https://docs.spring.io/spring-boot/docs/2.4.5/reference/htmlsingle/#boot-features-elasticsearch) + diff --git a/initial/bookstore/.mvn/wrapper/maven-wrapper.jar b/initial/bookstore/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index 5fd4d50..0000000 Binary files a/initial/bookstore/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/initial/bookstore/.mvn/wrapper/maven-wrapper.properties b/initial/bookstore/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index eb91947..0000000 --- a/initial/bookstore/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1 +0,0 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip \ No newline at end of file diff --git a/initial/bookstore/build.gradle b/initial/bookstore/build.gradle deleted file mode 100644 index c275586..0000000 --- a/initial/bookstore/build.gradle +++ /dev/null @@ -1,45 +0,0 @@ -buildscript { - ext { - springBootVersion = '2.2.2.RELEASE' - } - repositories { - mavenCentral() - maven { url 'https://repo.spring.io/milestone' } - maven { url 'https://repo.spring.io/snapshot' } - } - dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") - } -} - -apply plugin: 'java' -apply plugin: 'eclipse' -apply plugin: 'idea' -apply plugin: 'org.springframework.boot' -apply plugin: 'io.spring.dependency-management' - -bootJar { - baseName = 'bookstore' - version = '0.0.1-SNAPSHOT' -} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -repositories { - mavenCentral() -} - - -dependencies { - compile('org.springframework.boot:spring-boot-starter-webflux') - testCompile('org.springframework.boot:spring-boot-starter-test') -} - - -eclipse { - classpath { - containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') - containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' - } -} - diff --git a/initial/bookstore/pom.xml b/initial/bookstore/pom.xml deleted file mode 100644 index 61ab60d..0000000 --- a/initial/bookstore/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - 4.0.0 - - hello - bookstore - 0.0.1-SNAPSHOT - jar - - - org.springframework.boot - spring-boot-starter-parent - 2.2.2.RELEASE - - - - - UTF-8 - 1.8 - - - - - org.springframework.boot - spring-boot-starter-webflux - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - diff --git a/initial/build.gradle b/initial/build.gradle index d55d623..a7f15f9 100644 --- a/initial/build.gradle +++ b/initial/build.gradle @@ -1,32 +1,22 @@ -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:2.2.2.RELEASE") - } +plugins { + id 'org.springframework.boot' version '2.4.5' + id 'io.spring.dependency-management' version '1.0.11.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 = '11' repositories { - mavenCentral() + mavenCentral() } -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:spring-boot-starter-data-elasticsearch' + testImplementation 'org.springframework.boot:spring-boot-starter-test' } +test { + useJUnitPlatform() +} diff --git a/initial/gradle/wrapper/gradle-wrapper.jar b/initial/gradle/wrapper/gradle-wrapper.jar index f6b961f..e708b1c 100644 Binary files a/initial/gradle/wrapper/gradle-wrapper.jar and b/initial/gradle/wrapper/gradle-wrapper.jar differ diff --git a/initial/gradle/wrapper/gradle-wrapper.properties b/initial/gradle/wrapper/gradle-wrapper.properties index ae45383..442d913 100644 --- a/initial/gradle/wrapper/gradle-wrapper.properties +++ b/initial/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/initial/gradlew b/initial/gradlew index cccdd3d..4f906e0 100755 --- a/initial/gradlew +++ b/initial/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 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 +# +# https://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. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -66,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -109,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -138,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/initial/gradlew.bat b/initial/gradlew.bat index f955316..ac1b06f 100644 --- a/initial/gradlew.bat +++ b/initial/gradlew.bat @@ -1,84 +1,89 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/initial/mvnw b/initial/mvnw index 02217b1..a16b543 100755 --- a/initial/mvnw +++ b/initial/mvnw @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script +# Maven Start Up Batch script # # Required ENV vars: # ------------------ @@ -54,38 +54,16 @@ case "`uname`" in CYGWIN*) cygwin=true ;; MINGW*) mingw=true;; Darwin*) darwin=true - # - # Look for the Apple JDKs first to preserve the existing behaviour, and then look - # for the new JDKs provided by Oracle. - # - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then - # - # Oracle JDKs - # - export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then - # - # Apple JDKs - # - export JAVA_HOME=`/usr/libexec/java_home` - fi - ;; + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; esac if [ -z "$JAVA_HOME" ] ; then @@ -130,13 +108,12 @@ if $cygwin ; then CLASSPATH=`cygpath --path --unix "$CLASSPATH"` fi -# For Migwn, ensure paths are in UNIX format before anything is touched +# For Mingw, ensure paths are in UNIX format before anything is touched if $mingw ; then [ -n "$M2_HOME" ] && M2_HOME="`(cd "$M2_HOME"; pwd)`" [ -n "$JAVA_HOME" ] && JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? fi if [ -z "$JAVA_HOME" ]; then @@ -184,27 +161,28 @@ fi CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` -fi - # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { - local basedir=$(pwd) - local wdir=$(pwd) + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" while [ "$wdir" != '/' ] ; do if [ -d "$wdir"/.mvn ] ; then basedir=$wdir break fi - wdir=$(cd "$wdir/.."; pwd) + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround done echo "${basedir}" } @@ -216,9 +194,108 @@ concat_lines() { fi } -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + # Provide a "standardized" way to retrieve the CLI args that will # work with both Windows and non-Windows executions. MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" @@ -230,4 +307,4 @@ exec "$JAVACMD" \ $MAVEN_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} "$@" + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/initial/mvnw.cmd b/initial/mvnw.cmd old mode 100755 new mode 100644 index 4b98b78..c8d4337 --- a/initial/mvnw.cmd +++ b/initial/mvnw.cmd @@ -18,7 +18,7 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script +@REM Maven Start Up Batch script @REM @REM Required ENV vars: @REM JAVA_HOME - location of a JDK home dir @@ -26,7 +26,7 @@ @REM Optional ENV vars @REM M2_HOME - location of maven2's installed home dir @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven @REM e.g. to debug Maven itself, use @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 @@ -35,7 +35,9 @@ @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' @echo off -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% @REM set %HOME% to equivalent of $HOME @@ -80,8 +82,6 @@ goto error :init -set MAVEN_CMD_LINE_ARGS=%* - @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". @REM Fallback to current working directory if not found. @@ -117,11 +117,48 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s :endReadAdditionalConfig SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* if ERRORLEVEL 1 goto error goto end @@ -142,4 +179,4 @@ if "%MAVEN_BATCH_PAUSE%" == "on" pause if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% -exit /B %ERROR_CODE% \ No newline at end of file +exit /B %ERROR_CODE% diff --git a/initial/pom.xml b/initial/pom.xml index af5948b..4d596c8 100644 --- a/initial/pom.xml +++ b/initial/pom.xml @@ -1,41 +1,41 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.4.5 + + + com.example + indexing-data-elasticsearch + 0.0.1-SNAPSHOT + indexing-data-elasticsearch + Indexing data into Elasticsearch + + 15 + + + + org.springframework.boot + spring-boot-starter-data-elasticsearch + - org.springframework - draft-gs-template - 0.1.0 + + org.springframework.boot + spring-boot-starter-test + test + + - - org.springframework.boot - spring-boot-starter-parent - 2.2.2.RELEASE - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-test - test - - - - - 1.8 - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - + + + + org.springframework.boot + spring-boot-maven-plugin + + + diff --git a/initial/reading/.mvn/wrapper/maven-wrapper.jar b/initial/reading/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index 5fd4d50..0000000 Binary files a/initial/reading/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/initial/reading/.mvn/wrapper/maven-wrapper.properties b/initial/reading/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index eb91947..0000000 --- a/initial/reading/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1 +0,0 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip \ No newline at end of file diff --git a/initial/reading/build.gradle b/initial/reading/build.gradle deleted file mode 100644 index 6f941cd..0000000 --- a/initial/reading/build.gradle +++ /dev/null @@ -1,51 +0,0 @@ -buildscript { - ext { - springBootVersion = '2.2.2.RELEASE' - } - repositories { - mavenCentral() - maven { url 'https://repo.spring.io/milestone' } - maven { url 'https://repo.spring.io/snapshot' } - } - dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") - } -} - -apply plugin: 'java' -apply plugin: 'eclipse' -apply plugin: 'idea' -apply plugin: 'org.springframework.boot' -apply plugin: 'io.spring.dependency-management' - -bootJar { - baseName = 'reading' - version = '0.0.1-SNAPSHOT' -} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -repositories { - mavenCentral() -} - - -dependencies { - compile('spring-cloud-starter-circuitbreaker-reactor-resilience4j') - compile('org.springframework.boot:spring-boot-starter-webflux') - testCompile('org.springframework.boot:spring-boot-starter-test') -} - -dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-dependencies:Hoxton.SR1" - } -} - -eclipse { - classpath { - containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') - containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' - } -} - diff --git a/initial/reading/pom.xml b/initial/reading/pom.xml deleted file mode 100644 index 5741ed0..0000000 --- a/initial/reading/pom.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - 4.0.0 - - hello - reading - 0.0.1-SNAPSHOT - jar - - - org.springframework.boot - spring-boot-starter-parent - 2.2.2.RELEASE - - - - - UTF-8 - 1.8 - - - - - org.springframework.cloud - spring-cloud-starter-circuitbreaker-reactor-resilience4j - - - org.springframework.boot - spring-boot-starter-webflux - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.cloud - spring-cloud-dependencies - Hoxton.SR1 - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - diff --git a/initial/settings.gradle b/initial/settings.gradle new file mode 100644 index 0000000..bd183de --- /dev/null +++ b/initial/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'indexing-data-elasticsearch' diff --git a/complete/src/main/java/hello/Application.java b/initial/src/main/java/com/example/elasticsearch/ElasticsearchApplication.java similarity index 58% rename from complete/src/main/java/hello/Application.java rename to initial/src/main/java/com/example/elasticsearch/ElasticsearchApplication.java index 33c3f3b..62af5b1 100644 --- a/complete/src/main/java/hello/Application.java +++ b/initial/src/main/java/com/example/elasticsearch/ElasticsearchApplication.java @@ -1,12 +1,13 @@ -package hello; +package com.example.elasticsearch; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class Application { +public class ElasticsearchApplication { public static void main(String[] args) { - SpringApplication.run(Application.class, args); + SpringApplication.run(ElasticsearchApplication.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 diff --git a/initial/src/main/resources/application.properties b/initial/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/initial/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/initial/src/test/java/com/example/elasticsearch/ElasticsearchApplicationTests.java b/initial/src/test/java/com/example/elasticsearch/ElasticsearchApplicationTests.java new file mode 100644 index 0000000..b2f6500 --- /dev/null +++ b/initial/src/test/java/com/example/elasticsearch/ElasticsearchApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.elasticsearch; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ElasticsearchApplicationTests { + + @Test + void contextLoads() { + } + +}