diff --git a/algorithms-genetic/pom.xml b/algorithms-genetic/pom.xml
index 2a10a81980..fc6d36dac1 100644
--- a/algorithms-genetic/pom.xml
+++ b/algorithms-genetic/pom.xml
@@ -1,10 +1,10 @@
4.0.0
- com.baeldung
algorithms-genetic
0.0.1-SNAPSHOT
-
+ algorithms-genetic
+
com.baeldung
parent-modules
@@ -61,4 +61,5 @@
1.11
-
\ No newline at end of file
+
+
diff --git a/algorithms-miscellaneous-1/pom.xml b/algorithms-miscellaneous-1/pom.xml
index 16749d452e..75b031282b 100644
--- a/algorithms-miscellaneous-1/pom.xml
+++ b/algorithms-miscellaneous-1/pom.xml
@@ -1,10 +1,10 @@
4.0.0
- com.baeldung
algorithms-miscellaneous-1
0.0.1-SNAPSHOT
-
+ algorithms-miscellaneous-1
+
com.baeldung
parent-modules
diff --git a/algorithms-miscellaneous-2/pom.xml b/algorithms-miscellaneous-2/pom.xml
index eeae544612..25472d4888 100644
--- a/algorithms-miscellaneous-2/pom.xml
+++ b/algorithms-miscellaneous-2/pom.xml
@@ -1,9 +1,9 @@
4.0.0
- com.baeldung
algorithms-miscellaneous-2
0.0.1-SNAPSHOT
+ algorithms-miscellaneous-2
com.baeldung
diff --git a/algorithms-sorting/pom.xml b/algorithms-sorting/pom.xml
index 60ae37f2a4..2aee6e9199 100644
--- a/algorithms-sorting/pom.xml
+++ b/algorithms-sorting/pom.xml
@@ -1,9 +1,9 @@
4.0.0
- com.baeldung
algorithms-sorting
0.0.1-SNAPSHOT
+ algorithms-sorting
com.baeldung
diff --git a/annotations/annotation-processing/pom.xml b/annotations/annotation-processing/pom.xml
index 8e53334521..d9aca6040d 100644
--- a/annotations/annotation-processing/pom.xml
+++ b/annotations/annotation-processing/pom.xml
@@ -3,7 +3,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
annotation-processing
-
+ annotation-processing
+
com.baeldung
1.0.0-SNAPSHOT
diff --git a/annotations/annotation-user/pom.xml b/annotations/annotation-user/pom.xml
index 07ea9a5b5a..422cc7f119 100644
--- a/annotations/annotation-user/pom.xml
+++ b/annotations/annotation-user/pom.xml
@@ -3,6 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
annotation-user
+ annotation-user
annotations
diff --git a/annotations/pom.xml b/annotations/pom.xml
index 2c73d3d91b..6d83f5b057 100644
--- a/annotations/pom.xml
+++ b/annotations/pom.xml
@@ -4,7 +4,8 @@
4.0.0
annotations
pom
-
+ annotations
+
parent-modules
com.baeldung
diff --git a/apache-avro/pom.xml b/apache-avro/pom.xml
index ddf5844271..18f9c34d64 100644
--- a/apache-avro/pom.xml
+++ b/apache-avro/pom.xml
@@ -3,10 +3,9 @@
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">
4.0.0
- com.baeldung
apache-avro
0.0.1-SNAPSHOT
- Apache Avro
+ apache-avro
UTF-8
diff --git a/apache-bval/pom.xml b/apache-bval/pom.xml
index 5ddb1ecb59..786f587fb1 100644
--- a/apache-bval/pom.xml
+++ b/apache-bval/pom.xml
@@ -4,7 +4,8 @@
apache-bval
apache-bval
0.0.1-SNAPSHOT
-
+ apache-bval
+
com.baeldung
parent-modules
diff --git a/apache-curator/pom.xml b/apache-curator/pom.xml
index ac10811e7a..bcca38b199 100644
--- a/apache-curator/pom.xml
+++ b/apache-curator/pom.xml
@@ -4,6 +4,7 @@
apache-curator
0.0.1-SNAPSHOT
jar
+ apache-curator
com.baeldung
diff --git a/apache-cxf/cxf-aegis/pom.xml b/apache-cxf/cxf-aegis/pom.xml
index b7e9e426a2..1d36178b82 100644
--- a/apache-cxf/cxf-aegis/pom.xml
+++ b/apache-cxf/cxf-aegis/pom.xml
@@ -2,7 +2,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
cxf-aegis
-
+ cxf-aegis
+
com.baeldung
apache-cxf
diff --git a/apache-cxf/cxf-introduction/pom.xml b/apache-cxf/cxf-introduction/pom.xml
index a9e82c16b3..17f03afd25 100644
--- a/apache-cxf/cxf-introduction/pom.xml
+++ b/apache-cxf/cxf-introduction/pom.xml
@@ -4,7 +4,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
cxf-introduction
-
+ cxf-introduction
+
com.baeldung
apache-cxf
diff --git a/apache-cxf/cxf-jaxrs-implementation/pom.xml b/apache-cxf/cxf-jaxrs-implementation/pom.xml
index 89acbdf1bd..03d0f67c90 100644
--- a/apache-cxf/cxf-jaxrs-implementation/pom.xml
+++ b/apache-cxf/cxf-jaxrs-implementation/pom.xml
@@ -4,7 +4,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
cxf-jaxrs-implementation
-
+ cxf-jaxrs-implementation
+
com.baeldung
apache-cxf
diff --git a/apache-cxf/cxf-spring/pom.xml b/apache-cxf/cxf-spring/pom.xml
index 31e75e7cdd..97715af54c 100644
--- a/apache-cxf/cxf-spring/pom.xml
+++ b/apache-cxf/cxf-spring/pom.xml
@@ -3,6 +3,7 @@
4.0.0
cxf-spring
war
+ cxf-spring
com.baeldung
diff --git a/apache-cxf/pom.xml b/apache-cxf/pom.xml
index 8918fd4450..0016f33d70 100644
--- a/apache-cxf/pom.xml
+++ b/apache-cxf/pom.xml
@@ -1,9 +1,9 @@
4.0.0
- com.baeldung
apache-cxf
0.0.1-SNAPSHOT
+ apache-cxf
pom
diff --git a/apache-cxf/sse-jaxrs/pom.xml b/apache-cxf/sse-jaxrs/pom.xml
index d4b6c19d03..cb5c96660a 100644
--- a/apache-cxf/sse-jaxrs/pom.xml
+++ b/apache-cxf/sse-jaxrs/pom.xml
@@ -3,8 +3,8 @@
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">
4.0.0
-
sse-jaxrs
+ sse-jaxrs
pom
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-client/pom.xml b/apache-cxf/sse-jaxrs/sse-jaxrs-client/pom.xml
index 0f5406fbc7..c7acf22c32 100644
--- a/apache-cxf/sse-jaxrs/sse-jaxrs-client/pom.xml
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-client/pom.xml
@@ -3,15 +3,15 @@
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">
4.0.0
-
+ sse-jaxrs-client
+ sse-jaxrs-client
+
com.baeldung
sse-jaxrs
0.0.1-SNAPSHOT
- sse-jaxrs-client
-
3.2.0
@@ -21,7 +21,6 @@
org.codehaus.mojo
exec-maven-plugin
- 1.6.0
singleEvent
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml b/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml
index 2e82dc3829..eeb5726ee1 100644
--- a/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml
@@ -3,16 +3,16 @@
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">
4.0.0
-
+ sse-jaxrs-server
+ sse-jaxrs-server
+ war
+
com.baeldung
sse-jaxrs
0.0.1-SNAPSHOT
- sse-jaxrs-server
- war
-
2.4.2
false
diff --git a/apache-geode/pom.xml b/apache-geode/pom.xml
index a3f6604ac4..738accdcb8 100644
--- a/apache-geode/pom.xml
+++ b/apache-geode/pom.xml
@@ -3,11 +3,10 @@
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">
4.0.0
-
- com.baeldung
apache-geode
1.0-SNAPSHOT
-
+ apache-geode
+
com.baeldung
parent-modules
diff --git a/apache-opennlp/pom.xml b/apache-opennlp/pom.xml
index 985c9a2df2..6b2e6a9729 100644
--- a/apache-opennlp/pom.xml
+++ b/apache-opennlp/pom.xml
@@ -4,6 +4,7 @@
4.0.0
apache-opennlp
1.0-SNAPSHOT
+ apache-opennlp
jar
diff --git a/apache-poi/pom.xml b/apache-poi/pom.xml
index a1ec626d43..54c3e8e928 100644
--- a/apache-poi/pom.xml
+++ b/apache-poi/pom.xml
@@ -1,9 +1,9 @@
4.0.0
- com.baeldung
apache-poi
0.0.1-SNAPSHOT
+ apache-poi
com.baeldung
diff --git a/apache-pulsar/pom.xml b/apache-pulsar/pom.xml
index da004a7638..a4c09586eb 100644
--- a/apache-pulsar/pom.xml
+++ b/apache-pulsar/pom.xml
@@ -1,21 +1,22 @@
- 4.0.0
- com.baeldung.pulsar
- pulsar-java
- 0.0.1
+ 4.0.0
+ com.baeldung.pulsar
+ apache-pulsar
+ 0.0.1
+ apache-pulsar
-
-
- org.apache.pulsar
- pulsar-client
- 2.1.1-incubating
- compile
-
-
-
- 1.8
- 1.8
-
+
+
+ org.apache.pulsar
+ pulsar-client
+ 2.1.1-incubating
+ compile
+
+
+
+ 1.8
+ 1.8
+
diff --git a/apache-shiro/pom.xml b/apache-shiro/pom.xml
index 98d9563284..644d70b30a 100644
--- a/apache-shiro/pom.xml
+++ b/apache-shiro/pom.xml
@@ -5,7 +5,8 @@
4.0.0
apache-shiro
1.0-SNAPSHOT
-
+ apache-shiro
+
parent-boot-1
com.baeldung
diff --git a/apache-thrift/pom.xml b/apache-thrift/pom.xml
index b22364cb19..ab54fc2cef 100644
--- a/apache-thrift/pom.xml
+++ b/apache-thrift/pom.xml
@@ -1,9 +1,9 @@
4.0.0
- com.baeldung
apache-thrift
0.0.1-SNAPSHOT
+ apache-thrift
pom
diff --git a/apache-tika/pom.xml b/apache-tika/pom.xml
index 5a76fdeeda..0399914a5f 100644
--- a/apache-tika/pom.xml
+++ b/apache-tika/pom.xml
@@ -1,10 +1,10 @@
4.0.0
- com.baeldung
apache-tika
0.0.1-SNAPSHOT
-
+ apache-tika
+
com.baeldung
parent-modules
diff --git a/apache-zookeeper/pom.xml b/apache-zookeeper/pom.xml
index 0b29186ccc..53e4217358 100644
--- a/apache-zookeeper/pom.xml
+++ b/apache-zookeeper/pom.xml
@@ -1,9 +1,9 @@
4.0.0
- com.baeldung
apache-zookeeper
0.0.1-SNAPSHOT
+ apache-zookeeper
jar
diff --git a/asm/pom.xml b/asm/pom.xml
index 5aad2a0e37..e56438c808 100644
--- a/asm/pom.xml
+++ b/asm/pom.xml
@@ -5,6 +5,7 @@
com.baeldung.examples
asm
1.0
+ asm
jar
diff --git a/atomix/pom.xml b/atomix/pom.xml
index f85d2d7484..e50c1d867f 100644
--- a/atomix/pom.xml
+++ b/atomix/pom.xml
@@ -4,7 +4,8 @@
com.atomix.io
atomix
0.0.1-SNAPSHOT
-
+ atomix
+
com.baeldung
parent-modules
diff --git a/axon/pom.xml b/axon/pom.xml
index 915a04feb5..c643ea9e57 100644
--- a/axon/pom.xml
+++ b/axon/pom.xml
@@ -3,7 +3,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
axon
-
+ axon
+
parent-modules
com.baeldung
diff --git a/cas/cas-server/pom.xml b/cas/cas-server/pom.xml
index 9b61aaec3d..98f5f10493 100644
--- a/cas/cas-server/pom.xml
+++ b/cas/cas-server/pom.xml
@@ -3,8 +3,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd ">
4.0.0
cas-server
- war
1.0
+ cas-server
+ war
parent-boot-1
diff --git a/cdi/README.md b/cdi/README.md
index 0477ce85bd..bfb635be9e 100644
--- a/cdi/README.md
+++ b/cdi/README.md
@@ -1,3 +1,5 @@
### Relevant Articles:
- [CDI Interceptor vs Spring AspectJ](http://www.baeldung.com/cdi-interceptor-vs-spring-aspectj)
- [An Introduction to CDI (Contexts and Dependency Injection) in Java](http://www.baeldung.com/java-ee-cdi)
+- [Introduction to the Event Notification Model in CDI 2.0](https://www.baeldung.com/cdi-event-notification)
+
diff --git a/cdi/pom.xml b/cdi/pom.xml
index 0b735e0ca5..0cf5062ccc 100644
--- a/cdi/pom.xml
+++ b/cdi/pom.xml
@@ -2,9 +2,9 @@
4.0.0
- com.baeldung
cdi
1.0-SNAPSHOT
+ cdi
com.baeldung
diff --git a/core-groovy/pom.xml b/core-groovy/pom.xml
index 909250710e..e54c766280 100644
--- a/core-groovy/pom.xml
+++ b/core-groovy/pom.xml
@@ -4,6 +4,7 @@
4.0.0
core-groovy
1.0-SNAPSHOT
+ core-groovy
jar
diff --git a/core-java-9/pom.xml b/core-java-9/pom.xml
index f22d0a3ed9..cd1fa74dbb 100644
--- a/core-java-9/pom.xml
+++ b/core-java-9/pom.xml
@@ -1,7 +1,6 @@
4.0.0
- com.baeldung
core-java-9
0.2-SNAPSHOT
core-java-9
diff --git a/core-java-collections/src/main/java/com/baeldung/java/list/WaysToIterate.java b/core-java-collections/src/main/java/com/baeldung/java/list/WaysToIterate.java
new file mode 100644
index 0000000000..3cce08eabb
--- /dev/null
+++ b/core-java-collections/src/main/java/com/baeldung/java/list/WaysToIterate.java
@@ -0,0 +1,67 @@
+package com.baeldung.java.list;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ * Demonstrates the different ways to loop over
+ * the elements of a list.
+ */
+public class WaysToIterate {
+
+ List countries = Arrays.asList("Germany", "Panama", "Australia");
+
+ /**
+ * Iterate over a list using a basic for loop
+ */
+ public void iterateWithForLoop() {
+ for (int i = 0; i < countries.size(); i++) {
+ System.out.println(countries.get(i));
+ }
+ }
+
+ /**
+ * Iterate over a list using the enhanced for loop
+ */
+ public void iterateWithEnhancedForLoop() {
+ for (String country : countries) {
+ System.out.println(country);
+ }
+ }
+
+ /**
+ * Iterate over a list using an Iterator
+ */
+ public void iterateWithIterator() {
+ Iterator countriesIterator = countries.iterator();
+ while(countriesIterator.hasNext()) {
+ System.out.println(countriesIterator.next());
+ }
+ }
+
+ /**
+ * Iterate over a list using a ListIterator
+ */
+ public void iterateWithListIterator() {
+ ListIterator listIterator = countries.listIterator();
+ while(listIterator.hasNext()) {
+ System.out.println(listIterator.next());
+ }
+ }
+
+ /**
+ * Iterate over a list using the Iterable.forEach() method
+ */
+ public void iterateWithForEach() {
+ countries.forEach(System.out::println);
+ }
+
+ /**
+ * Iterate over a list using the Stream.forEach() method
+ */
+ public void iterateWithStreamForEach() {
+ countries.stream().forEach((c) -> System.out.println(c));
+ }
+}
\ No newline at end of file
diff --git a/core-java-collections/src/test/java/com/baeldung/java/list/WaysToIterateUnitTest.java b/core-java-collections/src/test/java/com/baeldung/java/list/WaysToIterateUnitTest.java
new file mode 100644
index 0000000000..973c60b233
--- /dev/null
+++ b/core-java-collections/src/test/java/com/baeldung/java/list/WaysToIterateUnitTest.java
@@ -0,0 +1,71 @@
+package com.baeldung.java.list;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.junit.Test;
+
+public class WaysToIterateUnitTest {
+
+ List globalCountries = new ArrayList();
+ List europeanCountries = Arrays.asList("Germany", "Panama", "Australia");
+
+ @Test
+ public void whenIteratingUsingForLoop_thenReturnThreeAsSizeOfList() {
+ for (int i = 0; i < europeanCountries.size(); i++) {
+ globalCountries.add(europeanCountries.get(i));
+ }
+ assertEquals(globalCountries.size(), 3);
+ globalCountries.clear();
+ }
+
+ @Test
+ public void whenIteratingUsingEnhancedForLoop_thenReturnThreeAsSizeOfList() {
+ for (String country : europeanCountries) {
+ globalCountries.add(country);
+ }
+ assertEquals(globalCountries.size(), 3);
+ globalCountries.clear();
+ }
+
+ @Test
+ public void whenIteratingUsingIterator_thenReturnThreeAsSizeOfList() {
+ Iterator countriesIterator = europeanCountries.iterator();
+ while (countriesIterator.hasNext()) {
+ globalCountries.add(countriesIterator.next());
+ }
+
+ assertEquals(globalCountries.size(), 3);
+ globalCountries.clear();
+ }
+
+ @Test
+ public void whenIteratingUsingListIterator_thenReturnThreeAsSizeOfList() {
+ ListIterator countriesIterator = europeanCountries.listIterator();
+ while (countriesIterator.hasNext()) {
+ globalCountries.add(countriesIterator.next());
+ }
+
+ assertEquals(globalCountries.size(), 3);
+ globalCountries.clear();
+ }
+
+ @Test
+ public void whenIteratingUsingForEach_thenReturnThreeAsSizeOfList() {
+ europeanCountries.forEach(country -> globalCountries.add(country));
+ assertEquals(globalCountries.size(), 3);
+ globalCountries.clear();
+ }
+
+ @Test
+ public void whenIteratingUsingStreamForEach_thenReturnThreeAsSizeOfList() {
+ europeanCountries.stream().forEach((country) -> globalCountries.add(country));
+ assertEquals(globalCountries.size(), 3);
+ globalCountries.clear();
+ }
+}
\ No newline at end of file
diff --git a/core-java-lang/README.md b/core-java-lang/README.md
index 62af72818f..79d2375c24 100644
--- a/core-java-lang/README.md
+++ b/core-java-lang/README.md
@@ -57,4 +57,5 @@
- [“Sneaky Throws” in Java](http://www.baeldung.com/java-sneaky-throws)
- [Inheritance and Composition (Is-a vs Has-a relationship) in Java](http://www.baeldung.com/java-inheritance-composition)
- [A Guide to Constructors in Java](https://www.baeldung.com/java-constructors)
+- [Retrieving a Class Name in Java](https://www.baeldung.com/java-class-name)
diff --git a/core-java/src/main/java/com/baeldung/className/RetrievingClassName.java b/core-java-lang/src/main/java/com/baeldung/className/RetrievingClassName.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/className/RetrievingClassName.java
rename to core-java-lang/src/main/java/com/baeldung/className/RetrievingClassName.java
diff --git a/core-java/src/test/java/com/baeldung/className/RetrievingClassNameUnitTest.java b/core-java-lang/src/test/java/com/baeldung/className/RetrievingClassNameUnitTest.java
similarity index 100%
rename from core-java/src/test/java/com/baeldung/className/RetrievingClassNameUnitTest.java
rename to core-java-lang/src/test/java/com/baeldung/className/RetrievingClassNameUnitTest.java
diff --git a/core-java-lang/src/test/java/com/baeldung/compoundoperators/CompoundOperatorsUnitTest.java b/core-java-lang/src/test/java/com/baeldung/compoundoperators/CompoundOperatorsUnitTest.java
new file mode 100644
index 0000000000..532776edd4
--- /dev/null
+++ b/core-java-lang/src/test/java/com/baeldung/compoundoperators/CompoundOperatorsUnitTest.java
@@ -0,0 +1,111 @@
+package com.baeldung.compoundoperators;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class CompoundOperatorsUnitTest {
+
+ @Test
+ public void whenAssignmentOperatorIsUsed_thenValueIsAssigned() {
+ int x = 5;
+
+ assertEquals(5, x);
+ }
+
+ @Test
+ public void whenCompoundAssignmentUsed_thenSameAsSimpleAssignment() {
+ int a = 3, b = 3, c = -2;
+ a = a * c; // Simple assignment operator
+ b *= c; // Compound assignment operator
+
+ assertEquals(a, b);
+ }
+
+ @Test
+ public void whenAssignmentOperatorIsUsed_thenValueIsReturned() {
+ long x = 1;
+ long y = (x+=2);
+
+ assertEquals(3, y);
+ assertEquals(y, x);
+ }
+
+ @Test
+ public void whenCompoundOperatorsAreUsed_thenOperationsArePerformedAndAssigned() {
+ //Simple assignment
+ int x = 5; //x is 5
+
+ //Incrementation
+ x += 5; //x is 10
+ assertEquals(10, x);
+
+ //Decrementation
+ x -= 2; //x is 8
+ assertEquals(8, x);
+
+ //Multiplication
+ x *= 2; //x is 16
+ assertEquals(16, x);
+
+ //Division
+ x /= 4; //x is 4
+ assertEquals(4, x);
+
+ //Modulus
+ x %= 3; //x is 1
+ assertEquals(1, x);
+
+
+ //Binary AND
+ x &= 4; //x is 0
+ assertEquals(0, x);
+
+ //Binary exclusive OR
+ x ^= 4; //x is 4
+ assertEquals(4, x);
+
+ //Binary inclusive OR
+ x |= 8; //x is 12
+ assertEquals(12, x);
+
+
+ //Binary Left Shift
+ x <<= 2; //x is 48
+ assertEquals(48, x);
+
+ //Binary Right Shift
+ x >>= 2; //x is 12
+ assertEquals(12, x);
+
+ //Shift right zero fill
+ x >>>= 1; //x is 6
+ assertEquals(6, x);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void whenArrayIsNull_thenThrowNullException() {
+ int[] numbers = null;
+
+ //Trying Incrementation
+ numbers[2] += 5;
+ }
+
+ @Test(expected = ArrayIndexOutOfBoundsException.class)
+ public void whenArrayIndexNotCorrect_thenThrowArrayIndexException() {
+ int[] numbers = {0, 1};
+
+ //Trying Incrementation
+ numbers[2] += 5;
+ }
+
+ @Test
+ public void whenArrayIndexIsCorrect_thenPerformOperation() {
+ int[] numbers = {0, 1};
+
+ //Incrementation
+ numbers[1] += 5;
+ assertEquals(6, numbers[1]);
+ }
+
+}
diff --git a/core-java-net/.gitignore b/core-java-net/.gitignore
new file mode 100644
index 0000000000..374c8bf907
--- /dev/null
+++ b/core-java-net/.gitignore
@@ -0,0 +1,25 @@
+*.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
+backup-pom.xml
+/bin/
+/temp
+
+#IntelliJ specific
+.idea/
+*.iml
\ No newline at end of file
diff --git a/core-java-net/README.md b/core-java-net/README.md
new file mode 100644
index 0000000000..b7a142ea27
--- /dev/null
+++ b/core-java-net/README.md
@@ -0,0 +1,3 @@
+=========
+
+## Core Java Net
diff --git a/core-java-net/pom.xml b/core-java-net/pom.xml
new file mode 100644
index 0000000000..28d5766a9a
--- /dev/null
+++ b/core-java-net/pom.xml
@@ -0,0 +1,19 @@
+
+ 4.0.0
+ core-java-net
+ 0.1.0-SNAPSHOT
+ jar
+ core-java-net
+
+
+ com.baeldung
+ parent-java
+ 0.0.1-SNAPSHOT
+ ../parent-java
+
+
+
+ core-java-net
+
+
diff --git a/core-java/src/main/java/com/baeldung/networking/proxies/CommandLineProxyDemo.java b/core-java-net/src/main/java/com/baeldung/networking/proxies/CommandLineProxyDemo.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/proxies/CommandLineProxyDemo.java
rename to core-java-net/src/main/java/com/baeldung/networking/proxies/CommandLineProxyDemo.java
diff --git a/core-java/src/main/java/com/baeldung/networking/proxies/DirectProxyDemo.java b/core-java-net/src/main/java/com/baeldung/networking/proxies/DirectProxyDemo.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/proxies/DirectProxyDemo.java
rename to core-java-net/src/main/java/com/baeldung/networking/proxies/DirectProxyDemo.java
diff --git a/core-java/src/main/java/com/baeldung/networking/proxies/SocksProxyDemo.java b/core-java-net/src/main/java/com/baeldung/networking/proxies/SocksProxyDemo.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/proxies/SocksProxyDemo.java
rename to core-java-net/src/main/java/com/baeldung/networking/proxies/SocksProxyDemo.java
diff --git a/core-java/src/main/java/com/baeldung/networking/proxies/SystemPropertyProxyDemo.java b/core-java-net/src/main/java/com/baeldung/networking/proxies/SystemPropertyProxyDemo.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/proxies/SystemPropertyProxyDemo.java
rename to core-java-net/src/main/java/com/baeldung/networking/proxies/SystemPropertyProxyDemo.java
diff --git a/core-java/src/main/java/com/baeldung/networking/proxies/UrlConnectionUtils.java b/core-java-net/src/main/java/com/baeldung/networking/proxies/UrlConnectionUtils.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/proxies/UrlConnectionUtils.java
rename to core-java-net/src/main/java/com/baeldung/networking/proxies/UrlConnectionUtils.java
diff --git a/core-java/src/main/java/com/baeldung/networking/proxies/WebProxyDemo.java b/core-java-net/src/main/java/com/baeldung/networking/proxies/WebProxyDemo.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/networking/proxies/WebProxyDemo.java
rename to core-java-net/src/main/java/com/baeldung/networking/proxies/WebProxyDemo.java
diff --git a/core-java-net/src/test/resources/.gitignore b/core-java-net/src/test/resources/.gitignore
new file mode 100644
index 0000000000..83c05e60c8
--- /dev/null
+++ b/core-java-net/src/test/resources/.gitignore
@@ -0,0 +1,13 @@
+*.class
+
+#folders#
+/target
+/neoDb*
+/data
+/src/main/webapp/WEB-INF/classes
+*/META-INF/*
+
+# Packaged files #
+*.jar
+*.war
+*.ear
\ No newline at end of file
diff --git a/core-java/README.md b/core-java/README.md
index e8923e9a2f..b8ad28cc0c 100644
--- a/core-java/README.md
+++ b/core-java/README.md
@@ -88,3 +88,4 @@
- [Changing the Order in a Sum Operation Can Produce Different Results?](https://www.baeldung.com/java-floating-point-sum-order)
- [Java – Try with Resources](https://www.baeldung.com/java-try-with-resources)
- [Abstract Classes in Java](https://www.baeldung.com/java-abstract-class)
+- [Guide to Character Encoding](https://www.baeldung.com/java-char-encoding)
diff --git a/core-java/pom.xml b/core-java/pom.xml
index 9fbc8f6810..64345ab14c 100644
--- a/core-java/pom.xml
+++ b/core-java/pom.xml
@@ -3,8 +3,8 @@
4.0.0
core-java
0.1.0-SNAPSHOT
- jar
core-java
+ jar
com.baeldung
diff --git a/core-java/src/main/java/com/baeldung/graph/Graph.java b/core-java/src/main/java/com/baeldung/graph/Graph.java
new file mode 100644
index 0000000000..43b5c0aa08
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/graph/Graph.java
@@ -0,0 +1,76 @@
+package com.baeldung.graph;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public class Graph {
+ private Map> adjVertices;
+
+ Graph() {
+ this.adjVertices = new HashMap>();
+ }
+
+ void addVertex(String label) {
+ adjVertices.putIfAbsent(new Vertex(label), new ArrayList<>());
+ }
+
+ void removeVertex(String label) {
+ Vertex v = new Vertex(label);
+ adjVertices.values().stream().map(e -> e.remove(v)).collect(Collectors.toList());
+ adjVertices.remove(new Vertex(label));
+ }
+
+ void addEdge(String label1, String label2) {
+ Vertex v1 = new Vertex(label1);
+ Vertex v2 = new Vertex(label2);
+ adjVertices.get(v1).add(v2);
+ adjVertices.get(v2).add(v1);
+ }
+
+ void removeEdge(String label1, String label2) {
+ Vertex v1 = new Vertex(label1);
+ Vertex v2 = new Vertex(label2);
+ List eV1 = adjVertices.get(v1);
+ List eV2 = adjVertices.get(v2);
+ if (eV1 != null)
+ eV1.remove(v2);
+ if (eV2 != null)
+ eV2.remove(v1);
+ }
+
+ List getAdjVertices(String label) {
+ return adjVertices.get(new Vertex(label));
+ }
+
+ String printGraph() {
+ StringBuffer sb = new StringBuffer();
+ for(Vertex v : adjVertices.keySet()) {
+ sb.append(v);
+ sb.append(adjVertices.get(v));
+ }
+ return sb.toString();
+ }
+
+ class Vertex {
+ String label;
+ Vertex(String label) {
+ this.label = label;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ Vertex vertex = (Vertex) obj;
+ return vertex.label == label;
+ }
+ @Override
+ public int hashCode() {
+ return label.hashCode();
+ }
+ @Override
+ public String toString() {
+ return label;
+ }
+ }
+}
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/graph/GraphTraversal.java b/core-java/src/main/java/com/baeldung/graph/GraphTraversal.java
new file mode 100644
index 0000000000..479e653a5c
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/graph/GraphTraversal.java
@@ -0,0 +1,44 @@
+package com.baeldung.graph;
+
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.Set;
+import java.util.Stack;
+
+import com.baeldung.graph.Graph.Vertex;
+
+public class GraphTraversal {
+ static Set depthFirstTraversal(Graph graph, String root) {
+ Set visited = new LinkedHashSet();
+ Stack stack = new Stack();
+ stack.push(root);
+ while (!stack.isEmpty()) {
+ String vertex = stack.pop();
+ if (!visited.contains(vertex)) {
+ visited.add(vertex);
+ for (Vertex v : graph.getAdjVertices(vertex)) {
+ stack.push(v.label);
+ }
+ }
+ }
+ return visited;
+ }
+
+ static Set breadthFirstTraversal(Graph graph, String root) {
+ Set visited = new LinkedHashSet();
+ Queue queue = new LinkedList();
+ queue.add(root);
+ visited.add(root);
+ while (!queue.isEmpty()) {
+ String vertex = queue.poll();
+ for (Vertex v : graph.getAdjVertices(vertex)) {
+ if (!visited.contains(v.label)) {
+ visited.add(v.label);
+ queue.add(v.label);
+ }
+ }
+ }
+ return visited;
+ }
+}
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/printf/PrintfExamples.java b/core-java/src/main/java/com/baeldung/printf/PrintfExamples.java
new file mode 100644
index 0000000000..3d451f6f50
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/printf/PrintfExamples.java
@@ -0,0 +1,61 @@
+package com.baeldung.printf;
+
+import java.util.Date;
+import java.util.Locale;
+
+public class PrintfExamples {
+
+ public static void main(String[] args) {
+
+ printfNewLine();
+ printfChar();
+ printfString();
+ printfNumber();
+ printfDateTime();
+ printfBoolean();
+ }
+
+ private static void printfNewLine() {
+ System.out.printf("baeldung%nline%nterminator");
+ }
+
+ private static void printfString() {
+ System.out.printf("'%s' %n", "baeldung");
+ System.out.printf("'%S' %n", "baeldung");
+ System.out.printf("'%15s' %n", "baeldung");
+ System.out.printf("'%-10s' %n", "baeldung");
+ }
+
+ private static void printfChar() {
+ System.out.printf("%c%n", 's');
+ System.out.printf("%C%n", 's');
+ }
+
+ private static void printfNumber() {
+ System.out.printf("simple integer: %d%n", 10000L);
+
+ System.out.printf(Locale.US, "%,d %n", 10000);
+ System.out.printf(Locale.ITALY, "%,d %n", 10000);
+
+ System.out.printf("%f%n", 5.1473);
+ System.out.printf("'%5.2f'%n", 5.1473);
+ System.out.printf("'%5.2e'%n", 5.1473);
+ }
+
+ private static void printfBoolean() {
+ System.out.printf("%b%n", null);
+ System.out.printf("%B%n", false);
+ System.out.printf("%B%n", 5.3);
+ System.out.printf("%b%n", "random text");
+ }
+
+ private static void printfDateTime() {
+ Date date = new Date();
+ System.out.printf("%tT%n", date);
+ System.out.printf("hours %tH: minutes %tM: seconds %tS%n", date, date, date);
+ System.out.printf("%1$tH:%1$tM:%1$tS %1$tp %1$tL %1$tN %1$tz %n", date);
+
+ System.out.printf("%1$tA %1$tB %1$tY %n", date);
+ System.out.printf("%1$td.%1$tm.%1$ty %n", date);
+ }
+}
diff --git a/core-java/src/test/java/com/baeldung/graph/GraphTraversalUnitTest.java b/core-java/src/test/java/com/baeldung/graph/GraphTraversalUnitTest.java
new file mode 100644
index 0000000000..d955d56d95
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/graph/GraphTraversalUnitTest.java
@@ -0,0 +1,36 @@
+package com.baeldung.graph;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class GraphTraversalUnitTest {
+ @Test
+ public void givenAGraph_whenTraversingDepthFirst_thenExpectedResult() {
+ Graph graph = createGraph();
+ Assert.assertEquals("[Bob, Rob, Maria, Alice, Mark]",
+ GraphTraversal.depthFirstTraversal(graph, "Bob").toString());
+ }
+
+ @Test
+ public void givenAGraph_whenTraversingBreadthFirst_thenExpectedResult() {
+ Graph graph = createGraph();
+ Assert.assertEquals("[Bob, Alice, Rob, Mark, Maria]",
+ GraphTraversal.breadthFirstTraversal(graph, "Bob").toString());
+ }
+
+ Graph createGraph() {
+ Graph graph = new Graph();
+ graph.addVertex("Bob");
+ graph.addVertex("Alice");
+ graph.addVertex("Mark");
+ graph.addVertex("Rob");
+ graph.addVertex("Maria");
+ graph.addEdge("Bob", "Alice");
+ graph.addEdge("Bob", "Rob");
+ graph.addEdge("Alice", "Mark");
+ graph.addEdge("Rob", "Mark");
+ graph.addEdge("Alice", "Maria");
+ graph.addEdge("Rob", "Maria");
+ return graph;
+ }
+}
\ No newline at end of file
diff --git a/core-java/src/test/java/com/baeldung/regexp/optmization/OptimizedMatcherUnitTest.java b/core-java/src/test/java/com/baeldung/regexp/optmization/OptimizedMatcherManualTest.java
similarity index 98%
rename from core-java/src/test/java/com/baeldung/regexp/optmization/OptimizedMatcherUnitTest.java
rename to core-java/src/test/java/com/baeldung/regexp/optmization/OptimizedMatcherManualTest.java
index 2be6b6ad4b..f44968a5a7 100644
--- a/core-java/src/test/java/com/baeldung/regexp/optmization/OptimizedMatcherUnitTest.java
+++ b/core-java/src/test/java/com/baeldung/regexp/optmization/OptimizedMatcherManualTest.java
@@ -11,7 +11,7 @@ import java.util.regex.Pattern;
import static org.junit.Assert.assertTrue;
-public class OptimizedMatcherUnitTest {
+public class OptimizedMatcherManualTest {
private String action;
diff --git a/core-kotlin/pom.xml b/core-kotlin/pom.xml
index 2b559b19e0..ed79ebc01b 100644
--- a/core-kotlin/pom.xml
+++ b/core-kotlin/pom.xml
@@ -3,6 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
core-kotlin
+ core-kotlin
jar
diff --git a/core-kotlin/src/main/kotlin/com/baeldung/operators/Money.kt b/core-kotlin/src/main/kotlin/com/baeldung/operators/Money.kt
new file mode 100644
index 0000000000..93eb78c5b6
--- /dev/null
+++ b/core-kotlin/src/main/kotlin/com/baeldung/operators/Money.kt
@@ -0,0 +1,31 @@
+package com.baeldung.operators
+
+import java.math.BigDecimal
+
+enum class Currency {
+ DOLLARS, EURO
+}
+
+class Money(val amount: BigDecimal, val currency: Currency) : Comparable {
+
+ override fun compareTo(other: Money): Int =
+ convert(Currency.DOLLARS).compareTo(other.convert(Currency.DOLLARS))
+
+ fun convert(currency: Currency): BigDecimal = TODO()
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (other !is Money) return false
+
+ if (amount != other.amount) return false
+ if (currency != other.currency) return false
+
+ return true
+ }
+
+ override fun hashCode(): Int {
+ var result = amount.hashCode()
+ result = 31 * result + currency.hashCode()
+ return result
+ }
+}
\ No newline at end of file
diff --git a/core-kotlin/src/main/kotlin/com/baeldung/operators/Page.kt b/core-kotlin/src/main/kotlin/com/baeldung/operators/Page.kt
new file mode 100644
index 0000000000..1077eb94f9
--- /dev/null
+++ b/core-kotlin/src/main/kotlin/com/baeldung/operators/Page.kt
@@ -0,0 +1,16 @@
+package com.baeldung.operators
+
+interface Page {
+ fun pageNumber(): Int
+ fun pageSize(): Int
+ fun elements(): MutableList
+}
+
+operator fun Page.get(index: Int): T = elements()[index]
+operator fun Page.get(start: Int, endExclusive: Int): List = elements().subList(start, endExclusive)
+operator fun Page.set(index: Int, value: T) {
+ elements()[index] = value
+}
+
+operator fun Page.contains(element: T): Boolean = element in elements()
+operator fun Page.iterator() = elements().iterator()
\ No newline at end of file
diff --git a/core-kotlin/src/main/kotlin/com/baeldung/operators/Point.kt b/core-kotlin/src/main/kotlin/com/baeldung/operators/Point.kt
new file mode 100644
index 0000000000..e3282e64cc
--- /dev/null
+++ b/core-kotlin/src/main/kotlin/com/baeldung/operators/Point.kt
@@ -0,0 +1,31 @@
+package com.baeldung.operators
+
+data class Point(val x: Int, val y: Int)
+
+operator fun Point.unaryMinus() = Point(-x, -y)
+operator fun Point.not() = Point(y, x)
+operator fun Point.inc() = Point(x + 1, y + 1)
+operator fun Point.dec() = Point(x - 1, y - 1)
+
+operator fun Point.plus(other: Point): Point = Point(x + other.x, y + other.y)
+operator fun Point.minus(other: Point): Point = Point(x - other.x, y - other.y)
+operator fun Point.times(other: Point): Point = Point(x * other.x, y * other.y)
+operator fun Point.div(other: Point): Point = Point(x / other.x, y / other.y)
+operator fun Point.rem(other: Point): Point = Point(x % other.x, y % other.y)
+operator fun Point.times(factor: Int): Point = Point(x * factor, y * factor)
+operator fun Int.times(point: Point): Point = Point(point.x * this, point.y * this)
+
+class Shape {
+ val points = mutableListOf()
+
+ operator fun Point.unaryPlus() {
+ points.add(this)
+ }
+}
+
+fun shape(init: Shape.() -> Unit): Shape {
+ val shape = Shape()
+ shape.init()
+
+ return shape
+}
\ No newline at end of file
diff --git a/core-kotlin/src/main/kotlin/com/baeldung/operators/Utils.kt b/core-kotlin/src/main/kotlin/com/baeldung/operators/Utils.kt
new file mode 100644
index 0000000000..0f16544f38
--- /dev/null
+++ b/core-kotlin/src/main/kotlin/com/baeldung/operators/Utils.kt
@@ -0,0 +1,8 @@
+package com.baeldung.operators
+
+import java.math.BigInteger
+
+operator fun MutableCollection.plusAssign(element: T) {
+ add(element)
+}
+operator fun BigInteger.plus(other: Int): BigInteger = add(BigInteger("$other"))
\ No newline at end of file
diff --git a/core-kotlin/src/test/kotlin/com/baeldung/operators/PageTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/operators/PageTest.kt
new file mode 100644
index 0000000000..4217fc0c08
--- /dev/null
+++ b/core-kotlin/src/test/kotlin/com/baeldung/operators/PageTest.kt
@@ -0,0 +1,28 @@
+package com.baeldung.operators
+
+import org.junit.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertTrue
+
+class PageTest {
+
+ private val page = PageImpl(1, 10, "Java", "Kotlin", "Scala")
+
+ @Test
+ fun `Get convention should work as expected`() {
+ assertEquals(page[1], "Kotlin")
+ assertEquals(page[1, 3], listOf("Kotlin", "Scala"))
+ }
+
+ @Test
+ fun `In convention should work on a page as expected`() {
+ assertTrue("Kotlin" in page)
+ }
+
+}
+
+private class PageImpl(val page: Int, val size: Int, vararg val elements: T) : Page {
+ override fun pageNumber(): Int = page
+ override fun pageSize(): Int = size
+ override fun elements(): MutableList = mutableListOf(*elements)
+}
\ No newline at end of file
diff --git a/core-kotlin/src/test/kotlin/com/baeldung/operators/PointTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/operators/PointTest.kt
new file mode 100644
index 0000000000..168ab6431d
--- /dev/null
+++ b/core-kotlin/src/test/kotlin/com/baeldung/operators/PointTest.kt
@@ -0,0 +1,48 @@
+package com.baeldung.operators
+
+import org.junit.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertTrue
+
+class PointTest {
+
+ private val p1 = Point(1, 2)
+ private val p2 = Point(2, 3)
+
+ @Test
+ fun `We should be able to add two points together using +`() {
+ assertEquals(p1 + p2, Point(3, 5))
+ }
+
+ @Test
+ fun `We shoud be able to subtract one point from another using -`() {
+ assertEquals(p1 - p2, Point(-1, -1))
+ }
+
+ @Test
+ fun `We should be able to multiply two points together with *`() {
+ assertEquals(p1 * p2, Point(2, 6))
+ }
+
+ @Test
+ fun `We should be able to divide one point by another`() {
+ assertEquals(p1 / p2, Point(0, 0))
+ }
+
+ @Test
+ fun `We should be able to scale a point by an integral factor`() {
+ assertEquals(p1 * 2, Point(2, 4))
+ assertEquals(2 * p1, Point(2, 4))
+ }
+
+ @Test
+ fun `We should be able to add points to an empty shape`() {
+ val line = shape {
+ +Point(0, 0)
+ +Point(1, 3)
+ }
+
+ assertTrue(Point(0, 0) in line.points)
+ assertTrue(Point(1, 3) in line.points)
+ }
+}
\ No newline at end of file
diff --git a/core-kotlin/src/test/kotlin/com/baeldung/operators/UtilsTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/operators/UtilsTest.kt
new file mode 100644
index 0000000000..4abe962cb5
--- /dev/null
+++ b/core-kotlin/src/test/kotlin/com/baeldung/operators/UtilsTest.kt
@@ -0,0 +1,13 @@
+package com.baeldung.operators
+
+import java.math.BigInteger
+import org.junit.Test
+import kotlin.test.assertEquals
+
+class UtilsTest {
+
+ @Test
+ fun `We should be able to add an int value to an existing BigInteger using +`() {
+ assertEquals(BigInteger.ZERO + 1, BigInteger.ONE)
+ }
+}
\ No newline at end of file
diff --git a/core-scala/pom.xml b/core-scala/pom.xml
index eb7c1c3330..343f21484a 100644
--- a/core-scala/pom.xml
+++ b/core-scala/pom.xml
@@ -4,6 +4,7 @@
4.0.0
core-scala
1.0-SNAPSHOT
+ core-scala
jar
diff --git a/data-structures/pom.xml b/data-structures/pom.xml
index c1a1f1d371..4958598234 100644
--- a/data-structures/pom.xml
+++ b/data-structures/pom.xml
@@ -1,9 +1,9 @@
4.0.0
- com.baeldung
data-structures
0.0.1-SNAPSHOT
+ data-structures
com.baeldung
diff --git a/drools/pom.xml b/drools/pom.xml
index 009ac8acec..b5cfc7d6dc 100644
--- a/drools/pom.xml
+++ b/drools/pom.xml
@@ -3,7 +3,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
drools
-
+ drools
+
com.baeldung
parent-spring-4
diff --git a/dubbo/pom.xml b/dubbo/pom.xml
index 6f81ec5cff..9fe228bf89 100644
--- a/dubbo/pom.xml
+++ b/dubbo/pom.xml
@@ -2,6 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
dubbo
+ dubbo
parent-modules
diff --git a/flyway-cdi-extension/pom.xml b/flyway-cdi-extension/pom.xml
index c6ee26f783..dbb32f1e5a 100644
--- a/flyway-cdi-extension/pom.xml
+++ b/flyway-cdi-extension/pom.xml
@@ -3,10 +3,10 @@
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">
4.0.0
-
com.baeldung
flyway-cdi-extension
1.0-SNAPSHOT
+ flyway-cdi-extension
1.8
diff --git a/guava-modules/guava-18/pom.xml b/guava-modules/guava-18/pom.xml
index ce9395fbf4..d55aa9ce82 100644
--- a/guava-modules/guava-18/pom.xml
+++ b/guava-modules/guava-18/pom.xml
@@ -2,10 +2,10 @@
4.0.0
- com.baeldung
guava-18
0.1.0-SNAPSHOT
-
+ guava-18
+
com.baeldung
parent-java
diff --git a/guava-modules/guava-19/pom.xml b/guava-modules/guava-19/pom.xml
index 5dfb4d2cec..0548bb0c1f 100644
--- a/guava-modules/guava-19/pom.xml
+++ b/guava-modules/guava-19/pom.xml
@@ -2,10 +2,10 @@
4.0.0
- com.baeldung
guava-19
0.1.0-SNAPSHOT
-
+ guava-19
+
com.baeldung
parent-java
diff --git a/guava-modules/guava-21/pom.xml b/guava-modules/guava-21/pom.xml
index 945b7c27c1..bdb1058a48 100644
--- a/guava-modules/guava-21/pom.xml
+++ b/guava-modules/guava-21/pom.xml
@@ -4,7 +4,8 @@
4.0.0
guava-21
1.0-SNAPSHOT
-
+ guava-21
+
com.baeldung
parent-java
diff --git a/guest/core-java-9/pom.xml b/guest/core-java-9/pom.xml
index e9271b42ff..3847c19d16 100644
--- a/guest/core-java-9/pom.xml
+++ b/guest/core-java-9/pom.xml
@@ -4,7 +4,8 @@
com.stackify
core-java-9
0.0.1-SNAPSHOT
-
+ core-java-9
+
com.baeldung
parent-modules
diff --git a/guest/core-java/pom.xml b/guest/core-java/pom.xml
index 787dd764a1..5057f7eaed 100644
--- a/guest/core-java/pom.xml
+++ b/guest/core-java/pom.xml
@@ -4,6 +4,7 @@
com.stackify
core-java
0.0.1-SNAPSHOT
+ core-java
com.baeldung
diff --git a/guest/core-kotlin/pom.xml b/guest/core-kotlin/pom.xml
index 6b189143a4..a57dd28ffd 100644
--- a/guest/core-kotlin/pom.xml
+++ b/guest/core-kotlin/pom.xml
@@ -6,7 +6,8 @@
1.0-SNAPSHOT
com.stackify
jar
-
+ core-kotlin
+
jcenter
diff --git a/guest/deep-jsf/pom.xml b/guest/deep-jsf/pom.xml
index e09b5e0606..12426a8833 100644
--- a/guest/deep-jsf/pom.xml
+++ b/guest/deep-jsf/pom.xml
@@ -4,6 +4,7 @@
com.stackify
deep-jsf
0.0.1-SNAPSHOT
+ deep-jsf
war
diff --git a/guest/junit5-example/pom.xml b/guest/junit5-example/pom.xml
index 457fb1fcaa..7c0cc3e776 100644
--- a/guest/junit5-example/pom.xml
+++ b/guest/junit5-example/pom.xml
@@ -4,7 +4,8 @@
junit5-example
junit5-example
0.0.1-SNAPSHOT
-
+ junit5-example
+
com.baeldung
parent-modules
diff --git a/guest/log4j2-example/pom.xml b/guest/log4j2-example/pom.xml
index f64869879f..ab55e0b60e 100644
--- a/guest/log4j2-example/pom.xml
+++ b/guest/log4j2-example/pom.xml
@@ -4,7 +4,8 @@
log4j2-example
log4j2-example
0.0.1-SNAPSHOT
-
+ log4j2-example
+
com.baeldung
parent-modules
diff --git a/guest/logback-example/pom.xml b/guest/logback-example/pom.xml
index 04de6a00a2..6e9fe0ddea 100644
--- a/guest/logback-example/pom.xml
+++ b/guest/logback-example/pom.xml
@@ -4,6 +4,7 @@
com.stackify
logback-example
0.0.1-SNAPSHOT
+ logback-example
com.baeldung
diff --git a/guest/memory-leaks/pom.xml b/guest/memory-leaks/pom.xml
index 956ae9c408..f1d411acbc 100644
--- a/guest/memory-leaks/pom.xml
+++ b/guest/memory-leaks/pom.xml
@@ -1,10 +1,10 @@
4.0.0
- com.baeldung
memory-leaks
0.0.1-SNAPSHOT
-
+ memory-leaks
+
com.baeldung
parent-modules
diff --git a/guest/remote-debugging/pom.xml b/guest/remote-debugging/pom.xml
index 974421de97..07b9cc49d8 100644
--- a/guest/remote-debugging/pom.xml
+++ b/guest/remote-debugging/pom.xml
@@ -5,8 +5,8 @@
com.stackify
remote-debugging
0.0.1-SNAPSHOT
+ remote-debugging
war
- remote-debugging
org.springframework.boot
diff --git a/guest/slf4j/guide/pom.xml b/guest/slf4j/guide/pom.xml
index 0db9b46247..657ede73b6 100644
--- a/guest/slf4j/guide/pom.xml
+++ b/guest/slf4j/guide/pom.xml
@@ -2,13 +2,12 @@
4.0.0
-
com.stackify.slf4j.guide
slf4j-parent-module
1.0.0-SNAPSHOT
+ slf4j-parent-module
pom
-
org.springframework.boot
spring-boot-starter-parent
diff --git a/guest/slf4j/guide/slf4j-log4j/pom.xml b/guest/slf4j/guide/slf4j-log4j/pom.xml
index 0d08fa6191..bca5392f4d 100644
--- a/guest/slf4j/guide/slf4j-log4j/pom.xml
+++ b/guest/slf4j/guide/slf4j-log4j/pom.xml
@@ -2,9 +2,9 @@
4.0.0
-
slf4j-log4j
0.0.1-SNAPSHOT
+ slf4j-log4j
jar
diff --git a/guest/slf4j/guide/slf4j-log4j2/pom.xml b/guest/slf4j/guide/slf4j-log4j2/pom.xml
index 643649335f..9473362cb8 100644
--- a/guest/slf4j/guide/slf4j-log4j2/pom.xml
+++ b/guest/slf4j/guide/slf4j-log4j2/pom.xml
@@ -2,9 +2,9 @@
4.0.0
-
slf4j-log4j2
0.0.1-SNAPSHOT
+ slf4j-log4j2
jar
diff --git a/guest/slf4j/guide/slf4j-logback/pom.xml b/guest/slf4j/guide/slf4j-logback/pom.xml
index e8aebf0ef6..0327e79732 100644
--- a/guest/slf4j/guide/slf4j-logback/pom.xml
+++ b/guest/slf4j/guide/slf4j-logback/pom.xml
@@ -2,9 +2,9 @@
4.0.0
-
slf4j-logback
0.0.1-SNAPSHOT
+ slf4j-logback
jar
diff --git a/guest/spring-boot-app/pom.xml b/guest/spring-boot-app/pom.xml
index 7daa8f668e..423dadbb99 100644
--- a/guest/spring-boot-app/pom.xml
+++ b/guest/spring-boot-app/pom.xml
@@ -4,6 +4,7 @@
spring-boot-app
spring-boot-app
0.0.1-SNAPSHOT
+ spring-boot-app
war
diff --git a/guest/spring-mvc/pom.xml b/guest/spring-mvc/pom.xml
index c0ef451605..3bffb1530d 100644
--- a/guest/spring-mvc/pom.xml
+++ b/guest/spring-mvc/pom.xml
@@ -5,8 +5,8 @@
com.stackify.guest
spring-mvc
0.0.1-SNAPSHOT
- jar
spring-mvc
+ jar
Spring MVC sample project
diff --git a/guest/thread-pools/pom.xml b/guest/thread-pools/pom.xml
index db9a5ac89f..2591cb2746 100644
--- a/guest/thread-pools/pom.xml
+++ b/guest/thread-pools/pom.xml
@@ -4,7 +4,8 @@
com.stackify
thread-pools
0.0.1-SNAPSHOT
-
+ thread-pools
+
com.baeldung
parent-modules
diff --git a/guest/tomcat-app/pom.xml b/guest/tomcat-app/pom.xml
index 7fd27e869b..9ce77c758a 100644
--- a/guest/tomcat-app/pom.xml
+++ b/guest/tomcat-app/pom.xml
@@ -4,6 +4,7 @@
com.stackify
tomcat-app
0.0.1-SNAPSHOT
+ tomcat-app
war
diff --git a/guest/webservices/rest-client/pom.xml b/guest/webservices/rest-client/pom.xml
index 5e52b7161c..8508186e86 100644
--- a/guest/webservices/rest-client/pom.xml
+++ b/guest/webservices/rest-client/pom.xml
@@ -3,6 +3,7 @@
com.stackify
rest-client
0.0.1-SNAPSHOT
+ rest-client
war
diff --git a/guest/webservices/rest-server/pom.xml b/guest/webservices/rest-server/pom.xml
index 4b3d241293..c576924215 100644
--- a/guest/webservices/rest-server/pom.xml
+++ b/guest/webservices/rest-server/pom.xml
@@ -4,6 +4,7 @@
com.stackify
rest-server
0.0.1-SNAPSHOT
+ rest-server
war
diff --git a/guest/webservices/spring-rest-service/pom.xml b/guest/webservices/spring-rest-service/pom.xml
index 49d35766e8..fcec8a3e12 100644
--- a/guest/webservices/spring-rest-service/pom.xml
+++ b/guest/webservices/spring-rest-service/pom.xml
@@ -4,6 +4,7 @@
com.stackify
spring-rest-service
0.0.1-SNAPSHOT
+ spring-rest-service
war
diff --git a/helidon/helidon-mp/pom.xml b/helidon/helidon-mp/pom.xml
index 1ec1131a67..1f39431886 100644
--- a/helidon/helidon-mp/pom.xml
+++ b/helidon/helidon-mp/pom.xml
@@ -2,9 +2,9 @@
4.0.0
-
helidon-mp
-
+ helidon-mp
+
com.baeldung.helidon
helidon
diff --git a/helidon/helidon-se/pom.xml b/helidon/helidon-se/pom.xml
index 5e14ecb81c..8982bf048e 100644
--- a/helidon/helidon-se/pom.xml
+++ b/helidon/helidon-se/pom.xml
@@ -3,9 +3,9 @@
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">
4.0.0
-
helidon-se
-
+ helidon-se
+
com.baeldung.helidon
helidon
diff --git a/helidon/pom.xml b/helidon/pom.xml
index ea8cc52ee0..85bab4db42 100644
--- a/helidon/pom.xml
+++ b/helidon/pom.xml
@@ -2,10 +2,9 @@
4.0.0
-
com.baeldung.helidon
helidon
- 1.0.0-SNAPSHOT
+ helidon
pom
diff --git a/image-processing/pom.xml b/image-processing/pom.xml
index fe8001ae3a..ce75145dc7 100644
--- a/image-processing/pom.xml
+++ b/image-processing/pom.xml
@@ -2,10 +2,10 @@
4.0.0
- com.baeldung
image-processing
1.0-SNAPSHOT
-
+ image-processing
+
com.baeldung
parent-modules
diff --git a/immutables/pom.xml b/immutables/pom.xml
index 17510690b0..efb21e584a 100644
--- a/immutables/pom.xml
+++ b/immutables/pom.xml
@@ -3,8 +3,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
immutables
- 1.0.0-SNAPSHOT
-
+ immutables
+
com.baeldung
parent-modules
diff --git a/java-collections-conversions/README.md b/java-collections-conversions/README.md
index 761a78d7b0..0f89e07d63 100644
--- a/java-collections-conversions/README.md
+++ b/java-collections-conversions/README.md
@@ -8,4 +8,5 @@
- [Converting between a List and a Set in Java](http://www.baeldung.com/convert-list-to-set-and-set-to-list)
- [Convert a Map to an Array, List or Set in Java](http://www.baeldung.com/convert-map-values-to-array-list-set)
- [Converting a List to String in Java](http://www.baeldung.com/java-list-to-string)
-- [How to Convert List to Map in Java](http://www.baeldung.com/java-list-to-map)
\ No newline at end of file
+- [How to Convert List to Map in Java](http://www.baeldung.com/java-list-to-map)
+- [Array to String Conversions](https://www.baeldung.com/java-array-to-string)
diff --git a/java-collections-maps/src/test/java/com/baeldung/java/map/ImmutableMapUnitTest.java b/java-collections-maps/src/test/java/com/baeldung/java/map/ImmutableMapUnitTest.java
new file mode 100644
index 0000000000..b239ae07d8
--- /dev/null
+++ b/java-collections-maps/src/test/java/com/baeldung/java/map/ImmutableMapUnitTest.java
@@ -0,0 +1,87 @@
+package com.baeldung.java.map;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.jupiter.api.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+
+public class ImmutableMapUnitTest {
+
+ @Test
+ public void whenCollectionsUnModifiableMapMethod_thenOriginalCollectionChangesReflectInUnmodifiableMap() {
+
+ Map mutableMap = new HashMap<>();
+ mutableMap.put("USA", "North America");
+
+ Map unmodifiableMap = Collections.unmodifiableMap(mutableMap);
+ assertThrows(UnsupportedOperationException.class, () -> unmodifiableMap.put("Canada", "North America"));
+
+ mutableMap.remove("USA");
+ assertFalse(unmodifiableMap.containsKey("USA"));
+
+ mutableMap.put("Mexico", "North America");
+ assertTrue(unmodifiableMap.containsKey("Mexico"));
+ }
+
+ @Test
+ @SuppressWarnings("deprecation")
+ public void whenGuavaImmutableMapFromCopyOfMethod_thenOriginalCollectionChangesDoNotReflectInImmutableMap() {
+
+ Map mutableMap = new HashMap<>();
+ mutableMap.put("USA", "North America");
+
+ ImmutableMap immutableMap = ImmutableMap.copyOf(mutableMap);
+ assertTrue(immutableMap.containsKey("USA"));
+
+ assertThrows(UnsupportedOperationException.class, () -> immutableMap.put("Canada", "North America"));
+
+ mutableMap.remove("USA");
+ assertTrue(immutableMap.containsKey("USA"));
+
+ mutableMap.put("Mexico", "North America");
+ assertFalse(immutableMap.containsKey("Mexico"));
+ }
+
+ @Test
+ @SuppressWarnings("deprecation")
+ public void whenGuavaImmutableMapFromBuilderMethod_thenOriginalCollectionChangesDoNotReflectInImmutableMap() {
+
+ Map mutableMap = new HashMap<>();
+ mutableMap.put("USA", "North America");
+
+ ImmutableMap immutableMap = ImmutableMap.builder()
+ .putAll(mutableMap)
+ .put("Costa Rica", "North America")
+ .build();
+ assertTrue(immutableMap.containsKey("USA"));
+ assertTrue(immutableMap.containsKey("Costa Rica"));
+
+ assertThrows(UnsupportedOperationException.class, () -> immutableMap.put("Canada", "North America"));
+
+ mutableMap.remove("USA");
+ assertTrue(immutableMap.containsKey("USA"));
+
+ mutableMap.put("Mexico", "North America");
+ assertFalse(immutableMap.containsKey("Mexico"));
+ }
+
+ @Test
+ @SuppressWarnings("deprecation")
+ public void whenGuavaImmutableMapFromOfMethod_thenOriginalCollectionChangesDoNotReflectInImmutableMap() {
+
+ ImmutableMap immutableMap = ImmutableMap.of("USA", "North America", "Costa Rica", "North America");
+ assertTrue(immutableMap.containsKey("USA"));
+ assertTrue(immutableMap.containsKey("Costa Rica"));
+
+ assertThrows(UnsupportedOperationException.class, () -> immutableMap.put("Canada", "North America"));
+ }
+
+}
diff --git a/java-ee-8-security-api/app-auth-basic-store-db/pom.xml b/java-ee-8-security-api/app-auth-basic-store-db/pom.xml
index 6ecc9f7e80..cf92fe2ecd 100644
--- a/java-ee-8-security-api/app-auth-basic-store-db/pom.xml
+++ b/java-ee-8-security-api/app-auth-basic-store-db/pom.xml
@@ -2,8 +2,8 @@
4.0.0
-
app-auth-basic-store-db
+ app-auth-basic-store-db
war
diff --git a/java-ee-8-security-api/app-auth-custom-form-store-custom/pom.xml b/java-ee-8-security-api/app-auth-custom-form-store-custom/pom.xml
index bf5315e993..43809f1cd5 100644
--- a/java-ee-8-security-api/app-auth-custom-form-store-custom/pom.xml
+++ b/java-ee-8-security-api/app-auth-custom-form-store-custom/pom.xml
@@ -2,8 +2,8 @@
4.0.0
-
app-auth-custom-form-store-custom
+ app-auth-custom-form-store-custom
war
diff --git a/java-ee-8-security-api/app-auth-custom-no-store/pom.xml b/java-ee-8-security-api/app-auth-custom-no-store/pom.xml
index c05c0f19be..f9d63f8623 100644
--- a/java-ee-8-security-api/app-auth-custom-no-store/pom.xml
+++ b/java-ee-8-security-api/app-auth-custom-no-store/pom.xml
@@ -2,8 +2,8 @@
4.0.0
-
app-auth-custom-no-store
+ app-auth-custom-no-store
war
diff --git a/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml b/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml
index 570b36add5..6a7b97b2d7 100644
--- a/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml
+++ b/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml
@@ -3,8 +3,8 @@
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">
4.0.0
-
app-auth-form-store-ldap
+ app-auth-form-store-ldap
war
diff --git a/java-ee-8-security-api/pom.xml b/java-ee-8-security-api/pom.xml
index 7546839492..ad33c74ad3 100644
--- a/java-ee-8-security-api/pom.xml
+++ b/java-ee-8-security-api/pom.xml
@@ -5,6 +5,7 @@
4.0.0
java-ee-8-security-api
1.0-SNAPSHOT
+ java-ee-8-security-api
pom
diff --git a/java-lite/pom.xml b/java-lite/pom.xml
index 5111cd2e7f..03f4e29f4e 100644
--- a/java-lite/pom.xml
+++ b/java-lite/pom.xml
@@ -5,6 +5,7 @@
org.baeldung
java-lite
1.0-SNAPSHOT
+ java-lite
war
diff --git a/java-rmi/pom.xml b/java-rmi/pom.xml
index 33931baedf..ad413b66ab 100644
--- a/java-rmi/pom.xml
+++ b/java-rmi/pom.xml
@@ -4,6 +4,7 @@
com.baeldung.rmi
java-rmi
1.0-SNAPSHOT
+ java-rmi
jar
diff --git a/java-spi/exchange-rate-api/pom.xml b/java-spi/exchange-rate-api/pom.xml
index b626916b56..fd3a7ae0a7 100644
--- a/java-spi/exchange-rate-api/pom.xml
+++ b/java-spi/exchange-rate-api/pom.xml
@@ -2,6 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
exchange-rate-api
+ exchange-rate-api
jar
diff --git a/java-spi/exchange-rate-app/pom.xml b/java-spi/exchange-rate-app/pom.xml
index a42a30ceda..7a076d560c 100644
--- a/java-spi/exchange-rate-app/pom.xml
+++ b/java-spi/exchange-rate-app/pom.xml
@@ -2,6 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
exchange-rate-app
+ exchange-rate-app
jar
diff --git a/java-spi/exchange-rate-impl/pom.xml b/java-spi/exchange-rate-impl/pom.xml
index 41c874c659..8a77b51793 100644
--- a/java-spi/exchange-rate-impl/pom.xml
+++ b/java-spi/exchange-rate-impl/pom.xml
@@ -2,6 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
exchange-rate-impl
+ exchange-rate-impl
jar
diff --git a/java-spi/pom.xml b/java-spi/pom.xml
index 9ac87bf960..97a22024bd 100644
--- a/java-spi/pom.xml
+++ b/java-spi/pom.xml
@@ -2,6 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
java-spi
+ java-spi
pom
diff --git a/java-strings/README.md b/java-strings/README.md
index 222b28e8ad..11893e68a2 100644
--- a/java-strings/README.md
+++ b/java-strings/README.md
@@ -38,3 +38,4 @@
- [Java Base64 Encoding and Decoding](https://www.baeldung.com/java-base64-encode-and-decode)
- [Generate a Secure Random Password in Java](https://www.baeldung.com/java-generate-secure-password)
- [Removing Repeated Characters from a String](https://www.baeldung.com/java-remove-repeated-char)
+- [Join Array of Primitives with Separator in Java](https://www.baeldung.com/java-join-primitive-array)
diff --git a/java-strings/pom.xml b/java-strings/pom.xml
index ab94c28d4d..f4fb1c0865 100755
--- a/java-strings/pom.xml
+++ b/java-strings/pom.xml
@@ -122,13 +122,13 @@
- 3.5
+ 3.8.1
1.10
3.6.1
1.19
61.1
- 26.0-jre
+ 27.0.1-jre
diff --git a/java-strings/src/main/java/com/baeldung/string/removeleadingtrailingchar/RemoveLeadingAndTrailingZeroes.java b/java-strings/src/main/java/com/baeldung/string/removeleadingtrailingchar/RemoveLeadingAndTrailingZeroes.java
new file mode 100644
index 0000000000..c9d748e897
--- /dev/null
+++ b/java-strings/src/main/java/com/baeldung/string/removeleadingtrailingchar/RemoveLeadingAndTrailingZeroes.java
@@ -0,0 +1,103 @@
+package com.baeldung.string.removeleadingtrailingchar;
+
+
+import org.apache.commons.lang3.StringUtils;
+
+import com.google.common.base.CharMatcher;
+
+public class RemoveLeadingAndTrailingZeroes {
+
+ public static String removeLeadingZeroesWithStringBuilder(String s) {
+ StringBuilder sb = new StringBuilder(s);
+
+ while (sb.length() > 1 && sb.charAt(0) == '0') {
+ sb.deleteCharAt(0);
+ }
+
+ return sb.toString();
+ }
+
+ public static String removeTrailingZeroesWithStringBuilder(String s) {
+ StringBuilder sb = new StringBuilder(s);
+
+ while (sb.length() > 1 && sb.charAt(sb.length() - 1) == '0') {
+ sb.setLength(sb.length() - 1);
+ }
+
+ return sb.toString();
+ }
+
+ public static String removeLeadingZeroesWithSubstring(String s) {
+ int index = 0;
+
+ for (; index < s.length() - 1; index++) {
+ if (s.charAt(index) != '0') {
+ break;
+ }
+ }
+
+ return s.substring(index);
+ }
+
+ public static String removeTrailingZeroesWithSubstring(String s) {
+ int index = s.length() - 1;
+
+ for (; index > 0; index--) {
+ if (s.charAt(index) != '0') {
+ break;
+ }
+ }
+
+ return s.substring(0, index + 1);
+ }
+
+ public static String removeLeadingZeroesWithApacheCommonsStripStart(String s) {
+ String stripped = StringUtils.stripStart(s, "0");
+
+ if (stripped.isEmpty() && !s.isEmpty()) {
+ return "0";
+ }
+
+ return stripped;
+ }
+
+ public static String removeTrailingZeroesWithApacheCommonsStripEnd(String s) {
+ String stripped = StringUtils.stripEnd(s, "0");
+
+ if (stripped.isEmpty() && !s.isEmpty()) {
+ return "0";
+ }
+
+ return stripped;
+ }
+
+ public static String removeLeadingZeroesWithGuavaTrimLeadingFrom(String s) {
+ String stripped = CharMatcher.is('0')
+ .trimLeadingFrom(s);
+
+ if (stripped.isEmpty() && !s.isEmpty()) {
+ return "0";
+ }
+
+ return stripped;
+ }
+
+ public static String removeTrailingZeroesWithGuavaTrimTrailingFrom(String s) {
+ String stripped = CharMatcher.is('0')
+ .trimTrailingFrom(s);
+
+ if (stripped.isEmpty() && !s.isEmpty()) {
+ return "0";
+ }
+
+ return stripped;
+ }
+
+ public static String removeLeadingZeroesWithRegex(String s) {
+ return s.replaceAll("^0+(?!$)", "");
+ }
+
+ public static String removeTrailingZeroesWithRegex(String s) {
+ return s.replaceAll("(?!^)0+$", "");
+ }
+}
diff --git a/java-strings/src/test/java/com/baeldung/string/removeleadingtrailingchar/RemoveLeadingAndTrailingZeroesUnitTest.java b/java-strings/src/test/java/com/baeldung/string/removeleadingtrailingchar/RemoveLeadingAndTrailingZeroesUnitTest.java
new file mode 100644
index 0000000000..55f932fea1
--- /dev/null
+++ b/java-strings/src/test/java/com/baeldung/string/removeleadingtrailingchar/RemoveLeadingAndTrailingZeroesUnitTest.java
@@ -0,0 +1,143 @@
+package com.baeldung.string.removeleadingtrailingchar;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.stream.Stream;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+public class RemoveLeadingAndTrailingZeroesUnitTest {
+
+ public static Stream leadingZeroTestProvider() {
+ return Stream.of(Arguments.of("", ""), Arguments.of("abc", "abc"), Arguments.of("123", "123"), Arguments.of("0abc", "abc"), Arguments.of("0123", "123"), Arguments.of("0000123", "123"), Arguments.of("1230", "1230"), Arguments.of("01230", "1230"), Arguments.of("01", "1"),
+ Arguments.of("0001", "1"), Arguments.of("0", "0"), Arguments.of("00", "0"), Arguments.of("0000", "0"), Arguments.of("12034", "12034"), Arguments.of("1200034", "1200034"), Arguments.of("0012034", "12034"), Arguments.of("1203400", "1203400"));
+ }
+
+ public static Stream trailingZeroTestProvider() {
+ return Stream.of(Arguments.of("", ""), Arguments.of("abc", "abc"), Arguments.of("123", "123"), Arguments.of("abc0", "abc"), Arguments.of("1230", "123"), Arguments.of("1230000", "123"), Arguments.of("0123", "0123"), Arguments.of("01230", "0123"), Arguments.of("10", "1"),
+ Arguments.of("1000", "1"), Arguments.of("0", "0"), Arguments.of("00", "0"), Arguments.of("0000", "0"), Arguments.of("12034", "12034"), Arguments.of("1200034", "1200034"), Arguments.of("0012034", "0012034"), Arguments.of("1203400", "12034"));
+ }
+
+ @ParameterizedTest
+ @MethodSource("leadingZeroTestProvider")
+ public void givenTestStrings_whenRemoveLeadingZeroesWithStringBuilder_thenReturnWithoutLeadingZeroes(String input, String expected) {
+ // given
+
+ // when
+ String result = RemoveLeadingAndTrailingZeroes.removeLeadingZeroesWithStringBuilder(input);
+
+ // then
+ assertThat(result).isEqualTo(expected);
+ }
+
+ @ParameterizedTest
+ @MethodSource("trailingZeroTestProvider")
+ public void givenTestStrings_whenRemoveTrailingZeroesWithStringBuilder_thenReturnWithoutTrailingZeroes(String input, String expected) {
+ // given
+
+ // when
+ String result = RemoveLeadingAndTrailingZeroes.removeTrailingZeroesWithStringBuilder(input);
+
+ // then
+ assertThat(result).isEqualTo(expected);
+ }
+
+ @ParameterizedTest
+ @MethodSource("leadingZeroTestProvider")
+ public void givenTestStrings_whenRemoveLeadingZeroesWithSubstring_thenReturnWithoutLeadingZeroes(String input, String expected) {
+ // given
+
+ // when
+ String result = RemoveLeadingAndTrailingZeroes.removeLeadingZeroesWithSubstring(input);
+
+ // then
+ assertThat(result).isEqualTo(expected);
+ }
+
+ @ParameterizedTest
+ @MethodSource("trailingZeroTestProvider")
+ public void givenTestStrings_whenRemoveTrailingZeroesWithSubstring_thenReturnWithoutTrailingZeroes(String input, String expected) {
+ // given
+
+ // when
+ String result = RemoveLeadingAndTrailingZeroes.removeTrailingZeroesWithSubstring(input);
+
+ // then
+ assertThat(result).isEqualTo(expected);
+ }
+
+ @ParameterizedTest
+ @MethodSource("leadingZeroTestProvider")
+ public void givenTestStrings_whenRemoveLeadingZeroesWithApacheCommonsStripStart_thenReturnWithoutLeadingZeroes(String input, String expected) {
+ // given
+
+ // when
+ String result = RemoveLeadingAndTrailingZeroes.removeLeadingZeroesWithApacheCommonsStripStart(input);
+
+ // then
+ assertThat(result).isEqualTo(expected);
+ }
+
+ @ParameterizedTest
+ @MethodSource("trailingZeroTestProvider")
+ public void givenTestStrings_whenRemoveTrailingZeroesWithApacheCommonsStripEnd_thenReturnWithoutTrailingZeroes(String input, String expected) {
+ // given
+
+ // when
+ String result = RemoveLeadingAndTrailingZeroes.removeTrailingZeroesWithApacheCommonsStripEnd(input);
+
+ // then
+ assertThat(result).isEqualTo(expected);
+ }
+
+ @ParameterizedTest
+ @MethodSource("leadingZeroTestProvider")
+ public void givenTestStrings_whenRemoveLeadingZeroesWithGuavaTrimLeadingFrom_thenReturnWithoutLeadingZeroes(String input, String expected) {
+ // given
+
+ // when
+ String result = RemoveLeadingAndTrailingZeroes.removeLeadingZeroesWithGuavaTrimLeadingFrom(input);
+
+ // then
+ assertThat(result).isEqualTo(expected);
+ }
+
+ @ParameterizedTest
+ @MethodSource("trailingZeroTestProvider")
+ public void givenTestStrings_whenRemoveTrailingZeroesWithGuavaTrimTrailingFrom_thenReturnWithoutTrailingZeroes(String input, String expected) {
+ // given
+
+ // when
+ String result = RemoveLeadingAndTrailingZeroes.removeTrailingZeroesWithGuavaTrimTrailingFrom(input);
+
+ // then
+ assertThat(result).isEqualTo(expected);
+ }
+
+ @ParameterizedTest
+ @MethodSource("leadingZeroTestProvider")
+ public void givenTestStrings_whenRemoveLeadingZeroesWithRegex_thenReturnWithoutLeadingZeroes(String input, String expected) {
+ // given
+
+ // when
+ String result = RemoveLeadingAndTrailingZeroes.removeLeadingZeroesWithRegex(input);
+
+ // then
+ assertThat(result).isEqualTo(expected);
+ }
+
+ @ParameterizedTest
+ @MethodSource("trailingZeroTestProvider")
+ public void givenTestStrings_whenRemoveTrailingZeroesWithRegex_thenReturnWithoutTrailingZeroes(String input, String expected) {
+ // given
+
+ // when
+ String result = RemoveLeadingAndTrailingZeroes.removeTrailingZeroesWithRegex(input);
+
+ // then
+ assertThat(result).isEqualTo(expected);
+ }
+
+}
diff --git a/java-vavr-stream/pom.xml b/java-vavr-stream/pom.xml
index 395d2c81ba..c92f3c8742 100644
--- a/java-vavr-stream/pom.xml
+++ b/java-vavr-stream/pom.xml
@@ -5,6 +5,7 @@
com.baeldung.samples
java-vavr-stream
1.0
+ java-vavr-stream
jar
diff --git a/java-websocket/pom.xml b/java-websocket/pom.xml
index e8ff8dfc36..7ba3ca61d0 100644
--- a/java-websocket/pom.xml
+++ b/java-websocket/pom.xml
@@ -1,10 +1,10 @@
4.0.0
- com.baeldung
java-websocket
- war
0.0.1-SNAPSHOT
+ java-websocket
+ war
com.baeldung
diff --git a/javafx/pom.xml b/javafx/pom.xml
index c9c5bc294e..44e6f7e8da 100644
--- a/javafx/pom.xml
+++ b/javafx/pom.xml
@@ -3,7 +3,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
javafx
-
+ javafx
+
parent-modules
com.baeldung
diff --git a/javax-servlets/pom.xml b/javax-servlets/pom.xml
index 7b4eecd880..f00dd0ebe8 100644
--- a/javax-servlets/pom.xml
+++ b/javax-servlets/pom.xml
@@ -5,6 +5,7 @@
com.baeldung.javax-servlets
javax-servlets
1.0-SNAPSHOT
+ javax-servlets
war
diff --git a/javaxval/pom.xml b/javaxval/pom.xml
index 22f1827213..5f2690b5b4 100644
--- a/javaxval/pom.xml
+++ b/javaxval/pom.xml
@@ -1,10 +1,10 @@
4.0.0
- com.baeldung
javaxval
0.1-SNAPSHOT
-
+ javaxval
+
com.baeldung
parent-modules
diff --git a/jee-7/pom.xml b/jee-7/pom.xml
index 9011648d17..97ed2cc51d 100644
--- a/jee-7/pom.xml
+++ b/jee-7/pom.xml
@@ -5,6 +5,7 @@
4.0.0
jee-7
1.0-SNAPSHOT
+ jee-7
war
JavaEE 7 Arquillian Archetype Sample
diff --git a/jenkins/hello-world/pom.xml b/jenkins/hello-world/pom.xml
index fb2154c7ad..f00a551173 100644
--- a/jenkins/hello-world/pom.xml
+++ b/jenkins/hello-world/pom.xml
@@ -2,10 +2,10 @@
4.0.0
- jenkins-hello-world
+ hello-world
1.0-SNAPSHOT
+ hello-world
hpi
- Hello World Plugin
A sample Jenkins Hello World plugin
diff --git a/jersey/pom.xml b/jersey/pom.xml
index b55bdc5330..a3adb4cf5a 100644
--- a/jersey/pom.xml
+++ b/jersey/pom.xml
@@ -2,9 +2,9 @@
4.0.0
- com.baeldung
jersey
0.0.1-SNAPSHOT
+ jersey
war
diff --git a/jhipster/jhipster-microservice/pom.xml b/jhipster/jhipster-microservice/pom.xml
index 4a60e47f87..051d5f70b7 100644
--- a/jhipster/jhipster-microservice/pom.xml
+++ b/jhipster/jhipster-microservice/pom.xml
@@ -3,9 +3,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
jhipster-microservice
+ jhipster-microservice
pom
- JHipster Microservice
-
+
jhipster
com.baeldung.jhipster
diff --git a/jhipster/jhipster-monolithic/pom.xml b/jhipster/jhipster-monolithic/pom.xml
index e242668759..12dead99df 100644
--- a/jhipster/jhipster-monolithic/pom.xml
+++ b/jhipster/jhipster-monolithic/pom.xml
@@ -3,6 +3,7 @@
4.0.0
jhipster-monolithic
war
+ jhipster-monolithic
JHipster Monolithic Application
diff --git a/jni/pom.xml b/jni/pom.xml
index d4cc409d33..4850e07ed7 100644
--- a/jni/pom.xml
+++ b/jni/pom.xml
@@ -2,7 +2,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
jni
-
+ jni
+
com.baeldung
parent-modules
diff --git a/jsf/pom.xml b/jsf/pom.xml
index 2ac8a9f7c2..fc6d4a0ee2 100644
--- a/jsf/pom.xml
+++ b/jsf/pom.xml
@@ -4,6 +4,7 @@
4.0.0
jsf
0.1-SNAPSHOT
+ jsf
war
diff --git a/json/pom.xml b/json/pom.xml
index b688baec06..db98ec437e 100644
--- a/json/pom.xml
+++ b/json/pom.xml
@@ -4,7 +4,8 @@
org.baeldung
json
0.0.1-SNAPSHOT
-
+ json
+
com.baeldung
parent-modules
diff --git a/jsoup/pom.xml b/jsoup/pom.xml
index 2704d7bc00..f6e25e7a23 100644
--- a/jsoup/pom.xml
+++ b/jsoup/pom.xml
@@ -3,6 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
jsoup
+ jsoup
jar
diff --git a/jta/pom.xml b/jta/pom.xml
index 89bdccf25e..4754c1872b 100644
--- a/jta/pom.xml
+++ b/jta/pom.xml
@@ -3,8 +3,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.baeldung
- jta-demo
+ jta
1.0-SNAPSHOT
+ jta
jar
JEE JTA demo
diff --git a/jws/pom.xml b/jws/pom.xml
index 1970ab9921..2c89b687f8 100644
--- a/jws/pom.xml
+++ b/jws/pom.xml
@@ -3,9 +3,9 @@
4.0.0
com.example
jws
- war
0.0.1-SNAPSHOT
- jws-example
+ jws
+ war
com.baeldung
diff --git a/kotlin-libraries/pom.xml b/kotlin-libraries/pom.xml
index 92a643e458..ae77a9aa2d 100644
--- a/kotlin-libraries/pom.xml
+++ b/kotlin-libraries/pom.xml
@@ -3,6 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
kotlin-libraries
+ kotlin-libraries
jar
diff --git a/libraries-data/src/main/kafka-connect/01_Quick_Start/connect-file-sink.properties b/libraries-data/src/main/kafka-connect/01_Quick_Start/connect-file-sink.properties
new file mode 100644
index 0000000000..594ccc6e95
--- /dev/null
+++ b/libraries-data/src/main/kafka-connect/01_Quick_Start/connect-file-sink.properties
@@ -0,0 +1,20 @@
+# 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
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+name=local-file-sink
+connector.class=FileStreamSink
+tasks.max=1
+file=test.sink.txt
+topics=connect-test
\ No newline at end of file
diff --git a/libraries-data/src/main/kafka-connect/01_Quick_Start/connect-file-source.properties b/libraries-data/src/main/kafka-connect/01_Quick_Start/connect-file-source.properties
new file mode 100644
index 0000000000..599cf4cb2a
--- /dev/null
+++ b/libraries-data/src/main/kafka-connect/01_Quick_Start/connect-file-source.properties
@@ -0,0 +1,20 @@
+# 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
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+name=local-file-source
+connector.class=FileStreamSource
+tasks.max=1
+file=test.txt
+topic=connect-test
\ No newline at end of file
diff --git a/libraries-data/src/main/kafka-connect/01_Quick_Start/connect-standalone.properties b/libraries-data/src/main/kafka-connect/01_Quick_Start/connect-standalone.properties
new file mode 100644
index 0000000000..a2369fa144
--- /dev/null
+++ b/libraries-data/src/main/kafka-connect/01_Quick_Start/connect-standalone.properties
@@ -0,0 +1,44 @@
+# 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
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# These are defaults. This file just demonstrates how to override some settings.
+bootstrap.servers=localhost:9092
+
+# The converters specify the format of data in Kafka and how to translate it into Connect data. Every Connect user will
+# need to configure these based on the format they want their data in when loaded from or stored into Kafka
+key.converter=org.apache.kafka.connect.json.JsonConverter
+value.converter=org.apache.kafka.connect.json.JsonConverter
+# Converter-specific settings can be passed in by prefixing the Converter's setting with the converter we want to apply
+# it to
+key.converter.schemas.enable=false
+value.converter.schemas.enable=false
+
+offset.storage.file.filename=/tmp/connect.offsets
+# Flush much faster than normal, which is useful for testing/debugging
+offset.flush.interval.ms=10000
+
+# Set to a list of filesystem paths separated by commas (,) to enable class loading isolation for plugins
+# (connectors, converters, transformations). The list should consist of top level directories that include
+# any combination of:
+# a) directories immediately containing jars with plugins and their dependencies
+# b) uber-jars with plugins and their dependencies
+# c) directories immediately containing the package directory structure of classes of plugins and their dependencies
+# Note: symlinks will be followed to discover dependencies or plugins.
+# Examples:
+# plugin.path=/usr/local/share/java,/usr/local/share/kafka/plugins,/opt/connectors,
+# Replace the relative path below with an absolute path if you are planning to start Kafka Connect from within a
+# directory other than the home directory of Confluent Platform.
+plugin.path=C:\Software\confluent-5.0.0\share\java
+#plugin.path=./share/java
diff --git a/libraries-data/src/main/kafka-connect/02_Distributed/connect-distributed.properties b/libraries-data/src/main/kafka-connect/02_Distributed/connect-distributed.properties
new file mode 100644
index 0000000000..5b91baddbd
--- /dev/null
+++ b/libraries-data/src/main/kafka-connect/02_Distributed/connect-distributed.properties
@@ -0,0 +1,88 @@
+##
+# 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
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+# This file contains some of the configurations for the Kafka Connect distributed worker. This file is intended
+# to be used with the examples, and some settings may differ from those used in a production system, especially
+# the `bootstrap.servers` and those specifying replication factors.
+
+# A list of host/port pairs to use for establishing the initial connection to the Kafka cluster.
+bootstrap.servers=localhost:9092
+
+# unique name for the cluster, used in forming the Connect cluster group. Note that this must not conflict with consumer group IDs
+group.id=connect-cluster
+
+# The converters specify the format of data in Kafka and how to translate it into Connect data. Every Connect user will
+# need to configure these based on the format they want their data in when loaded from or stored into Kafka
+key.converter=org.apache.kafka.connect.json.JsonConverter
+value.converter=org.apache.kafka.connect.json.JsonConverter
+# Converter-specific settings can be passed in by prefixing the Converter's setting with the converter we want to apply
+# it to
+key.converter.schemas.enable=true
+value.converter.schemas.enable=true
+
+# Topic to use for storing offsets. This topic should have many partitions and be replicated and compacted.
+# Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
+# the topic before starting Kafka Connect if a specific topic configuration is needed.
+# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
+# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
+# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
+offset.storage.topic=connect-offsets
+offset.storage.replication.factor=1
+#offset.storage.partitions=25
+
+# Topic to use for storing connector and task configurations; note that this should be a single partition, highly replicated,
+# and compacted topic. Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
+# the topic before starting Kafka Connect if a specific topic configuration is needed.
+# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
+# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
+# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
+config.storage.topic=connect-configs
+config.storage.replication.factor=1
+
+# Topic to use for storing statuses. This topic can have multiple partitions and should be replicated and compacted.
+# Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
+# the topic before starting Kafka Connect if a specific topic configuration is needed.
+# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
+# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
+# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
+status.storage.topic=connect-status
+status.storage.replication.factor=1
+#status.storage.partitions=5
+
+# Flush much faster than normal, which is useful for testing/debugging
+offset.flush.interval.ms=10000
+
+# These are provided to inform the user about the presence of the REST host and port configs
+# Hostname & Port for the REST API to listen on. If this is set, it will bind to the interface used to listen to requests.
+#rest.host.name=
+#rest.port=8083
+
+# The Hostname & Port that will be given out to other workers to connect to i.e. URLs that are routable from other servers.
+#rest.advertised.host.name=
+#rest.advertised.port=
+
+# Set to a list of filesystem paths separated by commas (,) to enable class loading isolation for plugins
+# (connectors, converters, transformations). The list should consist of top level directories that include
+# any combination of:
+# a) directories immediately containing jars with plugins and their dependencies
+# b) uber-jars with plugins and their dependencies
+# c) directories immediately containing the package directory structure of classes of plugins and their dependencies
+# Examples:
+# plugin.path=/usr/local/share/java,/usr/local/share/kafka/plugins,/opt/connectors,
+# Replace the relative path below with an absolute path if you are planning to start Kafka Connect from within a
+# directory other than the home directory of Confluent Platform.
+plugin.path=./share/java
diff --git a/libraries-data/src/main/kafka-connect/02_Distributed/connect-file-sink.json b/libraries-data/src/main/kafka-connect/02_Distributed/connect-file-sink.json
new file mode 100644
index 0000000000..8902ecce52
--- /dev/null
+++ b/libraries-data/src/main/kafka-connect/02_Distributed/connect-file-sink.json
@@ -0,0 +1,9 @@
+{
+ "name": "local-file-sink",
+ "config": {
+ "connector.class": "FileStreamSink",
+ "tasks.max": 1,
+ "file": "test-distributed.sink.txt",
+ "topics": "connect-distributed"
+ }
+}
diff --git a/libraries-data/src/main/kafka-connect/02_Distributed/connect-file-source.json b/libraries-data/src/main/kafka-connect/02_Distributed/connect-file-source.json
new file mode 100644
index 0000000000..77e949c91b
--- /dev/null
+++ b/libraries-data/src/main/kafka-connect/02_Distributed/connect-file-source.json
@@ -0,0 +1,9 @@
+{
+ "name": "local-file-source",
+ "config": {
+ "connector.class": "FileStreamSource",
+ "tasks.max": 1,
+ "file": "test-distributed.txt",
+ "topic": "connect-distributed"
+ }
+}
diff --git a/libraries-data/src/main/kafka-connect/03_Transform/connect-distributed.properties b/libraries-data/src/main/kafka-connect/03_Transform/connect-distributed.properties
new file mode 100644
index 0000000000..fa63be24b8
--- /dev/null
+++ b/libraries-data/src/main/kafka-connect/03_Transform/connect-distributed.properties
@@ -0,0 +1,88 @@
+##
+# 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
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+# This file contains some of the configurations for the Kafka Connect distributed worker. This file is intended
+# to be used with the examples, and some settings may differ from those used in a production system, especially
+# the `bootstrap.servers` and those specifying replication factors.
+
+# A list of host/port pairs to use for establishing the initial connection to the Kafka cluster.
+bootstrap.servers=localhost:9092
+
+# unique name for the cluster, used in forming the Connect cluster group. Note that this must not conflict with consumer group IDs
+group.id=connect-cluster
+
+# The converters specify the format of data in Kafka and how to translate it into Connect data. Every Connect user will
+# need to configure these based on the format they want their data in when loaded from or stored into Kafka
+key.converter=org.apache.kafka.connect.json.JsonConverter
+value.converter=org.apache.kafka.connect.json.JsonConverter
+# Converter-specific settings can be passed in by prefixing the Converter's setting with the converter we want to apply
+# it to
+key.converter.schemas.enable=false
+value.converter.schemas.enable=false
+
+# Topic to use for storing offsets. This topic should have many partitions and be replicated and compacted.
+# Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
+# the topic before starting Kafka Connect if a specific topic configuration is needed.
+# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
+# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
+# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
+offset.storage.topic=connect-offsets
+offset.storage.replication.factor=1
+#offset.storage.partitions=25
+
+# Topic to use for storing connector and task configurations; note that this should be a single partition, highly replicated,
+# and compacted topic. Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
+# the topic before starting Kafka Connect if a specific topic configuration is needed.
+# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
+# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
+# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
+config.storage.topic=connect-configs
+config.storage.replication.factor=1
+
+# Topic to use for storing statuses. This topic can have multiple partitions and should be replicated and compacted.
+# Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
+# the topic before starting Kafka Connect if a specific topic configuration is needed.
+# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
+# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
+# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
+status.storage.topic=connect-status
+status.storage.replication.factor=1
+#status.storage.partitions=5
+
+# Flush much faster than normal, which is useful for testing/debugging
+offset.flush.interval.ms=10000
+
+# These are provided to inform the user about the presence of the REST host and port configs
+# Hostname & Port for the REST API to listen on. If this is set, it will bind to the interface used to listen to requests.
+#rest.host.name=
+#rest.port=8083
+
+# The Hostname & Port that will be given out to other workers to connect to i.e. URLs that are routable from other servers.
+#rest.advertised.host.name=
+#rest.advertised.port=
+
+# Set to a list of filesystem paths separated by commas (,) to enable class loading isolation for plugins
+# (connectors, converters, transformations). The list should consist of top level directories that include
+# any combination of:
+# a) directories immediately containing jars with plugins and their dependencies
+# b) uber-jars with plugins and their dependencies
+# c) directories immediately containing the package directory structure of classes of plugins and their dependencies
+# Examples:
+# plugin.path=/usr/local/share/java,/usr/local/share/kafka/plugins,/opt/connectors,
+# Replace the relative path below with an absolute path if you are planning to start Kafka Connect from within a
+# directory other than the home directory of Confluent Platform.
+plugin.path=./share/java
diff --git a/libraries-data/src/main/kafka-connect/03_Transform/connect-file-source-transform.json b/libraries-data/src/main/kafka-connect/03_Transform/connect-file-source-transform.json
new file mode 100644
index 0000000000..e5e21a0608
--- /dev/null
+++ b/libraries-data/src/main/kafka-connect/03_Transform/connect-file-source-transform.json
@@ -0,0 +1,15 @@
+{
+ "name": "local-file-source",
+ "config": {
+ "connector.class": "FileStreamSource",
+ "tasks.max": 1,
+ "file": "transformation.txt",
+ "topic": "connect-transformation",
+ "transforms": "MakeMap,InsertSource",
+ "transforms.MakeMap.type": "org.apache.kafka.connect.transforms.HoistField$Value",
+ "transforms.MakeMap.field": "line",
+ "transforms.InsertSource.type": "org.apache.kafka.connect.transforms.InsertField$Value",
+ "transforms.InsertSource.static.field": "data_source",
+ "transforms.InsertSource.static.value": "test-file-source"
+ }
+}
diff --git a/libraries-data/src/main/kafka-connect/04_Custom/connect-distributed.properties b/libraries-data/src/main/kafka-connect/04_Custom/connect-distributed.properties
new file mode 100644
index 0000000000..5b91baddbd
--- /dev/null
+++ b/libraries-data/src/main/kafka-connect/04_Custom/connect-distributed.properties
@@ -0,0 +1,88 @@
+##
+# 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
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+# This file contains some of the configurations for the Kafka Connect distributed worker. This file is intended
+# to be used with the examples, and some settings may differ from those used in a production system, especially
+# the `bootstrap.servers` and those specifying replication factors.
+
+# A list of host/port pairs to use for establishing the initial connection to the Kafka cluster.
+bootstrap.servers=localhost:9092
+
+# unique name for the cluster, used in forming the Connect cluster group. Note that this must not conflict with consumer group IDs
+group.id=connect-cluster
+
+# The converters specify the format of data in Kafka and how to translate it into Connect data. Every Connect user will
+# need to configure these based on the format they want their data in when loaded from or stored into Kafka
+key.converter=org.apache.kafka.connect.json.JsonConverter
+value.converter=org.apache.kafka.connect.json.JsonConverter
+# Converter-specific settings can be passed in by prefixing the Converter's setting with the converter we want to apply
+# it to
+key.converter.schemas.enable=true
+value.converter.schemas.enable=true
+
+# Topic to use for storing offsets. This topic should have many partitions and be replicated and compacted.
+# Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
+# the topic before starting Kafka Connect if a specific topic configuration is needed.
+# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
+# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
+# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
+offset.storage.topic=connect-offsets
+offset.storage.replication.factor=1
+#offset.storage.partitions=25
+
+# Topic to use for storing connector and task configurations; note that this should be a single partition, highly replicated,
+# and compacted topic. Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
+# the topic before starting Kafka Connect if a specific topic configuration is needed.
+# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
+# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
+# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
+config.storage.topic=connect-configs
+config.storage.replication.factor=1
+
+# Topic to use for storing statuses. This topic can have multiple partitions and should be replicated and compacted.
+# Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
+# the topic before starting Kafka Connect if a specific topic configuration is needed.
+# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
+# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
+# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
+status.storage.topic=connect-status
+status.storage.replication.factor=1
+#status.storage.partitions=5
+
+# Flush much faster than normal, which is useful for testing/debugging
+offset.flush.interval.ms=10000
+
+# These are provided to inform the user about the presence of the REST host and port configs
+# Hostname & Port for the REST API to listen on. If this is set, it will bind to the interface used to listen to requests.
+#rest.host.name=
+#rest.port=8083
+
+# The Hostname & Port that will be given out to other workers to connect to i.e. URLs that are routable from other servers.
+#rest.advertised.host.name=
+#rest.advertised.port=
+
+# Set to a list of filesystem paths separated by commas (,) to enable class loading isolation for plugins
+# (connectors, converters, transformations). The list should consist of top level directories that include
+# any combination of:
+# a) directories immediately containing jars with plugins and their dependencies
+# b) uber-jars with plugins and their dependencies
+# c) directories immediately containing the package directory structure of classes of plugins and their dependencies
+# Examples:
+# plugin.path=/usr/local/share/java,/usr/local/share/kafka/plugins,/opt/connectors,
+# Replace the relative path below with an absolute path if you are planning to start Kafka Connect from within a
+# directory other than the home directory of Confluent Platform.
+plugin.path=./share/java
diff --git a/libraries-data/src/main/kafka-connect/04_Custom/connect-mongodb-sink.json b/libraries-data/src/main/kafka-connect/04_Custom/connect-mongodb-sink.json
new file mode 100644
index 0000000000..333768e4b7
--- /dev/null
+++ b/libraries-data/src/main/kafka-connect/04_Custom/connect-mongodb-sink.json
@@ -0,0 +1,22 @@
+{
+ "firstName": "John",
+ "lastName": "Smith",
+ "age": 25,
+ "address": {
+ "streetAddress": "21 2nd Street",
+ "city": "New York",
+ "state": "NY",
+ "postalCode": "10021"
+ },
+ "phoneNumber": [{
+ "type": "home",
+ "number": "212 555-1234"
+ }, {
+ "type": "fax",
+ "number": "646 555-4567"
+ }
+ ],
+ "gender": {
+ "type": "male"
+ }
+}
diff --git a/libraries-data/src/main/kafka-connect/04_Custom/connect-mqtt-source.json b/libraries-data/src/main/kafka-connect/04_Custom/connect-mqtt-source.json
new file mode 100644
index 0000000000..02d87c5ad7
--- /dev/null
+++ b/libraries-data/src/main/kafka-connect/04_Custom/connect-mqtt-source.json
@@ -0,0 +1,11 @@
+{
+ "name": "mqtt-source",
+ "config": {
+ "connector.class": "io.confluent.connect.mqtt.MqttSourceConnector",
+ "tasks.max": 1,
+ "mqtt.server.uri": "ws://broker.hivemq.com:8000/mqtt",
+ "mqtt.topics": "baeldung",
+ "kafka.topic": "connect-custom",
+ "value.converter": "org.apache.kafka.connect.converters.ByteArrayConverter"
+ }
+}
diff --git a/libraries-server/pom.xml b/libraries-server/pom.xml
index 6fca09faf4..661f5f01d5 100644
--- a/libraries-server/pom.xml
+++ b/libraries-server/pom.xml
@@ -1,9 +1,10 @@
4.0.0
- com.baeldung
libraries-server
0.0.1-SNAPSHOT
+ libraries-server
+
com.baeldung
parent-modules
diff --git a/linkrest/pom.xml b/linkrest/pom.xml
index a27caea1ff..073a173aff 100644
--- a/linkrest/pom.xml
+++ b/linkrest/pom.xml
@@ -1,9 +1,9 @@
4.0.0
- com.baeldung
linkrest
0.0.1-SNAPSHOT
+ linkrest
war
diff --git a/logging-modules/log4j/pom.xml b/logging-modules/log4j/pom.xml
index 1b27e03445..af97d812de 100644
--- a/logging-modules/log4j/pom.xml
+++ b/logging-modules/log4j/pom.xml
@@ -6,6 +6,7 @@
com.baeldung
log4j
1.0-SNAPSHOT
+ log4j
com.baeldung
@@ -44,12 +45,6 @@
disruptor
${disruptor.version}
-
-
- org.springframework.boot
- spring-boot-starter-webflux
- ${spring-boot.version}
-
@@ -57,7 +52,6 @@
2.7
2.7
3.3.6
- 2.1.0.RELEASE
\ No newline at end of file
diff --git a/logging-modules/log4j2/pom.xml b/logging-modules/log4j2/pom.xml
index 65da318636..d46f92dcd6 100644
--- a/logging-modules/log4j2/pom.xml
+++ b/logging-modules/log4j2/pom.xml
@@ -3,7 +3,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
log4j2
-
+ log4j2
+
com.baeldung
parent-modules
diff --git a/maven-archetype/pom.xml b/maven-archetype/pom.xml
index f7871c81ea..73ddc78fc7 100644
--- a/maven-archetype/pom.xml
+++ b/maven-archetype/pom.xml
@@ -5,9 +5,10 @@
com.baeldung.archetypes
maven-archetype
1.0-SNAPSHOT
+ maven-archetype
maven-archetype
Archetype used to generate rest application based on jaxrs 2.1
-
+
diff --git a/maven-polyglot/maven-polyglot-json-extension/pom.xml b/maven-polyglot/maven-polyglot-json-extension/pom.xml
index d5c5b7ab55..fe1e025d1f 100644
--- a/maven-polyglot/maven-polyglot-json-extension/pom.xml
+++ b/maven-polyglot/maven-polyglot-json-extension/pom.xml
@@ -3,11 +3,11 @@
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">
4.0.0
-
com.baeldung.maven.polyglot
maven-polyglot-json-extension
1.0-SNAPSHOT
-
+ maven-polyglot-json-extension
+
1.8
1.8
diff --git a/maven/pom.xml b/maven/pom.xml
index 4bec533226..01fd28db74 100644
--- a/maven/pom.xml
+++ b/maven/pom.xml
@@ -4,6 +4,7 @@
com.baeldung
maven
0.0.1-SNAPSHOT
+ maven
war
diff --git a/maven/versions-maven-plugin/pom.xml b/maven/versions-maven-plugin/pom.xml
index 295c77b860..dc0cba75f9 100644
--- a/maven/versions-maven-plugin/pom.xml
+++ b/maven/versions-maven-plugin/pom.xml
@@ -3,9 +3,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.baeldung
- versions-maven-plugin-example
+ versions-maven-plugin
0.0.1-SNAPSHOT
-
+ versions-maven-plugin
+
1.15
diff --git a/mesos-marathon/pom.xml b/mesos-marathon/pom.xml
index f92c00892b..dee8eca10d 100644
--- a/mesos-marathon/pom.xml
+++ b/mesos-marathon/pom.xml
@@ -5,7 +5,8 @@
com.baeldung
mesos-marathon
0.0.1-SNAPSHOT
-
+ mesos-marathon
+
parent-boot-1
com.baeldung
diff --git a/metrics/pom.xml b/metrics/pom.xml
index 9cf1ec588f..79d340aa49 100644
--- a/metrics/pom.xml
+++ b/metrics/pom.xml
@@ -3,7 +3,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
metrics
-
+ metrics
+
parent-modules
com.baeldung
diff --git a/microprofile/pom.xml b/microprofile/pom.xml
index d75b6443ed..52df348ace 100644
--- a/microprofile/pom.xml
+++ b/microprofile/pom.xml
@@ -5,6 +5,7 @@
com.baeldung
microprofile
1.0-SNAPSHOT
+ microprofile
war
diff --git a/msf4j/pom.xml b/msf4j/pom.xml
index 9a6483772b..4a6f63159d 100644
--- a/msf4j/pom.xml
+++ b/msf4j/pom.xml
@@ -5,6 +5,7 @@
com.baeldung.msf4j
msf4j
0.0.1-SNAPSHOT
+ msf4j
parent-modules
diff --git a/muleesb/pom.xml b/muleesb/pom.xml
index b34123567a..4b74b6d4f4 100644
--- a/muleesb/pom.xml
+++ b/muleesb/pom.xml
@@ -6,9 +6,9 @@
com.mycompany
muleesb
1.0.0-SNAPSHOT
- mule
- Mule muleesb Application
-
+ muleesb
+ mule
+
com.baeldung
parent-modules
diff --git a/mybatis/pom.xml b/mybatis/pom.xml
index aa9ff9e288..4e63d14ded 100644
--- a/mybatis/pom.xml
+++ b/mybatis/pom.xml
@@ -5,7 +5,8 @@
com.baeldung
mybatis
1.0.0-SNAPSHOT
-
+ mybatis
+
com.baeldung
parent-modules
diff --git a/optaplanner/pom.xml b/optaplanner/pom.xml
index 22abbedc8c..fbce0ea072 100644
--- a/optaplanner/pom.xml
+++ b/optaplanner/pom.xml
@@ -2,14 +2,15 @@
+ 4.0.0
+ optaplanner
+ optaplanner
+
parent-modules
com.baeldung
1.0.0-SNAPSHOT
- 4.0.0
-
- optaplanner
diff --git a/parent-boot-1/pom.xml b/parent-boot-1/pom.xml
index 171806390d..53f91f975d 100644
--- a/parent-boot-1/pom.xml
+++ b/parent-boot-1/pom.xml
@@ -3,6 +3,7 @@
4.0.0
parent-boot-1
0.0.1-SNAPSHOT
+ parent-boot-1
pom
Parent for all Spring Boot 1.x modules
diff --git a/parent-boot-2/pom.xml b/parent-boot-2/pom.xml
index 67837e1a4e..89afd79bf4 100644
--- a/parent-boot-2/pom.xml
+++ b/parent-boot-2/pom.xml
@@ -3,6 +3,7 @@
4.0.0
parent-boot-2
0.0.1-SNAPSHOT
+ parent-boot-2
pom
Parent for all Spring Boot 2 modules
diff --git a/patterns/design-patterns/README.md b/patterns/design-patterns/README.md
index ae372bd460..e56872b3fd 100644
--- a/patterns/design-patterns/README.md
+++ b/patterns/design-patterns/README.md
@@ -13,3 +13,4 @@
- [Interpreter Design Pattern in Java](http://www.baeldung.com/java-interpreter-pattern)
- [State Design Pattern in Java](https://www.baeldung.com/java-state-design-pattern)
- [The Decorator Pattern in Java](https://www.baeldung.com/java-decorator-pattern)
+- [Abstract Factory Pattern in Java](https://www.baeldung.com/java-abstract-factory-pattern)
diff --git a/patterns/design-patterns/pom.xml b/patterns/design-patterns/pom.xml
index dc2631b36e..ac201ad653 100644
--- a/patterns/design-patterns/pom.xml
+++ b/patterns/design-patterns/pom.xml
@@ -4,7 +4,9 @@
4.0.0
design-patterns
1.0
- jar
+ design-patterns
+ jar
+
com.baeldung
patterns
diff --git a/patterns/front-controller/pom.xml b/patterns/front-controller/pom.xml
index 435b0dd9cd..bb003dd00a 100644
--- a/patterns/front-controller/pom.xml
+++ b/patterns/front-controller/pom.xml
@@ -3,6 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
front-controller
+ front-controller
war
diff --git a/patterns/intercepting-filter/pom.xml b/patterns/intercepting-filter/pom.xml
index fa94d5d1fd..33589dc242 100644
--- a/patterns/intercepting-filter/pom.xml
+++ b/patterns/intercepting-filter/pom.xml
@@ -2,8 +2,8 @@
4.0.0
-
intercepting-filter
+ intercepting-filter
war
diff --git a/patterns/pom.xml b/patterns/pom.xml
index df09f1836a..bc1f5173e2 100644
--- a/patterns/pom.xml
+++ b/patterns/pom.xml
@@ -4,6 +4,7 @@
4.0.0
patterns
pom
+ patterns
com.baeldung
diff --git a/performance-tests/pom.xml b/performance-tests/pom.xml
index 8c9d027724..7d77c2a0e3 100644
--- a/performance-tests/pom.xml
+++ b/performance-tests/pom.xml
@@ -4,7 +4,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
performance-tests
-
+ performance-tests
+
parent-modules
com.baeldung
diff --git a/persistence-modules/README.md b/persistence-modules/README.md
index f12163bd6a..75ccc749e5 100644
--- a/persistence-modules/README.md
+++ b/persistence-modules/README.md
@@ -9,3 +9,4 @@
- [Introduction to Lettuce – the Java Redis Client](http://www.baeldung.com/java-redis-lettuce)
- [A Guide to Jdbi](http://www.baeldung.com/jdbi)
- [Pessimistic Locking in JPA](http://www.baeldung.com/jpa-pessimistic-locking)
+- [Get All Data from a Table with Hibernate](https://www.baeldung.com/hibernate-select-all)
diff --git a/persistence-modules/hbase/pom.xml b/persistence-modules/hbase/pom.xml
index ffd1464482..daf0db5291 100644
--- a/persistence-modules/hbase/pom.xml
+++ b/persistence-modules/hbase/pom.xml
@@ -3,6 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
hbase
+ hbase
parent-modules
diff --git a/persistence-modules/hibernate5/pom.xml b/persistence-modules/hibernate5/pom.xml
index 24f4055a82..363e2153b6 100644
--- a/persistence-modules/hibernate5/pom.xml
+++ b/persistence-modules/hibernate5/pom.xml
@@ -5,6 +5,7 @@
com.baeldung
hibernate5
0.0.1-SNAPSHOT
+ hibernate5
com.baeldung
diff --git a/persistence-modules/java-cassandra/pom.xml b/persistence-modules/java-cassandra/pom.xml
index 36ec6b5ac8..aac5d49547 100644
--- a/persistence-modules/java-cassandra/pom.xml
+++ b/persistence-modules/java-cassandra/pom.xml
@@ -4,6 +4,7 @@
com.baeldung
java-cassandra
1.0.0-SNAPSHOT
+ java-cassandra
com.baeldung
diff --git a/persistence-modules/java-cockroachdb/pom.xml b/persistence-modules/java-cockroachdb/pom.xml
index 870707c750..2a92934a6e 100644
--- a/persistence-modules/java-cockroachdb/pom.xml
+++ b/persistence-modules/java-cockroachdb/pom.xml
@@ -5,6 +5,7 @@
com.baeldung
java-cockroachdb
1.0-SNAPSHOT
+ java-cockroachdb
parent-modules
diff --git a/persistence-modules/java-jdbi/pom.xml b/persistence-modules/java-jdbi/pom.xml
index 885906fcd0..9281f4fd9d 100644
--- a/persistence-modules/java-jdbi/pom.xml
+++ b/persistence-modules/java-jdbi/pom.xml
@@ -4,6 +4,7 @@
4.0.0
java-jdbi
1.0-SNAPSHOT
+ java-jdbi
parent-modules
diff --git a/persistence-modules/java-jpa/pom.xml b/persistence-modules/java-jpa/pom.xml
index 78764f7148..ddab51a2e2 100644
--- a/persistence-modules/java-jpa/pom.xml
+++ b/persistence-modules/java-jpa/pom.xml
@@ -2,15 +2,16 @@
+ 4.0.0
+ java-jpa
+ java-jpa
+
parent-modules
com.baeldung
1.0.0-SNAPSHOT
../../pom.xml
- 4.0.0
-
- java-jpa
diff --git a/persistence-modules/java-mongodb/pom.xml b/persistence-modules/java-mongodb/pom.xml
index bbc48f54c2..9658ef567f 100644
--- a/persistence-modules/java-mongodb/pom.xml
+++ b/persistence-modules/java-mongodb/pom.xml
@@ -5,6 +5,7 @@
com.baeldung
java-mongodb
1.0-SNAPSHOT
+ java-mongodb
com.baeldung
diff --git a/persistence-modules/jnosql/jnosql-artemis/pom.xml b/persistence-modules/jnosql/jnosql-artemis/pom.xml
index 9c2bfd1ba0..8a978fb179 100644
--- a/persistence-modules/jnosql/jnosql-artemis/pom.xml
+++ b/persistence-modules/jnosql/jnosql-artemis/pom.xml
@@ -3,6 +3,9 @@
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">
4.0.0
+ jnosql-artemis
+ jnosql-artemis
+ war
com.baeldung.jnosql
@@ -10,9 +13,6 @@
1.0-SNAPSHOT
- jnosql-artemis
- war
-
2.4.2
false
diff --git a/persistence-modules/jnosql/jnosql-diana/pom.xml b/persistence-modules/jnosql/jnosql-diana/pom.xml
index 767defb2a8..126f0314d9 100644
--- a/persistence-modules/jnosql/jnosql-diana/pom.xml
+++ b/persistence-modules/jnosql/jnosql-diana/pom.xml
@@ -3,15 +3,15 @@
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">
4.0.0
-
+ jnosql-diana
+ jnosql-diana
+
com.baeldung.jnosql
jnosql
1.0-SNAPSHOT
- jnosql-diana
-
diff --git a/persistence-modules/jnosql/pom.xml b/persistence-modules/jnosql/pom.xml
index c87ad3cf4b..5fb29a3b9c 100644
--- a/persistence-modules/jnosql/pom.xml
+++ b/persistence-modules/jnosql/pom.xml
@@ -3,10 +3,10 @@
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">
4.0.0
-
com.baeldung.jnosql
jnosql
1.0-SNAPSHOT
+ jnosql
pom
diff --git a/persistence-modules/liquibase/pom.xml b/persistence-modules/liquibase/pom.xml
index cb2bee8d48..b06d38e6a0 100644
--- a/persistence-modules/liquibase/pom.xml
+++ b/persistence-modules/liquibase/pom.xml
@@ -3,6 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
liquibase
+ liquibase
parent-modules
diff --git a/persistence-modules/orientdb/pom.xml b/persistence-modules/orientdb/pom.xml
index e4bc9a0585..a8ac3fb789 100644
--- a/persistence-modules/orientdb/pom.xml
+++ b/persistence-modules/orientdb/pom.xml
@@ -4,8 +4,8 @@
4.0.0
orientdb
0.0.1-SNAPSHOT
+ orientdb
jar
- intro-orientdb
introduction to the OrientDB Java APIs
diff --git a/persistence-modules/spring-boot-h2/spring-boot-h2-database/pom.xml b/persistence-modules/spring-boot-h2/spring-boot-h2-database/pom.xml
index 4d677ab0d4..6ebc75de8d 100644
--- a/persistence-modules/spring-boot-h2/spring-boot-h2-database/pom.xml
+++ b/persistence-modules/spring-boot-h2/spring-boot-h2-database/pom.xml
@@ -3,10 +3,10 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
com.baeldung.h2db
spring-boot-h2-database
0.0.1-SNAPSHOT
+ spring-boot-h2-database
jar
Demo Spring Boot applications that starts H2 in memory database
diff --git a/persistence-modules/spring-boot-persistence-mongodb/.gitignore b/persistence-modules/spring-boot-persistence-mongodb/.gitignore
new file mode 100644
index 0000000000..f96dae6a60
--- /dev/null
+++ b/persistence-modules/spring-boot-persistence-mongodb/.gitignore
@@ -0,0 +1,4 @@
+
+/.idea/
+/target/
+/spring-boot-persistence.iml
diff --git a/persistence-modules/spring-boot-persistence-mongodb/pom.xml b/persistence-modules/spring-boot-persistence-mongodb/pom.xml
new file mode 100644
index 0000000000..fc267eedf6
--- /dev/null
+++ b/persistence-modules/spring-boot-persistence-mongodb/pom.xml
@@ -0,0 +1,106 @@
+
+
+ 4.0.0
+
+
+ parent-boot-2
+ com.baeldung
+ 0.0.1-SNAPSHOT
+ ../../parent-boot-2
+
+
+ spring-boot-persistence-mongodb
+ war
+ spring-boot-persistence-mongodb
+ This is simple boot application for Spring boot persistence mongodb test
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+
+
+ org.junit.platform
+ junit-platform-launcher
+ ${junit-platform.version}
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+ spring-boot-persistence
+
+
+ src/main/resources
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+
+
+
+
+
+
+ autoconfiguration
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ integration-test
+
+ test
+
+
+
+ **/*LiveTest.java
+ **/*IntegrationTest.java
+ **/*IntTest.java
+
+
+
+
+
+
+ json
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/SpringBootPersistenceApplication.java b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/SpringBootPersistenceApplication.java
new file mode 100644
index 0000000000..2dff3f37df
--- /dev/null
+++ b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/SpringBootPersistenceApplication.java
@@ -0,0 +1,13 @@
+package com.baeldung;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SpringBootPersistenceApplication {
+
+ public static void main(String ... args) {
+ SpringApplication.run(SpringBootPersistenceApplication.class, args);
+ }
+
+}
diff --git a/spring-boot/src/main/java/com/baeldung/mongodb/daos/UserRepository.java b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/mongodb/daos/UserRepository.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/mongodb/daos/UserRepository.java
rename to persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/mongodb/daos/UserRepository.java
diff --git a/spring-boot/src/main/java/com/baeldung/mongodb/events/UserModelListener.java b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/mongodb/events/UserModelListener.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/mongodb/events/UserModelListener.java
rename to persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/mongodb/events/UserModelListener.java
diff --git a/spring-boot/src/main/java/com/baeldung/mongodb/models/DatabaseSequence.java b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/mongodb/models/DatabaseSequence.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/mongodb/models/DatabaseSequence.java
rename to persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/mongodb/models/DatabaseSequence.java
diff --git a/spring-boot/src/main/java/com/baeldung/mongodb/models/User.java b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/mongodb/models/User.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/mongodb/models/User.java
rename to persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/mongodb/models/User.java
diff --git a/spring-boot/src/main/java/com/baeldung/mongodb/services/SequenceGeneratorService.java b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/mongodb/services/SequenceGeneratorService.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/mongodb/services/SequenceGeneratorService.java
rename to persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/mongodb/services/SequenceGeneratorService.java
diff --git a/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/application.properties b/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/application.properties
new file mode 100644
index 0000000000..5b1b8000d0
--- /dev/null
+++ b/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/application.properties
@@ -0,0 +1,8 @@
+spring.application.name=spring-boot-persistence
+server.port=${PORT:0}
+
+#spring boot mongodb
+spring.data.mongodb.host=localhost
+spring.data.mongodb.port=27017
+spring.data.mongodb.database=springboot-mongo
+
diff --git a/spring-boot/src/test/java/com/baeldung/mongodb/MongoDbAutoGeneratedFieldIntegrationTest.java b/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/mongodb/MongoDbAutoGeneratedFieldIntegrationTest.java
similarity index 88%
rename from spring-boot/src/test/java/com/baeldung/mongodb/MongoDbAutoGeneratedFieldIntegrationTest.java
rename to persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/mongodb/MongoDbAutoGeneratedFieldIntegrationTest.java
index 3430bca69a..cec1ad5fea 100644
--- a/spring-boot/src/test/java/com/baeldung/mongodb/MongoDbAutoGeneratedFieldIntegrationTest.java
+++ b/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/mongodb/MongoDbAutoGeneratedFieldIntegrationTest.java
@@ -5,17 +5,18 @@ import com.baeldung.mongodb.models.User;
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.junit4.SpringRunner;
-import static org.assertj.core.api.Assertions.assertThat;
-import java.util.List;
+import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
+@SpringBootTest
public class MongoDbAutoGeneratedFieldIntegrationTest {
@Autowired
- private UserRepository userRepository;
+ UserRepository userRepository;
@Test
public void contextLoads() {}
diff --git a/persistence-modules/spring-boot-persistence/pom.xml b/persistence-modules/spring-boot-persistence/pom.xml
index 80472fdd57..0ea42b1cb7 100644
--- a/persistence-modules/spring-boot-persistence/pom.xml
+++ b/persistence-modules/spring-boot-persistence/pom.xml
@@ -2,11 +2,11 @@
- 4.0.0
-
+ 4.0.0
com.baeldung
spring-boot-persistence
0.1.0
+ spring-boot-persistence
parent-boot-2
diff --git a/persistence-modules/spring-data-cassandra-reactive/pom.xml b/persistence-modules/spring-data-cassandra-reactive/pom.xml
new file mode 100644
index 0000000000..037b1fd3c1
--- /dev/null
+++ b/persistence-modules/spring-data-cassandra-reactive/pom.xml
@@ -0,0 +1,70 @@
+
+
+ 4.0.0
+
+ com.baeldung
+ spring-data-cassandra-reactive
+ 0.0.1-SNAPSHOT
+ jar
+
+ spring-data-cassandra-reactive
+ Spring Data Cassandra reactive
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.1.0.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+
+ 1.8
+
+
+
+
+ org.springframework.data
+ spring-data-cassandra
+ 2.1.2.RELEASE
+
+
+ io.projectreactor
+ reactor-core
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ io.projectreactor
+ reactor-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
diff --git a/persistence-modules/spring-data-cassandra-reactive/src/main/java/com/baeldung/cassandra/reactive/SpringDataCassandraReactiveApplication.java b/persistence-modules/spring-data-cassandra-reactive/src/main/java/com/baeldung/cassandra/reactive/SpringDataCassandraReactiveApplication.java
new file mode 100644
index 0000000000..5f467042a3
--- /dev/null
+++ b/persistence-modules/spring-data-cassandra-reactive/src/main/java/com/baeldung/cassandra/reactive/SpringDataCassandraReactiveApplication.java
@@ -0,0 +1,12 @@
+package com.baeldung.cassandra.reactive;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SpringDataCassandraReactiveApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringDataCassandraReactiveApplication.class, args);
+ }
+}
diff --git a/persistence-modules/spring-data-cassandra-reactive/src/main/java/com/baeldung/cassandra/reactive/controller/EmployeeController.java b/persistence-modules/spring-data-cassandra-reactive/src/main/java/com/baeldung/cassandra/reactive/controller/EmployeeController.java
new file mode 100644
index 0000000000..e9de213e61
--- /dev/null
+++ b/persistence-modules/spring-data-cassandra-reactive/src/main/java/com/baeldung/cassandra/reactive/controller/EmployeeController.java
@@ -0,0 +1,49 @@
+package com.baeldung.cassandra.reactive.controller;
+
+import com.baeldung.cassandra.reactive.model.Employee;
+import com.baeldung.cassandra.reactive.service.EmployeeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+import javax.annotation.PostConstruct;
+import java.util.ArrayList;
+import java.util.List;
+
+@RestController
+@RequestMapping("employee")
+public class EmployeeController {
+
+ @Autowired
+ EmployeeService employeeService;
+
+ @PostConstruct
+ public void saveEmployees() {
+ List employees = new ArrayList<>();
+ employees.add(new Employee(123, "John Doe", "Delaware", "jdoe@xyz.com", 31));
+ employees.add(new Employee(324, "Adam Smith", "North Carolina", "asmith@xyz.com", 43));
+ employees.add(new Employee(355, "Kevin Dunner", "Virginia", "kdunner@xyz.com", 24));
+ employees.add(new Employee(643, "Mike Lauren", "New York", "mlauren@xyz.com", 41));
+ employeeService.initializeEmployees(employees);
+ }
+
+ @GetMapping("/list")
+ public Flux getAllEmployees() {
+ Flux employees = employeeService.getAllEmployees();
+ return employees;
+ }
+
+ @GetMapping("/{id}")
+ public Mono getEmployeeById(@PathVariable int id) {
+ return employeeService.getEmployeeById(id);
+ }
+
+ @GetMapping("/filterByAge/{age}")
+ public Flux getEmployeesFilterByAge(@PathVariable int age) {
+ return employeeService.getEmployeesFilterByAge(age);
+ }
+}
diff --git a/persistence-modules/spring-data-cassandra-reactive/src/main/java/com/baeldung/cassandra/reactive/model/Employee.java b/persistence-modules/spring-data-cassandra-reactive/src/main/java/com/baeldung/cassandra/reactive/model/Employee.java
new file mode 100644
index 0000000000..a78f884778
--- /dev/null
+++ b/persistence-modules/spring-data-cassandra-reactive/src/main/java/com/baeldung/cassandra/reactive/model/Employee.java
@@ -0,0 +1,20 @@
+package com.baeldung.cassandra.reactive.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.cassandra.core.mapping.PrimaryKey;
+import org.springframework.data.cassandra.core.mapping.Table;
+
+@Table
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class Employee {
+ @PrimaryKey
+ private int id;
+ private String name;
+ private String address;
+ private String email;
+ private int age;
+}
diff --git a/persistence-modules/spring-data-cassandra-reactive/src/main/java/com/baeldung/cassandra/reactive/repository/EmployeeRepository.java b/persistence-modules/spring-data-cassandra-reactive/src/main/java/com/baeldung/cassandra/reactive/repository/EmployeeRepository.java
new file mode 100644
index 0000000000..22dc2b4565
--- /dev/null
+++ b/persistence-modules/spring-data-cassandra-reactive/src/main/java/com/baeldung/cassandra/reactive/repository/EmployeeRepository.java
@@ -0,0 +1,11 @@
+package com.baeldung.cassandra.reactive.repository;
+
+import com.baeldung.cassandra.reactive.model.Employee;
+import org.springframework.data.cassandra.repository.AllowFiltering;
+import org.springframework.data.cassandra.repository.ReactiveCassandraRepository;
+import reactor.core.publisher.Flux;
+
+public interface EmployeeRepository extends ReactiveCassandraRepository {
+ @AllowFiltering
+ Flux findByAgeGreaterThan(int age);
+}
diff --git a/persistence-modules/spring-data-cassandra-reactive/src/main/java/com/baeldung/cassandra/reactive/service/EmployeeService.java b/persistence-modules/spring-data-cassandra-reactive/src/main/java/com/baeldung/cassandra/reactive/service/EmployeeService.java
new file mode 100644
index 0000000000..40c330937a
--- /dev/null
+++ b/persistence-modules/spring-data-cassandra-reactive/src/main/java/com/baeldung/cassandra/reactive/service/EmployeeService.java
@@ -0,0 +1,35 @@
+package com.baeldung.cassandra.reactive.service;
+
+import com.baeldung.cassandra.reactive.model.Employee;
+import com.baeldung.cassandra.reactive.repository.EmployeeRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+import java.util.List;
+
+@Service
+public class EmployeeService {
+
+ @Autowired
+ EmployeeRepository employeeRepository;
+
+ public void initializeEmployees(List employees) {
+ Flux savedEmployees = employeeRepository.saveAll(employees);
+ savedEmployees.subscribe();
+ }
+
+ public Flux getAllEmployees() {
+ Flux employees = employeeRepository.findAll();
+ return employees;
+ }
+
+ public Flux getEmployeesFilterByAge(int age) {
+ return employeeRepository.findByAgeGreaterThan(age);
+ }
+
+ public Mono getEmployeeById(int id) {
+ return employeeRepository.findById(id);
+ }
+}
diff --git a/persistence-modules/spring-data-cassandra-reactive/src/main/resources/application.properties b/persistence-modules/spring-data-cassandra-reactive/src/main/resources/application.properties
new file mode 100644
index 0000000000..7ed2f10131
--- /dev/null
+++ b/persistence-modules/spring-data-cassandra-reactive/src/main/resources/application.properties
@@ -0,0 +1,2 @@
+spring.data.cassandra.keyspace-name=practice
+spring.data.cassandra.port=9042
\ No newline at end of file
diff --git a/persistence-modules/spring-data-cassandra-reactive/src/test/java/com/baeldung/cassandra/reactive/ReactiveEmployeeRepositoryIntegrationTest.java b/persistence-modules/spring-data-cassandra-reactive/src/test/java/com/baeldung/cassandra/reactive/ReactiveEmployeeRepositoryIntegrationTest.java
new file mode 100644
index 0000000000..ad726fe969
--- /dev/null
+++ b/persistence-modules/spring-data-cassandra-reactive/src/test/java/com/baeldung/cassandra/reactive/ReactiveEmployeeRepositoryIntegrationTest.java
@@ -0,0 +1,55 @@
+package com.baeldung.cassandra.reactive;
+
+import com.baeldung.cassandra.reactive.model.Employee;
+import com.baeldung.cassandra.reactive.repository.EmployeeRepository;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+import reactor.test.StepVerifier;
+
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class ReactiveEmployeeRepositoryIntegrationTest {
+
+ @Autowired
+ EmployeeRepository repository;
+
+ @Before
+ public void setUp() {
+
+ Flux deleteAndInsert = repository.deleteAll() //
+ .thenMany(repository.saveAll(Flux.just(
+ new Employee(111, "John Doe", "Delaware", "jdoe@xyz.com", 31),
+ new Employee(222, "Adam Smith", "North Carolina", "asmith@xyz.com", 43),
+ new Employee(333, "Kevin Dunner", "Virginia", "kdunner@xyz.com", 24),
+ new Employee(444, "Mike Lauren", "New York", "mlauren@xyz.com", 41))));
+
+ StepVerifier.create(deleteAndInsert).expectNextCount(4).verifyComplete();
+ }
+
+ @Test
+ public void givenRecordsAreInserted_whenDbIsQueried_thenShouldIncludeNewRecords() {
+
+ Mono saveAndCount = repository.count()
+ .doOnNext(System.out::println)
+ .thenMany(repository.saveAll(Flux.just(new Employee(325, "Kim Jones", "Florida", "kjones@xyz.com", 42),
+ new Employee(654, "Tom Moody", "New Hampshire", "tmoody@xyz.com", 44))))
+ .last()
+ .flatMap(v -> repository.count())
+ .doOnNext(System.out::println);
+
+ StepVerifier.create(saveAndCount).expectNext(6L).verifyComplete();
+ }
+
+ @Test
+ public void givenAgeForFilter_whenDbIsQueried_thenShouldReturnFilteredRecords() {
+ StepVerifier.create(repository.findByAgeGreaterThan(35)).expectNextCount(2).verifyComplete();
+ }
+
+}
diff --git a/persistence-modules/spring-data-gemfire/pom.xml b/persistence-modules/spring-data-gemfire/pom.xml
index 34346c502f..292b7387ac 100644
--- a/persistence-modules/spring-data-gemfire/pom.xml
+++ b/persistence-modules/spring-data-gemfire/pom.xml
@@ -5,6 +5,7 @@
com.baeldung
spring-data-gemfire
1.0.0-SNAPSHOT
+ spring-data-gemfire
jar
diff --git a/persistence-modules/spring-data-jpa/pom.xml b/persistence-modules/spring-data-jpa/pom.xml
index 643210ab89..786e587734 100644
--- a/persistence-modules/spring-data-jpa/pom.xml
+++ b/persistence-modules/spring-data-jpa/pom.xml
@@ -5,6 +5,7 @@
4.0.0
com.baeldung
spring-data-jpa
+ spring-data-jpa
parent-boot-2
diff --git a/persistence-modules/spring-data-keyvalue/pom.xml b/persistence-modules/spring-data-keyvalue/pom.xml
index 6675595f2b..1fee0a88d4 100644
--- a/persistence-modules/spring-data-keyvalue/pom.xml
+++ b/persistence-modules/spring-data-keyvalue/pom.xml
@@ -2,6 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
spring-data-keyvalue
+ spring-data-keyvalue
parent-boot-2
diff --git a/persistence-modules/spring-data-neo4j/pom.xml b/persistence-modules/spring-data-neo4j/pom.xml
index 2be4df71be..1e5d51ddf2 100644
--- a/persistence-modules/spring-data-neo4j/pom.xml
+++ b/persistence-modules/spring-data-neo4j/pom.xml
@@ -3,7 +3,8 @@
4.0.0
spring-data-neo4j
1.0
-
+ spring-data-neo4j
+
com.baeldung
parent-modules
diff --git a/persistence-modules/spring-data-redis/pom.xml b/persistence-modules/spring-data-redis/pom.xml
index bee3d683b8..683f874b6c 100644
--- a/persistence-modules/spring-data-redis/pom.xml
+++ b/persistence-modules/spring-data-redis/pom.xml
@@ -4,6 +4,7 @@
com.baeldung
spring-data-redis
1.0
+ spring-data-redis
jar
diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/HibernateUtil.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/HibernateUtil.java
new file mode 100644
index 0000000000..899fcde947
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/HibernateUtil.java
@@ -0,0 +1,38 @@
+package com.baeldung.hibernate.onetoone;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.service.ServiceRegistry;
+
+public class HibernateUtil {
+ private static SessionFactory sessionFactory;
+
+ private static SessionFactory buildSessionFactory(Strategy strategy) {
+ try {
+ // Create the SessionFactory from hibernate-annotation.cfg.xml
+ Configuration configuration = new Configuration();
+
+ for (Class> entityClass : strategy.getEntityClasses()) {
+ configuration.addAnnotatedClass(entityClass);
+ }
+ configuration.configure("one-to-one.cfg.xml");
+
+ ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties())
+ .build();
+
+ SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);
+
+ return sessionFactory;
+ } catch (Throwable ex) {
+ ex.printStackTrace();
+ throw new ExceptionInInitializerError(ex);
+ }
+ }
+
+ public static SessionFactory getSessionFactory(Strategy strategy) {
+ if (sessionFactory == null)
+ sessionFactory = buildSessionFactory(strategy);
+ return sessionFactory;
+ }
+}
diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/Strategy.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/Strategy.java
new file mode 100644
index 0000000000..3180566ca5
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/Strategy.java
@@ -0,0 +1,25 @@
+package com.baeldung.hibernate.onetoone;
+
+
+import java.util.Arrays;
+import java.util.List;
+
+public enum Strategy {
+ //See that the classes belongs to different packages
+ FOREIGN_KEY(Arrays.asList(com.baeldung.hibernate.onetoone.foreignkeybased.User.class,
+ com.baeldung.hibernate.onetoone.foreignkeybased.Address.class)),
+ SHARED_PRIMARY_KEY(Arrays.asList(com.baeldung.hibernate.onetoone.sharedkeybased.User.class,
+ com.baeldung.hibernate.onetoone.sharedkeybased.Address.class)),
+ JOIN_TABLE_BASED(Arrays.asList(com.baeldung.hibernate.onetoone.jointablebased.Employee.class,
+ com.baeldung.hibernate.onetoone.jointablebased.WorkStation.class));
+
+ private List> entityClasses;
+
+ Strategy(List> entityClasses) {
+ this.entityClasses = entityClasses;
+ }
+
+ public List> getEntityClasses() {
+ return entityClasses;
+ }
+}
diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/foreignkeybased/Address.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/foreignkeybased/Address.java
new file mode 100644
index 0000000000..e05eb46030
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/foreignkeybased/Address.java
@@ -0,0 +1,60 @@
+package com.baeldung.hibernate.onetoone.foreignkeybased;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "address")
+public class Address {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
+ private Long id;
+
+ @Column(name = "street")
+ private String street;
+
+ @Column(name = "city")
+ private String city;
+
+ @OneToOne(mappedBy = "address")
+ private User user;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getStreet() {
+ return street;
+ }
+
+ public void setStreet(String street) {
+ this.street = street;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+}
diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/foreignkeybased/User.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/foreignkeybased/User.java
new file mode 100644
index 0000000000..56b108d0d1
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/foreignkeybased/User.java
@@ -0,0 +1,51 @@
+package com.baeldung.hibernate.onetoone.foreignkeybased;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "users")
+public class User {
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
+ private Long id;
+
+ @Column(name = "username")
+ private String userName;
+
+ @OneToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "address_id", referencedColumnName = "id")
+ private Address address;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public Address getAddress() {
+ return address;
+ }
+
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+}
diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/jointablebased/Employee.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/jointablebased/Employee.java
new file mode 100644
index 0000000000..a0bc101b9f
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/jointablebased/Employee.java
@@ -0,0 +1,53 @@
+package com.baeldung.hibernate.onetoone.jointablebased;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "employee")
+public class Employee {
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
+ private Long id;
+
+ @Column(name = "ename")
+ private String name;
+
+ @OneToOne(cascade = CascadeType.ALL)
+ @JoinTable(name = "emp_workstation", joinColumns = {@JoinColumn(name = "employee_id", referencedColumnName = "id")},
+ inverseJoinColumns = {@JoinColumn(name = "workstation_id", referencedColumnName = "id")})
+ private WorkStation workStation;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public WorkStation getWorkStation() {
+ return workStation;
+ }
+
+ public void setWorkStation(WorkStation workStation) {
+ this.workStation = workStation;
+ }
+}
diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/jointablebased/WorkStation.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/jointablebased/WorkStation.java
new file mode 100644
index 0000000000..f530611f6e
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/jointablebased/WorkStation.java
@@ -0,0 +1,61 @@
+package com.baeldung.hibernate.onetoone.jointablebased;
+
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "workstation")
+public class WorkStation {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
+ private Long id;
+
+ @Column(name = "workstation_number")
+ private Integer workstationNumber;
+
+ @Column(name = "floor")
+ private String floor;
+
+ @OneToOne(mappedBy = "workStation")
+ private Employee employee;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Integer getWorkstationNumber() {
+ return workstationNumber;
+ }
+
+ public void setWorkstationNumber(Integer workstationNumber) {
+ this.workstationNumber = workstationNumber;
+ }
+
+ public String getFloor() {
+ return floor;
+ }
+
+ public void setFloor(String floor) {
+ this.floor = floor;
+ }
+
+ public Employee getEmployee() {
+ return employee;
+ }
+
+ public void setEmployee(Employee employee) {
+ this.employee = employee;
+ }
+}
\ No newline at end of file
diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/sharedkeybased/Address.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/sharedkeybased/Address.java
new file mode 100644
index 0000000000..927516f6bb
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/sharedkeybased/Address.java
@@ -0,0 +1,60 @@
+package com.baeldung.hibernate.onetoone.sharedkeybased;
+
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.MapsId;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "address")
+public class Address {
+
+ @Id
+ @Column(name = "id")
+ private Long id;
+
+ @Column(name = "street")
+ private String street;
+
+ @Column(name = "city")
+ private String city;
+
+ @OneToOne
+ @MapsId
+ private User user;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getStreet() {
+ return street;
+ }
+
+ public void setStreet(String street) {
+ this.street = street;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+}
diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/sharedkeybased/User.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/sharedkeybased/User.java
new file mode 100644
index 0000000000..fa00db1271
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/onetoone/sharedkeybased/User.java
@@ -0,0 +1,50 @@
+package com.baeldung.hibernate.onetoone.sharedkeybased;
+
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "users")
+public class User {
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name = "id")
+ private Long id;
+
+ @Column(name = "username")
+ private String userName;
+
+ @OneToOne(mappedBy = "user", cascade = CascadeType.ALL)
+ private Address address;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public Address getAddress() {
+ return address;
+ }
+
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+}
diff --git a/persistence-modules/spring-hibernate-5/src/main/resources/one-to-one.cfg.xml b/persistence-modules/spring-hibernate-5/src/main/resources/one-to-one.cfg.xml
new file mode 100644
index 0000000000..7522036acb
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/main/resources/one-to-one.cfg.xml
@@ -0,0 +1,16 @@
+
+
+
+
+ org.h2.Driver
+
+ jdbc:h2:mem:spring_hibernate_one_to_one
+ sa
+ org.hibernate.dialect.H2Dialect
+ thread
+ true
+ create-drop
+
+
\ No newline at end of file
diff --git a/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/onetoone/HibernateOneToOneAnnotationFKBasedIntegrationTest.java b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/onetoone/HibernateOneToOneAnnotationFKBasedIntegrationTest.java
new file mode 100644
index 0000000000..475c93f6ff
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/onetoone/HibernateOneToOneAnnotationFKBasedIntegrationTest.java
@@ -0,0 +1,80 @@
+package com.baeldung.hibernate.onetoone;
+
+import com.baeldung.hibernate.onetoone.foreignkeybased.Address;
+import com.baeldung.hibernate.onetoone.foreignkeybased.User;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class HibernateOneToOneAnnotationFKBasedIntegrationTest {
+
+ private static SessionFactory sessionFactory;
+
+ private Session session;
+
+ @BeforeClass
+ public static void beforeTests() {
+ sessionFactory = HibernateUtil.getSessionFactory(Strategy.FOREIGN_KEY);
+ }
+
+ @Before
+ public void setUp() {
+ session = sessionFactory.openSession();
+ session.beginTransaction();
+ }
+
+ @Test
+ public void givenData_whenInsert_thenCreates1to1relationship() {
+ User user = new User();
+ user.setUserName("alice@baeldung.com");
+
+ Address address = new Address();
+ address.setStreet("FK Street");
+ address.setCity("FK City");
+
+ address.setUser(user);
+ user.setAddress(address);
+
+ //Address entry will automatically be created by hibernate, since cascade type is specified as ALL
+ session.persist(user);
+ session.getTransaction().commit();
+
+ assert1to1InsertedData();
+ }
+
+ private void assert1to1InsertedData() {
+ @SuppressWarnings("unchecked")
+ List userList = session.createQuery("FROM User").list();
+
+ assertNotNull(userList);
+ assertEquals(1, userList.size());
+
+ User user = userList.get(0);
+ assertEquals("alice@baeldung.com", user.getUserName());
+
+ Address address = user.getAddress();
+ assertNotNull(address);
+ assertEquals("FK Street", address.getStreet());
+ assertEquals("FK City", address.getCity());
+
+ }
+
+ @After
+ public void tearDown() {
+ session.close();
+ }
+
+ @AfterClass
+ public static void afterTests() {
+ sessionFactory.close();
+ }
+}
diff --git a/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/onetoone/HibernateOneToOneAnnotationJTBasedIntegrationTest.java b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/onetoone/HibernateOneToOneAnnotationJTBasedIntegrationTest.java
new file mode 100644
index 0000000000..df4cd4d137
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/onetoone/HibernateOneToOneAnnotationJTBasedIntegrationTest.java
@@ -0,0 +1,80 @@
+package com.baeldung.hibernate.onetoone;
+
+import com.baeldung.hibernate.onetoone.jointablebased.Employee;
+import com.baeldung.hibernate.onetoone.jointablebased.WorkStation;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class HibernateOneToOneAnnotationJTBasedIntegrationTest {
+
+ private static SessionFactory sessionFactory;
+
+ private Session session;
+
+ @BeforeClass
+ public static void beforeTests() {
+ sessionFactory = HibernateUtil.getSessionFactory(Strategy.JOIN_TABLE_BASED);
+ }
+
+ @Before
+ public void setUp() {
+ session = sessionFactory.openSession();
+ session.beginTransaction();
+ }
+
+ @Test
+ public void givenData_whenInsert_thenCreates1to1relationship() {
+ Employee employee = new Employee();
+ employee.setName("bob@baeldung.com");
+
+ WorkStation workStation = new WorkStation();
+ workStation.setWorkstationNumber(626);
+ workStation.setFloor("Sixth Floor");
+
+
+ employee.setWorkStation(workStation);
+ workStation.setEmployee(employee);
+
+ session.persist(employee);
+ session.getTransaction().commit();
+
+ assert1to1InsertedData();
+ }
+
+ private void assert1to1InsertedData() {
+ @SuppressWarnings("unchecked")
+ List employeeList = session.createQuery("FROM Employee").list();
+ assertNotNull(employeeList);
+ assertEquals(1, employeeList.size());
+
+ Employee employee = employeeList.get(0);
+ assertEquals("bob@baeldung.com", employee.getName());
+
+ WorkStation workStation = employee.getWorkStation();
+
+ assertNotNull(workStation);
+ assertEquals((long) 626, (long) workStation.getWorkstationNumber());
+ assertEquals("Sixth Floor", workStation.getFloor());
+
+ }
+
+ @After
+ public void tearDown() {
+ session.close();
+ }
+
+ @AfterClass
+ public static void afterTests() {
+ sessionFactory.close();
+ }
+}
diff --git a/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/onetoone/HibernateOneToOneAnnotationSPKBasedIntegrationTest.java b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/onetoone/HibernateOneToOneAnnotationSPKBasedIntegrationTest.java
new file mode 100644
index 0000000000..7931a8e3fe
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/onetoone/HibernateOneToOneAnnotationSPKBasedIntegrationTest.java
@@ -0,0 +1,79 @@
+package com.baeldung.hibernate.onetoone;
+
+import com.baeldung.hibernate.onetoone.sharedkeybased.Address;
+import com.baeldung.hibernate.onetoone.sharedkeybased.User;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class HibernateOneToOneAnnotationSPKBasedIntegrationTest {
+
+ private static SessionFactory sessionFactory;
+
+ private Session session;
+
+ @BeforeClass
+ public static void beforeTests() {
+ sessionFactory = HibernateUtil.getSessionFactory(Strategy.SHARED_PRIMARY_KEY);
+ }
+
+ @Before
+ public void setUp() {
+ session = sessionFactory.openSession();
+ session.beginTransaction();
+ }
+
+ @Test
+ public void givenData_whenInsert_thenCreates1to1relationship() {
+ User user = new User();
+ user.setUserName("alice@baeldung.com");
+
+ Address address = new Address();
+ address.setStreet("SPK Street");
+ address.setCity("SPK City");
+
+ address.setUser(user);
+ user.setAddress(address);
+
+ //Address entry will automatically be created by hibernate, since cascade type is specified as ALL
+ session.persist(user);
+ session.getTransaction().commit();
+
+ assert1to1InsertedData();
+ }
+
+
+ private void assert1to1InsertedData() {
+ @SuppressWarnings("unchecked")
+ List userList = session.createQuery("FROM User").list();
+ assertNotNull(userList);
+ assertEquals(1, userList.size());
+
+ User user = userList.get(0);
+ assertEquals("alice@baeldung.com", user.getUserName());
+
+ Address address = user.getAddress();
+ assertNotNull(address);
+ assertEquals("SPK Street", address.getStreet());
+ assertEquals("SPK City", address.getCity());
+ }
+
+ @After
+ public void tearDown() {
+ session.close();
+ }
+
+ @AfterClass
+ public static void afterTests() {
+ sessionFactory.close();
+ }
+}
diff --git a/persistence-modules/spring-hibernate-5/src/test/resources/one-to-one.cfg.xml b/persistence-modules/spring-hibernate-5/src/test/resources/one-to-one.cfg.xml
new file mode 100644
index 0000000000..60417e312d
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/test/resources/one-to-one.cfg.xml
@@ -0,0 +1,16 @@
+
+
+
+
+ org.h2.Driver
+
+ jdbc:h2:mem:spring_hibernate_one_to_one
+ sa
+ org.hibernate.dialect.H2Dialect
+ thread
+ true
+ create-drop
+
+
diff --git a/pom.xml b/pom.xml
index 70248b9993..dabb4a9628 100644
--- a/pom.xml
+++ b/pom.xml
@@ -323,206 +323,170 @@
parent-boot-1
- parent-boot-2
- parent-spring-4
- parent-spring-5
- parent-java
- parent-kotlin
- asm
- atomix
- persistence-modules/apache-cayenne
- aws
- aws-lambda
- akka-streams
- algorithms-genetic
- algorithms-miscellaneous-1
- algorithms-miscellaneous-2
- algorithms-sorting
- annotations
- apache-cxf
- apache-fop
- apache-geode
- apache-poi
- apache-tika
- apache-thrift
- apache-curator
- apache-zookeeper
- apache-opennlp
- autovalue
- axon
- azure
- bootique
- cdi
- java-strings
-
- core-java
- core-java-lang
- core-java-arrays
- core-java-collections
- java-collections-conversions
- java-collections-maps
- core-java-io
- core-java-8
- java-streams
- persistence-modules/core-java-persistence
- core-kotlin
- kotlin-libraries
- core-groovy
- core-java-concurrency
- core-java-concurrency-collections
- couchbase
- persistence-modules/deltaspike
- dozer
- ethereum
- feign
- flips
- testing-modules/groovy-spock
- google-cloud
- google-web-toolkit
- gson
- guava
- guava-collections
- guava-modules/guava-18
- guava-modules/guava-19
- guava-modules/guava-21
- guice
- disruptor
- core-scala
- spring-static-resources
- hazelcast
- persistence-modules/hbase
- persistence-modules/hibernate5
- httpclient
- hystrix
- image-processing
- immutables
- persistence-modules/influxdb
- jackson
- persistence-modules/java-cassandra
- vavr
- java-lite
- java-numbers
- java-rmi
- java-vavr-stream
- javax-servlets
- javaxval
- jaxb
- javafx
- jgroups
- jee-7
- jee-7-security
- jhipster
- jjwt
- jsf
- json-path
- json
- jsoup
- testing-modules/junit-5
-
- libraries
- libraries-data
- libraries-security
- libraries-server
- linkrest
- logging-modules/log-mdc
- logging-modules/log4j
- logging-modules/log4j2
- logging-modules/logback
- lombok
- mapstruct
- metrics
- maven
- mesos-marathon
- msf4j
- testing-modules/mockito
- testing-modules/mockito-2
- testing-modules/mocks
- mustache
- mvn-wrapper
- noexception
- persistence-modules/orientdb
- osgi
- orika
- patterns
- pdf
- protobuffer
- persistence-modules/querydsl
- reactor-core
- persistence-modules/redis
- testing-modules/rest-assured
- testing-modules/rest-testing
- resteasy
- rxjava
- rxjava-2
- spring-swagger-codegen
- testing-modules/selenium-junit-testng
- persistence-modules/solr
- spark-java
- spring-4
- spring-5
- spring-5-data-reactive
- spring-5-reactive
- spring-5-reactive-security
- spring-5-reactive-client
- spring-5-mvc
- spring-5-security
- spring-5-security-oauth
- spring-5-reactive-oauth
- spring-activiti
- spring-akka
- spring-amqp
- spring-all
- spring-amqp-simple
- spring-apache-camel
- spring-batch
- spring-bom
- spring-boot
- spring-boot-client
- spring-boot-keycloak
- spring-boot-bootstrap
- spring-boot-admin
- spring-boot-camel
- spring-boot-ops
- persistence-modules/spring-boot-persistence
- spring-boot-security
- spring-boot-mvc
- spring-boot-vue
- spring-boot-logging-log4j2
- spring-boot-disable-console-logging
- spring-cloud-data-flow
- spring-cloud
- spring-cloud-bus
- spring-core
- spring-cucumber
- spring-ejb
- spring-aop
- persistence-modules/spring-data-cassandra
- persistence-modules/spring-data-couchbase-2
- persistence-modules/spring-data-dynamodb
- persistence-modules/spring-data-elasticsearch
- persistence-modules/spring-data-jpa
- persistence-modules/spring-data-keyvalue
- persistence-modules/spring-data-mongodb
- persistence-modules/spring-data-neo4j
- persistence-modules/spring-data-redis
- spring-data-rest
- persistence-modules/spring-data-solr
- spring-dispatcher-servlet
- spring-exceptions
- spring-freemarker
- persistence-modules/spring-hibernate-3
- persistence-modules/spring-hibernate4
- persistence-modules/spring-hibernate-5
- persistence-modules/spring-data-eclipselink
- spring-integration
- spring-jenkins-pipeline
- spring-jersey
- jmeter
- spring-jms
- spring-jooq
- persistence-modules/spring-jpa
- ddd
-
+ parent-boot-2
+ parent-spring-4
+ parent-spring-5
+ parent-java
+ parent-kotlin
+
+ asm
+ atomix
+ aws
+ aws-lambda
+ akka-streams
+ algorithms-genetic
+ algorithms-miscellaneous-1
+ algorithms-miscellaneous-2
+ algorithms-sorting
+ annotations
+ apache-cxf
+ apache-fop
+ apache-poi
+ apache-tika
+ apache-thrift
+ apache-curator
+ apache-zookeeper
+ apache-opennlp
+ autovalue
+ axon
+ azure
+ apache-velocity
+ apache-solrj
+ apache-meecrowave
+ antlr
+
+ bootique
+
+ cdi
+ core-java-collections
+ core-java-io
+ core-java-8
+ core-groovy
+ couchbase
+
+
+ core-java
+ core-java-net
+
+ dozer
+ disruptor
+ drools
+ deeplearning4j
+
+ ethereum
+
+ feign
+ flips
+
+ google-cloud
+ gson
+ guava
+ guava-collections
+ guava-modules/guava-18
+ guava-modules/guava-19
+ guava-modules/guava-21
+ guice
+
+ hazelcast
+ hystrix
+ httpclient
+
+ image-processing
+ immutables
+
+ jackson
+ java-strings
+
+ java-collections-conversions
+ java-collections-maps
+ java-streams
+ java-lite
+ java-numbers
+ java-rmi
+ java-vavr-stream
+ javax-servlets
+ javaxval
+ jaxb
+ javafx
+ jgroups
+
+ jee-7-security
+ jjwt
+ jsf
+ json-path
+ json
+ jsoup
+ jta
+ jws
+ jersey
+ java-spi
+ java-ee-8-security-api
+
+
+ libraries-data
+ linkrest
+ logging-modules/log-mdc
+ logging-modules/log4j
+ logging-modules/logback
+ lombok
+ lucene
+
+ mapstruct
+ maven
+ mesos-marathon
+ msf4j
+ mustache
+ mvn-wrapper
+ mybatis
+ metrics
+ maven-archetype
+
+ noexception
+
+ osgi
+ orika
+
+ patterns
+ pdf
+ protobuffer
+ performance-tests
+
+ persistence-modules/java-jdbi
+ persistence-modules/redis
+ persistence-modules/orientdb
+ persistence-modules/querydsl
+ persistence-modules/apache-cayenne
+ persistence-modules/solr
+ persistence-modules/spring-data-dynamodb
+ persistence-modules/spring-data-keyvalue
+ persistence-modules/spring-data-neo4j
+ persistence-modules/spring-data-solr
+ persistence-modules/spring-hibernate-5
+ persistence-modules/spring-data-eclipselink
+ persistence-modules/spring-jpa
+ persistence-modules/spring-hibernate-3
+ persistence-modules/spring-data-gemfire
+ persistence-modules/spring-boot-persistence
+ persistence-modules/liquibase
+ persistence-modules/java-cockroachdb
+ persistence-modules/deltaspike
+ persistence-modules/hbase
+ persistence-modules/influxdb
+ persistence-modules/spring-hibernate4
+ persistence-modules/spring-data-mongodb
+ persistence-modules/java-cassandra
+ persistence-modules/spring-data-cassandra
+ persistence-modules/spring-data-couchbase-2
+ persistence-modules/spring-data-redis
+ persistence-modules/spring-boot-persistence-mongodb
+
+ reactor-core
+ resteasy
+ rxjava
+ rxjava-2
+ rabbitmq
+
@@ -561,6 +525,78 @@
parent-java
parent-kotlin
+ spring-4
+ spring-5
+ spring-5-reactive
+ spring-5-reactive-security
+ spring-5-reactive-client
+ spring-5-mvc
+ spring-5-security
+ spring-5-security-oauth
+
+ spring-aop
+ spring-activiti
+ spring-akka
+ spring-amqp
+ spring-all
+ spring-apache-camel
+ spring-batch
+ spring-bom
+ spring-boot-keycloak
+ spring-boot-bootstrap
+ spring-boot-admin
+ spring-boot-camel
+ spring-boot-security
+ spring-boot-mvc
+ spring-boot-logging-log4j2
+ spring-boot-disable-console-logging
+ spring-boot-property-exp
+ spring-boot-ctx-fluent
+ spring-boot
+ spring-boot-ops
+
+ spring-cloud-data-flow
+ spring-cloud
+ spring-cloud-bus
+ spring-core
+ spring-cucumber
+ spring-data-rest
+ spring-drools
+ spring-dispatcher-servlet
+ spring-ejb
+ spring-exceptions
+
+ spring-freemarker
+ spring-integration
+
+ spring-jinq
+ spring-jenkins-pipeline
+ spring-jersey
+ spring-jms
+ spring-jooq
+ spring-kafka
+ spring-katharsis
+ spring-ldap
+
+ spring-mockito
+ spring-mvc-forms-jsp
+ spring-mvc-forms-thymeleaf
+ spring-mvc-java
+ spring-mvc-velocity
+ spring-mvc-webflow
+ spring-mvc-xml
+ spring-mvc-kotlin
+
+ spring-protobuf
+ spring-quartz
+ spring-rest-angular
+ spring-rest-full
+ spring-rest-query-language
+ spring-rest
+ spring-resttemplate
+ spring-rest-simple
+ spring-remoting
+
spring-session
spring-sleuth
spring-social-login
@@ -568,129 +604,17 @@
spring-state-machine
spring-thymeleaf
spring-userservice
+
spring-zuul
- spring-remoting
spring-reactor
spring-vertx
- spring-jinq
+ spring-vault
spring-rest-embedded-tomcat
- testing-modules/testing
- testing-modules/testng
- video-tutorials
- xml
- xmlunit-2
- struts-2
- apache-velocity
- apache-solrj
- rabbitmq
- vertx
- persistence-modules/spring-data-gemfire
- mybatis
- spring-drools
- drools
- persistence-modules/liquibase
- spring-boot-property-exp
- testing-modules/mockserver
- testing-modules/test-containers
- undertow
- vaadin
- vertx-and-rxjava
- saas
- deeplearning4j
- lucene
- vraptor
- persistence-modules/java-cockroachdb
- spring-security-thymeleaf
- persistence-modules/java-jdbi
- jersey
- java-spi
- performance-tests
- twilio
- spring-boot-ctx-fluent
- java-ee-8-security-api
- spring-webflux-amqp
- antlr
- maven-archetype
- optaplanner
- apache-meecrowave
- spring-reactive-kotlin
- persistence-modules/jnosql
- spring-boot-angular-ecommerce
- jta
-
- java-websocket
- persistence-modules/activejdbc
- animal-sniffer-mvn-plugin
- apache-avro
- apache-bval
- apache-shiro
- apache-spark
- asciidoctor
- checker-plugin
-
-
- core-java-sun
- custom-pmd
- dagger
- data-structures
- dubbo
- persistence-modules/flyway
-
-
- jni
- jooby
-
-
-
- ratpack
- rest-with-spark-java
- spring-boot-autoconfiguration
- spring-boot-custom-starter
- spring-boot-jasypt
- spring-data-rest-querydsl
- spring-groovy
- spring-mobile
- spring-mustache
- spring-mvc-simple
- spring-mybatis
- spring-rest-hal-browser
- spring-rest-shell
- spring-rest-template
- spring-roo
- spring-security-stormpath
- sse-jaxrs
- static-analysis
- stripe
-
- Twitter4J
- wicket
- xstream
- cas/cas-secured-app
- cas/cas-server
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- spring-boot-custom-starter/greeter
- persistence-modules/spring-boot-h2/spring-boot-h2-database
-
-
-
-
- flyway-cdi-extension
+ spring-swagger-codegen
+ spring-webflux-amqp
+ spring-static-resources
+ spring-security-thymeleaf
spring-security-acl
spring-security-cache-control
spring-security-client/spring-security-jsp-authentication
@@ -702,7 +626,6 @@
spring-security-client/spring-security-thymeleaf-config
spring-security-core
spring-security-mvc-boot
- spring-security-mvc-custom
spring-security-mvc-digest-auth
spring-security-mvc-ldap
spring-security-mvc-login
@@ -710,73 +633,67 @@
spring-security-mvc-session
spring-security-mvc-socket
spring-security-openid
-
+
spring-security-rest-basic-auth
spring-security-rest-custom
spring-security-rest
spring-security-sso
spring-security-x509
+ spring-security-mvc-custom
- spring-kafka
- spring-katharsis
- spring-ldap
- spring-mockito
- spring-mvc-forms-jsp
- spring-mvc-forms-thymeleaf
- spring-mvc-java
- spring-mvc-velocity
- spring-mvc-webflow
- spring-mvc-xml
- spring-mvc-kotlin
- spring-protobuf
- spring-quartz
- spring-rest-angular
- spring-rest-full
- spring-rest-query-language
-
-
- spring-resttemplate
- helidon
-
-
-
-
-
- default-third
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
- 3
- true
-
- **/*IntegrationTest.java
- **/*IntTest.java
- **/*LongRunningUnitTest.java
- **/*ManualTest.java
- **/*JdbcTest.java
- **/*LiveTest.java
-
-
-
-
-
-
-
-
- parent-boot-1
- parent-boot-2
- parent-spring-4
- parent-spring-5
- parent-java
- parent-kotlin
+ spark-java
+ saas
+ struts-2
+ testing-modules/selenium-junit-testng
+ testing-modules/groovy-spock
+ testing-modules/mockito
+ testing-modules/mockito-2
+ testing-modules/mocks
+ testing-modules/rest-assured
+ testing-modules/rest-testing
+ testing-modules/junit-5
+ testing-modules/junit5-migration
+ testing-modules/testing
+ testing-modules/testng
+ testing-modules/mockserver
+ testing-modules/test-containers
+ twilio
+
+ undertow
+
+ video-tutorials
+ vaadin
+ vertx-and-rxjava
+ vraptor
+ vertx
+ vavr
+
+ xmlunit-2
+ xml
+
+
+
+
+
+
+ google-web-toolkit
+
+ -->
+
+
+
+
@@ -1000,6 +917,10 @@
core-java-8
core-groovy
couchbase
+
+
+ core-java
+ core-java-net
dozer
disruptor
@@ -1029,7 +950,7 @@
jackson
java-strings
-
+
java-collections-conversions
java-collections-maps
java-streams
@@ -1042,7 +963,8 @@
jaxb
javafx
jgroups
- jee-7
+
jee-7-security
jjwt
jsf
@@ -1055,6 +977,7 @@
java-spi
java-ee-8-security-api
+
libraries-data
linkrest
logging-modules/log-mdc
@@ -1105,6 +1028,11 @@
persistence-modules/hbase
persistence-modules/influxdb
persistence-modules/spring-hibernate4
+ persistence-modules/spring-data-mongodb
+ persistence-modules/java-cassandra
+ persistence-modules/spring-data-cassandra
+ persistence-modules/spring-data-couchbase-2
+ persistence-modules/spring-data-redis
reactor-core
resteasy
@@ -1112,11 +1040,6 @@
rxjava-2
rabbitmq
-
-
-
@@ -1152,12 +1075,15 @@
parent-kotlin
spring-4
+ spring-5
spring-5-reactive
spring-5-reactive-security
spring-5-reactive-client
spring-5-mvc
spring-5-security
spring-5-security-oauth
+
+ spring-aop
spring-activiti
spring-akka
spring-amqp
@@ -1165,7 +1091,6 @@
spring-apache-camel
spring-batch
spring-bom
-
spring-boot-keycloak
spring-boot-bootstrap
spring-boot-admin
@@ -1174,29 +1099,34 @@
spring-boot-mvc
spring-boot-logging-log4j2
spring-boot-disable-console-logging
+ spring-boot-property-exp
+ spring-boot-ctx-fluent
+ spring-boot
+ spring-boot-ops
spring-cloud-data-flow
spring-cloud
spring-cloud-bus
spring-core
spring-cucumber
- spring-ejb
- spring-aop
-
spring-data-rest
+ spring-drools
spring-dispatcher-servlet
+ spring-ejb
spring-exceptions
+
spring-freemarker
-
spring-integration
+
+ spring-jinq
spring-jenkins-pipeline
spring-jersey
-
spring-jms
spring-jooq
spring-kafka
spring-katharsis
spring-ldap
+
spring-mockito
spring-mvc-forms-jsp
spring-mvc-forms-thymeleaf
@@ -1205,6 +1135,7 @@
spring-mvc-webflow
spring-mvc-xml
spring-mvc-kotlin
+
spring-protobuf
spring-quartz
spring-rest-angular
@@ -1213,6 +1144,26 @@
spring-rest
spring-resttemplate
spring-rest-simple
+ spring-remoting
+
+ spring-session
+ spring-sleuth
+ spring-social-login
+ spring-spel
+ spring-state-machine
+ spring-thymeleaf
+ spring-userservice
+
+ spring-zuul
+ spring-reactor
+ spring-vertx
+ spring-vault
+ spring-rest-embedded-tomcat
+ spring-swagger-codegen
+ spring-webflux-amqp
+
+ spring-static-resources
+ spring-security-thymeleaf
spring-security-acl
spring-security-cache-control
spring-security-client/spring-security-jsp-authentication
@@ -1231,74 +1182,13 @@
spring-security-mvc-session
spring-security-mvc-socket
spring-security-openid
-
+
spring-security-rest-basic-auth
spring-security-rest-custom
spring-security-rest
spring-security-sso
spring-security-x509
- spring-session
- spring-sleuth
- spring-social-login
- spring-spel
- spring-state-machine
- spring-thymeleaf
- spring-userservice
- spring-zuul
- spring-remoting
- spring-reactor
- spring-vertx
- spring-vault
- spring-jinq
- spring-rest-embedded-tomcat
-
- spring-static-resources
- spring-swagger-codegen
- spring-drools
- spring-boot-property-exp
- spring-security-thymeleaf
- spring-boot-ctx-fluent
- spring-webflux-amqp
-
-
-
-
-
-
-
-
-
- integration-lite-third
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- **/*ManualTest.java
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
- **/*IntTest.java
-
-
-
-
-
-
-
- parent-boot-1
- parent-boot-2
- parent-spring-4
- parent-spring-5
- parent-java
- parent-kotlin
+ spring-security-mvc-custom
spark-java
saas
@@ -1333,337 +1223,26 @@
-
-
-
-
-
-
-
- integration
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- **/*ManualTest.java
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
- **/*IntTest.java
-
-
-
-
-
-
-
-
- parent-boot-1
- parent-boot-2
- parent-spring-4
- parent-spring-5
- parent-java
- parent-kotlin
-
-
-
-
-
-
-
-
-
- testing-modules/mockito
- testing-modules/mockito-2
- testing-modules/mocks
- mustache
- mvn-wrapper
- noexception
- persistence-modules/orientdb
- osgi
- orika
- patterns
- pdf
- protobuffer
- persistence-modules/querydsl
- reactor-core
- persistence-modules/redis
- testing-modules/rest-assured
- testing-modules/rest-testing
- resteasy
- rxjava
- rxjava-2
- spring-swagger-codegen
- testing-modules/selenium-junit-testng
- persistence-modules/solr
- spark-java
- spring-4
- spring-5
- spring-5-data-reactive
- spring-5-reactive
- spring-5-reactive-security
- spring-5-reactive-client
- spring-5-mvc
- spring-5-security
- spring-5-security-oauth
- spring-activiti
- spring-akka
- spring-amqp
- spring-all
+
+
+
-
-
-
- spring-bom
- spring-boot
- spring-boot-client
- spring-boot-keycloak
- spring-boot-bootstrap
- spring-boot-admin
- spring-boot-camel
- spring-boot-ops
- persistence-modules/spring-boot-persistence
- spring-boot-security
- spring-boot-mvc
- spring-boot-logging-log4j2
- spring-boot-disable-console-logging
- spring-cloud-data-flow
- spring-cloud
- spring-cloud-bus
- spring-core
- spring-cucumber
- spring-ejb
- spring-aop
- persistence-modules/spring-data-cassandra
- persistence-modules/spring-data-couchbase-2
- persistence-modules/spring-data-dynamodb
- persistence-modules/spring-data-elasticsearch
- persistence-modules/spring-data-keyvalue
- persistence-modules/spring-data-mongodb
- persistence-modules/spring-data-jpa
- persistence-modules/spring-data-neo4j
- persistence-modules/spring-data-redis
- spring-data-rest
-
-
-
-
-
-
- persistence-modules/spring-data-solr
- spring-dispatcher-servlet
- spring-exceptions
- spring-freemarker
- persistence-modules/spring-hibernate-3
- persistence-modules/spring-hibernate4
- persistence-modules/spring-hibernate-5
- persistence-modules/spring-data-eclipselink
- spring-integration
- spring-jenkins-pipeline
- spring-jersey
- spring-jms
- spring-jooq
- persistence-modules/spring-jpa
- spring-kafka
- spring-katharsis
- spring-ldap
- spring-mockito
- spring-mvc-forms-jsp
- spring-mvc-forms-thymeleaf
- spring-mvc-java
- spring-mvc-velocity
- spring-mvc-webflow
- spring-mvc-xml
- spring-mvc-kotlin
- spring-protobuf
- spring-quartz
- spring-rest-angular
- spring-rest-full
- spring-rest-query-language
- spring-rest
- spring-resttemplate
- spring-rest-simple
- spring-reactive-kotlin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- java-websocket
- persistence-modules/activejdbc
- animal-sniffer-mvn-plugin
- apache-avro
- apache-bval
- apache-shiro
- apache-spark
- asciidoctor
- checker-plugin
-
-
- core-java-sun
- custom-pmd
- dagger
- data-structures
- dubbo
- persistence-modules/flyway
-
-
- jni
- jooby
-
-
-
- ratpack
- rest-with-spark-java
- spring-boot-autoconfiguration
- spring-boot-custom-starter
- spring-boot-jasypt
- spring-data-rest-querydsl
- spring-groovy
- spring-mobile
- spring-mustache
- spring-mvc-simple
- spring-mybatis
- spring-rest-hal-browser
- spring-rest-shell
- spring-rest-template
- spring-roo
- spring-security-stormpath
- sse-jaxrs
- static-analysis
- stripe
-
-
- wicket
- xstream
- cas/cas-secured-app
-
-
-
-
-
-
-
-
-
-
-
-
-
- jenkins/hello-world
-
-
-
- spring-boot-custom-starter/greeter
- persistence-modules/spring-boot-h2/spring-boot-h2-database
-
-
-
-
+ spring-5-data-reactive
+ -->
+
@@ -1697,22 +1276,8 @@
parent-spring-5
parent-java
parent-kotlin
- libraries
- geotools
- jhipster
- testing-modules/gatling
- spring-boot
- spring-boot-ops
- spring-5
- core-kotlin
- kotlin-libraries
- core-java
- google-web-toolkit
- spring-security-mvc-custom
- persistence-modules/hibernate5
- persistence-modules/spring-data-elasticsearch
- core-java-concurrency
- core-java-concurrency-collections
+
+
diff --git a/protobuffer/pom.xml b/protobuffer/pom.xml
index ff443a1615..d9e6cb26e4 100644
--- a/protobuffer/pom.xml
+++ b/protobuffer/pom.xml
@@ -3,7 +3,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
protobuffer
-
+ protobuffer
+
parent-modules
com.baeldung
diff --git a/reactor-core/pom.xml b/reactor-core/pom.xml
index cf720ad6ea..db9550df7b 100644
--- a/reactor-core/pom.xml
+++ b/reactor-core/pom.xml
@@ -1,11 +1,11 @@
4.0.0
-
org.baeldung
reactor-core
0.0.1-SNAPSHOT
-
+ reactor-core
+
com.baeldung
parent-modules
diff --git a/restx/README.md b/restx/README.md
new file mode 100644
index 0000000000..665f7ea82d
--- /dev/null
+++ b/restx/README.md
@@ -0,0 +1,4 @@
+# Relevant Articles
+
+* [Introduction to RESTX](https://www.baeldung.com/java-restx)
+
diff --git a/restx/data/credentials.json b/restx/data/credentials.json
new file mode 100644
index 0000000000..c1a4fcf531
--- /dev/null
+++ b/restx/data/credentials.json
@@ -0,0 +1,12 @@
+{
+ "//": "lines with // keys are just comments (we don't have real comments in json)",
+ "//": "this file stores password passed through md5+bcrypt hash",
+ "//": "you can use `restx hash md5+bcrypt {password}` shell command to get hashed passwords to put here",
+
+ "//": "to help startup with restx, there are comments with clear text passwords,",
+ "//": "which should obviously not be stored here.",
+ "user1": "$2a$10$iZluFUJShbjb1ue68bLrDuGCeJL9EMLHelVIf8u0SUbCseDOvKnoe",
+ "//": "user 1 password is 'user1-pwd'",
+ "user2": "$2a$10$oym3SYMFXf/9gGfDKKHO4eM1vWNqAZMsRZCL.BORCaP4yp5cdiCXu",
+ "//": "user 2 password is 'user2-pwd'"
+}
\ No newline at end of file
diff --git a/restx/data/users.json b/restx/data/users.json
new file mode 100644
index 0000000000..834e03c4b4
--- /dev/null
+++ b/restx/data/users.json
@@ -0,0 +1,4 @@
+[
+ {"name":"user1", "roles": ["hello"]},
+ {"name":"user2", "roles": []}
+]
\ No newline at end of file
diff --git a/restx/md.restx.json b/restx/md.restx.json
new file mode 100644
index 0000000000..c87244001c
--- /dev/null
+++ b/restx/md.restx.json
@@ -0,0 +1,38 @@
+{
+ "module": "restx-demo:restx-demo:0.1-SNAPSHOT",
+ "packaging": "war",
+
+ "properties": {
+ "java.version": "1.8",
+ "restx.version": "0.35-rc4"
+ },
+ "fragments": {
+ "maven": [
+ "classpath:///restx/build/fragments/maven/javadoc-apidoclet.xml" ]
+ },
+ "dependencies": {
+ "compile": [
+ "io.restx:restx-core:${restx.version}",
+ "io.restx:restx-security-basic:${restx.version}",
+ "io.restx:restx-core-annotation-processor:${restx.version}",
+ "io.restx:restx-factory:${restx.version}",
+ "io.restx:restx-factory-admin:${restx.version}",
+ "io.restx:restx-validation:${restx.version}",
+ "io.restx:restx-monitor-codahale:${restx.version}",
+ "io.restx:restx-monitor-admin:${restx.version}",
+ "io.restx:restx-log-admin:${restx.version}",
+ "io.restx:restx-i18n-admin:${restx.version}",
+ "io.restx:restx-stats-admin:${restx.version}",
+ "io.restx:restx-servlet:${restx.version}",
+ "io.restx:restx-server-jetty8:${restx.version}!optional",
+ "io.restx:restx-apidocs:${restx.version}",
+ "io.restx:restx-specs-admin:${restx.version}",
+ "io.restx:restx-admin:${restx.version}",
+ "ch.qos.logback:logback-classic:1.0.13"
+ ],
+ "test": [
+ "io.restx:restx-specs-tests:${restx.version}",
+ "junit:junit:4.11"
+ ]
+ }
+}
diff --git a/restx/pom.xml b/restx/pom.xml
new file mode 100644
index 0000000000..c6233b968c
--- /dev/null
+++ b/restx/pom.xml
@@ -0,0 +1,155 @@
+
+
+ 4.0.0
+
+ restx
+ 0.1-SNAPSHOT
+ war
+ restx-demo
+
+
+ 1.8
+ 1.8
+ 0.35-rc4
+
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+ io.restx
+ restx-core
+ ${restx.version}
+
+
+ io.restx
+ restx-security-basic
+ ${restx.version}
+
+
+ io.restx
+ restx-core-annotation-processor
+ ${restx.version}
+
+
+ io.restx
+ restx-factory
+ ${restx.version}
+
+
+ io.restx
+ restx-factory-admin
+ ${restx.version}
+
+
+ io.restx
+ restx-validation
+ ${restx.version}
+
+
+ io.restx
+ restx-monitor-codahale
+ ${restx.version}
+
+
+ io.restx
+ restx-monitor-admin
+ ${restx.version}
+
+
+ io.restx
+ restx-log-admin
+ ${restx.version}
+
+
+ io.restx
+ restx-i18n-admin
+ ${restx.version}
+
+
+ io.restx
+ restx-stats-admin
+ ${restx.version}
+
+
+ io.restx
+ restx-servlet
+ ${restx.version}
+
+
+ io.restx
+ restx-server-jetty8
+ ${restx.version}
+ true
+
+
+ io.restx
+ restx-apidocs
+ ${restx.version}
+
+
+ io.restx
+ restx-specs-admin
+ ${restx.version}
+
+
+ io.restx
+ restx-admin
+ ${restx.version}
+
+
+ ch.qos.logback
+ logback-classic
+ 1.0.13
+
+
+ io.restx
+ restx-specs-tests
+ ${restx.version}
+ test
+
+
+ junit
+ junit
+ 4.11
+ test
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+
+ attach-docs
+
+ prepare-package
+
+ jar
+
+
+
+
+ ${maven.compiler.source}
+ restx.apidocs.doclet.ApidocsDoclet
+
+ io.restx
+ restx-apidocs-doclet
+ ${restx.version}
+
+ -restx-target-dir ${project.basedir}/target/classes
+
+
+
+
+
diff --git a/restx/src/main/java/restx/demo/AppModule.java b/restx/src/main/java/restx/demo/AppModule.java
new file mode 100644
index 0000000000..26bc681481
--- /dev/null
+++ b/restx/src/main/java/restx/demo/AppModule.java
@@ -0,0 +1,74 @@
+package restx.demo;
+
+import restx.config.ConfigLoader;
+import restx.config.ConfigSupplier;
+import restx.factory.Provides;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Charsets;
+import com.google.common.collect.ImmutableSet;
+import restx.security.*;
+import restx.factory.Module;
+import restx.factory.Provides;
+import javax.inject.Named;
+
+import java.nio.file.Paths;
+
+@Module
+public class AppModule {
+ @Provides
+ public SignatureKey signatureKey() {
+ return new SignatureKey("restx-demo -447494532235718370 restx-demo 801c9eaf-4116-48f2-906b-e979fba72757".getBytes(Charsets.UTF_8));
+ }
+
+ @Provides
+ @Named("restx.admin.password")
+ public String restxAdminPassword() {
+ return "4780";
+ }
+
+ @Provides
+ public ConfigSupplier appConfigSupplier(ConfigLoader configLoader) {
+ // Load settings.properties in restx.demo package as a set of config entries
+ return configLoader.fromResource("restx/demo/settings");
+ }
+
+ @Provides
+ public CredentialsStrategy credentialsStrategy() {
+ return new BCryptCredentialsStrategy();
+ }
+
+ @Provides
+ public BasicPrincipalAuthenticator basicPrincipalAuthenticator(
+ SecuritySettings securitySettings, CredentialsStrategy credentialsStrategy,
+ @Named("restx.admin.passwordHash") String defaultAdminPasswordHash, ObjectMapper mapper) {
+ return new StdBasicPrincipalAuthenticator(new StdUserService<>(
+ // use file based users repository.
+ // Developer's note: prefer another storage mechanism for your users if you need real user management
+ // and better perf
+ new FileBasedUserRepository<>(
+ StdUser.class, // this is the class for the User objects, that you can get in your app code
+ // with RestxSession.current().getPrincipal().get()
+ // it can be a custom user class, it just need to be json deserializable
+ mapper,
+
+ // this is the default restx admin, useful to access the restx admin console.
+ // if one user with restx-admin role is defined in the repository, this default user won't be
+ // available anymore
+ new StdUser("admin", ImmutableSet.of("*")),
+
+ // the path where users are stored
+ Paths.get("data/users.json"),
+
+ // the path where credentials are stored. isolating both is a good practice in terms of security
+ // it is strongly recommended to follow this approach even if you use your own repository
+ Paths.get("data/credentials.json"),
+
+ // tells that we want to reload the files dynamically if they are touched.
+ // this has a performance impact, if you know your users / credentials never change without a
+ // restart you can disable this to get better perfs
+ true),
+ credentialsStrategy, defaultAdminPasswordHash),
+ securitySettings);
+ }
+}
diff --git a/restx/src/main/java/restx/demo/AppServer.java b/restx/src/main/java/restx/demo/AppServer.java
new file mode 100644
index 0000000000..d66aadac68
--- /dev/null
+++ b/restx/src/main/java/restx/demo/AppServer.java
@@ -0,0 +1,32 @@
+package restx.demo;
+
+import com.google.common.base.Optional;
+import restx.server.WebServer;
+import restx.server.Jetty8WebServer;
+
+/**
+ * This class can be used to run the app.
+ *
+ * Alternatively, you can deploy the app as a war in a regular container like tomcat or jetty.
+ *
+ * Reading the port from system env PORT makes it compatible with heroku.
+ */
+public class AppServer {
+ public static final String WEB_INF_LOCATION = "src/main/webapp/WEB-INF/web.xml";
+ public static final String WEB_APP_LOCATION = "src/main/webapp";
+
+ public static void main(String[] args) throws Exception {
+ int port = Integer.valueOf(Optional.fromNullable(System.getenv("PORT")).or("8080"));
+ WebServer server = new Jetty8WebServer(WEB_INF_LOCATION, WEB_APP_LOCATION, port, "0.0.0.0");
+
+ /*
+ * load mode from system property if defined, or default to dev
+ * be careful with that setting, if you use this class to launch your server in production, make sure to launch
+ * it with -Drestx.mode=prod or change the default here
+ */
+ System.setProperty("restx.mode", System.getProperty("restx.mode", "dev"));
+ System.setProperty("restx.app.package", "restx.demo");
+
+ server.startAndAwait();
+ }
+}
diff --git a/restx/src/main/java/restx/demo/Roles.java b/restx/src/main/java/restx/demo/Roles.java
new file mode 100644
index 0000000000..1240da70d1
--- /dev/null
+++ b/restx/src/main/java/restx/demo/Roles.java
@@ -0,0 +1,10 @@
+package restx.demo;
+
+/**
+ * A list of roles for the application.
+ *
+ * We don't use an enum here because it must be used inside an annotation.
+ */
+public final class Roles {
+ public static final String HELLO_ROLE = "hello";
+}
diff --git a/restx/src/main/java/restx/demo/domain/Message.java b/restx/src/main/java/restx/demo/domain/Message.java
new file mode 100644
index 0000000000..733c00deff
--- /dev/null
+++ b/restx/src/main/java/restx/demo/domain/Message.java
@@ -0,0 +1,21 @@
+package restx.demo.domain;
+
+public class Message {
+ private String message;
+
+ public String getMessage() {
+ return message;
+ }
+
+ public Message setMessage(final String message) {
+ this.message = message;
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return "Message{" +
+ "message='" + message + '\'' +
+ '}';
+ }
+}
diff --git a/restx/src/main/java/restx/demo/rest/HelloResource.java b/restx/src/main/java/restx/demo/rest/HelloResource.java
new file mode 100644
index 0000000000..5cb2c2a5e6
--- /dev/null
+++ b/restx/src/main/java/restx/demo/rest/HelloResource.java
@@ -0,0 +1,62 @@
+package restx.demo.rest;
+
+import restx.demo.domain.Message;
+import restx.demo.Roles;
+import org.joda.time.DateTime;
+import restx.annotations.GET;
+import restx.annotations.POST;
+import restx.annotations.RestxResource;
+import restx.factory.Component;
+import restx.security.PermitAll;
+import restx.security.RolesAllowed;
+import restx.security.RestxSession;
+
+import javax.validation.constraints.NotNull;
+
+@Component @RestxResource
+public class HelloResource {
+
+ /**
+ * Say hello to currently logged in user.
+ *
+ * Authorized only for principals with Roles.HELLO_ROLE role.
+ *
+ * @return a Message to say hello
+ */
+ @GET("/message")
+ @RolesAllowed(Roles.HELLO_ROLE)
+ public Message sayHello() {
+ return new Message().setMessage(String.format(
+ "hello %s, it's %s",
+ RestxSession.current().getPrincipal().get().getName(),
+ DateTime.now().toString("HH:mm:ss")));
+ }
+
+ /**
+ * Say hello to anybody.
+ *
+ * Does not require authentication.
+ *
+ * @return a Message to say hello
+ */
+ @GET("/hello")
+ @PermitAll
+ public Message helloPublic(String who) {
+ return new Message().setMessage(String.format(
+ "hello %s, it's %s",
+ who, DateTime.now().toString("HH:mm:ss")));
+ }
+
+ public static class MyPOJO {
+ @NotNull
+ String value;
+ public String getValue(){ return value; }
+ public void setValue(String value){ this.value = value; }
+ }
+ @POST("/mypojo")
+ @PermitAll
+ public MyPOJO helloPojo(MyPOJO pojo){
+ pojo.setValue("hello "+pojo.getValue());
+ return pojo;
+ }
+}
diff --git a/restx/src/main/resources/logback.xml b/restx/src/main/resources/logback.xml
new file mode 100644
index 0000000000..524bca6b1f
--- /dev/null
+++ b/restx/src/main/resources/logback.xml
@@ -0,0 +1,94 @@
+
+
+ true
+
+
+
+
+ ${LOGS_FOLDER}/errors.log
+
+ ERROR
+
+
+ %d [%-16thread] [%-10X{principal}] %-5level %logger{36} - %msg%n
+
+
+ ${LOGS_FOLDER}/errors.%d.log
+ 30
+
+
+
+
+
+
+
+ ${LOGS_FOLDER}/app.log
+
+ INFO
+
+
+ %d [%-16thread] [%-10X{principal}] %-5level %logger{36} - %msg%n
+
+
+ ${LOGS_FOLDER}/app.%d.log
+ 10
+
+
+
+ ${LOGS_FOLDER}/debug.log
+
+ %d [%-16thread] [%-10X{principal}] %-5level %logger{36} - %msg%n
+
+
+ ${LOGS_FOLDER}/debug.%i.log.zip
+ 1
+ 3
+
+
+
+ 50MB
+
+
+
+
+
+
+
+
+
+
+
+ %d [%-16thread] [%-10X{principal}] %-5level %logger{36} - %msg%n
+
+
+
+ ${LOGS_FOLDER}/app.log
+
+ %d [%-16thread] [%-10X{principal}] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/restx/src/main/resources/restx/demo/settings.properties b/restx/src/main/resources/restx/demo/settings.properties
new file mode 100644
index 0000000000..a03c2eea97
--- /dev/null
+++ b/restx/src/main/resources/restx/demo/settings.properties
@@ -0,0 +1 @@
+app.name=restx-demo
\ No newline at end of file
diff --git a/restx/src/main/webapp/WEB-INF/web.xml b/restx/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..c651794526
--- /dev/null
+++ b/restx/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,15 @@
+
+
+
+ restx
+ restx.servlet.RestxMainRouterServlet
+ 1
+
+
+ restx
+ /api/*
+
+
diff --git a/restx/src/test/java/restx/demo/rest/HelloResourceSpecUnitTest.java b/restx/src/test/java/restx/demo/rest/HelloResourceSpecUnitTest.java
new file mode 100644
index 0000000000..f67e4565b3
--- /dev/null
+++ b/restx/src/test/java/restx/demo/rest/HelloResourceSpecUnitTest.java
@@ -0,0 +1,23 @@
+package restx.demo.rest;
+
+import org.junit.runner.RunWith;
+
+import restx.tests.FindSpecsIn;
+import restx.tests.RestxSpecTestsRunner;
+
+@RunWith(RestxSpecTestsRunner.class)
+@FindSpecsIn("specs/hello")
+public class HelloResourceSpecUnitTest {
+
+ /**
+ * Useless, thanks to both @RunWith(RestxSpecTestsRunner.class) & @FindSpecsIn()
+ *
+ * @Rule
+ * public RestxSpecRule rule = new RestxSpecRule();
+ *
+ * @Test
+ * public void test_spec() throws Exception {
+ * rule.runTest(specTestPath);
+ * }
+ */
+}
diff --git a/restx/src/test/resources/specs/hello/should_admin_say_hello.spec.yaml b/restx/src/test/resources/specs/hello/should_admin_say_hello.spec.yaml
new file mode 100644
index 0000000000..1b7b8f0f90
--- /dev/null
+++ b/restx/src/test/resources/specs/hello/should_admin_say_hello.spec.yaml
@@ -0,0 +1,10 @@
+title: should admin say hello
+given:
+ - time: 2013-08-28T01:18:00.822+02:00
+ - uuids: [ "e2b4430f-9541-4602-9a3a-413d17c56a6b" ]
+wts:
+ - when: |
+ GET message
+ $RestxSession: {"_expires":"2013-09-27T01:18:00.822+02:00","principal":"admin","sessionKey":"e2b4430f-9541-4602-9a3a-413d17c56a6b"}
+ then: |
+ {"message":"hello admin, it's 01:18:00"}
diff --git a/restx/src/test/resources/specs/hello/should_anyone_say_hello.spec.yaml b/restx/src/test/resources/specs/hello/should_anyone_say_hello.spec.yaml
new file mode 100644
index 0000000000..29b6faca34
--- /dev/null
+++ b/restx/src/test/resources/specs/hello/should_anyone_say_hello.spec.yaml
@@ -0,0 +1,8 @@
+title: should admin say hello
+given:
+ - time: 2013-08-28T01:18:00.822+02:00
+wts:
+ - when: |
+ GET hello?who=xavier
+ then: |
+ {"message":"hello xavier, it's 01:18:00"}
diff --git a/restx/src/test/resources/specs/hello/should_missing_value_triggers_validation_error.spec.yaml b/restx/src/test/resources/specs/hello/should_missing_value_triggers_validation_error.spec.yaml
new file mode 100644
index 0000000000..d0c6323caf
--- /dev/null
+++ b/restx/src/test/resources/specs/hello/should_missing_value_triggers_validation_error.spec.yaml
@@ -0,0 +1,17 @@
+title: should missing post value triggers a validation error
+given:
+ - time: 2013-08-28T01:18:00.822+02:00
+ - uuids: [ "e2b4430f-9541-4602-9a3a-413d17c56a6b" ]
+wts:
+ - when: |
+ POST mypojo
+ $RestxSession: {"_expires":"2013-09-27T01:18:00.822+02:00","principal":"user1","sessionKey":"e2b4430f-9541-4602-9a3a-413d17c56a6b"}
+ {}
+ then: |
+ 400
+ - when: |
+ POST mypojo
+ $RestxSession: {"_expires":"2013-09-27T01:18:00.822+02:00","principal":"user1","sessionKey":"e2b4430f-9541-4602-9a3a-413d17c56a6b"}
+ {"value":"world"}
+ then: |
+ {"value":"hello world"}
diff --git a/restx/src/test/resources/specs/hello/should_user1_say_hello.spec.yaml b/restx/src/test/resources/specs/hello/should_user1_say_hello.spec.yaml
new file mode 100644
index 0000000000..791a3a2776
--- /dev/null
+++ b/restx/src/test/resources/specs/hello/should_user1_say_hello.spec.yaml
@@ -0,0 +1,10 @@
+title: should user1 say hello
+given:
+ - time: 2013-08-28T01:18:00.822+02:00
+ - uuids: [ "e2b4430f-9541-4602-9a3a-413d17c56a6b" ]
+wts:
+ - when: |
+ GET message
+ $RestxSession: {"_expires":"2013-09-27T01:18:00.822+02:00","principal":"user1","sessionKey":"e2b4430f-9541-4602-9a3a-413d17c56a6b"}
+ then: |
+ {"message":"hello user1, it's 01:18:00"}
diff --git a/restx/src/test/resources/specs/hello/should_user2_not_say_hello.spec.yaml b/restx/src/test/resources/specs/hello/should_user2_not_say_hello.spec.yaml
new file mode 100644
index 0000000000..ead5af8d0c
--- /dev/null
+++ b/restx/src/test/resources/specs/hello/should_user2_not_say_hello.spec.yaml
@@ -0,0 +1,10 @@
+title: should user2 not say hello
+given:
+ - time: 2013-08-28T01:19:44.770+02:00
+ - uuids: [ "56f71fcc-42d3-422f-9458-8ad37fc4a0b5" ]
+wts:
+ - when: |
+ GET message
+ $RestxSession: {"_expires":"2013-09-27T01:19:44.770+02:00","principal":"user2","sessionKey":"56f71fcc-42d3-422f-9458-8ad37fc4a0b5"}
+ then: |
+ 403
diff --git a/rxjava-2/pom.xml b/rxjava-2/pom.xml
index a18b096b6d..3b4c167f3a 100644
--- a/rxjava-2/pom.xml
+++ b/rxjava-2/pom.xml
@@ -2,10 +2,10 @@
4.0.0
-
rxjava-2
1.0-SNAPSHOT
-
+ rxjava-2
+
com.baeldung
parent-java
diff --git a/rxjava/pom.xml b/rxjava/pom.xml
index b316001d87..596a5196da 100644
--- a/rxjava/pom.xml
+++ b/rxjava/pom.xml
@@ -2,10 +2,10 @@
4.0.0
-
rxjava
1.0-SNAPSHOT
-
+ rxjava
+
com.baeldung
parent-java
diff --git a/spring-5-data-reactive/pom.xml b/spring-5-data-reactive/pom.xml
index 5c723c6e29..aa73cf11ae 100644
--- a/spring-5-data-reactive/pom.xml
+++ b/spring-5-data-reactive/pom.xml
@@ -3,6 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
spring-5-data-reactive
+ spring-5-data-reactive
jar
diff --git a/spring-5-reactive/README.md b/spring-5-reactive/README.md
index 267925b798..fc898a56dc 100644
--- a/spring-5-reactive/README.md
+++ b/spring-5-reactive/README.md
@@ -16,3 +16,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [Server-Sent Events in Spring](https://www.baeldung.com/spring-server-sent-events)
- [A Guide to Spring Session Reactive Support: WebSession](https://www.baeldung.com/spring-session-reactive)
- [Validation for Functional Endpoints in Spring 5](https://www.baeldung.com/spring-functional-endpoints-validation)
+- [Logging a Reactive Sequence](https://www.baeldung.com/spring-reactive-sequence-logging)
+
diff --git a/logging-modules/log4j/src/main/java/com/baeldung/webFluxLogging/WebFluxLoggingExample.java b/spring-5-reactive/src/main/java/com/baeldung/webflux/logging/WebFluxLoggingExample.java
similarity index 91%
rename from logging-modules/log4j/src/main/java/com/baeldung/webFluxLogging/WebFluxLoggingExample.java
rename to spring-5-reactive/src/main/java/com/baeldung/webflux/logging/WebFluxLoggingExample.java
index f429fd57f3..c4881b2296 100644
--- a/logging-modules/log4j/src/main/java/com/baeldung/webFluxLogging/WebFluxLoggingExample.java
+++ b/spring-5-reactive/src/main/java/com/baeldung/webflux/logging/WebFluxLoggingExample.java
@@ -1,4 +1,4 @@
-package com.baeldung.webFluxLogging;
+package com.baeldung.webflux.logging;
import reactor.core.publisher.Flux;
diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/CustomRequestSecurityConfig.java b/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/CustomRequestSecurityConfig.java
index 51caee8178..2aba5a82ac 100644
--- a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/CustomRequestSecurityConfig.java
+++ b/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/CustomRequestSecurityConfig.java
@@ -115,5 +115,4 @@ public class CustomRequestSecurityConfig extends WebSecurityConfigurerAdapter {
}
return null;
}
-
}
diff --git a/spring-amqp-simple/pom.xml b/spring-amqp-simple/pom.xml
index ea9c227d8c..57d84acee6 100644
--- a/spring-amqp-simple/pom.xml
+++ b/spring-amqp-simple/pom.xml
@@ -5,6 +5,7 @@
com.baeldung
spring-amqp-simple
1.0.0-SNAPSHOT
+ spring-amqp-simple
parent-boot-1
diff --git a/spring-boot-admin/pom.xml b/spring-boot-admin/pom.xml
index 58cea728cc..23852dee57 100644
--- a/spring-boot-admin/pom.xml
+++ b/spring-boot-admin/pom.xml
@@ -3,6 +3,7 @@
4.0.0
spring-boot-admin
0.0.1-SNAPSHOT
+ spring-boot-admin
pom
diff --git a/spring-boot-autoconfiguration/pom.xml b/spring-boot-autoconfiguration/pom.xml
index b88587f731..1c3d8796ed 100644
--- a/spring-boot-autoconfiguration/pom.xml
+++ b/spring-boot-autoconfiguration/pom.xml
@@ -5,7 +5,7 @@
spring-boot-autoconfiguration
0.0.1-SNAPSHOT
war
- spring-boot-auto-configuration
+ spring-boot-autoconfiguration
This is simple boot application demonstrating a custom auto-configuration
diff --git a/spring-boot-camel/pom.xml b/spring-boot-camel/pom.xml
index 19a0bec809..8bab0ed5c8 100644
--- a/spring-boot-camel/pom.xml
+++ b/spring-boot-camel/pom.xml
@@ -5,7 +5,8 @@
com.example
spring-boot-camel
0.0.1-SNAPSHOT
-
+ spring-boot-camel
+
com.baeldung
parent-modules
diff --git a/spring-boot-crud/pom.xml b/spring-boot-crud/pom.xml
index f803a7e70b..749bf9cb5a 100644
--- a/spring-boot-crud/pom.xml
+++ b/spring-boot-crud/pom.xml
@@ -3,10 +3,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4.0.0
-
com.baeldung.spring-boot-crud
spring-boot-crud
0.1.0
+ spring-boot-crud
org.springframework.boot
diff --git a/spring-boot-crud/src/main/java/com/baeldung/crud/Application.java b/spring-boot-crud/src/main/java/com/baeldung/crud/Application.java
index 436cccb964..0b686e90e9 100644
--- a/spring-boot-crud/src/main/java/com/baeldung/crud/Application.java
+++ b/spring-boot-crud/src/main/java/com/baeldung/crud/Application.java
@@ -14,11 +14,10 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableJpaRepositories(basePackages="com.baeldung.crud.repositories")
@EnableTransactionManagement
@EntityScan(basePackages="com.baeldung.crud.entities")
-
-@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
+
}
diff --git a/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java b/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java
index 1b7185c2fd..9a6cb477aa 100644
--- a/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java
+++ b/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java
@@ -1,8 +1,7 @@
package com.baeldung.crud.controllers;
-import com.baeldung.crud.UserRepository;
-import com.baeldung.crud.entities.User;
import javax.validation.Valid;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@@ -11,6 +10,9 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
+import com.baeldung.crud.entities.User;
+import com.baeldung.crud.repositories.UserRepository;
+
@Controller
public class UserController {
diff --git a/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java b/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java
index 7773a962fb..2de0828ae5 100644
--- a/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java
+++ b/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java
@@ -1,16 +1,18 @@
package com.baeldung.crud;
-import com.baeldung.crud.UserController;
-import com.baeldung.crud.entities.User;
-import com.baeldung.crud.UserRepository;
import static org.assertj.core.api.Assertions.assertThat;
-import org.junit.BeforeClass;
-import org.junit.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
+import com.baeldung.crud.controllers.UserController;
+import com.baeldung.crud.entities.User;
+import com.baeldung.crud.repositories.UserRepository;
+
public class UserControllerUnitTest {
private static UserController userController;
diff --git a/spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java b/spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java
index a3c6a922d8..565f6727c3 100644
--- a/spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java
+++ b/spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java
@@ -1,9 +1,11 @@
package com.baeldung.crud;
-import com.baeldung.crud.User;
import static org.assertj.core.api.Assertions.assertThat;
+
import org.junit.Test;
+import com.baeldung.crud.entities.User;
+
public class UserUnitTest {
@Test
diff --git a/spring-boot-ctx-fluent/pom.xml b/spring-boot-ctx-fluent/pom.xml
index f9b691aea7..b238374612 100644
--- a/spring-boot-ctx-fluent/pom.xml
+++ b/spring-boot-ctx-fluent/pom.xml
@@ -1,10 +1,10 @@
4.0.0
-
com.baeldung
spring-boot-ctx-fluent
0.0.1-SNAPSHOT
+ spring-boot-ctx-fluent
jar
diff --git a/spring-boot-custom-starter/greeter-library/pom.xml b/spring-boot-custom-starter/greeter-library/pom.xml
index 3717ba005c..7e0c5c4d22 100644
--- a/spring-boot-custom-starter/greeter-library/pom.xml
+++ b/spring-boot-custom-starter/greeter-library/pom.xml
@@ -1,10 +1,11 @@
4.0.0
-
com.baeldung
greeter-library
0.0.1-SNAPSHOT
+ greeter-library
+
spring-boot-custom-starter
com.baeldung
diff --git a/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml b/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml
index 5862bdd6c8..1e4ee698c6 100644
--- a/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml
+++ b/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml
@@ -1,10 +1,10 @@
4.0.0
-
com.baeldung
greeter-spring-boot-autoconfigure
0.0.1-SNAPSHOT
+ greeter-spring-boot-autoconfigure
spring-boot-custom-starter
diff --git a/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml b/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml
index 88c5d1caf5..91cc41d669 100644
--- a/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml
+++ b/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml
@@ -1,10 +1,10 @@
4.0.0
-
com.baeldung
greeter-spring-boot-sample-app
0.0.1-SNAPSHOT
+ greeter-spring-boot-sample-app