Merge branch 'master' into BAEL-16646 and move code for article "Comparing Dates in Java" from module java-dates-2 to module java-dates (to be further split).
# Conflicts: # java-dates-conversion/pom.xml
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@ bin/
|
||||
*.class
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
|
||||
4
algorithms-miscellaneous-1/.gitignore
vendored
4
algorithms-miscellaneous-1/.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
/target/
|
||||
.settings/
|
||||
.classpath
|
||||
.project
|
||||
@@ -1,18 +1,9 @@
|
||||
## Relevant articles:
|
||||
|
||||
- [Validating Input With Finite Automata in Java](http://www.baeldung.com/java-finite-automata)
|
||||
- [Example of Hill Climbing Algorithm](http://www.baeldung.com/java-hill-climbing-algorithm)
|
||||
- [Monte Carlo Tree Search for Tic-Tac-Toe Game](http://www.baeldung.com/java-monte-carlo-tree-search)
|
||||
- [Binary Search Algorithm in Java](http://www.baeldung.com/java-binary-search)
|
||||
- [Introduction to Minimax Algorithm](http://www.baeldung.com/java-minimax-algorithm)
|
||||
- [How to Calculate Levenshtein Distance in Java?](http://www.baeldung.com/java-levenshtein-distance)
|
||||
- [How to Find the Kth Largest Element in Java](http://www.baeldung.com/java-kth-largest-element)
|
||||
- [Multi-Swarm Optimization Algorithm in Java](http://www.baeldung.com/java-multi-swarm-algorithm)
|
||||
- [String Search Algorithms for Large Texts](http://www.baeldung.com/java-full-text-search-algorithms)
|
||||
- [Check If a String Contains All The Letters of The Alphabet](https://www.baeldung.com/java-string-contains-all-letters)
|
||||
- [Find the Middle Element of a Linked List](http://www.baeldung.com/java-linked-list-middle-element)
|
||||
- [Calculate Factorial in Java](https://www.baeldung.com/java-calculate-factorial)
|
||||
- [Find Substrings That Are Palindromes in Java](https://www.baeldung.com/java-palindrome-substrings)
|
||||
- [Find the Longest Substring without Repeating Characters](https://www.baeldung.com/java-longest-substring-without-repeated-characters)
|
||||
- [Permutations of an Array in Java](https://www.baeldung.com/java-array-permutations)
|
||||
- [Generate Combinations in Java](https://www.baeldung.com/java-combinations-algorithm)
|
||||
- [Validating Input With Finite Automata in Java](https://www.baeldung.com/java-finite-automata)
|
||||
- [Example of Hill Climbing Algorithm](https://www.baeldung.com/java-hill-climbing-algorithm)
|
||||
- [Monte Carlo Tree Search for Tic-Tac-Toe Game](https://www.baeldung.com/java-monte-carlo-tree-search)
|
||||
- [Binary Search Algorithm in Java](https://www.baeldung.com/java-binary-search)
|
||||
- [Introduction to Minimax Algorithm](https://www.baeldung.com/java-minimax-algorithm)
|
||||
- [How to Calculate Levenshtein Distance in Java?](https://www.baeldung.com/java-levenshtein-distance)
|
||||
- [How to Find the Kth Largest Element in Java](https://www.baeldung.com/java-kth-largest-element)
|
||||
9
algorithms-miscellaneous-4/README.md
Normal file
9
algorithms-miscellaneous-4/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
## Relevant articles:
|
||||
|
||||
- [Multi-Swarm Optimization Algorithm in Java](https://www.baeldung.com/java-multi-swarm-algorithm)
|
||||
- [String Search Algorithms for Large Texts](https://www.baeldung.com/java-full-text-search-algorithms)
|
||||
- [Check If a String Contains All The Letters of The Alphabet](https://www.baeldung.com/java-string-contains-all-letters)
|
||||
- [Find the Middle Element of a Linked List](https://www.baeldung.com/java-linked-list-middle-element)
|
||||
- [Find Substrings That Are Palindromes in Java](https://www.baeldung.com/java-palindrome-substrings)
|
||||
- [Find the Longest Substring without Repeating Characters](https://www.baeldung.com/java-longest-substring-without-repeated-characters)
|
||||
- [Permutations of an Array in Java](https://www.baeldung.com/java-array-permutations)
|
||||
51
algorithms-miscellaneous-4/pom.xml
Normal file
51
algorithms-miscellaneous-4/pom.xml
Normal file
@@ -0,0 +1,51 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>algorithms-miscellaneous-4</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>algorithms-miscellaneous-4</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${org.assertj.core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>${exec-maven-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||
<guava.version>27.0.1-jre</guava.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
13
algorithms-miscellaneous-4/src/main/resources/logback.xml
Normal file
13
algorithms-miscellaneous-4/src/main/resources/logback.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -2,6 +2,7 @@ package com.baeldung.bucketsort;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class IntegerBucketSorter implements Sorter<Integer> {
|
||||
@@ -28,43 +29,40 @@ public class IntegerBucketSorter implements Sorter<Integer> {
|
||||
}
|
||||
|
||||
private List<Integer> concatenateSortedBuckets(List<List<Integer>> buckets){
|
||||
List<Integer> sortedArray = new ArrayList<>();
|
||||
int index = 0;
|
||||
List<Integer> sortedArray = new LinkedList<>();
|
||||
for(List<Integer> bucket : buckets){
|
||||
for(int number : bucket){
|
||||
sortedArray.add(index++, number);
|
||||
}
|
||||
sortedArray.addAll(bucket);
|
||||
}
|
||||
return sortedArray;
|
||||
}
|
||||
|
||||
private List<List<Integer>> splitIntoUnsortedBuckets(List<Integer> initialList){
|
||||
|
||||
final int[] codes = createHashes(initialList);
|
||||
final int max = findMax(initialList);
|
||||
final int numberOfBuckets = (int) Math.sqrt(initialList.size());
|
||||
|
||||
List<List<Integer>> buckets = new ArrayList<>(codes[1]);
|
||||
for(int i = 0; i < codes[1]; i++) buckets.add(new ArrayList<>());
|
||||
List<List<Integer>> buckets = new ArrayList<>();
|
||||
for(int i = 0; i < numberOfBuckets; i++) buckets.add(new ArrayList<>());
|
||||
|
||||
//distribute the data
|
||||
for (int i : initialList) {
|
||||
buckets.get(hash(i, codes)).add(i);
|
||||
buckets.get(hash(i, max, numberOfBuckets)).add(i);
|
||||
}
|
||||
return buckets;
|
||||
|
||||
}
|
||||
|
||||
private int[] createHashes(List<Integer> input){
|
||||
int m = input.get(0);
|
||||
for (int i = 1; i < input.size(); i++) {
|
||||
if (m < input.get(i)) {
|
||||
m = input.get(i);
|
||||
private int findMax(List<Integer> input){
|
||||
int m = Integer.MIN_VALUE;
|
||||
for (int i : input){
|
||||
m = Math.max(i, m);
|
||||
}
|
||||
}
|
||||
return new int[]{m, (int) Math.sqrt(input.size())};
|
||||
return m;
|
||||
}
|
||||
|
||||
private static int hash(int i, int[] code) {
|
||||
return (int) ((double) i / code[0] * (code[1] - 1));
|
||||
private static int hash(int i, int max, int numberOfBuckets) {
|
||||
return (int) ((double) i / max * (numberOfBuckets - 1));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -16,14 +16,17 @@
|
||||
<dependency>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>bazelgreeting</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>${bazelgreeting.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.9</version>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<bazelgreeting.version>1.0.0-SNAPSHOT</bazelgreeting.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
5
core-java-modules/core-java-io-files/.gitignore
vendored
Normal file
5
core-java-modules/core-java-io-files/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
0.*
|
||||
|
||||
# Files generated by integration tests
|
||||
# *.txt
|
||||
/temp
|
||||
6
core-java-modules/core-java-io-files/README.md
Normal file
6
core-java-modules/core-java-io-files/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
=========
|
||||
|
||||
## Core Java IO Files Cookbooks and Examples
|
||||
|
||||
### Relevant Articles:
|
||||
- [How to Avoid the Java FileNotFoundException When Loading Resources](https://www.baeldung.com/java-classpath-resource-cannot-be-opened)
|
||||
296
core-java-modules/core-java-io-files/pom.xml
Normal file
296
core-java-modules/core-java-io-files/pom.xml
Normal file
@@ -0,0 +1,296 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>core-java-io-files</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-io-files</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<!-- utils -->
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.collections</groupId>
|
||||
<artifactId>collections-generic</artifactId>
|
||||
<version>${collections-generic.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>${commons-collections4.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-math3</artifactId>
|
||||
<version>${commons-math3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.decimal4j</groupId>
|
||||
<artifactId>decimal4j</artifactId>
|
||||
<version>${decimal4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>${bouncycastle.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.unix4j</groupId>
|
||||
<artifactId>unix4j-command</artifactId>
|
||||
<version>${unix4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.grep4j</groupId>
|
||||
<artifactId>grep4j</artifactId>
|
||||
<version>${grep4j.version}</version>
|
||||
</dependency>
|
||||
<!-- web -->
|
||||
<!-- marshalling -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<!-- logging -->
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>log4j-over-slf4j</artifactId>
|
||||
<version>${org.slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- test scoped -->
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jayway.awaitility</groupId>
|
||||
<artifactId>awaitility</artifactId>
|
||||
<version>${avaitility.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>${commons-codec.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.javamoney</groupId>
|
||||
<artifactId>moneta</artifactId>
|
||||
<version>${moneta.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.owasp.esapi</groupId>
|
||||
<artifactId>esapi</artifactId>
|
||||
<version>${esapi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.messaging.mq</groupId>
|
||||
<artifactId>fscontext</artifactId>
|
||||
<version>${fscontext.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.codepoetics</groupId>
|
||||
<artifactId>protonpack</artifactId>
|
||||
<version>${protonpack.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>one.util</groupId>
|
||||
<artifactId>streamex</artifactId>
|
||||
<version>${streamex.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vavr</groupId>
|
||||
<artifactId>vavr</artifactId>
|
||||
<version>${vavr.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-core</artifactId>
|
||||
<version>${jmh-core.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-generator-annprocess</artifactId>
|
||||
<version>${jmh-generator-annprocess.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<version>${hsqldb.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.asynchttpclient/async-http-client -->
|
||||
<dependency>
|
||||
<groupId>org.asynchttpclient</groupId>
|
||||
<artifactId>async-http-client</artifactId>
|
||||
<version>${async-http-client.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.opencsv</groupId>
|
||||
<artifactId>opencsv</artifactId>
|
||||
<version>${opencsv.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Mime Type Resolution Libraries -->
|
||||
<dependency>
|
||||
<groupId>org.apache.tika</groupId>
|
||||
<artifactId>tika-core</artifactId>
|
||||
<version>${tika.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.jmimemagic</groupId>
|
||||
<artifactId>jmimemagic</artifactId>
|
||||
<version>${jmime-magic.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>core-java-io-files</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>${exec-maven-plugin.version}</version>
|
||||
<configuration>
|
||||
<executable>java</executable>
|
||||
<mainClass>com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed</mainClass>
|
||||
<arguments>
|
||||
<argument>-Xmx300m</argument>
|
||||
<argument>-XX:+UseParallelGC</argument>
|
||||
<argument>-classpath</argument>
|
||||
<classpath />
|
||||
<argument>com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>${maven-javadoc-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<!-- Build an executable JAR -->
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>${maven-jar-plugin.version}</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<mainClass>com.baeldung.resource.MyResourceLoader</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>integration</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>run-benchmarks</id>
|
||||
<!-- <phase>integration-test</phase> -->
|
||||
<phase>none</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<classpathScope>test</classpathScope>
|
||||
<executable>java</executable>
|
||||
<arguments>
|
||||
<argument>-classpath</argument>
|
||||
<classpath />
|
||||
<argument>org.openjdk.jmh.Main</argument>
|
||||
<argument>.*</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<properties>
|
||||
|
||||
<!-- util -->
|
||||
<bouncycastle.version>1.55</bouncycastle.version>
|
||||
<commons-codec.version>1.10</commons-codec.version>
|
||||
<commons-math3.version>3.6.1</commons-math3.version>
|
||||
<decimal4j.version>1.0.3</decimal4j.version>
|
||||
<commons-collections4.version>4.1</commons-collections4.version>
|
||||
<collections-generic.version>4.01</collections-generic.version>
|
||||
<unix4j.version>0.4</unix4j.version>
|
||||
<grep4j.version>1.8.7</grep4j.version>
|
||||
<fscontext.version>4.6-b01</fscontext.version>
|
||||
<protonpack.version>1.13</protonpack.version>
|
||||
<streamex.version>0.6.5</streamex.version>
|
||||
<vavr.version>0.9.0</vavr.version>
|
||||
<opencsv.version>4.1</opencsv.version>
|
||||
<!-- testing -->
|
||||
<assertj.version>3.6.1</assertj.version>
|
||||
<avaitility.version>1.7.0</avaitility.version>
|
||||
|
||||
<!-- maven plugins -->
|
||||
<maven-javadoc-plugin.version>3.0.0-M1</maven-javadoc-plugin.version>
|
||||
<hsqldb.version>2.4.0</hsqldb.version>
|
||||
<esapi.version>2.1.0.1</esapi.version>
|
||||
<jmh-generator-annprocess.version>1.19</jmh-generator-annprocess.version>
|
||||
<async-http-client.version>2.4.5</async-http-client.version>
|
||||
<!-- Mime Type Libraries -->
|
||||
<tika.version>1.18</tika.version>
|
||||
<jmime-magic.version>0.1.5</jmime-magic.version>
|
||||
<maven-jar-plugin.version>3.1.0</maven-jar-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.baeldung.resource;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MyResourceLoader {
|
||||
|
||||
private void loadFileWithReader() throws IOException {
|
||||
|
||||
try (FileReader fileReader = new FileReader("src/main/resources/input.txt");
|
||||
BufferedReader reader = new BufferedReader(fileReader)) {
|
||||
String contents = reader.lines()
|
||||
.collect(Collectors.joining(System.lineSeparator()));
|
||||
System.out.println(contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void loadFileAsResource() throws IOException {
|
||||
|
||||
try (InputStream inputStream = getClass().getResourceAsStream("/input.txt");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||
String contents = reader.lines()
|
||||
.collect(Collectors.joining(System.lineSeparator()));
|
||||
System.out.println(contents);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
MyResourceLoader resourceLoader = new MyResourceLoader();
|
||||
|
||||
resourceLoader.loadFileAsResource();
|
||||
resourceLoader.loadFileWithReader();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In lacus enim, scelerisque id sapien ut, semper euismod quam. Nunc ullamcorper semper blandit. Praesent quis quam mollis, iaculis lectus a, fringilla leo. Interdum et malesuada fames ac ante ipsum primis in faucibus. Duis vitae auctor mauris. Pellentesque eu pellentesque lorem, vel ultricies libero. Pellentesque vestibulum sagittis eros. In vestibulum lacus elit. Interdum et malesuada fames ac ante ipsum primis in faucibus.
|
||||
|
||||
Vivamus pharetra lacus fringilla nisl molestie eleifend. Donec et dolor non quam mattis mattis. Proin malesuada maximus elit id semper. Donec facilisis dolor ut feugiat auctor. Proin accumsan semper consectetur. Vivamus facilisis odio vel bibendum imperdiet. Sed rutrum nisi nec nisi interdum fringilla. Aliquam laoreet velit ullamcorper egestas ultrices. Aliquam ultricies sem sed orci interdum, eu porta purus malesuada. Sed accumsan, nunc ut maximus rhoncus, arcu ante pretium ex, non ultrices magna nisi et velit. Pellentesque tempor mi quis lacus consectetur, quis imperdiet enim efficitur. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
|
||||
|
||||
Nunc sed maximus erat. Aenean imperdiet finibus massa ac aliquam. Interdum et malesuada fames ac ante ipsum primis in faucibus. Duis dignissim cursus purus, eu tempus urna. Nunc sed mauris scelerisque, luctus eros ut, viverra nisi. Maecenas congue sed ligula in eleifend. Praesent nec dignissim enim, dictum efficitur massa. Nullam eros dui, rutrum quis aliquam accumsan, sollicitudin cursus eros. Phasellus euismod, lorem vitae vehicula ullamcorper, leo lorem vestibulum magna, vitae malesuada libero ipsum id lorem. Aenean finibus turpis facilisis tortor bibendum, vitae dignissim dolor dictum. Ut quis ornare nisi, non rutrum sapien.
|
||||
|
||||
Etiam placerat, est eget placerat imperdiet, neque urna tristique est, a dictum nisl dolor vitae leo. Vivamus porttitor mi vitae volutpat ultrices. Quisque at ante porta mauris ultricies iaculis. Phasellus iaculis sollicitudin urna nec facilisis. Suspendisse dapibus vulputate scelerisque. Fusce felis diam, eleifend in tristique in, malesuada a purus. Suspendisse euismod ipsum sed urna imperdiet, quis venenatis lacus dapibus. Maecenas vitae est vel sem fringilla ornare at ut mi. Quisque porta, nulla at rutrum fringilla, mi ligula egestas libero, ac convallis elit diam et sapien. Vestibulum purus tortor, ornare ut enim sed, mattis lobortis erat. Maecenas ac ante tincidunt, euismod mauris a, fermentum diam. Nullam arcu est, consequat sed enim in, bibendum aliquet velit. Donec bibendum magna ac augue sagittis vehicula. Curabitur nec mauris eu augue bibendum volutpat. Fusce fringilla varius fringilla.
|
||||
|
||||
Aliquam faucibus massa non orci accumsan, porta consectetur diam vulputate. Nullam nec erat mollis, imperdiet libero nec, tincidunt neque. Aenean varius purus nec est auctor, sed vulputate libero varius. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vel neque elit. Donec vulputate fermentum nulla, ut aliquam neque tempor in. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec vel venenatis est. Suspendisse luctus elit quis dui dapibus, id sodales dolor cursus. Curabitur ut vehicula dui. Fusce aliquet est et ante feugiat, et tempus ex congue. Nunc eget dapibus leo. Nunc eu accumsan diam. Suspendisse risus eros, rutrum et volutpat in, consequat in nulla. Suspendisse id felis a orci accumsan iaculis.
|
||||
|
||||
Duis tincidunt diam eget tortor aliquet sodales. Etiam sodales purus ac urna mollis, et cursus enim porttitor. Nulla viverra ligula nunc, ornare condimentum felis posuere sed. Fusce aliquet pretium sagittis. Sed ac mi elementum massa dictum ornare. Integer quis dapibus lectus. Curabitur in rhoncus justo, et vulputate justo. Integer eget efficitur felis.
|
||||
|
||||
Sed finibus vel tortor ac egestas. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas vestibulum nulla mi, blandit efficitur sapien fermentum eu. Integer sed turpis eros. Phasellus sed aliquam ligula. Etiam dictum quam in dapibus mattis. Donec et tristique quam. Pellentesque gravida luctus dolor, eu ornare sapien. Donec justo ante, lacinia non sem et, ultricies dignissim nibh. Vivamus eu nisl et magna pulvinar efficitur. Sed at vehicula lectus, sit amet luctus sem. Morbi vehicula sapien nisi, nec sagittis orci vestibulum et.
|
||||
|
||||
Praesent non finibus diam. Quisque sit amet nisl vitae augue lobortis commodo. Morbi ullamcorper, tortor id ornare maximus, erat ipsum ullamcorper ipsum, in imperdiet diam sem vel erat. Sed pellentesque quis ex sed volutpat. Vestibulum volutpat diam ac dignissim sollicitudin. Praesent at luctus ex, at volutpat dui. Nunc nulla dui, lobortis et pharetra quis, efficitur in turpis. Donec sodales auctor purus id mollis. Sed auctor eu erat eget bibendum. Mauris tincidunt ornare neque id consequat. Suspendisse non massa ante. Quisque velit enim, rhoncus at erat eget, scelerisque placerat elit. Donec finibus luctus dolor. In sed eleifend lorem. Sed tempor ullamcorper lorem nec tristique. Fusce nec volutpat neque, id elementum est.
|
||||
|
||||
Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum mattis elementum tellus, vitae maximus nulla eleifend ut. Vestibulum eu nibh vulputate, posuere felis eget, aliquet ex. Nullam leo ex, lacinia a ante ac, accumsan efficitur ligula. Vestibulum ornare gravida tempus. Proin rhoncus felis sit amet dolor commodo facilisis. Integer aliquet, diam sed pharetra feugiat, sem massa mollis orci, eget pretium libero nunc at quam. Ut rhoncus quam vitae massa hendrerit, ornare condimentum odio varius. Donec odio sapien, tristique eget libero ac, interdum facilisis odio. Phasellus nec mauris vel dolor semper mattis et quis ligula. Donec nec porttitor nunc. Integer maximus quam vitae sem gravida, ut commodo ex porttitor.
|
||||
|
||||
Sed cursus nisi turpis, vel laoreet massa blandit ut. Cras posuere velit nulla, nec pellentesque ipsum dignissim eget. Donec pharetra, ex et commodo viverra, leo dolor dapibus tellus, vel dignissim est sem ac lectus. Quisque a arcu dapibus, aliquet magna sed, rhoncus neque. Integer suscipit, nulla ac varius lacinia, orci metus scelerisque neque, a laoreet nibh risus vitae dolor. Pellentesque felis metus, pulvinar vel cursus id, ultrices non purus. Donec mi lectus, faucibus sit amet nunc at, sagittis pretium lectus. Fusce nec purus arcu. Mauris neque neque, blandit eget mi at, auctor tempus orci. Mauris sapien lorem, luctus nec tellus non, porttitor aliquam dui.
|
||||
|
||||
Mauris non ex risus. Aliquam imperdiet in eros eget placerat. Sed congue sed sapien porta sollicitudin. Phasellus tempor hendrerit metus vitae tincidunt. Suspendisse congue nisi sed augue dapibus, at pretium ante mollis. Cras non posuere nulla. Proin malesuada finibus magna vel iaculis. Cras in dapibus lorem. Pellentesque volutpat dolor sit amet magna tincidunt mollis. Nunc et lectus sodales, accumsan est vitae, ornare augue. Maecenas malesuada arcu leo, eget blandit lectus porttitor et. Nam aliquam sapien sit amet purus consequat lobortis. Aenean varius, augue porta dignissim efficitur, felis velit dapibus leo, tincidunt ultricies magna felis id ligula. Duis hendrerit, lectus eu elementum euismod, elit lectus consequat mi, sit amet egestas justo massa ut urna. Proin eleifend interdum ultrices.
|
||||
|
||||
Donec lacinia orci pharetra ornare tincidunt. Nulla facilisi. Maecenas malesuada dui ac elit sagittis tincidunt id dictum dolor. Quisque lobortis purus ac metus volutpat viverra. Proin finibus sapien ut odio semper consectetur. Sed gravida luctus egestas. Mauris pretium volutpat elit, at commodo arcu sagittis nec. Ut condimentum fringilla urna ac dignissim. Cras aliquam metus pulvinar, pulvinar nibh at, placerat arcu. Nulla ornare tortor sed lectus mollis, vitae fringilla tellus egestas. Vivamus efficitur tincidunt sapien, sed finibus mi congue eu. Nullam magna velit, lacinia vitae ligula eget, molestie consectetur felis. Suspendisse varius turpis orci, ac laoreet arcu accumsan sed. Fusce quis fermentum lacus, nec varius libero. Pellentesque ac odio ut justo lobortis elementum sit amet vehicula lorem. Nulla interdum nulla eget mi tristique, vitae egestas nunc egestas.
|
||||
|
||||
Curabitur commodo libero eu elit tincidunt, quis placerat risus vehicula. Vestibulum vehicula id nunc iaculis fermentum. Aenean semper, tellus ac semper rutrum, justo lorem feugiat leo, quis vulputate neque dui non ligula. Etiam egestas, enim eget tempor porta, nunc est tristique ante, vel suscipit massa lorem vel diam. Donec faucibus ante id turpis rhoncus congue. Nullam laoreet, diam efficitur scelerisque consequat, ligula leo ultrices est, non fermentum elit mauris ut dolor. Morbi non porttitor lorem. Sed volutpat sapien et lorem porttitor, ultricies ultricies tellus congue. Mauris sodales, tortor nec sagittis finibus, dui odio aliquet nibh, in luctus sapien massa eu risus. Nulla in est sed ante molestie vehicula vel nec lectus. Fusce maximus a quam eget aliquam. Vivamus pulvinar quis nisi a maximus. Proin cursus lacus sapien, et hendrerit elit pretium a. Donec tellus lectus, consectetur id dolor a, luctus rutrum libero. Suspendisse auctor scelerisque dui, nec pellentesque felis viverra nec. Cras elit ex, varius sed pulvinar sed, suscipit ultrices lacus.
|
||||
|
||||
Vivamus eu luctus lectus. Maecenas congue magna orci, quis semper nulla blandit vel. Phasellus dignissim risus placerat lacinia sagittis. Praesent at gravida nisi, at pulvinar diam. Nulla egestas lectus sed felis facilisis egestas. Curabitur posuere gravida urna eu vestibulum. Pellentesque at dolor gravida, placerat quam sit amet, fermentum ligula. Morbi fringilla, mi eget mollis dictum, neque dolor ullamcorper leo, a rutrum libero ipsum eget orci. Curabitur consectetur iaculis vestibulum. Suspendisse ultricies ligula et neque lacinia luctus. Sed dignissim neque id eros sollicitudin pellentesque.
|
||||
|
||||
Donec et magna quis lectus pharetra finibus a fringilla sapien. Phasellus accumsan, erat eu sodales cursus, tortor elit dapibus risus, ut ornare neque arcu in tellus. Nam ac vehicula diam, at aliquam nisl. Cras in sem eget nisi ultrices rutrum sit amet eu velit. Sed molestie tellus eget ante scelerisque, sit amet pulvinar neque fringilla. Nunc volutpat facilisis egestas. Cras sodales dui ac massa egestas, in mattis leo rhoncus. Pellentesque vitae urna vehicula ipsum sodales suscipit. Sed commodo tempus fringilla.
|
||||
|
||||
Etiam egestas elit vitae mi maximus fringilla quis eget libero. Fusce finibus ultrices tellus at molestie. Pellentesque posuere blandit elementum. Etiam eu erat eu urna hendrerit euismod. Nulla quis lectus rhoncus, ultricies urna eget, pretium neque. Cras sit amet ipsum sit amet purus rutrum ultricies nec vitae tortor. Sed tempor dapibus augue in pulvinar. Ut pretium sapien in malesuada accumsan. Donec eget ultrices erat, ut efficitur ligula. Sed posuere mauris est, nec convallis ipsum tempus non.
|
||||
|
||||
Duis a ullamcorper ante. Quisque eu ultricies metus, at aliquet odio. Nullam tempus molestie augue ut varius. Fusce purus eros, dictum nec finibus sed, sodales et diam. Suspendisse sed mi purus. Donec eleifend ipsum diam, nec fringilla enim laoreet non. Phasellus condimentum, magna sit amet porttitor suscipit, arcu risus lobortis dolor, ac fringilla nibh nisl vel purus. Phasellus facilisis posuere orci sit amet tempus. Nam nec enim maximus, rhoncus felis a, rutrum diam.
|
||||
|
||||
Suspendisse potenti. Donec vel tempor neque. In aliquet nulla in eleifend bibendum. Sed sapien sem, finibus in sodales vitae, euismod in sem. Phasellus nec elit a erat pulvinar semper. Aliquam luctus nisl in libero molestie aliquam. Nunc ac ornare felis. Ut non mauris ut ipsum rhoncus pretium. Curabitur tristique lacus a sagittis aliquam. Morbi vel volutpat tellus. Maecenas volutpat, lacus sed tempus imperdiet, eros tellus volutpat nisi, a egestas augue nulla quis arcu. In sollicitudin imperdiet efficitur. Suspendisse viverra aliquet nisi, congue ultrices arcu hendrerit in.
|
||||
|
||||
Maecenas vitae vestibulum nunc. Nullam semper faucibus tincidunt. Etiam sed hendrerit risus. Proin gravida, urna nec tincidunt tempus, nulla sapien porttitor nibh, porttitor lobortis nunc quam et tortor. Praesent ut varius lacus, ut hendrerit enim. Ut nec turpis ac felis imperdiet bibendum. Phasellus porttitor enim odio, et vehicula mi convallis vel. Quisque porta scelerisque sagittis. Praesent dignissim sagittis vulputate. Aenean non justo ac est volutpat bibendum. Aliquam mattis, sapien dapibus pellentesque semper, velit urna malesuada diam, nec varius nibh eros at erat. Proin leo ante, ultricies id velit ut, faucibus porta nibh. Sed nec fermentum urna, sed mollis leo. Aliquam erat volutpat.
|
||||
|
||||
Donec condimentum, urna sed hendrerit vestibulum, ante nibh lacinia dui, in tincidunt odio sem eget orci. In hac habitasse platea dictumst. Mauris id ex id ante tempus finibus eu sagittis erat. Quisque interdum urna risus, vel varius nibh euismod non. Nulla eget pellentesque quam. Aliquam vestibulum ac tortor non lobortis. Sed vitae erat sed libero dignissim dictum nec in turpis. Vivamus id ornare elit, ut facilisis lectus. Morbi dictum purus eget ipsum dignissim porttitor. Sed at vehicula purus, nec rhoncus quam. Nunc a nisl quis arcu blandit fermentum vel quis odio. Vivamus rhoncus, sapien sed lacinia hendrerit, velit urna fermentum dolor, id feugiat magna ligula sed urna. Proin euismod efficitur libero, eget porttitor lacus tempus quis. Duis tincidunt quis est a laoreet. Nam sit amet tristique nisl, sit amet mattis mi.
|
||||
|
||||
Aenean id dictum nulla, sed laoreet magna. Morbi consectetur in turpis at aliquam. Maecenas rutrum feugiat metus, at ullamcorper augue fermentum ut. Vivamus in magna pretium nibh dictum rhoncus luctus at orci. In hac habitasse platea dictumst. Fusce convallis, nulla nec hendrerit suscipit, ipsum diam lobortis sem, vitae elementum lectus erat sit amet magna. Quisque sollicitudin fringilla purus, ac molestie justo congue vitae. Nulla sapien leo, ullamcorper ac tellus in, cursus rhoncus enim. Suspendisse rutrum magna non ex elementum elementum id vitae enim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse ornare libero eu molestie pulvinar. Phasellus faucibus, magna eget rutrum porta, lorem turpis blandit lectus, eu viverra massa risus et ex.
|
||||
|
||||
Ut consectetur eros lacus, ac ullamcorper lacus mattis a. Cras congue justo ut erat interdum, et scelerisque nisi malesuada. Quisque sed sapien sollicitudin purus tincidunt finibus vestibulum vel dolor. Cras iaculis bibendum erat, a dictum urna viverra et. Integer non neque vulputate, tincidunt purus nec, rutrum arcu. Aliquam nec magna non sem semper laoreet quis at quam. Mauris dui lectus, convallis eu efficitur at, facilisis nec lorem. Cras felis sem, egestas ac rutrum vel, mollis et ex. Aenean semper egestas libero, nec commodo mi blandit efficitur. Duis nec quam in massa dignissim sagittis vel vitae leo. Nam molestie hendrerit auctor.
|
||||
|
||||
Sed suscipit egestas tellus sed cursus. Donec vel massa sit amet dui condimentum accumsan. Phasellus libero eros, lobortis a nisi id, porttitor maximus lectus. Praesent consectetur diam urna, id viverra turpis elementum in. Vivamus vitae pretium justo, nec tempor felis. Vivamus volutpat ultricies magna. Suspendisse vulputate lectus ac orci volutpat ullamcorper. Nulla eu leo pretium, commodo arcu accumsan, tempor nisl. Fusce sit amet tellus a ipsum vehicula laoreet sed vitae mauris. Duis porttitor massa mattis nibh placerat consequat. Fusce rutrum commodo tortor eget pellentesque. Suspendisse tempor enim libero, consequat dictum nibh dictum varius. Pellentesque feugiat sit amet urna sed facilisis. Curabitur a sagittis augue.
|
||||
13
core-java-modules/core-java-io-files/src/test/resources/.gitignore
vendored
Normal file
13
core-java-modules/core-java-io-files/src/test/resources/.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
*.class
|
||||
|
||||
#folders#
|
||||
/target
|
||||
/neoDb*
|
||||
/data
|
||||
/src/main/webapp/WEB-INF/classes
|
||||
*/META-INF/*
|
||||
|
||||
# Packaged files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
@@ -10,6 +10,6 @@
|
||||
- [Java ‘private’ Access Modifier](https://www.baeldung.com/java-private-keyword)
|
||||
- [Marker Interfaces in Java](https://www.baeldung.com/java-marker-interfaces)
|
||||
- [Java equals() and hashCode() Contracts](https://www.baeldung.com/java-equals-hashcode-contracts)
|
||||
- [Immutable Objects in Java](http://www.baeldung.com/java-immutable-object)
|
||||
- [Inheritance and Composition (Is-a vs Has-a relationship) in Java](http://www.baeldung.com/java-inheritance-composition)
|
||||
- [Immutable Objects in Java](https://www.baeldung.com/java-immutable-object)
|
||||
- [Inheritance and Composition (Is-a vs Has-a relationship) in Java](https://www.baeldung.com/java-inheritance-composition)
|
||||
- [A Guide to Constructors in Java](https://www.baeldung.com/java-constructors)
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
*.class
|
||||
|
||||
0.*
|
||||
|
||||
#folders#
|
||||
/target
|
||||
/neoDb*
|
||||
/data
|
||||
/src/main/webapp/WEB-INF/classes
|
||||
*/META-INF/*
|
||||
.resourceCache
|
||||
|
||||
# Packaged files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# Files generated by integration tests
|
||||
*.txt
|
||||
backup-pom.xml
|
||||
/bin/
|
||||
/temp
|
||||
|
||||
#IntelliJ specific
|
||||
.idea/
|
||||
*.iml
|
||||
@@ -3,9 +3,9 @@
|
||||
## Core Java Lang OOP 3 Cookbooks and Examples
|
||||
|
||||
### Relevant Articles:
|
||||
- [Pass-By-Value as a Parameter Passing Mechanism in Java](http://www.baeldung.com/java-pass-by-value-or-pass-by-reference)
|
||||
- [Access Modifiers in Java](http://www.baeldung.com/java-access-modifiers)
|
||||
- [Guide to the super Java Keyword](http://www.baeldung.com/java-super)
|
||||
- [Guide to the this Java Keyword](http://www.baeldung.com/java-this)
|
||||
- [Pass-By-Value as a Parameter Passing Mechanism in Java](https://www.baeldung.com/java-pass-by-value-or-pass-by-reference)
|
||||
- [Access Modifiers in Java](https://www.baeldung.com/java-access-modifiers)
|
||||
- [Guide to the super Java Keyword](https://www.baeldung.com/java-super)
|
||||
- [Guide to the this Java Keyword](https://www.baeldung.com/java-this)
|
||||
- [Java Public Access Modifier](https://www.baeldung.com/java-public-keyword)
|
||||
- [Composition, Aggregation and Association in Java](https://www.baeldung.com/java-composition-aggregation-association)
|
||||
@@ -3,13 +3,13 @@
|
||||
## Core Java Lang OOP Cookbooks and Examples
|
||||
|
||||
### Relevant Articles:
|
||||
- [Guide to hashCode() in Java](http://www.baeldung.com/java-hashcode)
|
||||
- [A Guide to the Static Keyword in Java](http://www.baeldung.com/java-static)
|
||||
- [Polymorphism in Java](http://www.baeldung.com/java-polymorphism)
|
||||
- [Method Overloading and Overriding in Java](http://www.baeldung.com/java-method-overload-override)
|
||||
- [How to Make a Deep Copy of an Object in Java](http://www.baeldung.com/java-deep-copy)
|
||||
- [Guide to Inheritance in Java](http://www.baeldung.com/java-inheritance)
|
||||
- [Object Type Casting in Java](http://www.baeldung.com/java-type-casting)
|
||||
- [The “final” Keyword in Java](http://www.baeldung.com/java-final)
|
||||
- [Type Erasure in Java Explained](http://www.baeldung.com/java-type-erasure)
|
||||
- [Variable and Method Hiding in Java](http://www.baeldung.com/java-variable-method-hiding)
|
||||
- [Guide to hashCode() in Java](https://www.baeldung.com/java-hashcode)
|
||||
- [A Guide to the Static Keyword in Java](https://www.baeldung.com/java-static)
|
||||
- [Polymorphism in Java](https://www.baeldung.com/java-polymorphism)
|
||||
- [Method Overloading and Overriding in Java](https://www.baeldung.com/java-method-overload-override)
|
||||
- [How to Make a Deep Copy of an Object in Java](https://www.baeldung.com/java-deep-copy)
|
||||
- [Guide to Inheritance in Java](https://www.baeldung.com/java-inheritance)
|
||||
- [Object Type Casting in Java](https://www.baeldung.com/java-type-casting)
|
||||
- [The “final” Keyword in Java](https://www.baeldung.com/java-final)
|
||||
- [Type Erasure in Java Explained](https://www.baeldung.com/java-type-erasure)
|
||||
- [Variable and Method Hiding in Java](https://www.baeldung.com/java-variable-method-hiding)
|
||||
|
||||
@@ -22,3 +22,4 @@
|
||||
- [ZoneOffset in Java](https://www.baeldung.com/java-zone-offset)
|
||||
- [Differences Between ZonedDateTime and OffsetDateTime](https://www.baeldung.com/java-zoneddatetime-offsetdatetime)
|
||||
- [Introduction to Joda-Time](http://www.baeldung.com/joda-time)
|
||||
- [Comparing Dates in Java](https://www.baeldung.com/java-comparing-dates)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.baeldung.date.comparison;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import static java.time.temporal.ChronoUnit.*;
|
||||
|
||||
public class DateTimeComparisonUtils {
|
||||
|
||||
public static boolean isSameDay(LocalDateTime timestamp, LocalDate localDateToCompare) {
|
||||
return timestamp.toLocalDate().isEqual(localDateToCompare);
|
||||
}
|
||||
|
||||
public static boolean isSameDay(LocalDateTime timestamp, LocalDateTime timestampToCompare) {
|
||||
return timestamp.truncatedTo(DAYS).isEqual(timestampToCompare.truncatedTo(DAYS));
|
||||
}
|
||||
|
||||
public static boolean isSameHour(LocalDateTime timestamp, LocalDateTime timestampToCompare) {
|
||||
return timestamp.truncatedTo(HOURS).isEqual(timestampToCompare.truncatedTo(HOURS));
|
||||
}
|
||||
|
||||
public static boolean isSameMinute(LocalDateTime timestamp, LocalDateTime timestampToCompare) {
|
||||
return timestamp.truncatedTo(MINUTES).isEqual(timestampToCompare.truncatedTo(MINUTES));
|
||||
}
|
||||
|
||||
public static boolean isSameHour(ZonedDateTime zonedTimestamp, ZonedDateTime zonedTimestampToCompare) {
|
||||
return zonedTimestamp.truncatedTo(HOURS).isEqual(zonedTimestampToCompare.truncatedTo(HOURS));
|
||||
}
|
||||
|
||||
public static boolean isSameHour(ZonedDateTime zonedDateTime, LocalDateTime localDateTime, ZoneId zoneId) {
|
||||
return isSameHour(zonedDateTime, localDateTime.atZone(zoneId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.date.comparison;
|
||||
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class LegacyDateComparisonUtils {
|
||||
|
||||
public static boolean isSameDay(Date date, Date dateToCompare) {
|
||||
return DateUtils.isSameDay(date, dateToCompare);
|
||||
}
|
||||
|
||||
public static boolean isSameHour(Date date, Date dateToCompare) {
|
||||
return DateUtils.truncatedEquals(date, dateToCompare, Calendar.HOUR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.baeldung.date.comparison;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
class DateTimeComparisonUtilsUnitTest {
|
||||
|
||||
@Test
|
||||
void givenLocalDateTimes_whenIsSameDay_thenCompareTrue() {
|
||||
LocalDateTime firstTimestamp = LocalDateTime.of(2019, 8, 10, 11, 00, 0);
|
||||
LocalDateTime secondTimestamp = firstTimestamp.plusHours(5);
|
||||
LocalDateTime thirdTimestamp = firstTimestamp.plusDays(1);
|
||||
|
||||
assertThat(DateTimeComparisonUtils.isSameDay(firstTimestamp, secondTimestamp), is(true));
|
||||
|
||||
assertThat(DateTimeComparisonUtils.isSameDay(secondTimestamp, thirdTimestamp), is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenLocalDateAndLocalDateTime_whenIsSameDay_thenCompareTrue() {
|
||||
LocalDate localDate = LocalDate.of(2019, 8, 10);
|
||||
LocalDateTime localDateTime = LocalDateTime.of(2019, 8, 10, 11, 30, 0);
|
||||
|
||||
assertThat(DateTimeComparisonUtils.isSameDay(localDateTime, localDate), is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenLocalDateTimes_whenIsSameHour_thenCompareTrue() {
|
||||
LocalDateTime firstTimestamp = LocalDateTime.of(2019, 8, 10, 8, 00, 0);
|
||||
LocalDateTime secondTimestamp = firstTimestamp.plusMinutes(15);
|
||||
LocalDateTime thirdTimestamp = firstTimestamp.plusHours(2);
|
||||
|
||||
assertThat(DateTimeComparisonUtils.isSameHour(firstTimestamp, secondTimestamp), is(true));
|
||||
|
||||
assertThat(DateTimeComparisonUtils.isSameHour(secondTimestamp, thirdTimestamp), is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenLocalDateTimes_whenIsSameMinute_thenCompareTrue() {
|
||||
LocalDateTime firstTimestamp = LocalDateTime.of(2019, 8, 10, 8, 15, 0);
|
||||
LocalDateTime secondTimestamp = firstTimestamp.plusSeconds(30);
|
||||
LocalDateTime thirdTimestamp = firstTimestamp.plusMinutes(5);
|
||||
|
||||
assertThat(DateTimeComparisonUtils.isSameMinute(firstTimestamp, secondTimestamp), is(true));
|
||||
|
||||
assertThat(DateTimeComparisonUtils.isSameMinute(secondTimestamp, thirdTimestamp), is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenZonedDateTimes_whenIsSameHour_thenCompareTrue() {
|
||||
ZonedDateTime zonedTimestamp = ZonedDateTime.of(2019, 8, 10, 8, 0, 0, 30,
|
||||
ZoneId.of("America/New_York"));
|
||||
ZonedDateTime zonedTimestampToCompare = ZonedDateTime.of(2019, 8, 10, 14, 0, 0, 0,
|
||||
ZoneId.of("Europe/Berlin"));
|
||||
|
||||
assertThat(DateTimeComparisonUtils.isSameHour(zonedTimestamp, zonedTimestampToCompare), is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenZonedDateTimeAndLocalDateTime_whenIsSameHour_thenCompareTrue() {
|
||||
ZonedDateTime zonedTimestamp = ZonedDateTime.of(2019, 8, 10, 8, 15, 0, 0,
|
||||
ZoneId.of("America/New_York"));
|
||||
LocalDateTime localTimestamp = LocalDateTime.of(2019, 8, 10, 14, 20, 0);
|
||||
ZoneId zoneId = ZoneId.of("Europe/Berlin");
|
||||
|
||||
assertThat(DateTimeComparisonUtils.isSameHour(zonedTimestamp, localTimestamp, zoneId), is(true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.baeldung.date.comparison;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.time.*;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class Java8DateTimeApiGeneralComparisonsUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenLocalDates_whenComparing_thenAssertsPass() {
|
||||
LocalDate firstDate = LocalDate.of(2019, 8, 10);
|
||||
LocalDate secondDate = LocalDate.of(2019, 7, 1);
|
||||
LocalDate thirdDate = LocalDate.of(2019, 7, 1); // same date as secondDate
|
||||
|
||||
assertThat(firstDate.isAfter(secondDate), is(true));
|
||||
assertThat(firstDate.isBefore(secondDate), is(false));
|
||||
|
||||
assertThat(firstDate.isEqual(secondDate), is(false));
|
||||
assertThat(firstDate.equals(secondDate), is(false));
|
||||
|
||||
assertThat(firstDate.compareTo(secondDate), is(1));
|
||||
assertThat(secondDate.compareTo(firstDate), is(-1));
|
||||
|
||||
assertThat(secondDate.isAfter(thirdDate), is(false));
|
||||
assertThat(secondDate.isBefore(thirdDate), is(false));
|
||||
assertThat(secondDate.isEqual(thirdDate), is(true));
|
||||
assertThat(secondDate.equals(thirdDate), is(true));
|
||||
assertThat(secondDate.compareTo(thirdDate), is(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenLocalDateTimes_whenComparing_thenAssertsPass() {
|
||||
LocalDateTime firstTimestamp = LocalDateTime.of(2019, 8, 10, 11, 30, 0);
|
||||
LocalDateTime secondTimestamp = LocalDateTime.of(2019, 8, 10, 11, 15, 0);
|
||||
LocalDateTime thirdTimestamp = LocalDateTime.of(2019, 8, 10, 11, 15, 0); // same as secondTimestamp
|
||||
|
||||
assertThat(firstTimestamp.isAfter(secondTimestamp), is(true));
|
||||
assertThat(firstTimestamp.isBefore(secondTimestamp), is(false));
|
||||
|
||||
assertThat(firstTimestamp.isEqual(secondTimestamp), is(false));
|
||||
assertThat(firstTimestamp.equals(secondTimestamp), is(false));
|
||||
|
||||
assertThat(firstTimestamp.compareTo(secondTimestamp), is(1));
|
||||
assertThat(secondTimestamp.compareTo(firstTimestamp), is(-1));
|
||||
|
||||
assertThat(secondTimestamp.isAfter(thirdTimestamp), is(false));
|
||||
assertThat(secondTimestamp.isBefore(thirdTimestamp), is(false));
|
||||
assertThat(secondTimestamp.isEqual(thirdTimestamp), is(true));
|
||||
assertThat(secondTimestamp.compareTo(thirdTimestamp), is(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenZonedDateTimes_whenComparing_thenAssertsPass() {
|
||||
ZonedDateTime timeInNewYork = ZonedDateTime.of(2019, 8, 10, 8, 0, 0, 0,
|
||||
ZoneId.of("America/New_York"));
|
||||
ZonedDateTime timeInBerlin = ZonedDateTime.of(2019, 8, 10, 14, 0, 0, 0,
|
||||
ZoneId.of("Europe/Berlin"));
|
||||
|
||||
assertThat(timeInNewYork.isAfter(timeInBerlin), is(false));
|
||||
assertThat(timeInNewYork.isBefore(timeInBerlin), is(false));
|
||||
|
||||
assertThat(timeInNewYork.isEqual(timeInBerlin), is(true));
|
||||
assertThat(timeInNewYork.equals(timeInBerlin), is(false));
|
||||
|
||||
assertThat(timeInNewYork.compareTo(timeInBerlin), is(-1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenLocalTimes_whenComparing_thenAssertsPass() {
|
||||
LocalTime firstTime = LocalTime.of(8, 30);
|
||||
LocalTime secondTime = LocalTime.of(9, 45);
|
||||
|
||||
assertThat(firstTime.isAfter(secondTime), is(false));
|
||||
assertThat(firstTime.isBefore(secondTime), is(true));
|
||||
|
||||
assertThat(firstTime.equals(secondTime), is(false));
|
||||
|
||||
assertThat(firstTime.compareTo(secondTime), is(-1));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.baeldung.date.comparison;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
class LegacyDateComparisonUtilsUnitTest {
|
||||
|
||||
private Date toDate(LocalDateTime localDateTime) {
|
||||
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenDatesWithDifferentHours_whenIsSameDay_thenReturnsTrue() {
|
||||
Date firstDate = toDate(LocalDateTime.of(2019, 8, 10, 11, 00, 00));
|
||||
Date secondDate = toDate(LocalDateTime.of(2019, 8, 10, 12, 00, 00));
|
||||
Date thirdDate = toDate(LocalDateTime.of(2019, 8, 15, 12, 00, 00));
|
||||
|
||||
assertThat(LegacyDateComparisonUtils.isSameDay(firstDate, secondDate), is(true));
|
||||
assertThat(LegacyDateComparisonUtils.isSameDay(secondDate, thirdDate), is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenDatesWithingSameHour_whenIsSameHour_thenReturnsTrue() {
|
||||
Date firstDate = toDate(LocalDateTime.of(2019, 8, 10, 11, 00, 00));
|
||||
Date secondDate = toDate(LocalDateTime.of(2019, 8, 10, 11, 15, 00));
|
||||
Date thirdDate = toDate(LocalDateTime.of(2019, 8, 10, 12, 00, 00));
|
||||
|
||||
assertThat(LegacyDateComparisonUtils.isSameHour(firstDate, secondDate), is(true));
|
||||
assertThat(LegacyDateComparisonUtils.isSameHour(secondDate, thirdDate), is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenDates__whenComparing_thenAssertsPass() {
|
||||
Date firstDate = toDate(LocalDateTime.of(2019, 8, 10, 0, 00, 00));
|
||||
Date secondDate = toDate(LocalDateTime.of(2019, 8, 15, 0, 00, 00));
|
||||
Date thirdDate = toDate(LocalDateTime.of(2019, 8, 15, 0, 00, 00)); // same date as secondDate
|
||||
|
||||
assertThat(firstDate.after(secondDate), is(false));
|
||||
assertThat(firstDate.before(secondDate), is(true));
|
||||
assertThat(firstDate.compareTo(secondDate), is(-1));
|
||||
assertThat(firstDate.equals(secondDate), is(false));
|
||||
|
||||
assertThat(thirdDate.after(secondDate), is(false));
|
||||
assertThat(thirdDate.before(secondDate), is(false));
|
||||
assertThat(thirdDate.compareTo(secondDate), is(0));
|
||||
assertThat(thirdDate.equals(secondDate), is(true));
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@
|
||||
<dependency>
|
||||
<groupId>io.arrow-kt</groupId>
|
||||
<artifactId>arrow-core</artifactId>
|
||||
<version>0.7.3</version>
|
||||
<version>${arrow-core.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -117,7 +117,7 @@
|
||||
<dependency>
|
||||
<groupId>nl.komponents.kovenant</groupId>
|
||||
<artifactId>kovenant</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>${kovenant.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
|
||||
@@ -132,13 +132,13 @@
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>27.1-jre</version>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-collections-immutable -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlinx</groupId>
|
||||
<artifactId>kotlinx-collections-immutable</artifactId>
|
||||
<version>0.1</version>
|
||||
<version>${kotlinx-collections-immutable.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- MockK dependencies-->
|
||||
@@ -151,26 +151,26 @@
|
||||
<dependency>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy</artifactId>
|
||||
<version>1.8.13</version>
|
||||
<version>${byte-buddy.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy-agent</artifactId>
|
||||
<version>1.8.13</version>
|
||||
<version>${byte-buddy.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.objenesis</groupId>
|
||||
<artifactId>objenesis</artifactId>
|
||||
<version>2.6</version>
|
||||
<version>${objenesis.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.reactivex.rxjava2</groupId>
|
||||
<artifactId>rxkotlin</artifactId>
|
||||
<version>2.3.0</version>
|
||||
<version>${rxkotlin.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -186,6 +186,13 @@
|
||||
<assertj.version>3.10.0</assertj.version>
|
||||
<exposed.version>0.10.4</exposed.version>
|
||||
<mockk.version>1.9.3</mockk.version>
|
||||
<guava.version>27.1-jre</guava.version>
|
||||
<kovenant.version>3.3.0</kovenant.version>
|
||||
<byte-buddy.version>1.8.13</byte-buddy.version>
|
||||
<objenesis.version>2.6</objenesis.version>
|
||||
<rxkotlin.version>2.3.0</rxkotlin.version>
|
||||
<kotlinx-collections-immutable.version>0.1</kotlinx-collections-immutable.version>
|
||||
<arrow-core.version>0.7.3</arrow-core.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -6,5 +6,4 @@
|
||||
- [Serenity BDD with Spring and JBehave](http://www.baeldung.com/serenity-spring-jbehave)
|
||||
- [Introduction to Awaitlity](http://www.baeldung.com/awaitlity-testing)
|
||||
- [Introduction to Hoverfly in Java](http://www.baeldung.com/hoverfly)
|
||||
- [Hamcrest File Matchers](https://www.baeldung.com/hamcrest-file-matchers)
|
||||
- [Hamcrest Text Matchers](http://www.baeldung.com/hamcrest-text-matchers)
|
||||
- [Testing with Hamcrest](http://www.baeldung.com/java-junit-hamcrest-guide)
|
||||
@@ -1,2 +0,0 @@
|
||||
### Relevant Articles:
|
||||
- [Testing with Hamcrest](http://www.baeldung.com/java-junit-hamcrest-guide)
|
||||
@@ -579,7 +579,7 @@
|
||||
<dependency>
|
||||
<groupId>org.asciidoctor</groupId>
|
||||
<artifactId>asciidoctor-maven-plugin</artifactId>
|
||||
<version>1.5.7.1</version>
|
||||
<version>${asciidoctor-maven-plugin.version}</version>
|
||||
</dependency>
|
||||
<!-- Reflections -->
|
||||
<dependency>
|
||||
@@ -789,6 +789,7 @@
|
||||
<mockftpserver.version>2.7.1</mockftpserver.version>
|
||||
<commons-net.version>3.6</commons-net.version>
|
||||
<reflections.version>0.9.11</reflections.version>
|
||||
<asciidoctor-maven-plugin.version>1.5.7.1</asciidoctor-maven-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -18,23 +18,26 @@
|
||||
<h2.version>1.4.199</h2.version>
|
||||
<httpPort>9080</httpPort>
|
||||
<httpsPort>9443</httpsPort>
|
||||
<nimbus-jose-jwt.version>7.3</nimbus-jose-jwt.version>
|
||||
<bcprov-jdk15on.version>1.62</bcprov-jdk15on.version>
|
||||
<bcpkix-jdk15on.version>1.62</bcpkix-jdk15on.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.nimbusds</groupId>
|
||||
<artifactId>nimbus-jose-jwt</artifactId>
|
||||
<version>7.3</version>
|
||||
<version>${nimbus-jose-jwt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.62</version>
|
||||
<version>${bcprov-jdk15on.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcpkix-jdk15on</artifactId>
|
||||
<version>1.62</version>
|
||||
<version>${bcpkix-jdk15on.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
|
||||
@@ -18,13 +18,14 @@
|
||||
<httpsPort>8643</httpsPort>
|
||||
<jwt.issuer>http://localhost:9080</jwt.issuer>
|
||||
<jwt.resourceId>http://localhost:9280</jwt.resourceId>
|
||||
<microprofile-jwt-auth-api.version>1.1</microprofile-jwt-auth-api.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.microprofile.jwt</groupId>
|
||||
<artifactId>microprofile-jwt-auth-api</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>${microprofile-jwt-auth-api.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -15,19 +15,21 @@
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
<openliberty.version>RELEASE</openliberty.version>
|
||||
<openliberty.maven.version>2.6.4</openliberty.maven.version>
|
||||
<javaee-web-api.version>8.0</javaee-web-api.version>
|
||||
<microprofile-config-api.version>1.3</microprofile-config-api.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-web-api</artifactId>
|
||||
<version>8.0</version>
|
||||
<version>${javaee-web-api.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.microprofile.config</groupId>
|
||||
<artifactId>microprofile-config-api</artifactId>
|
||||
<version>1.3</version>
|
||||
<version>${microprofile-config-api.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
<dependency>
|
||||
<groupId>org.optaplanner</groupId>
|
||||
<artifactId>optaplanner-core</artifactId>
|
||||
<version>7.9.0.Final</version>
|
||||
<version>${optaplanner-core.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<optaplanner-core.version>7.9.0.Final</optaplanner-core.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -57,7 +57,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<compilerArgument>-proc:none</compilerArgument>
|
||||
</configuration>
|
||||
@@ -65,7 +65,7 @@
|
||||
<plugin>
|
||||
<groupId>org.bsc.maven</groupId>
|
||||
<artifactId>maven-processor-plugin</artifactId>
|
||||
<version>3.3.3</version>
|
||||
<version>${maven-processor-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>process</id>
|
||||
@@ -86,7 +86,7 @@
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>${build-helper-maven-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-source</id>
|
||||
@@ -110,6 +110,8 @@
|
||||
<eclipselink.version>2.7.4-RC1</eclipselink.version>
|
||||
<postgres.version>42.2.5</postgres.version>
|
||||
<javax.persistence-api.version>2.2</javax.persistence-api.version>
|
||||
<maven-processor-plugin.version>3.3.3</maven-processor-plugin.version>
|
||||
<build-helper-maven-plugin.version>3.0.0</build-helper-maven-plugin.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<r2dbc-h2.version>0.8.0.M8</r2dbc-h2.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -41,7 +42,7 @@
|
||||
<dependency>
|
||||
<groupId>io.r2dbc</groupId>
|
||||
<artifactId>r2dbc-h2</artifactId>
|
||||
<version>0.8.0.M8</version>
|
||||
<version>${r2dbc-h2.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<dependency>
|
||||
<groupId>io.sirix</groupId>
|
||||
<artifactId>sirix-core</artifactId>
|
||||
<version>0.9.3</version>
|
||||
<version>${sirix-core.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -48,5 +48,6 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.release.version>11</maven.release.version>
|
||||
<sirix-core.version>0.9.3</sirix-core.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
31
persistence-modules/spring-boot-jdbi/.gitignore
vendored
31
persistence-modules/spring-boot-jdbi/.gitignore
vendored
@@ -1,31 +0,0 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**
|
||||
!**/src/test/**
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you 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.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MavenWrapperDownloader {
|
||||
|
||||
/**
|
||||
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
||||
*/
|
||||
private static final String DEFAULT_DOWNLOAD_URL =
|
||||
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
|
||||
|
||||
/**
|
||||
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
|
||||
* use instead of the default one.
|
||||
*/
|
||||
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
||||
".mvn/wrapper/maven-wrapper.properties";
|
||||
|
||||
/**
|
||||
* Path where the maven-wrapper.jar will be saved to.
|
||||
*/
|
||||
private static final String MAVEN_WRAPPER_JAR_PATH =
|
||||
".mvn/wrapper/maven-wrapper.jar";
|
||||
|
||||
/**
|
||||
* Name of the property which should be used to override the default download url for the wrapper.
|
||||
*/
|
||||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("- Downloader started");
|
||||
File baseDirectory = new File(args[0]);
|
||||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||
|
||||
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||
// wrapperUrl parameter.
|
||||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||
String url = DEFAULT_DOWNLOAD_URL;
|
||||
if(mavenWrapperPropertyFile.exists()) {
|
||||
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||
try {
|
||||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||
Properties mavenWrapperProperties = new Properties();
|
||||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||
} catch (IOException e) {
|
||||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||
} finally {
|
||||
try {
|
||||
if(mavenWrapperPropertyFileInputStream != null) {
|
||||
mavenWrapperPropertyFileInputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Ignore ...
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading from: : " + url);
|
||||
|
||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||
if(!outputFile.getParentFile().exists()) {
|
||||
if(!outputFile.getParentFile().mkdirs()) {
|
||||
System.out.println(
|
||||
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||
try {
|
||||
downloadFileFromURL(url, outputFile);
|
||||
System.out.println("Done");
|
||||
System.exit(0);
|
||||
} catch (Throwable e) {
|
||||
System.out.println("- Error downloading");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
||||
URL website = new URL(urlString);
|
||||
ReadableByteChannel rbc;
|
||||
rbc = Channels.newChannel(website.openStream());
|
||||
FileOutputStream fos = new FileOutputStream(destination);
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
fos.close();
|
||||
rbc.close();
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
|
||||
9
persistence-modules/spring-boot-jdbi/HELP.md
Normal file
9
persistence-modules/spring-boot-jdbi/HELP.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# 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 DevTools](https://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#using-boot-devtools)
|
||||
* [Spring Configuration Processor](https://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/#configuration-metadata-annotation-processor)
|
||||
|
||||
286
persistence-modules/spring-boot-jdbi/mvnw
vendored
286
persistence-modules/spring-boot-jdbi/mvnw
vendored
@@ -1,286 +0,0 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you 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.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven2 Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# 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
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# 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
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`which java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
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
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
|
||||
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 command -v wget > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
fi
|
||||
wget "$jarUrl" -O "$wrapperJarPath"
|
||||
elif command -v curl > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
fi
|
||||
curl -o "$wrapperJarPath" "$jarUrl"
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
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
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||
161
persistence-modules/spring-boot-jdbi/mvnw.cmd
vendored
161
persistence-modules/spring-boot-jdbi/mvnw.cmd
vendored
@@ -1,161 +0,0 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. 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,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven2 Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@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_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
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.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% (
|
||||
echo Found %WRAPPER_JAR%
|
||||
) else (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
%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
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
||||
@@ -27,7 +27,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>2.1.7.RELEASE</version>
|
||||
<version>2.1.8.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.1.5.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
<plugin>
|
||||
<groupId>com.mysema.maven</groupId>
|
||||
<artifactId>apt-maven-plugin</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>${apt-maven-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
@@ -148,6 +148,7 @@
|
||||
<!-- util -->
|
||||
<guava.version>21.0</guava.version>
|
||||
<assertj.version>3.8.0</assertj.version>
|
||||
<apt-maven-plugin.version>1.1.3</apt-maven-plugin.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
4
pom.xml
4
pom.xml
@@ -339,6 +339,7 @@
|
||||
<module>algorithms-miscellaneous-1</module>
|
||||
<module>algorithms-miscellaneous-2</module>
|
||||
<module>algorithms-miscellaneous-3</module>
|
||||
<module>algorithms-miscellaneous-4</module>
|
||||
<module>algorithms-miscellaneous-5</module>
|
||||
<module>algorithms-sorting</module>
|
||||
<module>animal-sniffer-mvn-plugin</module>
|
||||
@@ -402,6 +403,7 @@
|
||||
<module>core-java-modules/core-java-concurrency-basic</module>
|
||||
<module>core-java-modules/core-java-concurrency-collections</module>
|
||||
<module>core-java-modules/core-java-io</module>
|
||||
<module>core-java-modules/core-java-io-files</module>
|
||||
<module>core-java-modules/core-java-nio</module>
|
||||
<module>core-java-modules/core-java-security</module>
|
||||
<module>core-java-modules/core-java-lang-syntax</module>
|
||||
@@ -1075,6 +1077,7 @@
|
||||
<module>algorithms-miscellaneous-1</module>
|
||||
<module>algorithms-miscellaneous-2</module>
|
||||
<module>algorithms-miscellaneous-3</module>
|
||||
<module>algorithms-miscellaneous-4</module>
|
||||
<module>algorithms-miscellaneous-5</module>
|
||||
<module>algorithms-sorting</module>
|
||||
<module>animal-sniffer-mvn-plugin</module>
|
||||
@@ -1134,6 +1137,7 @@
|
||||
<module>core-java-modules/core-java-concurrency-basic</module>
|
||||
<module>core-java-modules/core-java-concurrency-collections</module>
|
||||
<module>core-java-modules/core-java-io</module>
|
||||
<module>core-java-modules/core-java-io-files</module>
|
||||
<module>core-java-modules/core-java-nio</module>
|
||||
<module>core-java-modules/core-java-security</module>
|
||||
<module>core-java-modules/core-java-lang-syntax</module>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
## Spring Data Reactive Project
|
||||
|
||||
This module contains articles about reactive Spring 5 Data
|
||||
|
||||
### The Course
|
||||
The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@ package com.baeldung.couchbase;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
|
||||
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(exclude = MongoAutoConfiguration.class)
|
||||
public class ReactiveCouchbaseApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.baeldung.couchbase.configuration;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:couchbase.properties")
|
||||
public class CouchbaseProperties {
|
||||
|
||||
private final List<String> bootstrapHosts;
|
||||
|
||||
@@ -2,7 +2,11 @@ package com.baeldung.couchbase.configuration;
|
||||
|
||||
import com.couchbase.client.java.env.CouchbaseEnvironment;
|
||||
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.couchbase.config.AbstractReactiveCouchbaseConfiguration;
|
||||
import org.springframework.data.couchbase.config.BeanNames;
|
||||
import org.springframework.data.couchbase.repository.support.IndexManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,4 +40,9 @@ public abstract class ReactiveCouchbaseConfiguration extends AbstractReactiveCou
|
||||
.bootstrapHttpDirectPort(couchbaseProperties.getPort())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean(name = BeanNames.COUCHBASE_INDEX_MANAGER)
|
||||
public IndexManager couchbaseIndexManager() {
|
||||
return new IndexManager(true, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.UUID;
|
||||
@ViewIndexed(designDoc = ViewPersonRepository.DESIGN_DOCUMENT)
|
||||
public interface ViewPersonRepository extends ReactiveCrudRepository<Person, UUID> {
|
||||
|
||||
String DESIGN_DOCUMENT = "persons";
|
||||
String DESIGN_DOCUMENT = "person";
|
||||
|
||||
@View(designDocument = ViewPersonRepository.DESIGN_DOCUMENT)
|
||||
Flux<Person> findByFirstName(String firstName);
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
spring.couchbase.bucket.name=default
|
||||
spring.couchbase.bootstrap-hosts=localhost
|
||||
spring.couchbase.port=8091
|
||||
spring.couchbase.bucket.password=123456
|
||||
@@ -12,7 +12,7 @@ import reactor.test.StepVerifier;
|
||||
import java.util.UUID;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@SpringBootTest(properties = {"spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration"})
|
||||
public class N1QLPersonRepositoryLiveTest {
|
||||
|
||||
@Autowired private N1QLPersonRepository personRepository;
|
||||
|
||||
@@ -13,7 +13,7 @@ import reactor.test.StepVerifier;
|
||||
import java.util.UUID;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@SpringBootTest(properties = {"spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration"})
|
||||
public class N1QLSortingPersonRepositoryLiveTest {
|
||||
|
||||
@Autowired private N1QLSortingPersonRepository personRepository;
|
||||
|
||||
@@ -8,6 +8,7 @@ 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.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -16,7 +17,8 @@ import reactor.test.StepVerifier;
|
||||
import java.util.UUID;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(properties = { "spring.couchbase.port=10010" }, classes = { ViewReactiveCouchbaseConfiguration.class, CouchbaseProperties.class, CouchbaseMockConfiguration.class })
|
||||
@SpringBootTest(properties = { "spring.couchbase.port=10010", "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration,org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration" },
|
||||
classes = { CouchbaseMockConfiguration.class, ViewReactiveCouchbaseConfiguration.class, CouchbaseProperties.class })
|
||||
public class ViewPersonRepositoryIntegrationTest {
|
||||
|
||||
@Autowired private ViewPersonRepository personRepository;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
## Spring 5 MVC
|
||||
|
||||
This module contains articles about Spring 5 model-view-controller (MVC) pattern
|
||||
|
||||
### Relevant Articles:
|
||||
- [Spring Boot and Kotlin](http://www.baeldung.com/spring-boot-kotlin)
|
||||
- [Spring MVC Streaming and SSE Request Processing](https://www.baeldung.com/spring-mvc-sse-streams)
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
## Spring 5 Reactive Project
|
||||
|
||||
This module contains articles about reactive Spring 5
|
||||
|
||||
- [Spring WebClient vs. RestTemplate](https://www.baeldung.com/spring-webclient-resttemplate)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
## Spring REST Example Project
|
||||
|
||||
This module contains articles about reactive Spring 5 WebClient
|
||||
|
||||
### The Course
|
||||
The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
## Spring 5 Reactive OAuth
|
||||
|
||||
This module contains articles about reactive Spring 5 OAuth
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Spring Security OAuth Login with WebFlux](https://www.baeldung.com/spring-oauth-login-webflux)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
## Spring 5 Reactive Security Examples
|
||||
|
||||
This module contains articles about reactive Spring Security 5
|
||||
|
||||
### The Course
|
||||
The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
## Spring 5 Reactive Project
|
||||
|
||||
This module contains articles about reactive Spring 5
|
||||
|
||||
### The Course
|
||||
The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||
|
||||
@@ -20,3 +22,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||
- [Testing Reactive Streams Using StepVerifier and TestPublisher](https://www.baeldung.com/reactive-streams-step-verifier-test-publisher)
|
||||
- [Debugging Reactive Streams in Spring 5](https://www.baeldung.com/spring-debugging-reactive-streams)
|
||||
- [Static Content in Spring WebFlux](https://www.baeldung.com/spring-webflux-static-content)
|
||||
- [more...](/spring-5-reactive-2)
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
## Spring 5 Security OAuth
|
||||
|
||||
This module contains articles about Spring 5 OAuth Security
|
||||
|
||||
## Relevant articles:
|
||||
|
||||
- [Spring Security 5 – OAuth2 Login](http://www.baeldung.com/spring-security-5-oauth2-login)
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
## Spring 5 Security
|
||||
|
||||
This module contains articles about Spring Security 5
|
||||
|
||||
## Relevant articles:
|
||||
|
||||
- [Extra Login Fields with Spring Security](http://www.baeldung.com/spring-security-extra-login-fields)
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
## Spring 5 WebFlux
|
||||
|
||||
This module contains articles about Spring 5 WebFlux
|
||||
|
||||
## Relevant articles:
|
||||
|
||||
- [Spring Boot Reactor Netty Configuration](https://www.baeldung.com/spring-boot-reactor-netty)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</dependencyManagement>
|
||||
|
||||
<properties>
|
||||
<spring.boot.version>1.5.8.RELEASE</spring.boot.version>
|
||||
<spring.boot.version>2.1.7.RELEASE</spring.boot.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -18,7 +18,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -59,7 +59,7 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-boot-admin-starter-client.version>1.5.4</spring-boot-admin-starter-client.version>
|
||||
<spring-boot-admin-starter-client.version>2.1.6</spring-boot-admin-starter-client.version>
|
||||
<spring-boot-maven-plugin.version>2.0.4.RELEASE</spring-boot-maven-plugin.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
#basic auth creddentials
|
||||
security.user.name=client
|
||||
security.user.password=client
|
||||
spring.security.user.name=client
|
||||
spring.security.user.password=client
|
||||
|
||||
#configs to connect to a secured server
|
||||
spring.boot.admin.url=http://localhost:8080
|
||||
spring.boot.admin.username=admin
|
||||
spring.boot.admin.password=admin
|
||||
spring.boot.admin.client.url=http://localhost:8080
|
||||
#spring.boot.admin.client.instance.service-base-url=http://localhost:8081
|
||||
spring.boot.admin.client.username=admin
|
||||
spring.boot.admin.client.password=admin
|
||||
|
||||
#configs to give secured server info
|
||||
spring.boot.admin.client.metadata.user.name=${security.user.name}
|
||||
spring.boot.admin.client.metadata.user.password=${security.user.password}
|
||||
spring.boot.admin.client.instance.metadata.user.name=${spring.security.user.name}
|
||||
spring.boot.admin.client.instance.metadata.user.password=${spring.security.user.password}
|
||||
|
||||
#app config
|
||||
spring.application.name=spring-boot-admin-client
|
||||
server.port=8081
|
||||
|
||||
management.endpoints.web.exposure.include=*
|
||||
management.endpoint.health.show-details=always
|
||||
@@ -18,18 +18,14 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- dependencies used to enable admin server and UI -->
|
||||
<!-- https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-starter-server -->
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-server</artifactId>
|
||||
<version>${spring-boot-admin-server.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-server-ui</artifactId>
|
||||
<artifactId>spring-boot-admin-starter-server</artifactId>
|
||||
<version>${spring-boot-admin-server.version}</version>
|
||||
</dependency>
|
||||
|
||||
@@ -37,7 +33,7 @@
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-server-ui-login</artifactId>
|
||||
<version>${spring-boot-admin-server.version}</version>
|
||||
<version>${spring-boot-admin-server-ui-login.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -47,6 +43,7 @@
|
||||
<groupId>com.hazelcast</groupId>
|
||||
<artifactId>hazelcast</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--declare the admin server as a client, for self monitoring -->
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
@@ -82,8 +79,9 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-boot-admin-server.version>1.5.4</spring-boot-admin-server.version>
|
||||
<spring-boot-admin-starter-client.version>1.5.4</spring-boot-admin-starter-client.version>
|
||||
<spring-boot-admin-server.version>2.1.6</spring-boot-admin-server.version>
|
||||
<spring-boot-admin-starter-client.version>2.1.6</spring-boot-admin-starter-client.version>
|
||||
<spring-boot-admin-server-ui-login.version>1.5.7</spring-boot-admin-server-ui-login.version>
|
||||
<spring-boot-maven-plugin.version>2.0.4.RELEASE</spring-boot-maven-plugin.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.baeldung.springbootadminserver;
|
||||
|
||||
import de.codecentric.boot.admin.config.EnableAdminServer;
|
||||
import de.codecentric.boot.admin.server.config.EnableAdminServer;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
|
||||
@@ -2,8 +2,14 @@ package com.baeldung.springbootadminserver.configs;
|
||||
|
||||
import com.hazelcast.config.Config;
|
||||
import com.hazelcast.config.EvictionPolicy;
|
||||
import com.hazelcast.config.ListConfig;
|
||||
import com.hazelcast.config.InMemoryFormat;
|
||||
import com.hazelcast.config.MapConfig;
|
||||
import com.hazelcast.config.MergePolicyConfig;
|
||||
import com.hazelcast.config.TcpIpConfig;
|
||||
import com.hazelcast.map.merge.PutIfAbsentMapMergePolicy;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -12,13 +18,30 @@ public class HazelcastConfig {
|
||||
|
||||
@Bean
|
||||
public Config hazelcast() {
|
||||
return new Config()
|
||||
.setProperty("hazelcast.jmx", "true")
|
||||
.addMapConfig(new MapConfig("spring-boot-admin-application-store")
|
||||
MapConfig eventStoreMap = new MapConfig("spring-boot-admin-event-store").setInMemoryFormat(InMemoryFormat.OBJECT)
|
||||
.setBackupCount(1)
|
||||
.setEvictionPolicy(EvictionPolicy.NONE))
|
||||
.addListConfig(new ListConfig("spring-boot-admin-event-store")
|
||||
.setEvictionPolicy(EvictionPolicy.NONE)
|
||||
.setMergePolicyConfig(new MergePolicyConfig(PutIfAbsentMapMergePolicy.class.getName(), 100));
|
||||
|
||||
MapConfig sentNotificationsMap = new MapConfig("spring-boot-admin-application-store").setInMemoryFormat(InMemoryFormat.OBJECT)
|
||||
.setBackupCount(1)
|
||||
.setMaxSize(1000));
|
||||
.setEvictionPolicy(EvictionPolicy.LRU)
|
||||
.setMergePolicyConfig(new MergePolicyConfig(PutIfAbsentMapMergePolicy.class.getName(), 100));
|
||||
|
||||
Config config = new Config();
|
||||
config.addMapConfig(eventStoreMap);
|
||||
config.addMapConfig(sentNotificationsMap);
|
||||
config.setProperty("hazelcast.jmx", "true");
|
||||
|
||||
config.getNetworkConfig()
|
||||
.getJoin()
|
||||
.getMulticastConfig()
|
||||
.setEnabled(false);
|
||||
TcpIpConfig tcpIpConfig = config.getNetworkConfig()
|
||||
.getJoin()
|
||||
.getTcpIpConfig();
|
||||
tcpIpConfig.setEnabled(true);
|
||||
tcpIpConfig.setMembers(Collections.singletonList("127.0.0.1"));
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,40 @@
|
||||
package com.baeldung.springbootadminserver.configs;
|
||||
|
||||
import de.codecentric.boot.admin.notify.LoggingNotifier;
|
||||
import de.codecentric.boot.admin.notify.RemindingNotifier;
|
||||
import de.codecentric.boot.admin.notify.filter.FilteringNotifier;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import de.codecentric.boot.admin.server.domain.entities.InstanceRepository;
|
||||
import de.codecentric.boot.admin.server.notify.LoggingNotifier;
|
||||
import de.codecentric.boot.admin.server.notify.RemindingNotifier;
|
||||
import de.codecentric.boot.admin.server.notify.filter.FilteringNotifier;
|
||||
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
public class NotifierConfiguration {
|
||||
@Autowired
|
||||
private InstanceRepository repository;
|
||||
|
||||
// @Autowired private Notifier notifier;
|
||||
|
||||
@Bean
|
||||
public LoggingNotifier notifier() {
|
||||
return new LoggingNotifier();
|
||||
return new LoggingNotifier(repository);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilteringNotifier filteringNotifier() {
|
||||
return new FilteringNotifier(notifier());
|
||||
return new FilteringNotifier(notifier(), repository);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
@Bean(initMethod = "start", destroyMethod = "stop")
|
||||
public RemindingNotifier remindingNotifier() {
|
||||
RemindingNotifier remindingNotifier = new RemindingNotifier(filteringNotifier());
|
||||
remindingNotifier.setReminderPeriod(TimeUnit.MINUTES.toMillis(5));
|
||||
RemindingNotifier remindingNotifier = new RemindingNotifier(filteringNotifier(), repository);
|
||||
remindingNotifier.setReminderPeriod(Duration.ofMinutes(5));
|
||||
remindingNotifier.setCheckReminderInverval(Duration.ofSeconds(60));
|
||||
return remindingNotifier;
|
||||
}
|
||||
|
||||
@Scheduled(fixedRate = 60_000L)
|
||||
public void remind() {
|
||||
remindingNotifier().sendReminders();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,56 @@
|
||||
package com.baeldung.springbootadminserver.configs;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
|
||||
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
|
||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||
|
||||
import de.codecentric.boot.admin.server.config.AdminServerProperties;
|
||||
|
||||
@Configuration
|
||||
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
private final AdminServerProperties adminServer;
|
||||
|
||||
public WebSecurityConfig(AdminServerProperties adminServer) {
|
||||
this.adminServer = adminServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http
|
||||
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
|
||||
successHandler.setTargetUrlParameter("redirectTo");
|
||||
successHandler.setDefaultTargetUrl(this.adminServer.getContextPath() + "/");
|
||||
|
||||
http.authorizeRequests()
|
||||
.antMatchers(this.adminServer.getContextPath() + "/assets/**")
|
||||
.permitAll()
|
||||
.antMatchers(this.adminServer.getContextPath() + "/login")
|
||||
.permitAll()
|
||||
.anyRequest()
|
||||
.authenticated()
|
||||
.and()
|
||||
.formLogin()
|
||||
.loginPage("/login.html")
|
||||
.loginProcessingUrl("/login")
|
||||
.permitAll();
|
||||
http
|
||||
.loginPage(this.adminServer.getContextPath() + "/login")
|
||||
.successHandler(successHandler)
|
||||
.and()
|
||||
.logout()
|
||||
.logoutUrl("/logout");
|
||||
http
|
||||
.logoutUrl(this.adminServer.getContextPath() + "/logout")
|
||||
.and()
|
||||
.httpBasic()
|
||||
.and()
|
||||
.csrf()
|
||||
.disable();
|
||||
http
|
||||
.authorizeRequests()
|
||||
.antMatchers("/login.html", "/**/*.css", "/img/**", "/third-party/**")
|
||||
.permitAll();
|
||||
http
|
||||
.authorizeRequests()
|
||||
.antMatchers("/**")
|
||||
.authenticated();
|
||||
http.httpBasic();
|
||||
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
|
||||
.ignoringRequestMatchers(new AntPathRequestMatcher(this.adminServer.getContextPath() + "/instances", HttpMethod.POST.toString()), new AntPathRequestMatcher(this.adminServer.getContextPath() + "/instances/*", HttpMethod.DELETE.toString()),
|
||||
new AntPathRequestMatcher(this.adminServer.getContextPath() + "/actuator/**"))
|
||||
.and()
|
||||
.rememberMe()
|
||||
.key(UUID.randomUUID()
|
||||
.toString())
|
||||
.tokenValiditySeconds(1209600);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
spring.application.name=spring-boot-admin-server
|
||||
|
||||
security.user.name=admin
|
||||
security.user.password=admin
|
||||
spring.security.user.name=admin
|
||||
spring.security.user.password=admin
|
||||
|
||||
#configs to connect to self register the admin server as a client
|
||||
spring.boot.admin.url=http://localhost:8080
|
||||
spring.boot.admin.username=${security.user.name}
|
||||
spring.boot.admin.password=${security.user.password}
|
||||
spring.boot.admin.client.url=http://localhost:8080
|
||||
spring.boot.admin.client.username=${spring.security.user.name}
|
||||
spring.boot.admin.client.password=${spring.security.user.password}
|
||||
|
||||
#configs to give secured server info
|
||||
spring.boot.admin.client.metadata.user.name=${security.user.name}
|
||||
spring.boot.admin.client.metadata.user.password=${security.user.password}
|
||||
spring.boot.admin.client.instance.metadata.user.name=${spring.security.user.name}
|
||||
spring.boot.admin.client.instance.metadata.user.password=${spring.security.user.password}
|
||||
|
||||
management.endpoints.web.exposure.include=*
|
||||
management.endpoint.health.show-details=always
|
||||
|
||||
#mail notifications
|
||||
#spring.mail.host=smtp.gmail.com
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.baeldung.springbootadminserver;
|
||||
|
||||
import com.baeldung.springbootadminserver.configs.NotifierConfiguration;
|
||||
import de.codecentric.boot.admin.notify.Notifier;
|
||||
import de.codecentric.boot.admin.notify.RemindingNotifier;
|
||||
import de.codecentric.boot.admin.notify.filter.FilteringNotifier;
|
||||
|
||||
import de.codecentric.boot.admin.server.notify.Notifier;
|
||||
import de.codecentric.boot.admin.server.notify.RemindingNotifier;
|
||||
import de.codecentric.boot.admin.server.notify.filter.FilteringNotifier;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<version>1.5.10.RELEASE</version>
|
||||
<version>${spring-boot.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -18,25 +18,22 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<version>2.1.6.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
<version>2.1.6.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
<version>2.1.6.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>1.4.197</version>
|
||||
<version>${h2.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.baeldung.nonblockingcoroutines.repository.ProductRepositoryCoroutines
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
@@ -28,17 +30,17 @@ class ProductControllerCoroutines {
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/stock")
|
||||
suspend fun findOneInStock(@PathVariable id: Int): ProductStockView {
|
||||
val product: Deferred<Product?> = GlobalScope.async {
|
||||
suspend fun findOneInStock(@PathVariable id: Int): ProductStockView = coroutineScope {
|
||||
val product: Deferred<Product?> = async(start = CoroutineStart.LAZY) {
|
||||
productRepository.getProductById(id)
|
||||
}
|
||||
val quantity: Deferred<Int> = GlobalScope.async {
|
||||
val quantity: Deferred<Int> = async(start = CoroutineStart.LAZY) {
|
||||
webClient.get()
|
||||
.uri("/stock-service/product/$id/quantity")
|
||||
.accept(APPLICATION_JSON)
|
||||
.awaitExchange().awaitBody<Int>()
|
||||
}
|
||||
return ProductStockView(product.await()!!, quantity.await())
|
||||
ProductStockView(product.await()!!, quantity.await())
|
||||
}
|
||||
|
||||
@FlowPreview
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.4</version>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -79,5 +79,6 @@
|
||||
<start-class>com.baeldung.springbootlogging.SpringBootLoggingApplication</start-class>
|
||||
<spring-boot-starter-log4j.version>1.3.8.RELEASE</spring-boot-starter-log4j.version>
|
||||
<gelfj.version>1.1.16</gelfj.version>
|
||||
<lombok.version>1.18.4</lombok.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user