diff --git a/blade/pom.xml b/blade/pom.xml
index 6d73913e25..f463c7f077 100644
--- a/blade/pom.xml
+++ b/blade/pom.xml
@@ -106,7 +106,7 @@
java
-jar
- sample-blade-app.jar
+ blade.jar
diff --git a/core-java-modules/core-java-arrays-3/README.md b/core-java-modules/core-java-arrays-3/README.md
new file mode 100644
index 0000000000..9f2885a2ce
--- /dev/null
+++ b/core-java-modules/core-java-arrays-3/README.md
@@ -0,0 +1,5 @@
+## Core Java Arrays (Part 3)
+
+This module contains articles about Java arrays
+
+## Relevant Articles
diff --git a/core-java-modules/core-java-arrays-3/pom.xml b/core-java-modules/core-java-arrays-3/pom.xml
new file mode 100644
index 0000000000..516d9b2b37
--- /dev/null
+++ b/core-java-modules/core-java-arrays-3/pom.xml
@@ -0,0 +1,31 @@
+
+
+ 4.0.0
+ core-java-arrays-3
+ 0.1.0-SNAPSHOT
+ core-java-arrays-3
+ jar
+
+
+ com.baeldung
+ parent-java
+ 0.0.1-SNAPSHOT
+ ../../parent-java
+
+
+
+
+ org.assertj
+ assertj-core
+ ${assertj.version}
+ test
+
+
+
+
+ 3.14.0
+
+
+
\ No newline at end of file
diff --git a/core-java-modules/core-java-arrays-3/src/test/java/com/baeldung/arrays/deepequals/ArraysDeepEqualsUnitTest.java b/core-java-modules/core-java-arrays-3/src/test/java/com/baeldung/arrays/deepequals/ArraysDeepEqualsUnitTest.java
new file mode 100644
index 0000000000..a9b8ed7e3f
--- /dev/null
+++ b/core-java-modules/core-java-arrays-3/src/test/java/com/baeldung/arrays/deepequals/ArraysDeepEqualsUnitTest.java
@@ -0,0 +1,96 @@
+package com.baeldung.arrays.deepequals;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Objects;
+import org.junit.jupiter.api.Test;
+
+public class ArraysDeepEqualsUnitTest {
+
+ class Person {
+ private int id;
+ private String name;
+ private int age;
+
+ Person(int id, String name, int age) {
+ this.id = id;
+ this.name = name;
+ this.age = age;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj instanceof Person))
+ return false;
+ Person person = (Person) obj;
+ return id == person.id && name.equals(person.name) && age == person.age;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, name, age);
+ }
+ }
+
+ @Test
+ void givenTwoUnidimensionalObjectTypeArrays_whenUsingEqualsAndDeepEquals_thenBothShouldReturnTrue() {
+ Object[] anArray = new Object[] { "string1", "string2", "string3" };
+ Object[] anotherArray = new Object[] { "string1", "string2", "string3" };
+
+ assertTrue(Arrays.equals(anArray, anotherArray));
+ assertTrue(Arrays.deepEquals(anArray, anotherArray));
+ }
+
+ @Test
+ void givenTwoUnidimensionalObjectTypeArraysWithNullElements_whenUsingEqualsAndDeepEquals_thenBothShouldReturnTrue() {
+ Object[] anArray = new Object[] { "string1", null, "string3" };
+ Object[] anotherArray = new Object[] { "string1", null, "string3" };
+
+ assertTrue(Arrays.equals(anArray, anotherArray));
+ assertTrue(Arrays.deepEquals(anArray, anotherArray));
+ }
+
+ @Test
+ void givenTwoUnidimensionalObjectTypeArraysWithNestedElements_whenUsingEqualsAndDeepEquals_thenShouldReturnDifferently() {
+ Object[] anArray = new Object[] { "string1", null, new String[] { "nestedString1", "nestedString2" } };
+ Object[] anotherArray = new Object[] { "string1", null, new String[] { "nestedString1", "nestedString2" } };
+
+ assertFalse(Arrays.equals(anArray, anotherArray));
+ assertTrue(Arrays.deepEquals(anArray, anotherArray));
+ }
+
+ @Test
+ void givenTwoMultidimensionalPrimitiveTypeArrays_whenUsingEqualsAndDeepEquals_thenBothShouldReturnDifferently() {
+ int[][] anArray = { { 1, 2, 3 }, { 4, 5, 6, 9 }, { 7 } };
+ int[][] anotherArray = { { 1, 2, 3 }, { 4, 5, 6, 9 }, { 7 } };
+
+ assertFalse(Arrays.equals(anArray, anotherArray));
+ assertTrue(Arrays.deepEquals(anArray, anotherArray));
+ }
+
+ @Test
+ void givenTwoMultidimensionalObjectTypeArrays_whenUsingEqualsAndDeepEquals_thenBothShouldReturnDifferently() {
+ Person personArray1[][] = { { new Person(1, "John", 22), new Person(2, "Mike", 23) }, { new Person(3, "Steve", 27), new Person(4, "Gary", 28) } };
+ Person personArray2[][] = { { new Person(1, "John", 22), new Person(2, "Mike", 23) }, { new Person(3, "Steve", 27), new Person(4, "Gary", 28) } };
+
+ assertFalse(Arrays.equals(personArray1, personArray2));
+ assertTrue(Arrays.deepEquals(personArray1, personArray2));
+ }
+
+ @Test
+ void givenTwoMultidimensionalObjectTypeArrays_whenUsingDeepEqualsFromObjectsAndArraysClasses_thenBothShouldReturnTrue() {
+ Person personArray1[][] = { { new Person(1, "John", 22), new Person(2, "Mike", 23) }, { new Person(3, "Steve", 27), new Person(4, "Gary", 28) } };
+ Person personArray2[][] = { { new Person(1, "John", 22), new Person(2, "Mike", 23) }, { new Person(3, "Steve", 27), new Person(4, "Gary", 28) } };
+
+ assertTrue(Objects.deepEquals(personArray1, personArray2));
+ assertTrue(Arrays.deepEquals(personArray1, personArray2));
+ }
+}
diff --git a/core-java-modules/core-java-io/src/test/java/com/baeldung/readfile/FileOperationsManualTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/readfile/FileOperationsManualTest.java
deleted file mode 100644
index b837c6b4dd..0000000000
--- a/core-java-modules/core-java-io/src/test/java/com/baeldung/readfile/FileOperationsManualTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package com.baeldung.readfile;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.Matchers;
-import org.junit.Test;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
-public class FileOperationsManualTest {
-
- @Test
- public void givenFileName_whenUsingClassloader_thenFileData() throws IOException {
- String expectedData = "Hello World from fileTest.txt!!!";
-
- ClassLoader classLoader = getClass().getClassLoader();
- File file = new File(classLoader.getResource("fileTest.txt").getFile());
- InputStream inputStream = new FileInputStream(file);
- String data = readFromInputStream(inputStream);
-
- assertEquals(expectedData, data.trim());
- }
-
- @Test
- public void givenFileNameAsAbsolutePath_whenUsingClasspath_thenFileData() throws IOException {
- String expectedData = "Hello World from fileTest.txt!!!";
-
- Class clazz = FileOperationsManualTest.class;
- InputStream inputStream = clazz.getResourceAsStream("/fileTest.txt");
- String data = readFromInputStream(inputStream);
-
- assertEquals(expectedData, data.trim());
- }
-
- @Test
- public void givenFileName_whenUsingJarFile_thenFileData() throws IOException {
- String expectedData = "MIT License";
-
- Class clazz = Matchers.class;
- InputStream inputStream = clazz.getResourceAsStream("/LICENSE.txt");
- String data = readFromInputStream(inputStream);
-
- assertThat(data.trim(), CoreMatchers.containsString(expectedData));
- }
-
- @Test
- public void givenURLName_whenUsingURL_thenFileData() throws IOException {
- String expectedData = "Example Domain";
-
- URL urlObject = new URL("http://www.example.com/");
-
- URLConnection urlConnection = urlObject.openConnection();
-
- InputStream inputStream = urlConnection.getInputStream();
- String data = readFromInputStream(inputStream);
-
- assertThat(data.trim(), CoreMatchers.containsString(expectedData));
- }
-
- @Test
- public void givenFileName_whenUsingFileUtils_thenFileData() throws IOException {
- String expectedData = "Hello World from fileTest.txt!!!";
-
- ClassLoader classLoader = getClass().getClassLoader();
- File file = new File(classLoader.getResource("fileTest.txt").getFile());
- String data = FileUtils.readFileToString(file, "UTF-8");
-
- assertEquals(expectedData, data.trim());
- }
-
- @Test
- public void givenFilePath_whenUsingFilesReadAllBytes_thenFileData() throws IOException, URISyntaxException {
- String expectedData = "Hello World from fileTest.txt!!!";
-
- Path path = Paths.get(getClass().getClassLoader().getResource("fileTest.txt").toURI());
-
- byte[] fileBytes = Files.readAllBytes(path);
- String data = new String(fileBytes);
-
- assertEquals(expectedData, data.trim());
- }
-
- @Test
- public void givenFilePath_whenUsingFilesLines_thenFileData() throws IOException, URISyntaxException {
- String expectedData = "Hello World from fileTest.txt!!!";
-
- Path path = Paths.get(getClass().getClassLoader().getResource("fileTest.txt").toURI());
-
- Stream lines = Files.lines(path);
- String data = lines.collect(Collectors.joining("\n"));
- lines.close();
-
- assertEquals(expectedData, data.trim());
- }
-
- private String readFromInputStream(InputStream inputStream) throws IOException {
- StringBuilder resultStringBuilder = new StringBuilder();
- try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) {
- String line;
- while ((line = bufferedReader.readLine()) != null) {
- resultStringBuilder.append(line).append("\n");
- }
- }
-
- return resultStringBuilder.toString();
- }
-
- @Test
- public void givenFileName_whenUsingIOUtils_thenFileData() throws IOException {
- String expectedData = "This is a content of the file";
-
- FileInputStream fis = new FileInputStream("src/test/resources/fileToRead.txt");
- String data = IOUtils.toString(fis, "UTF-8");
-
- assertEquals(expectedData, data.trim());
- }
-}
\ No newline at end of file
diff --git a/core-java-modules/core-java-io/src/test/java/com/baeldung/readfile/JavaReadFromFileUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/readfile/JavaReadFromFileUnitTest.java
index a4ccaad594..aa37a22e1f 100644
--- a/core-java-modules/core-java-io/src/test/java/com/baeldung/readfile/JavaReadFromFileUnitTest.java
+++ b/core-java-modules/core-java-io/src/test/java/com/baeldung/readfile/JavaReadFromFileUnitTest.java
@@ -1,11 +1,15 @@
package com.baeldung.readfile;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.Matchers;
import org.junit.Test;
-import org.junit.Ignore;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.io.*;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
@@ -13,55 +17,148 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Scanner;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class JavaReadFromFileUnitTest {
- private static final Logger LOG = LoggerFactory.getLogger(JavaReadFromFileUnitTest.class);
-
@Test
public void whenReadWithBufferedReader_thenCorrect() throws IOException {
- final String expected_value = "Hello world";
+ final String expected_value = "Hello, world!";
- final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/test_read.in"));
+ final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/fileTest.txt"));
final String currentLine = reader.readLine();
reader.close();
assertEquals(expected_value, currentLine);
}
+ @Test
+ public void givenFileName_whenUsingClassloader_thenFileData() throws IOException {
+ String expectedData = "Hello, world!";
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ File file = new File(classLoader.getResource("fileTest.txt").getFile());
+ InputStream inputStream = new FileInputStream(file);
+ String data = readFromInputStream(inputStream);
+
+ assertEquals(expectedData, data.trim());
+ }
+
+ @Test
+ public void givenFileNameAsAbsolutePath_whenUsingClasspath_thenFileData() throws IOException {
+ String expectedData = "Hello, world!";
+
+ Class clazz = JavaReadFromFileUnitTest.class;
+ InputStream inputStream = clazz.getResourceAsStream("/fileTest.txt");
+ String data = readFromInputStream(inputStream);
+
+ assertEquals(expectedData, data.trim());
+ }
+
+ @Test
+ public void givenFileName_whenUsingJarFile_thenFileData() throws IOException {
+ String expectedData = "BSD License";
+
+ Class clazz = Matchers.class;
+ InputStream inputStream = clazz.getResourceAsStream("/LICENSE.txt");
+ String data = readFromInputStream(inputStream);
+
+ assertThat(data.trim(), CoreMatchers.containsString(expectedData));
+ }
+
+ @Test
+ public void givenURLName_whenUsingURL_thenFileData() throws IOException {
+ String expectedData = "Example Domain";
+
+ URL urlObject = new URL("http://www.example.com/");
+
+ URLConnection urlConnection = urlObject.openConnection();
+
+ InputStream inputStream = urlConnection.getInputStream();
+ String data = readFromInputStream(inputStream);
+
+ assertThat(data.trim(), CoreMatchers.containsString(expectedData));
+ }
+
+ @Test
+ public void givenFileName_whenUsingFileUtils_thenFileData() throws IOException {
+ String expectedData = "Hello, world!";
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ File file = new File(classLoader.getResource("fileTest.txt").getFile());
+ String data = FileUtils.readFileToString(file, "UTF-8");
+
+ assertEquals(expectedData, data.trim());
+ }
+
+ @Test
+ public void givenFilePath_whenUsingFilesReadAllBytes_thenFileData() throws IOException, URISyntaxException {
+ String expectedData = "Hello, world!";
+
+ Path path = Paths.get(getClass().getClassLoader().getResource("fileTest.txt").toURI());
+
+ byte[] fileBytes = Files.readAllBytes(path);
+ String data = new String(fileBytes);
+
+ assertEquals(expectedData, data.trim());
+ }
+
+ @Test
+ public void givenFilePath_whenUsingFilesLines_thenFileData() throws IOException, URISyntaxException {
+ String expectedData = "Hello, world!";
+
+ Path path = Paths.get(getClass().getClassLoader().getResource("fileTest.txt").toURI());
+
+ Stream lines = Files.lines(path);
+ String data = lines.collect(Collectors.joining("\n"));
+ lines.close();
+
+ assertEquals(expectedData, data.trim());
+ }
+
+ @Test
+ public void givenFileName_whenUsingIOUtils_thenFileData() throws IOException {
+ String expectedData = "Hello, world!";
+
+ FileInputStream fis = new FileInputStream("src/test/resources/fileTest.txt");
+ String data = IOUtils.toString(fis, "UTF-8");
+
+ assertEquals(expectedData, data.trim());
+ }
+
@Test
public void whenReadWithScanner_thenCorrect() throws IOException {
- final Scanner scanner = new Scanner(new File("src/test/resources/test_read1.in"));
+ final Scanner scanner = new Scanner(new File("src/test/resources/fileTest.txt"));
scanner.useDelimiter(" ");
assertTrue(scanner.hasNext());
- assertEquals("Hello", scanner.next());
- assertEquals("world", scanner.next());
- assertEquals(1, scanner.nextInt());
+ assertEquals("Hello,", scanner.next());
+ assertEquals("world!", scanner.next());
scanner.close();
-
}
@Test
public void whenReadWithScannerTwoDelimiters_thenCorrect() throws IOException {
- final Scanner scanner = new Scanner(new File("src/test/resources/test_read2.in"));
- scanner.useDelimiter(",| ");
+ final Scanner scanner = new Scanner(new File("src/test/resources/fileTest.txt"));
+ scanner.useDelimiter("\\s|,");
- assertTrue(scanner.hasNextInt());
- assertEquals(2, scanner.nextInt());
- assertEquals(3, scanner.nextInt());
- assertEquals(4, scanner.nextInt());
+ assertTrue(scanner.hasNext());
+ assertEquals("Hello", scanner.next());
+ assertEquals("", scanner.next());
+ assertEquals("world!", scanner.next());
scanner.close();
}
@Test
public void whenReadWithStreamTokenizer_thenCorrectTokens() throws IOException {
- final FileReader reader = new FileReader("src/test/resources/test_read3.in");
+ final FileReader reader = new FileReader("src/test/resources/fileTestTokenizer.txt");
final StreamTokenizer tokenizer = new StreamTokenizer(reader);
tokenizer.nextToken();
@@ -78,49 +175,36 @@ public class JavaReadFromFileUnitTest {
@Test
public void whenReadWithDataInputStream_thenCorrect() throws IOException {
- final String expected_value = "Hello";
+ String expectedValue = "Hello, world!";
+ String file ="src/test/resources/fileTest.txt";
- String result;
- final DataInputStream reader = new DataInputStream(new FileInputStream("src/test/resources/test_read4.in"));
- result = reader.readUTF();
- reader.close();
+ String result = null;
- assertEquals(expected_value, result);
- }
+ DataInputStream reader = new DataInputStream(new FileInputStream(file));
+ int nBytesToRead = reader.available();
+ if(nBytesToRead > 0) {
+ byte[] bytes = new byte[nBytesToRead];
+ reader.read(bytes);
+ result = new String(bytes);
+ }
- public void whenReadTwoFilesWithSequenceInputStream_thenCorrect() throws IOException {
- final int expected_value1 = 2000;
- final int expected_value2 = 5000;
-
- final FileInputStream stream1 = new FileInputStream("src/test/resources/test_read5.in");
- final FileInputStream stream2 = new FileInputStream("src/test/resources/test_read6.in");
-
- final SequenceInputStream sequence = new SequenceInputStream(stream1, stream2);
- final DataInputStream reader = new DataInputStream(sequence);
-
- assertEquals(expected_value1, reader.readInt());
- assertEquals(expected_value2, reader.readInt());
-
- reader.close();
- stream2.close();
+ assertEquals(expectedValue, result);
}
@Test
- @Ignore // TODO
public void whenReadUTFEncodedFile_thenCorrect() throws IOException {
final String expected_value = "青空";
- final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/test_read7.in"), "UTF-8"));
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/fileTestUtf8.txt"), "UTF-8"));
final String currentLine = reader.readLine();
reader.close();
- LOG.debug(currentLine);
-
+
assertEquals(expected_value, currentLine);
}
@Test
public void whenReadFileContentsIntoString_thenCorrect() throws IOException {
- final String expected_value = "Hello world \n Test line \n";
- final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/test_read8.in"));
+ final String expected_value = "Hello, world!\n";
+ final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/fileTest.txt"));
final StringBuilder builder = new StringBuilder();
String currentLine = reader.readLine();
while (currentLine != null) {
@@ -136,8 +220,8 @@ public class JavaReadFromFileUnitTest {
@Test
public void whenReadWithFileChannel_thenCorrect() throws IOException {
- final String expected_value = "Hello world";
- final RandomAccessFile reader = new RandomAccessFile("src/test/resources/test_read.in", "r");
+ final String expected_value = "Hello, world!";
+ final RandomAccessFile reader = new RandomAccessFile("src/test/resources/fileTest.txt", "r");
final FileChannel channel = reader.getChannel();
int bufferSize = 1024;
@@ -154,8 +238,8 @@ public class JavaReadFromFileUnitTest {
@Test
public void whenReadSmallFileJava7_thenCorrect() throws IOException {
- final String expected_value = "Hello world";
- final Path path = Paths.get("src/test/resources/test_read.in");
+ final String expected_value = "Hello, world!";
+ final Path path = Paths.get("src/test/resources/fileTest.txt");
final String read = Files.readAllLines(path, Charset.defaultCharset()).get(0);
assertEquals(expected_value, read);
@@ -163,12 +247,24 @@ public class JavaReadFromFileUnitTest {
@Test
public void whenReadLargeFileJava7_thenCorrect() throws IOException {
- final String expected_value = "Hello world";
+ final String expected_value = "Hello, world!";
- final Path path = Paths.get("src/test/resources/test_read.in");
+ final Path path = Paths.get("src/test/resources/fileTest.txt");
final BufferedReader reader = Files.newBufferedReader(path, Charset.defaultCharset());
final String line = reader.readLine();
assertEquals(expected_value, line);
}
+ private String readFromInputStream(InputStream inputStream) throws IOException {
+ StringBuilder resultStringBuilder = new StringBuilder();
+ try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) {
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ resultStringBuilder.append(line).append("\n");
+ }
+ }
+
+ return resultStringBuilder.toString();
+ }
+
}
diff --git a/core-java-modules/core-java-io/src/test/resources/fileTest.txt b/core-java-modules/core-java-io/src/test/resources/fileTest.txt
index ce4bea208b..5dd01c177f 100644
--- a/core-java-modules/core-java-io/src/test/resources/fileTest.txt
+++ b/core-java-modules/core-java-io/src/test/resources/fileTest.txt
@@ -1 +1 @@
-Hello World from fileTest.txt!!!
\ No newline at end of file
+Hello, world!
\ No newline at end of file
diff --git a/core-java-modules/core-java-io/src/test/resources/test_read3.in b/core-java-modules/core-java-io/src/test/resources/fileTestTokenizer.txt
similarity index 100%
rename from core-java-modules/core-java-io/src/test/resources/test_read3.in
rename to core-java-modules/core-java-io/src/test/resources/fileTestTokenizer.txt
diff --git a/core-java-modules/core-java-io/src/test/resources/test_read7.in b/core-java-modules/core-java-io/src/test/resources/fileTestUtf8.txt
similarity index 100%
rename from core-java-modules/core-java-io/src/test/resources/test_read7.in
rename to core-java-modules/core-java-io/src/test/resources/fileTestUtf8.txt
diff --git a/core-java-modules/core-java-io/src/test/resources/test_read1.in b/core-java-modules/core-java-io/src/test/resources/test_read1.in
deleted file mode 100644
index 1e46242993..0000000000
--- a/core-java-modules/core-java-io/src/test/resources/test_read1.in
+++ /dev/null
@@ -1 +0,0 @@
-Hello world 1
\ No newline at end of file
diff --git a/core-java-modules/core-java-io/src/test/resources/test_read2.in b/core-java-modules/core-java-io/src/test/resources/test_read2.in
deleted file mode 100644
index fe47dc003b..0000000000
--- a/core-java-modules/core-java-io/src/test/resources/test_read2.in
+++ /dev/null
@@ -1 +0,0 @@
-2,3 4
\ No newline at end of file
diff --git a/core-java-modules/core-java-io/src/test/resources/test_read4.in b/core-java-modules/core-java-io/src/test/resources/test_read4.in
deleted file mode 100644
index 5727d54bfc..0000000000
Binary files a/core-java-modules/core-java-io/src/test/resources/test_read4.in and /dev/null differ
diff --git a/core-java-modules/core-java-io/src/test/resources/test_read8.in b/core-java-modules/core-java-io/src/test/resources/test_read8.in
deleted file mode 100644
index 10fc1aac8a..0000000000
--- a/core-java-modules/core-java-io/src/test/resources/test_read8.in
+++ /dev/null
@@ -1,2 +0,0 @@
-Hello world
- Test line
diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml
index c1a9acca6b..4e08271fa1 100644
--- a/core-java-modules/pom.xml
+++ b/core-java-modules/pom.xml
@@ -31,6 +31,7 @@
core-java-annotations
core-java-arrays
core-java-arrays-2
+ core-java-arrays-3
core-java-collections
core-java-collections-2
diff --git a/ddd/pom.xml b/ddd/pom.xml
index 9a0523a4c6..f27f1d24a9 100644
--- a/ddd/pom.xml
+++ b/ddd/pom.xml
@@ -20,6 +20,10 @@
org.springframework.boot
spring-boot-starter-data-mongodb
+
+ org.springframework.boot
+ spring-boot-starter-data-cassandra
+
org.junit.jupiter
junit-jupiter-api
diff --git a/ddd/src/main/java/com/baeldung/dddhexagonalspring/DomainLayerApplication.java b/ddd/src/main/java/com/baeldung/dddhexagonalspring/DomainLayerApplication.java
index 988f96042b..235021b03e 100644
--- a/ddd/src/main/java/com/baeldung/dddhexagonalspring/DomainLayerApplication.java
+++ b/ddd/src/main/java/com/baeldung/dddhexagonalspring/DomainLayerApplication.java
@@ -1,13 +1,37 @@
package com.baeldung.dddhexagonalspring;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
+import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.PropertySource;
+import com.baeldung.dddhexagonalspring.application.cli.CliOrderController;
+
@SpringBootApplication
@PropertySource(value = { "classpath:ddd-layers.properties" })
-public class DomainLayerApplication {
+public class DomainLayerApplication implements CommandLineRunner {
+
public static void main(final String[] args) {
- SpringApplication.run(DomainLayerApplication.class, args);
+ SpringApplication application = new SpringApplication(DomainLayerApplication.class);
+ // uncomment to run just the console application
+ // application.setWebApplicationType(WebApplicationType.NONE);
+ application.run(args);
+ }
+
+ @Autowired
+ public CliOrderController orderController;
+
+ @Autowired
+ public ConfigurableApplicationContext context;
+
+ @Override
+ public void run(String... args) throws Exception {
+ orderController.createCompleteOrder();
+ orderController.createIncompleteOrder();
+ // uncomment to stop the context when execution is done
+ // context.close();
}
}
diff --git a/ddd/src/main/java/com/baeldung/dddhexagonalspring/application/cli/CliOrderController.java b/ddd/src/main/java/com/baeldung/dddhexagonalspring/application/cli/CliOrderController.java
new file mode 100644
index 0000000000..3d595533f3
--- /dev/null
+++ b/ddd/src/main/java/com/baeldung/dddhexagonalspring/application/cli/CliOrderController.java
@@ -0,0 +1,47 @@
+package com.baeldung.dddhexagonalspring.application.cli;
+
+import java.math.BigDecimal;
+import java.util.UUID;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.baeldung.dddhexagonalspring.domain.Product;
+import com.baeldung.dddhexagonalspring.domain.service.OrderService;
+
+@Component
+public class CliOrderController {
+
+ private static final Logger LOG = LoggerFactory.getLogger(CliOrderController.class);
+
+ private final OrderService orderService;
+
+ @Autowired
+ public CliOrderController(OrderService orderService) {
+ this.orderService = orderService;
+ }
+
+ public void createCompleteOrder() {
+ LOG.info("<>");
+ UUID orderId = createOrder();
+ orderService.completeOrder(orderId);
+ }
+
+ public void createIncompleteOrder() {
+ LOG.info("<>");
+ UUID orderId = createOrder();
+ }
+
+ private UUID createOrder() {
+ LOG.info("Placing a new order with two products");
+ Product mobilePhone = new Product(UUID.randomUUID(), BigDecimal.valueOf(200), "mobile");
+ Product razor = new Product(UUID.randomUUID(), BigDecimal.valueOf(50), "razor");
+ LOG.info("Creating order with mobile phone");
+ UUID orderId = orderService.createOrder(mobilePhone);
+ LOG.info("Adding a razor to the order");
+ orderService.addProduct(orderId, razor);
+ return orderId;
+ }
+}
diff --git a/ddd/src/main/java/com/baeldung/dddhexagonalspring/application/controller/OrderController.java b/ddd/src/main/java/com/baeldung/dddhexagonalspring/application/rest/OrderController.java
similarity index 96%
rename from ddd/src/main/java/com/baeldung/dddhexagonalspring/application/controller/OrderController.java
rename to ddd/src/main/java/com/baeldung/dddhexagonalspring/application/rest/OrderController.java
index 80ba36d01b..12bb8ddea4 100644
--- a/ddd/src/main/java/com/baeldung/dddhexagonalspring/application/controller/OrderController.java
+++ b/ddd/src/main/java/com/baeldung/dddhexagonalspring/application/rest/OrderController.java
@@ -1,4 +1,4 @@
-package com.baeldung.dddhexagonalspring.application.controller;
+package com.baeldung.dddhexagonalspring.application.rest;
import com.baeldung.dddhexagonalspring.application.request.AddProductRequest;
import com.baeldung.dddhexagonalspring.application.request.CreateOrderRequest;
diff --git a/ddd/src/main/java/com/baeldung/dddhexagonalspring/domain/Order.java b/ddd/src/main/java/com/baeldung/dddhexagonalspring/domain/Order.java
index 7d40007411..a8745eadbe 100644
--- a/ddd/src/main/java/com/baeldung/dddhexagonalspring/domain/Order.java
+++ b/ddd/src/main/java/com/baeldung/dddhexagonalspring/domain/Order.java
@@ -4,6 +4,7 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import java.util.UUID;
public class Order {
@@ -40,13 +41,11 @@ public class Order {
}
private OrderItem getOrderItem(final UUID id) {
- return orderItems
- .stream()
- .filter(orderItem -> orderItem
- .getProductId()
- .equals(id))
- .findFirst()
- .orElseThrow(() -> new DomainException("Product with " + id + " doesn't exist."));
+ return orderItems.stream()
+ .filter(orderItem -> orderItem.getProductId()
+ .equals(id))
+ .findFirst()
+ .orElseThrow(() -> new DomainException("Product with " + id + " doesn't exist."));
}
private void validateState() {
@@ -77,6 +76,21 @@ public class Order {
return Collections.unmodifiableList(orderItems);
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, orderItems, price, status);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!(obj instanceof Order))
+ return false;
+ Order other = (Order) obj;
+ return Objects.equals(id, other.id) && Objects.equals(orderItems, other.orderItems) && Objects.equals(price, other.price) && status == other.status;
+ }
+
private Order() {
}
}
diff --git a/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/configuration/CassandraConfiguration.java b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/configuration/CassandraConfiguration.java
new file mode 100644
index 0000000000..3b5911979a
--- /dev/null
+++ b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/configuration/CassandraConfiguration.java
@@ -0,0 +1,10 @@
+package com.baeldung.dddhexagonalspring.infrastracture.configuration;
+
+import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
+
+import com.baeldung.dddhexagonalspring.infrastracture.repository.cassandra.SpringDataCassandraOrderRepository;
+
+@EnableCassandraRepositories(basePackageClasses = SpringDataCassandraOrderRepository.class)
+public class CassandraConfiguration {
+
+}
diff --git a/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/configuration/MongoDBConfiguration.java b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/configuration/MongoDBConfiguration.java
index fd76b2eb0e..8ec6daf370 100644
--- a/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/configuration/MongoDBConfiguration.java
+++ b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/configuration/MongoDBConfiguration.java
@@ -1,8 +1,9 @@
package com.baeldung.dddhexagonalspring.infrastracture.configuration;
-import com.baeldung.dddhexagonalspring.infrastracture.repository.SpringDataOrderRepository;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
-@EnableMongoRepositories(basePackageClasses = SpringDataOrderRepository.class)
+import com.baeldung.dddhexagonalspring.infrastracture.repository.mongo.SpringDataMongoOrderRepository;
+
+@EnableMongoRepositories(basePackageClasses = SpringDataMongoOrderRepository.class)
public class MongoDBConfiguration {
}
diff --git a/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/CassandraDbOrderRepository.java b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/CassandraDbOrderRepository.java
new file mode 100644
index 0000000000..686fc428e7
--- /dev/null
+++ b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/CassandraDbOrderRepository.java
@@ -0,0 +1,38 @@
+package com.baeldung.dddhexagonalspring.infrastracture.repository.cassandra;
+
+import java.util.Optional;
+import java.util.UUID;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.baeldung.dddhexagonalspring.domain.Order;
+import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository;
+
+@Component
+public class CassandraDbOrderRepository implements OrderRepository {
+
+ private final SpringDataCassandraOrderRepository orderRepository;
+
+ @Autowired
+ public CassandraDbOrderRepository(SpringDataCassandraOrderRepository orderRepository) {
+ this.orderRepository = orderRepository;
+ }
+
+ @Override
+ public Optional findById(UUID id) {
+ Optional orderEntity = orderRepository.findById(id);
+ if (orderEntity.isPresent()) {
+ return Optional.of(orderEntity.get()
+ .toOrder());
+ } else {
+ return Optional.empty();
+ }
+ }
+
+ @Override
+ public void save(Order order) {
+ orderRepository.save(new OrderEntity(order));
+ }
+
+}
diff --git a/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/OrderEntity.java b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/OrderEntity.java
new file mode 100644
index 0000000000..b9841a4433
--- /dev/null
+++ b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/OrderEntity.java
@@ -0,0 +1,75 @@
+package com.baeldung.dddhexagonalspring.infrastracture.repository.cassandra;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+import org.springframework.data.cassandra.core.mapping.PrimaryKey;
+
+import com.baeldung.dddhexagonalspring.domain.Order;
+import com.baeldung.dddhexagonalspring.domain.OrderItem;
+import com.baeldung.dddhexagonalspring.domain.OrderStatus;
+import com.baeldung.dddhexagonalspring.domain.Product;
+
+public class OrderEntity {
+
+ @PrimaryKey
+ private UUID id;
+ private OrderStatus status;
+ private List orderItemEntities;
+ private BigDecimal price;
+
+ public OrderEntity(UUID id, OrderStatus status, List orderItemEntities, BigDecimal price) {
+ this.id = id;
+ this.status = status;
+ this.orderItemEntities = orderItemEntities;
+ this.price = price;
+ }
+
+ public OrderEntity() {
+ }
+
+ public OrderEntity(Order order) {
+ this.id = order.getId();
+ this.price = order.getPrice();
+ this.status = order.getStatus();
+ this.orderItemEntities = order.getOrderItems()
+ .stream()
+ .map(OrderItemEntity::new)
+ .collect(Collectors.toList());
+
+ }
+
+ public Order toOrder() {
+ List orderItems = orderItemEntities.stream()
+ .map(OrderItemEntity::toOrderItem)
+ .collect(Collectors.toList());
+ List namelessProducts = orderItems.stream()
+ .map(orderItem -> new Product(orderItem.getProductId(), orderItem.getPrice(), ""))
+ .collect(Collectors.toList());
+ Order order = new Order(id, namelessProducts.remove(0));
+ namelessProducts.forEach(product -> order.addOrder(product));
+ if (status == OrderStatus.COMPLETED) {
+ order.complete();
+ }
+ return order;
+ }
+
+ public UUID getId() {
+ return id;
+ }
+
+ public OrderStatus getStatus() {
+ return status;
+ }
+
+ public List getOrderItems() {
+ return orderItemEntities;
+ }
+
+ public BigDecimal getPrice() {
+ return price;
+ }
+
+}
diff --git a/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/OrderItemEntity.java b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/OrderItemEntity.java
new file mode 100644
index 0000000000..2cf8ac7845
--- /dev/null
+++ b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/OrderItemEntity.java
@@ -0,0 +1,44 @@
+package com.baeldung.dddhexagonalspring.infrastracture.repository.cassandra;
+
+import java.math.BigDecimal;
+import java.util.UUID;
+
+import org.springframework.data.cassandra.core.mapping.UserDefinedType;
+
+import com.baeldung.dddhexagonalspring.domain.OrderItem;
+import com.baeldung.dddhexagonalspring.domain.Product;
+
+@UserDefinedType
+public class OrderItemEntity {
+
+ private UUID productId;
+ private BigDecimal price;
+
+ public OrderItemEntity() {
+ }
+
+ public OrderItemEntity(final OrderItem orderItem) {
+ this.productId = orderItem.getProductId();
+ this.price = orderItem.getPrice();
+ }
+
+ public OrderItem toOrderItem() {
+ return new OrderItem(new Product(productId, price, ""));
+ }
+
+ public UUID getProductId() {
+ return productId;
+ }
+
+ public void setProductId(UUID productId) {
+ this.productId = productId;
+ }
+
+ public BigDecimal getPrice() {
+ return price;
+ }
+
+ public void setPrice(BigDecimal price) {
+ this.price = price;
+ }
+}
diff --git a/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/SpringDataCassandraOrderRepository.java b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/SpringDataCassandraOrderRepository.java
new file mode 100644
index 0000000000..93cd7ab83f
--- /dev/null
+++ b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/cassandra/SpringDataCassandraOrderRepository.java
@@ -0,0 +1,10 @@
+package com.baeldung.dddhexagonalspring.infrastracture.repository.cassandra;
+
+import java.util.UUID;
+
+import org.springframework.data.cassandra.repository.CassandraRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface SpringDataCassandraOrderRepository extends CassandraRepository {
+}
diff --git a/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/MongoDbOrderRepository.java b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/mongo/MongoDbOrderRepository.java
similarity index 75%
rename from ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/MongoDbOrderRepository.java
rename to ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/mongo/MongoDbOrderRepository.java
index 3123ef3e2f..b48b738cbd 100644
--- a/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/MongoDbOrderRepository.java
+++ b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/mongo/MongoDbOrderRepository.java
@@ -1,20 +1,23 @@
-package com.baeldung.dddhexagonalspring.infrastracture.repository;
-
-import com.baeldung.dddhexagonalspring.domain.Order;
-import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
+package com.baeldung.dddhexagonalspring.infrastracture.repository.mongo;
import java.util.Optional;
import java.util.UUID;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Component;
+
+import com.baeldung.dddhexagonalspring.domain.Order;
+import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository;
+
@Component
+@Primary
public class MongoDbOrderRepository implements OrderRepository {
- private final SpringDataOrderRepository orderRepository;
+ private final SpringDataMongoOrderRepository orderRepository;
@Autowired
- public MongoDbOrderRepository(final SpringDataOrderRepository orderRepository) {
+ public MongoDbOrderRepository(final SpringDataMongoOrderRepository orderRepository) {
this.orderRepository = orderRepository;
}
diff --git a/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/SpringDataOrderRepository.java b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/mongo/SpringDataMongoOrderRepository.java
similarity index 74%
rename from ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/SpringDataOrderRepository.java
rename to ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/mongo/SpringDataMongoOrderRepository.java
index 0279a5ce4a..73aa74e7d7 100644
--- a/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/SpringDataOrderRepository.java
+++ b/ddd/src/main/java/com/baeldung/dddhexagonalspring/infrastracture/repository/mongo/SpringDataMongoOrderRepository.java
@@ -1,4 +1,4 @@
-package com.baeldung.dddhexagonalspring.infrastracture.repository;
+package com.baeldung.dddhexagonalspring.infrastracture.repository.mongo;
import com.baeldung.dddhexagonalspring.domain.Order;
import org.springframework.data.mongodb.repository.MongoRepository;
@@ -7,5 +7,5 @@ import org.springframework.stereotype.Repository;
import java.util.UUID;
@Repository
-public interface SpringDataOrderRepository extends MongoRepository {
+public interface SpringDataMongoOrderRepository extends MongoRepository {
}
diff --git a/ddd/src/main/resources/ddd-layers.properties b/ddd/src/main/resources/ddd-layers.properties
index 0479996b17..412c24eef7 100644
--- a/ddd/src/main/resources/ddd-layers.properties
+++ b/ddd/src/main/resources/ddd-layers.properties
@@ -1,5 +1,12 @@
+spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=order-database
spring.data.mongodb.username=order
-spring.data.mongodb.password=order
\ No newline at end of file
+spring.data.mongodb.password=order
+
+spring.data.cassandra.keyspaceName=order_database
+spring.data.cassandra.username=cassandra
+spring.data.cassandra.password=cassandra
+spring.data.cassandra.contactPoints=localhost
+spring.data.cassandra.port=9042
\ No newline at end of file
diff --git a/ddd/src/test/java/com/baeldung/dddhexagonalspring/infrastracture/repository/CassandraDbOrderRepositoryIntegrationTest.java b/ddd/src/test/java/com/baeldung/dddhexagonalspring/infrastracture/repository/CassandraDbOrderRepositoryIntegrationTest.java
new file mode 100644
index 0000000000..668d1e5e34
--- /dev/null
+++ b/ddd/src/test/java/com/baeldung/dddhexagonalspring/infrastracture/repository/CassandraDbOrderRepositoryIntegrationTest.java
@@ -0,0 +1,57 @@
+package com.baeldung.dddhexagonalspring.infrastracture.repository;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.math.BigDecimal;
+import java.util.Optional;
+import java.util.UUID;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
+
+import com.baeldung.dddhexagonalspring.domain.Order;
+import com.baeldung.dddhexagonalspring.domain.Product;
+import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository;
+import com.baeldung.dddhexagonalspring.infrastracture.repository.cassandra.SpringDataCassandraOrderRepository;
+
+@SpringJUnitConfig
+@SpringBootTest
+@TestPropertySource("classpath:ddd-layers-test.properties")
+class CassandraDbOrderRepositoryIntegrationTest {
+
+ @Autowired
+ private SpringDataCassandraOrderRepository cassandraOrderRepository;
+
+ @Autowired
+ private OrderRepository orderRepository;
+
+ @AfterEach
+ void cleanUp() {
+ cassandraOrderRepository.deleteAll();
+ }
+
+ @Test
+ void shouldFindById_thenReturnOrder() {
+
+ // given
+ final UUID id = UUID.randomUUID();
+ final Order order = createOrder(id);
+ order.addOrder(new Product(UUID.randomUUID(), BigDecimal.TEN, "second"));
+ order.complete();
+
+ // when
+ orderRepository.save(order);
+
+ final Optional result = orderRepository.findById(id);
+
+ assertEquals(order, result.get());
+ }
+
+ private Order createOrder(UUID id) {
+ return new Order(id, new Product(UUID.randomUUID(), BigDecimal.TEN, "product"));
+ }
+}
\ No newline at end of file
diff --git a/ddd/src/test/java/com/baeldung/dddhexagonalspring/infrastracture/repository/MongoDbOrderRepositoryIntegrationTest.java b/ddd/src/test/java/com/baeldung/dddhexagonalspring/infrastracture/repository/MongoDbOrderRepositoryIntegrationTest.java
new file mode 100644
index 0000000000..9a7736c419
--- /dev/null
+++ b/ddd/src/test/java/com/baeldung/dddhexagonalspring/infrastracture/repository/MongoDbOrderRepositoryIntegrationTest.java
@@ -0,0 +1,55 @@
+package com.baeldung.dddhexagonalspring.infrastracture.repository;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.math.BigDecimal;
+import java.util.Optional;
+import java.util.UUID;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
+
+import com.baeldung.dddhexagonalspring.domain.Order;
+import com.baeldung.dddhexagonalspring.domain.Product;
+import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository;
+import com.baeldung.dddhexagonalspring.infrastracture.repository.mongo.SpringDataMongoOrderRepository;
+
+@SpringJUnitConfig
+@SpringBootTest
+@TestPropertySource("classpath:ddd-layers-test.properties")
+class MongoDbOrderRepositoryIntegrationTest {
+
+ @Autowired
+ private SpringDataMongoOrderRepository mongoOrderRepository;
+
+ @Autowired
+ private OrderRepository orderRepository;
+
+ @AfterEach
+ void cleanUp() {
+ mongoOrderRepository.deleteAll();
+ }
+
+ @Test
+ void shouldFindById_thenReturnOrder() {
+
+ // given
+ final UUID id = UUID.randomUUID();
+ final Order order = createOrder(id);
+
+ // when
+ orderRepository.save(order);
+
+ final Optional result = orderRepository.findById(id);
+
+ assertEquals(order, result.get());
+ }
+
+ private Order createOrder(UUID id) {
+ return new Order(id, new Product(UUID.randomUUID(), BigDecimal.TEN, "product"));
+ }
+}
\ No newline at end of file
diff --git a/ddd/src/test/java/com/baeldung/dddhexagonalspring/infrastracture/repository/MongoDbOrderRepositoryUnitTest.java b/ddd/src/test/java/com/baeldung/dddhexagonalspring/infrastracture/repository/MongoDbOrderRepositoryUnitTest.java
index 8f7e8260a3..4c75daaa4d 100644
--- a/ddd/src/test/java/com/baeldung/dddhexagonalspring/infrastracture/repository/MongoDbOrderRepositoryUnitTest.java
+++ b/ddd/src/test/java/com/baeldung/dddhexagonalspring/infrastracture/repository/MongoDbOrderRepositoryUnitTest.java
@@ -2,6 +2,9 @@ package com.baeldung.dddhexagonalspring.infrastracture.repository;
import com.baeldung.dddhexagonalspring.domain.Order;
import com.baeldung.dddhexagonalspring.domain.Product;
+import com.baeldung.dddhexagonalspring.infrastracture.repository.mongo.MongoDbOrderRepository;
+import com.baeldung.dddhexagonalspring.infrastracture.repository.mongo.SpringDataMongoOrderRepository;
+
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -14,12 +17,12 @@ import static org.mockito.Mockito.*;
class MongoDbOrderRepositoryUnitTest {
- private SpringDataOrderRepository springDataOrderRepository;
+ private SpringDataMongoOrderRepository springDataOrderRepository;
private MongoDbOrderRepository tested;
@BeforeEach
- void setUp(){
- springDataOrderRepository = mock(SpringDataOrderRepository.class);
+ void setUp() {
+ springDataOrderRepository = mock(SpringDataMongoOrderRepository.class);
tested = new MongoDbOrderRepository(springDataOrderRepository);
}
diff --git a/ddd/src/test/resources/com/baeldung/dddhexagonalspring/README.md b/ddd/src/test/resources/com/baeldung/dddhexagonalspring/README.md
index e0337498fc..1355514a3d 100644
--- a/ddd/src/test/resources/com/baeldung/dddhexagonalspring/README.md
+++ b/ddd/src/test/resources/com/baeldung/dddhexagonalspring/README.md
@@ -4,4 +4,6 @@ To run this project, follow these steps:
* Run the application database by executing `docker-compose up` in this directory.
* Launch the Spring Boot Application (DomainLayerApplication).
-* By default, application will connect to this database (configuration in *ddd-layers.properties*)
\ No newline at end of file
+* By default, the application will connect to the one of the two databases (configuration in *ddd-layers.properties*)
+ * check `CassandraDbOrderRepository.java` and `MongoDbOrderRepository.java`
+ * switch between the databases by making one of the above beans primary using the `@Primary` annotation
\ No newline at end of file
diff --git a/ddd/src/test/resources/com/baeldung/dddhexagonalspring/cassandra-init.cql b/ddd/src/test/resources/com/baeldung/dddhexagonalspring/cassandra-init.cql
new file mode 100644
index 0000000000..cbb22d2525
--- /dev/null
+++ b/ddd/src/test/resources/com/baeldung/dddhexagonalspring/cassandra-init.cql
@@ -0,0 +1,12 @@
+CREATE KEYSPACE IF NOT exists order_database
+WITH replication = {'class':'SimpleStrategy', 'replication_factor':1};
+
+CREATE TYPE IF NOT EXISTS order_database.orderitementity (productid uuid, price decimal);
+
+CREATE TABLE IF NOT EXISTS order_database.orderentity(
+ id uuid,
+ status text,
+ orderitementities list>,
+ price decimal,
+ primary key(id)
+);
diff --git a/ddd/src/test/resources/com/baeldung/dddhexagonalspring/docker-compose.yml b/ddd/src/test/resources/com/baeldung/dddhexagonalspring/docker-compose.yml
index d85ddf4a0e..7de0d30d43 100644
--- a/ddd/src/test/resources/com/baeldung/dddhexagonalspring/docker-compose.yml
+++ b/ddd/src/test/resources/com/baeldung/dddhexagonalspring/docker-compose.yml
@@ -3,6 +3,7 @@ version: '3'
services:
order-mongo-database:
image: mongo:3.4.13
+ container_name: order-mongo-db
restart: always
ports:
- 27017:27017
@@ -11,4 +12,19 @@ services:
MONGO_INITDB_ROOT_PASSWORD: admin
MONGO_INITDB_DATABASE: order-database
volumes:
- - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
\ No newline at end of file
+ - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
+ order-cassandra-database:
+ image: cassandra:3.11.5
+ container_name: order-cassandra-db
+ restart: always
+ ports:
+ - 9042:9042
+ order-cassandra-init:
+ image: cassandra:3.11.5
+ container_name: order-cassandra-db-init
+ depends_on:
+ - order-cassandra-database
+ volumes:
+ - ./cassandra-init.cql:/cassandra-init.cql:ro
+ command: bin/bash -c "echo Initializing cassandra schema... && sleep 30 && cqlsh -u cassandra -p cassandra -f cassandra-init.cql order-cassandra-db"
+
\ No newline at end of file
diff --git a/ddd/src/test/resources/ddd-layers-test.properties b/ddd/src/test/resources/ddd-layers-test.properties
new file mode 100644
index 0000000000..d41689d91b
--- /dev/null
+++ b/ddd/src/test/resources/ddd-layers-test.properties
@@ -0,0 +1,12 @@
+spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
+spring.data.mongodb.host=127.0.0.1
+spring.data.mongodb.port=27017
+spring.data.mongodb.database=order-database
+spring.data.mongodb.username=order
+spring.data.mongodb.password=order
+
+spring.data.cassandra.keyspaceName=order_database
+spring.data.cassandra.username=cassandra
+spring.data.cassandra.password=cassandra
+spring.data.cassandra.contactPoints=127.0.0.1
+spring.data.cassandra.port=9042
\ No newline at end of file
diff --git a/gradle-6/.gitignore b/gradle-6/.gitignore
new file mode 100644
index 0000000000..6987887957
--- /dev/null
+++ b/gradle-6/.gitignore
@@ -0,0 +1,18 @@
+
+# Gradle
+
+.gradle
+build
+
+# Ignore Gradle GUI config
+gradle-app.setting
+
+# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
+!gradle-wrapper.jar
+
+# Cache of project
+.gradletasknamecache
+
+# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
+# gradle/wrapper/gradle-wrapper.properties
+
diff --git a/gradle-6/build.gradle.kts b/gradle-6/build.gradle.kts
new file mode 100644
index 0000000000..fb3c3f88a2
--- /dev/null
+++ b/gradle-6/build.gradle.kts
@@ -0,0 +1,5 @@
+subprojects {
+ repositories {
+ mavenCentral()
+ }
+}
\ No newline at end of file
diff --git a/gradle-6/configuration-avoidance/build.gradle.kts b/gradle-6/configuration-avoidance/build.gradle.kts
new file mode 100644
index 0000000000..e84f08bf93
--- /dev/null
+++ b/gradle-6/configuration-avoidance/build.gradle.kts
@@ -0,0 +1,37 @@
+plugins {
+ base
+}
+
+description = """
+ Demonstrates Gradle Configuraiton Avoidance API. Creates a new configuration "extralibs" to
+ which we add dependencies. The custom task "copyExtraLibs" copies those dependencies to a new
+ build directory "extra-libs". This build uses the Task Configuraion Avoidance APIs which have
+ been marked stable in Gradle 6.0
+""".trimIndent()
+
+// extraLibs is a NamedDomainObjectProvider - the Configuration object will not be
+// realized until it is needed. In the meantime, the build may reference it by name
+val extralibs by configurations.registering
+
+dependencies {
+ // we can call extralibs.name without causing the extralibs to be realized
+ add(extralibs.name, "junit:junit:4.12")
+}
+
+// extraLibsDir is a Provider - the Directory object will not be realized until it is
+// needed
+val extraLibsDir = project.layout.buildDirectory.dir("extra-libs")
+
+// copyExtraLibs is a TaskProvider - the task will not be realized until it is needed
+val copyExtraLibs by tasks.registering(Copy::class) {
+ // the copy task's "from" and "into" APIs accept Provider types to support configuration
+ // avoidance
+ from(extralibs)
+ into(extraLibsDir)
+}
+
+// configures the "build" task only if it needs to be
+tasks.build {
+ // dependsOn accepts a TaskProvider to avoid realizing the copyExtraLibs needlessly
+ dependsOn(copyExtraLibs)
+}
diff --git a/gradle-6/dependency-constraints/build.gradle.kts b/gradle-6/dependency-constraints/build.gradle.kts
new file mode 100644
index 0000000000..41336d3c91
--- /dev/null
+++ b/gradle-6/dependency-constraints/build.gradle.kts
@@ -0,0 +1,29 @@
+plugins {
+ `java-library`
+}
+
+group = "com.baeldung"
+version = "1.0.0"
+
+dependencies {
+ api("io.reactivex.rxjava2:rxjava:2.2.16")
+ implementation("com.google.guava:guava") {
+ version {
+ require("10.0")
+ prefer("28.1-jre")
+ because("Only uses ImmutableList type, so any version since 2.0 will do, but tested with 28.1-jre")
+ }
+ }
+
+ testImplementation("org.junit.jupiter:junit-jupiter-api:5.5.2")
+ testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.5.2")
+}
+
+tasks.compileJava {
+ sourceCompatibility = "1.8"
+ targetCompatibility = "1.8"
+}
+
+tasks.test {
+ useJUnitPlatform()
+}
diff --git a/gradle-6/dependency-constraints/src/main/java/com/baeldung/gradle/RxHelloWorld.java b/gradle-6/dependency-constraints/src/main/java/com/baeldung/gradle/RxHelloWorld.java
new file mode 100644
index 0000000000..e4ebd9ba6b
--- /dev/null
+++ b/gradle-6/dependency-constraints/src/main/java/com/baeldung/gradle/RxHelloWorld.java
@@ -0,0 +1,24 @@
+package com.baeldung.gradle;
+
+import com.google.common.collect.ImmutableList;
+import io.reactivex.Observable;
+
+import java.util.List;
+
+/**
+ * Demonstrates a library type that returns an RxJava type.
+ */
+public class RxHelloWorld {
+
+ /**
+ * @return an {@link Observable} that emits events "hello" and "world" before completing.
+ */
+ public static Observable hello() {
+ // Guava ImmutableList class is an implementation detail.
+ List values = ImmutableList.of("hello", "world");
+ return Observable.fromIterable(values);
+ }
+
+ private RxHelloWorld() {
+ }
+}
diff --git a/gradle-6/dependency-constraints/src/test/java/com/baeldung/gradle/RxHelloWorldUnitTest.java b/gradle-6/dependency-constraints/src/test/java/com/baeldung/gradle/RxHelloWorldUnitTest.java
new file mode 100644
index 0000000000..8a05fcfda3
--- /dev/null
+++ b/gradle-6/dependency-constraints/src/test/java/com/baeldung/gradle/RxHelloWorldUnitTest.java
@@ -0,0 +1,14 @@
+package com.baeldung.gradle;
+
+import org.junit.jupiter.api.Test;
+
+import static com.baeldung.gradle.RxHelloWorld.hello;
+
+/**
+ * Unit test for {@link RxHelloWorld}.
+ */
+final class RxHelloWorldUnitTest {
+ @Test void it_emits_hello_world_values() {
+ hello().test().assertValues("hello", "world").assertComplete();
+ }
+}
diff --git a/gradle-6/fibonacci-recursive/build.gradle.kts b/gradle-6/fibonacci-recursive/build.gradle.kts
new file mode 100644
index 0000000000..0872a52472
--- /dev/null
+++ b/gradle-6/fibonacci-recursive/build.gradle.kts
@@ -0,0 +1,17 @@
+plugins {
+ `java-library`
+}
+
+dependencies {
+ api(project(":fibonacci-spi"))
+ compileOnly("com.google.auto.service:auto-service-annotations:1.0-rc6")
+ annotationProcessor("com.google.auto.service:auto-service:1.0-rc6")
+
+ testImplementation(testFixtures(project(":fibonacci-spi")))
+ testImplementation("org.junit.jupiter:junit-jupiter-api:5.5.2")
+ testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.5.2")
+}
+
+tasks.test {
+ useJUnitPlatform()
+}
\ No newline at end of file
diff --git a/gradle-6/fibonacci-recursive/src/main/java/com/baeldung/fibonacci/impl/RecursiveFibonacci.java b/gradle-6/fibonacci-recursive/src/main/java/com/baeldung/fibonacci/impl/RecursiveFibonacci.java
new file mode 100644
index 0000000000..def79521bd
--- /dev/null
+++ b/gradle-6/fibonacci-recursive/src/main/java/com/baeldung/fibonacci/impl/RecursiveFibonacci.java
@@ -0,0 +1,20 @@
+package com.baeldung.fibonacci.impl;
+
+import com.baeldung.fibonacci.FibonacciSequenceGenerator;
+import com.google.auto.service.AutoService;
+
+/**
+ * Recursive implementation of the {@link FibonacciSequenceGenerator}.
+ */
+@AutoService(FibonacciSequenceGenerator.class) public final class RecursiveFibonacci implements FibonacciSequenceGenerator {
+
+ @Override public int generate(int nth) {
+ if (nth < 0) {
+ throw new IllegalArgumentException("sequence number must be 0 or greater");
+ }
+ if (nth <= 1) {
+ return nth;
+ }
+ return generate(nth - 1) + generate(nth - 2);
+ }
+}
diff --git a/gradle-6/fibonacci-recursive/src/test/java/com/baeldung/fibonacci/impl/RecursiveFibonacciUnitTest.java b/gradle-6/fibonacci-recursive/src/test/java/com/baeldung/fibonacci/impl/RecursiveFibonacciUnitTest.java
new file mode 100644
index 0000000000..766f3b251b
--- /dev/null
+++ b/gradle-6/fibonacci-recursive/src/test/java/com/baeldung/fibonacci/impl/RecursiveFibonacciUnitTest.java
@@ -0,0 +1,13 @@
+package com.baeldung.fibonacci.impl;
+
+import com.baeldung.fibonacci.FibonacciSequenceGenerator;
+import com.baeldung.fibonacci.FibonacciSequenceGeneratorFixture;
+
+/**
+ * Unit test which reuses the {@link FibonacciSequenceGeneratorFixture} test mix-in exported from the fibonacci-spi project.
+ */
+final class RecursiveFibonacciUnitTest implements FibonacciSequenceGeneratorFixture {
+ @Override public FibonacciSequenceGenerator provide() {
+ return new RecursiveFibonacci();
+ }
+}
diff --git a/gradle-6/fibonacci-spi/build.gradle.kts b/gradle-6/fibonacci-spi/build.gradle.kts
new file mode 100644
index 0000000000..e571f329a9
--- /dev/null
+++ b/gradle-6/fibonacci-spi/build.gradle.kts
@@ -0,0 +1,13 @@
+plugins {
+ `java-library`
+ `java-test-fixtures`
+}
+
+dependencies {
+ testFixturesApi("org.junit.jupiter:junit-jupiter-api:5.5.2")
+ testFixturesImplementation("org.junit.jupiter:junit-jupiter-engine:5.5.2")
+}
+
+tasks.test {
+ useJUnitPlatform()
+}
\ No newline at end of file
diff --git a/gradle-6/fibonacci-spi/src/main/java/com/baeldung/fibonacci/FibonacciSequenceGenerator.java b/gradle-6/fibonacci-spi/src/main/java/com/baeldung/fibonacci/FibonacciSequenceGenerator.java
new file mode 100644
index 0000000000..5fd99100fc
--- /dev/null
+++ b/gradle-6/fibonacci-spi/src/main/java/com/baeldung/fibonacci/FibonacciSequenceGenerator.java
@@ -0,0 +1,13 @@
+package com.baeldung.fibonacci;
+
+/**
+ * Describes an SPI for a Fibonacci sequence generator function.
+ */
+public interface FibonacciSequenceGenerator {
+
+ /**
+ * @param nth the index of the number in the fibonacci sequence
+ * @return the nth number in the fibonacci sequence
+ */
+ int generate(int nth);
+}
diff --git a/gradle-6/fibonacci-spi/src/testFixtures/java/com/baeldung/fibonacci/FibonacciSequenceGeneratorFixture.java b/gradle-6/fibonacci-spi/src/testFixtures/java/com/baeldung/fibonacci/FibonacciSequenceGeneratorFixture.java
new file mode 100644
index 0000000000..5394590c03
--- /dev/null
+++ b/gradle-6/fibonacci-spi/src/testFixtures/java/com/baeldung/fibonacci/FibonacciSequenceGeneratorFixture.java
@@ -0,0 +1,30 @@
+package com.baeldung.fibonacci;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+/**
+ * Reusable test fixture for {@link FibonacciSequenceGenerator} implementations. Tests will be skipped if no such implementation exists.
+ */
+public interface FibonacciSequenceGeneratorFixture {
+
+ /**
+ * @return the implementation of {@link FibonacciSequenceGenerator} to test. Must not be null
+ */
+ FibonacciSequenceGenerator provide();
+
+ @Test default void when_sequence_index_is_negative_then_throws() {
+ final FibonacciSequenceGenerator generator = provide();
+ assertThrows(IllegalArgumentException.class, () -> generator.generate(-1));
+ }
+
+ @Test default void when_given_index_then_generates_fibonacci_number() {
+ final FibonacciSequenceGenerator generator = provide();
+ final int[] sequence = { 0, 1, 1, 2, 3, 5, 8 };
+ for (int i = 0; i < sequence.length; i++) {
+ assertEquals(sequence[i], generator.generate(i));
+ }
+ }
+}
diff --git a/gradle-6/gradle.properties b/gradle-6/gradle.properties
new file mode 100644
index 0000000000..7da8b3d72a
--- /dev/null
+++ b/gradle-6/gradle.properties
@@ -0,0 +1,2 @@
+org.gradle.parallel=true
+org.gradle.configureondemand=true
diff --git a/gradle-6/gradle/wrapper/gradle-wrapper.jar b/gradle-6/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000000..cc4fdc293d
Binary files /dev/null and b/gradle-6/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle-6/gradle/wrapper/gradle-wrapper.properties b/gradle-6/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000000..94920145f3
--- /dev/null
+++ b/gradle-6/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradle-6/gradlew b/gradle-6/gradlew
new file mode 100755
index 0000000000..2fe81a7d95
--- /dev/null
+++ b/gradle-6/gradlew
@@ -0,0 +1,183 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/gradle-6/gradlew.bat b/gradle-6/gradlew.bat
new file mode 100644
index 0000000000..24467a141f
--- /dev/null
+++ b/gradle-6/gradlew.bat
@@ -0,0 +1,100 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/gradle-6/httpclient-platform/build.gradle.kts b/gradle-6/httpclient-platform/build.gradle.kts
new file mode 100644
index 0000000000..a021bff013
--- /dev/null
+++ b/gradle-6/httpclient-platform/build.gradle.kts
@@ -0,0 +1,11 @@
+plugins {
+ `java-platform`
+}
+
+dependencies {
+ constraints {
+ api("org.apache.httpcomponents:fluent-hc:4.5.10")
+ api("org.apache.httpcomponents:httpclient:4.5.10")
+ runtime("commons-logging:commons-logging:1.2")
+ }
+}
\ No newline at end of file
diff --git a/gradle-6/module-metadata-publishing/build.gradle.kts b/gradle-6/module-metadata-publishing/build.gradle.kts
new file mode 100644
index 0000000000..9812c72f6f
--- /dev/null
+++ b/gradle-6/module-metadata-publishing/build.gradle.kts
@@ -0,0 +1,12 @@
+plugins {
+ java
+ `maven-publish`
+}
+
+publishing {
+ publications {
+ register("mavenJava") {
+ from(components["java"])
+ }
+ }
+}
\ No newline at end of file
diff --git a/gradle-6/person-rest-client/build.gradle.kts b/gradle-6/person-rest-client/build.gradle.kts
new file mode 100644
index 0000000000..c562b3e164
--- /dev/null
+++ b/gradle-6/person-rest-client/build.gradle.kts
@@ -0,0 +1,8 @@
+plugins {
+ `java-library`
+}
+
+dependencies {
+ api(platform(project(":httpclient-platform")))
+ implementation("org.apache.httpcomponents:fluent-hc")
+}
\ No newline at end of file
diff --git a/gradle-6/settings.gradle.kts b/gradle-6/settings.gradle.kts
new file mode 100644
index 0000000000..88cf74c4d7
--- /dev/null
+++ b/gradle-6/settings.gradle.kts
@@ -0,0 +1,10 @@
+rootProject.name = "gradle-6"
+
+include("configuration-avoidance")
+include("dependency-constraints")
+include("fibonacci-spi")
+include("fibonacci-recursive")
+include("httpclient-platform")
+include("module-metadata-publishing")
+include("person-rest-client")
+include("widget-rest-client")
\ No newline at end of file
diff --git a/gradle-6/widget-rest-client/build.gradle.kts b/gradle-6/widget-rest-client/build.gradle.kts
new file mode 100644
index 0000000000..e1af4b7f71
--- /dev/null
+++ b/gradle-6/widget-rest-client/build.gradle.kts
@@ -0,0 +1,8 @@
+plugins {
+ `java-library`
+}
+
+dependencies {
+ api(platform(project(":httpclient-platform")))
+ implementation("org.apache.httpcomponents:httpclient")
+}
\ No newline at end of file
diff --git a/persistence-modules/spring-hibernate-3/README.md b/persistence-modules/spring-hibernate-3/README.md
index 898c6522a9..610d586f85 100644
--- a/persistence-modules/spring-hibernate-3/README.md
+++ b/persistence-modules/spring-hibernate-3/README.md
@@ -4,8 +4,8 @@ This module contains articles about Spring with Hibernate 3
### Relevant Articles:
-- [Hibernate 3 with Spring](http://www.baeldung.com/hibernate3-spring)
-- [HibernateException: No Hibernate Session Bound to Thread in Hibernate 3](http://www.baeldung.com/no-hibernate-session-bound-to-thread-exception)
+- [Hibernate 3 with Spring](https://www.baeldung.com/hibernate3-spring)
+- [HibernateException: No Hibernate Session Bound to Thread in Hibernate 3](https://www.baeldung.com/no-hibernate-session-bound-to-thread-exception)
### Quick Start
diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/AbstractHibernateDao.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/AbstractHibernateDao.java
similarity index 97%
rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/AbstractHibernateDao.java
rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/AbstractHibernateDao.java
index 0f8b132891..701c6c43c7 100644
--- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/AbstractHibernateDao.java
+++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/AbstractHibernateDao.java
@@ -1,4 +1,4 @@
-package org.baeldung.persistence.dao;
+package com.baeldung.persistence.dao;
import java.io.Serializable;
import java.util.List;
diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/EventDao.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/EventDao.java
similarity index 70%
rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/EventDao.java
rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/EventDao.java
index 74da643f35..e6519d54c8 100644
--- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/EventDao.java
+++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/EventDao.java
@@ -1,18 +1,18 @@
-package org.baeldung.persistence.dao;
-
-
-import org.baeldung.persistence.model.Event;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public class EventDao extends AbstractHibernateDao implements IEventDao {
-
- public EventDao() {
- super();
-
- setClazz(Event.class);
- }
-
- // API
-
-}
+package com.baeldung.persistence.dao;
+
+
+import com.baeldung.persistence.model.Event;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class EventDao extends AbstractHibernateDao implements IEventDao {
+
+ public EventDao() {
+ super();
+
+ setClazz(Event.class);
+ }
+
+ // API
+
+}
diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/FooDao.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/FooDao.java
similarity index 73%
rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/FooDao.java
rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/FooDao.java
index 23de04169e..afcd958bc2 100644
--- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/FooDao.java
+++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/FooDao.java
@@ -1,6 +1,6 @@
-package org.baeldung.persistence.dao;
+package com.baeldung.persistence.dao;
-import org.baeldung.persistence.model.Foo;
+import com.baeldung.persistence.model.Foo;
import org.springframework.stereotype.Repository;
@Repository
diff --git a/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IEventDao.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IEventDao.java
new file mode 100644
index 0000000000..da2be1ce1e
--- /dev/null
+++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IEventDao.java
@@ -0,0 +1,8 @@
+package com.baeldung.persistence.dao;
+
+import com.baeldung.persistence.model.Event;
+
+
+public interface IEventDao extends IOperations {
+ //
+}
diff --git a/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IFooDao.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IFooDao.java
new file mode 100644
index 0000000000..f79883980a
--- /dev/null
+++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IFooDao.java
@@ -0,0 +1,7 @@
+package com.baeldung.persistence.dao;
+
+import com.baeldung.persistence.model.Foo;
+
+public interface IFooDao extends IOperations {
+ //
+}
diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IOperations.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IOperations.java
similarity index 89%
rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IOperations.java
rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IOperations.java
index 8c5a5e1aed..66f8008f27 100644
--- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IOperations.java
+++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/dao/IOperations.java
@@ -1,4 +1,4 @@
-package org.baeldung.persistence.dao;
+package com.baeldung.persistence.dao;
import java.io.Serializable;
import java.util.List;
diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/model/Event.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/model/Event.java
similarity index 89%
rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/model/Event.java
rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/model/Event.java
index 1d659ed75c..37a9758cd5 100644
--- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/model/Event.java
+++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/model/Event.java
@@ -1,45 +1,45 @@
-package org.baeldung.persistence.model;
-
-import java.io.Serializable;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-@Entity
-@Table(name = "EVENTS")
-public class Event implements Serializable {
-
- @Id
- @GeneratedValue
- private Long id;
-
- private String description;
-
- public Event() {
- }
-
-
- public Event(String description) {
- this.description = description;
- }
-
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
+package com.baeldung.persistence.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "EVENTS")
+public class Event implements Serializable {
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ private String description;
+
+ public Event() {
+ }
+
+
+ public Event(String description) {
+ this.description = description;
+ }
+
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
}
\ No newline at end of file
diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/model/Foo.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/model/Foo.java
similarity index 97%
rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/model/Foo.java
rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/model/Foo.java
index 8e1dee33e8..9af3d07bed 100644
--- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/model/Foo.java
+++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/model/Foo.java
@@ -1,4 +1,4 @@
-package org.baeldung.persistence.model;
+package com.baeldung.persistence.model;
import java.io.Serializable;
diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/service/EventService.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/service/EventService.java
similarity index 72%
rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/service/EventService.java
rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/service/EventService.java
index 6171751cc5..bf9afed38b 100644
--- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/service/EventService.java
+++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/service/EventService.java
@@ -1,27 +1,27 @@
-package org.baeldung.persistence.service;
-
-
-import org.baeldung.persistence.dao.IEventDao;
-import org.baeldung.persistence.model.Event;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-@Service
-@Transactional
-public class EventService {
-
- @Autowired
- private IEventDao dao;
-
- public EventService() {
- super();
- }
-
- // API
-
- public void create(final Event entity) {
- dao.create(entity);
- }
-
-}
+package com.baeldung.persistence.service;
+
+
+import com.baeldung.persistence.model.Event;
+import com.baeldung.persistence.dao.IEventDao;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+@Transactional
+public class EventService {
+
+ @Autowired
+ private IEventDao dao;
+
+ public EventService() {
+ super();
+ }
+
+ // API
+
+ public void create(final Event entity) {
+ dao.create(entity);
+ }
+
+}
diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/service/FooService.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/service/FooService.java
similarity index 75%
rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/service/FooService.java
rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/service/FooService.java
index b07698c438..ad88062216 100644
--- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/service/FooService.java
+++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/persistence/service/FooService.java
@@ -1,7 +1,7 @@
-package org.baeldung.persistence.service;
+package com.baeldung.persistence.service;
-import org.baeldung.persistence.dao.IFooDao;
-import org.baeldung.persistence.model.Foo;
+import com.baeldung.persistence.dao.IFooDao;
+import com.baeldung.persistence.model.Foo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceConfig.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceConfig.java
similarity index 94%
rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceConfig.java
rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceConfig.java
index 03b9bfac33..29472174b2 100644
--- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceConfig.java
+++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceConfig.java
@@ -1,4 +1,4 @@
-package org.baeldung.spring;
+package com.baeldung.spring;
import java.util.Properties;
@@ -22,7 +22,7 @@ import com.google.common.base.Preconditions;
@Configuration
@EnableTransactionManagement
@PropertySource({ "classpath:persistence-h2.properties" })
-@ComponentScan({ "org.baeldung.persistence.dao", "org.baeldung.persistence.service" })
+@ComponentScan({ "com.baeldung.persistence.dao", "com.baeldung.persistence.service" })
public class PersistenceConfig {
@Autowired
@@ -36,7 +36,7 @@ public class PersistenceConfig {
public AnnotationSessionFactoryBean sessionFactory() {
final AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean();
sessionFactory.setDataSource(dataSource());
- sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });
+ sessionFactory.setPackagesToScan(new String[] { "com.baeldung.persistence.model" });
sessionFactory.setHibernateProperties(hibernateProperties());
return sessionFactory;
diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceConfigHibernate3.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceConfigHibernate3.java
similarity index 97%
rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceConfigHibernate3.java
rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceConfigHibernate3.java
index f38da21dc0..08ae9a76df 100644
--- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceConfigHibernate3.java
+++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceConfigHibernate3.java
@@ -1,4 +1,4 @@
-package org.baeldung.spring;
+package com.baeldung.spring;
import java.util.Properties;
@@ -24,7 +24,7 @@ import com.google.common.base.Preconditions;
@Configuration
@EnableTransactionManagement
@PropertySource({ "classpath:persistence-h2.properties" })
-@ComponentScan({ "org.baeldung.persistence.dao", "org.baeldung.persistence.service" })
+@ComponentScan({ "com.baeldung.persistence.dao", "com.baeldung.persistence.service" })
public class PersistenceConfigHibernate3 {
@Autowired
diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java
similarity index 82%
rename from persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java
rename to persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java
index 5831d2745c..798fb740a7 100644
--- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/spring/PersistenceXmlConfig.java
+++ b/persistence-modules/spring-hibernate-3/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java
@@ -1,4 +1,4 @@
-package org.baeldung.spring;
+package com.baeldung.spring;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
@@ -6,7 +6,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
// @Configuration
@EnableTransactionManagement
-@ComponentScan({ "org.baeldung.persistence.dao", "org.baeldung.persistence.service" })
+@ComponentScan({ "com.baeldung.persistence.dao", "com.baeldung.persistence.service" })
@ImportResource({ "classpath:persistenceConfig.xml" })
public class PersistenceXmlConfig {
diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IEventDao.java b/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IEventDao.java
deleted file mode 100644
index f7be705905..0000000000
--- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IEventDao.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.baeldung.persistence.dao;
-
-import org.baeldung.persistence.model.Event;
-
-
-
-public interface IEventDao extends IOperations {
- //
-}
diff --git a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IFooDao.java b/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IFooDao.java
deleted file mode 100644
index 6a3bd95d71..0000000000
--- a/persistence-modules/spring-hibernate-3/src/main/java/org/baeldung/persistence/dao/IFooDao.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.baeldung.persistence.dao;
-
-import org.baeldung.persistence.model.Foo;
-
-public interface IFooDao extends IOperations {
- //
-}
diff --git a/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemo.cfg.xml b/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemo.cfg.xml
index 8a710cc559..896c080983 100644
--- a/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemo.cfg.xml
+++ b/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemo.cfg.xml
@@ -4,6 +4,6 @@
"http://hibernate.org/dtd/hibernate-configuration-3.0.dtd">
-
+
diff --git a/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemoPersistenceConfig.xml b/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemoPersistenceConfig.xml
index 263e902e7c..5f9e8c0107 100644
--- a/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemoPersistenceConfig.xml
+++ b/persistence-modules/spring-hibernate-3/src/main/resources/exceptionDemoPersistenceConfig.xml
@@ -16,7 +16,7 @@
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
-
+
diff --git a/persistence-modules/spring-hibernate-3/src/main/resources/persistenceConfig.xml b/persistence-modules/spring-hibernate-3/src/main/resources/persistenceConfig.xml
index f39817383b..03d4d022e6 100644
--- a/persistence-modules/spring-hibernate-3/src/main/resources/persistenceConfig.xml
+++ b/persistence-modules/spring-hibernate-3/src/main/resources/persistenceConfig.xml
@@ -9,7 +9,7 @@
-
+
${hibernate.hbm2ddl.auto}
diff --git a/persistence-modules/spring-hibernate-3/src/main/webapp/WEB-INF/web.xml b/persistence-modules/spring-hibernate-3/src/main/webapp/WEB-INF/web.xml
index ad56bf28c7..69ce04fe06 100644
--- a/persistence-modules/spring-hibernate-3/src/main/webapp/WEB-INF/web.xml
+++ b/persistence-modules/spring-hibernate-3/src/main/webapp/WEB-INF/web.xml
@@ -11,7 +11,7 @@
contextConfigLocation
- org.baeldung.spring
+ com.baeldung.spring
org.springframework.web.context.ContextLoaderListener
diff --git a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/SpringContextTest.java
similarity index 88%
rename from persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/SpringContextTest.java
rename to persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/SpringContextTest.java
index 956d5279a3..8b352b490d 100644
--- a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/SpringContextTest.java
+++ b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/SpringContextTest.java
@@ -1,6 +1,6 @@
-package org.baeldung;
+package com.baeldung;
-import org.baeldung.spring.PersistenceConfig;
+import com.baeldung.spring.PersistenceConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
diff --git a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java
similarity index 91%
rename from persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java
rename to persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java
index b6e4a5592f..7874f7c679 100644
--- a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java
+++ b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java
@@ -1,10 +1,9 @@
-package org.baeldung.persistence.service;
+package com.baeldung.persistence.service;
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
-import org.baeldung.persistence.model.Foo;
-import org.baeldung.persistence.service.FooService;
-import org.baeldung.spring.PersistenceConfig;
+import com.baeldung.spring.PersistenceConfig;
+import com.baeldung.persistence.model.Foo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/HibernateExceptionScen1MainIntegrationTest.java b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/HibernateExceptionScen1MainIntegrationTest.java
similarity index 90%
rename from persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/HibernateExceptionScen1MainIntegrationTest.java
rename to persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/HibernateExceptionScen1MainIntegrationTest.java
index 08032660c0..99dc7b42be 100644
--- a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/HibernateExceptionScen1MainIntegrationTest.java
+++ b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/HibernateExceptionScen1MainIntegrationTest.java
@@ -1,7 +1,7 @@
-package org.baeldung.persistence.service;
+package com.baeldung.persistence.service;
-import org.baeldung.persistence.model.Event;
-import org.baeldung.spring.PersistenceConfigHibernate3;
+import com.baeldung.persistence.model.Event;
+import com.baeldung.spring.PersistenceConfigHibernate3;
import org.hamcrest.core.IsInstanceOf;
import org.hibernate.HibernateException;
import org.junit.Ignore;
diff --git a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/HibernateExceptionScen2MainIntegrationTest.java b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/HibernateExceptionScen2MainIntegrationTest.java
similarity index 91%
rename from persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/HibernateExceptionScen2MainIntegrationTest.java
rename to persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/HibernateExceptionScen2MainIntegrationTest.java
index 44cc6ca010..d3e475a244 100644
--- a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/HibernateExceptionScen2MainIntegrationTest.java
+++ b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/HibernateExceptionScen2MainIntegrationTest.java
@@ -1,7 +1,7 @@
-package org.baeldung.persistence.service;
+package com.baeldung.persistence.service;
-import org.baeldung.persistence.model.Event;
-import org.baeldung.spring.PersistenceConfig;
+import com.baeldung.persistence.model.Event;
+import com.baeldung.spring.PersistenceConfig;
import org.hamcrest.core.IsInstanceOf;
import org.hibernate.HibernateException;
import org.junit.Ignore;
diff --git a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest.java b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest.java
similarity index 88%
rename from persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest.java
rename to persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest.java
index 2b29dcb7a9..d1c5cc04e6 100644
--- a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest.java
+++ b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest.java
@@ -1,42 +1,42 @@
-package org.baeldung.persistence.service;
-
-import org.baeldung.persistence.model.Event;
-import org.baeldung.spring.PersistenceXmlConfig;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.orm.hibernate3.HibernateSystemException;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.support.AnnotationConfigContextLoader;
-
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = { PersistenceXmlConfig.class }, loader = AnnotationConfigContextLoader.class)
-public class NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest {
-
- @Autowired
- EventService service;
-
- @Rule
- public ExpectedException expectedEx = ExpectedException.none();
-
- @Test
- public final void whenEntityIsCreated_thenNoExceptions() {
- service.create(new Event("from Annotation Session Bean Factory"));
- }
-
- @Test
- @Ignore
- public final void whenNoTransBoundToSession_thenException() {
- expectedEx.expect(HibernateSystemException.class);
- expectedEx.expectMessage("No Hibernate Session bound to thread, "
- + "and configuration does not allow creation of "
- + "non-transactional one here");
- service.create(new Event("from Annotation Session Bean Factory"));
- }
-
-}
+package com.baeldung.persistence.service;
+
+import com.baeldung.persistence.model.Event;
+import com.baeldung.spring.PersistenceXmlConfig;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.orm.hibernate3.HibernateSystemException;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.support.AnnotationConfigContextLoader;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = { PersistenceXmlConfig.class }, loader = AnnotationConfigContextLoader.class)
+public class NoHibernateSessBoundUsingAnnoSessionBeanMainIntegrationTest {
+
+ @Autowired
+ EventService service;
+
+ @Rule
+ public ExpectedException expectedEx = ExpectedException.none();
+
+ @Test
+ public final void whenEntityIsCreated_thenNoExceptions() {
+ service.create(new Event("from Annotation Session Bean Factory"));
+ }
+
+ @Test
+ @Ignore
+ public final void whenNoTransBoundToSession_thenException() {
+ expectedEx.expect(HibernateSystemException.class);
+ expectedEx.expectMessage("No Hibernate Session bound to thread, "
+ + "and configuration does not allow creation of "
+ + "non-transactional one here");
+ service.create(new Event("from Annotation Session Bean Factory"));
+ }
+
+}
diff --git a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest.java b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest.java
similarity index 86%
rename from persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest.java
rename to persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest.java
index 1bc6c07b18..1df6aa172c 100644
--- a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/persistence/service/NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest.java
+++ b/persistence-modules/spring-hibernate-3/src/test/java/com/baeldung/persistence/service/NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest.java
@@ -1,39 +1,38 @@
-package org.baeldung.persistence.service;
-
-import org.baeldung.persistence.model.Event;
-import org.hibernate.HibernateException;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.orm.hibernate3.HibernateSystemException;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath:exceptionDemoPersistenceConfig.xml" })
-public class NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest {
-
- @Autowired
- EventService service;
-
- @Rule
- public ExpectedException expectedEx = ExpectedException.none();
-
- @Test
- public final void whenEntityIsCreated_thenNoExceptions() {
- service.create(new Event("from local session bean factory"));
- }
-
- @Test
- @Ignore
- public final void whenNoTransBoundToSession_thenException() {
- expectedEx.expect(HibernateException.class);
- expectedEx.expectMessage("No Hibernate Session bound to thread, "
- + "and configuration does not allow creation "
- + "of non-transactional one here");
- service.create(new Event("from local session bean factory"));
- }
-}
+package com.baeldung.persistence.service;
+
+import com.baeldung.persistence.model.Event;
+import org.hibernate.HibernateException;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "classpath:exceptionDemoPersistenceConfig.xml" })
+public class NoHibernateSessBoundUsingLocalSessionBeanMainIntegrationTest {
+
+ @Autowired
+ EventService service;
+
+ @Rule
+ public ExpectedException expectedEx = ExpectedException.none();
+
+ @Test
+ public final void whenEntityIsCreated_thenNoExceptions() {
+ service.create(new Event("from local session bean factory"));
+ }
+
+ @Test
+ @Ignore
+ public final void whenNoTransBoundToSession_thenException() {
+ expectedEx.expect(HibernateException.class);
+ expectedEx.expectMessage("No Hibernate Session bound to thread, "
+ + "and configuration does not allow creation "
+ + "of non-transactional one here");
+ service.create(new Event("from local session bean factory"));
+ }
+}
diff --git a/persistence-modules/spring-hibernate-5/README.md b/persistence-modules/spring-hibernate-5/README.md
index a74600a47f..c3c8fa7b9f 100644
--- a/persistence-modules/spring-hibernate-5/README.md
+++ b/persistence-modules/spring-hibernate-5/README.md
@@ -4,11 +4,11 @@ This module contains articles about Hibernate 5 with Spring.
### Relevant articles
-- [Hibernate Many to Many Annotation Tutorial](http://www.baeldung.com/hibernate-many-to-many)
-- [Programmatic Transactions in the Spring TestContext Framework](http://www.baeldung.com/spring-test-programmatic-transactions)
-- [JPA Criteria Queries](http://www.baeldung.com/hibernate-criteria-queries)
-- [Introduction to Hibernate Search](http://www.baeldung.com/hibernate-search)
+- [Hibernate Many to Many Annotation Tutorial](https://www.baeldung.com/hibernate-many-to-many)
+- [Programmatic Transactions in the Spring TestContext Framework](https://www.baeldung.com/spring-test-programmatic-transactions)
+- [JPA Criteria Queries](https://www.baeldung.com/hibernate-criteria-queries)
+- [Introduction to Hibernate Search](https://www.baeldung.com/hibernate-search)
- [@DynamicUpdate with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-dynamicupdate)
-- [Hibernate Second-Level Cache](http://www.baeldung.com/hibernate-second-level-cache)
-- [Deleting Objects with Hibernate](http://www.baeldung.com/delete-with-hibernate)
-- [Spring, Hibernate and a JNDI Datasource](http://www.baeldung.com/spring-persistence-jpa-jndi-datasource)
+- [Hibernate Second-Level Cache](https://www.baeldung.com/hibernate-second-level-cache)
+- [Deleting Objects with Hibernate](https://www.baeldung.com/delete-with-hibernate)
+- [Spring, Hibernate and a JNDI Datasource](https://www.baeldung.com/spring-persistence-jpa-jndi-datasource)
diff --git a/persistence-modules/spring-hibernate-5/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/SpringContextTest.java
similarity index 96%
rename from persistence-modules/spring-hibernate-5/src/test/java/org/baeldung/SpringContextTest.java
rename to persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/SpringContextTest.java
index 6815ebf304..e19965773e 100644
--- a/persistence-modules/spring-hibernate-5/src/test/java/org/baeldung/SpringContextTest.java
+++ b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/persistence-modules/spring-hibernate4/README.md b/persistence-modules/spring-hibernate4/README.md
index c9e2b5abfc..cfa13ca3b0 100644
--- a/persistence-modules/spring-hibernate4/README.md
+++ b/persistence-modules/spring-hibernate4/README.md
@@ -3,13 +3,13 @@
This module contains articles about Spring with Hibernate 4
### Relevant Articles:
-- [Guide to Hibernate 4 with Spring](http://www.baeldung.com/hibernate-4-spring)
-- [Hibernate Pagination](http://www.baeldung.com/hibernate-pagination)
-- [Sorting with Hibernate](http://www.baeldung.com/hibernate-sort)
-- [Stored Procedures with Hibernate](http://www.baeldung.com/stored-procedures-with-hibernate-tutorial)
-- [Hibernate: save, persist, update, merge, saveOrUpdate](http://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate)
-- [Eager/Lazy Loading In Hibernate](http://www.baeldung.com/hibernate-lazy-eager-loading)
-- [The DAO with Spring and Hibernate](http://www.baeldung.com/persistence-layer-with-spring-and-hibernate)
+- [Guide to Hibernate 4 with Spring](https://www.baeldung.com/hibernate-4-spring)
+- [Hibernate Pagination](https://www.baeldung.com/hibernate-pagination)
+- [Sorting with Hibernate](https://www.baeldung.com/hibernate-sort)
+- [Stored Procedures with Hibernate](https://www.baeldung.com/stored-procedures-with-hibernate-tutorial)
+- [Hibernate: save, persist, update, merge, saveOrUpdate](https://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate)
+- [Eager/Lazy Loading In Hibernate](https://www.baeldung.com/hibernate-lazy-eager-loading)
+- [The DAO with Spring and Hibernate](https://www.baeldung.com/persistence-layer-with-spring-and-hibernate)
- [Auditing with JPA, Hibernate, and Spring Data JPA](https://www.baeldung.com/database-auditing-jpa)
### Quick Start
diff --git a/persistence-modules/spring-hibernate4/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/SpringContextTest.java
similarity index 96%
rename from persistence-modules/spring-hibernate4/src/test/java/org/baeldung/SpringContextTest.java
rename to persistence-modules/spring-hibernate4/src/test/java/com/baeldung/SpringContextTest.java
index 6815ebf304..e19965773e 100644
--- a/persistence-modules/spring-hibernate4/src/test/java/org/baeldung/SpringContextTest.java
+++ b/persistence-modules/spring-hibernate4/src/test/java/com/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/persistence-modules/spring-jpa/README.md b/persistence-modules/spring-jpa/README.md
index 489d990fc3..27a2fe8368 100644
--- a/persistence-modules/spring-jpa/README.md
+++ b/persistence-modules/spring-jpa/README.md
@@ -4,13 +4,13 @@
### Relevant Articles:
-- [The DAO with JPA and Spring](http://www.baeldung.com/spring-dao-jpa)
-- [JPA Pagination](http://www.baeldung.com/jpa-pagination)
-- [Sorting with JPA](http://www.baeldung.com/jpa-sort)
-- [Self-Contained Testing Using an In-Memory Database](http://www.baeldung.com/spring-jpa-test-in-memory-database)
-- [A Guide to Spring AbstractRoutingDatasource](http://www.baeldung.com/spring-abstract-routing-data-source)
-- [Obtaining Auto-generated Keys in Spring JDBC](http://www.baeldung.com/spring-jdbc-autogenerated-keys)
-- [Transactions with Spring 4 and JPA](http://www.baeldung.com/transaction-configuration-with-jpa-and-spring)
+- [The DAO with JPA and Spring](https://www.baeldung.com/spring-dao-jpa)
+- [JPA Pagination](https://www.baeldung.com/jpa-pagination)
+- [Sorting with JPA](https://www.baeldung.com/jpa-sort)
+- [Self-Contained Testing Using an In-Memory Database](https://www.baeldung.com/spring-jpa-test-in-memory-database)
+- [A Guide to Spring AbstractRoutingDatasource](https://www.baeldung.com/spring-abstract-routing-data-source)
+- [Obtaining Auto-generated Keys in Spring JDBC](https://www.baeldung.com/spring-jdbc-autogenerated-keys)
+- [Transactions with Spring 4 and JPA](https://www.baeldung.com/transaction-configuration-with-jpa-and-spring)
- [Use Criteria Queries in a Spring Data Application](https://www.baeldung.com/spring-data-criteria-queries)
- [Many-To-Many Relationship in JPA](https://www.baeldung.com/jpa-many-to-many)
- [Spring Persistence (Hibernate and JPA) with a JNDI datasource](https://www.baeldung.com/spring-persistence-hibernate-and-jpa-with-a-jndi-datasource/)
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/annotations/MyUtilityRepository.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/annotations/MyUtilityRepository.java
similarity index 90%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/annotations/MyUtilityRepository.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/annotations/MyUtilityRepository.java
index 5fe54b80d9..a23e9d9fe4 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/annotations/MyUtilityRepository.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/annotations/MyUtilityRepository.java
@@ -1,4 +1,4 @@
-package org.baeldung.annotations;
+package com.baeldung.annotations;
import java.io.Serializable;
import java.util.Optional;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/annotations/Person.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/annotations/Person.java
similarity index 93%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/annotations/Person.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/annotations/Person.java
index 309a4f43e1..b881535e05 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/annotations/Person.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/annotations/Person.java
@@ -1,4 +1,4 @@
-package org.baeldung.annotations;
+package com.baeldung.annotations;
import java.util.Date;
@@ -8,7 +8,7 @@ import javax.persistence.NamedStoredProcedureQuery;
import javax.persistence.ParameterMode;
import javax.persistence.StoredProcedureParameter;
-import org.baeldung.persistence.multiple.model.user.User;
+import com.baeldung.persistence.multiple.model.user.User;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/annotations/PersonRepository.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/annotations/PersonRepository.java
similarity index 96%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/annotations/PersonRepository.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/annotations/PersonRepository.java
index 58558860ff..77b7067f11 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/annotations/PersonRepository.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/annotations/PersonRepository.java
@@ -1,4 +1,4 @@
-package org.baeldung.annotations;
+package com.baeldung.annotations;
import javax.persistence.LockModeType;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/config/PersistenceJPAConfig.java
similarity index 94%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/config/PersistenceJPAConfig.java
index ec0d4bca3c..4eda4d9274 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/config/PersistenceJPAConfig.java
@@ -1,4 +1,4 @@
-package org.baeldung.config;
+package com.baeldung.config;
import java.util.Properties;
@@ -25,8 +25,8 @@ import com.google.common.base.Preconditions;
@Configuration
@EnableTransactionManagement
@PropertySource({ "classpath:persistence-h2.properties" })
-@ComponentScan({ "org.baeldung.persistence" })
-@EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao")
+@ComponentScan({ "com.baeldung.persistence" })
+@EnableJpaRepositories(basePackages = "com.baeldung.persistence.dao")
public class PersistenceJPAConfig {
@Autowired
@@ -42,7 +42,7 @@ public class PersistenceJPAConfig {
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
- em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });
+ em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" });
final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(vendorAdapter);
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfigXml.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/config/PersistenceJPAConfigXml.java
similarity index 84%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfigXml.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/config/PersistenceJPAConfigXml.java
index 3df36e62ee..95224a4662 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfigXml.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/config/PersistenceJPAConfigXml.java
@@ -1,4 +1,4 @@
-package org.baeldung.config;
+package com.baeldung.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
@@ -6,7 +6,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
// @Configuration
@EnableTransactionManagement
-@ComponentScan({ "org.baeldung.persistence" })
+@ComponentScan({ "com.baeldung.persistence" })
@ImportResource({ "classpath:jpaConfig.xml" })
public class PersistenceJPAConfigXml {
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/SpringWebConfig.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/config/SpringWebConfig.java
similarity index 92%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/config/SpringWebConfig.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/config/SpringWebConfig.java
index 6afb271b10..475970d1f0 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/SpringWebConfig.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/config/SpringWebConfig.java
@@ -1,4 +1,4 @@
-package org.baeldung.config;
+package com.baeldung.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@@ -10,7 +10,7 @@ import org.springframework.web.servlet.view.JstlView;
@EnableWebMvc
@Configuration
-@ComponentScan({ "org.baeldung.web" })
+@ComponentScan({ "com.baeldung.web" })
public class SpringWebConfig extends WebMvcConfigurerAdapter {
@Bean
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/StudentJpaConfig.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/config/StudentJpaConfig.java
similarity index 94%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/config/StudentJpaConfig.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/config/StudentJpaConfig.java
index 17047cbab2..08f37ea806 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/StudentJpaConfig.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/config/StudentJpaConfig.java
@@ -1,4 +1,4 @@
-package org.baeldung.config;
+package com.baeldung.config;
import java.util.Properties;
@@ -18,7 +18,7 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
-@EnableJpaRepositories(basePackages = "org.baeldung.inmemory.persistence.dao")
+@EnableJpaRepositories(basePackages = "com.baeldung.inmemory.persistence.dao")
@PropertySource("persistence-student.properties")
@EnableTransactionManagement
public class StudentJpaConfig {
@@ -41,7 +41,7 @@ public class StudentJpaConfig {
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
- em.setPackagesToScan(new String[] { "org.baeldung.inmemory.persistence.model" });
+ em.setPackagesToScan(new String[] { "com.baeldung.inmemory.persistence.model" });
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
em.setJpaProperties(additionalProperties());
return em;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/WebInitializer.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/config/WebInitializer.java
similarity index 95%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/config/WebInitializer.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/config/WebInitializer.java
index cf6e69eb39..be81cca76b 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/WebInitializer.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/config/WebInitializer.java
@@ -1,4 +1,4 @@
-package org.baeldung.config;
+package com.baeldung.config;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/dsrouting/ClientDao.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDao.java
similarity index 95%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/dsrouting/ClientDao.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDao.java
index 9e19cf4ed9..e8117ba4fa 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/dsrouting/ClientDao.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDao.java
@@ -1,4 +1,4 @@
-package org.baeldung.dsrouting;
+package com.baeldung.dsrouting;
import javax.sql.DataSource;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/dsrouting/ClientDataSourceRouter.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDataSourceRouter.java
similarity index 91%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/dsrouting/ClientDataSourceRouter.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDataSourceRouter.java
index 997e461cde..a9f5d83b55 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/dsrouting/ClientDataSourceRouter.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDataSourceRouter.java
@@ -1,4 +1,4 @@
-package org.baeldung.dsrouting;
+package com.baeldung.dsrouting;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/dsrouting/ClientDatabase.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDatabase.java
similarity index 64%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/dsrouting/ClientDatabase.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDatabase.java
index 619b8707d8..d8d178a4d5 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/dsrouting/ClientDatabase.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDatabase.java
@@ -1,4 +1,4 @@
-package org.baeldung.dsrouting;
+package com.baeldung.dsrouting;
public enum ClientDatabase {
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/dsrouting/ClientDatabaseContextHolder.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDatabaseContextHolder.java
similarity index 95%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/dsrouting/ClientDatabaseContextHolder.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDatabaseContextHolder.java
index c08559e877..ae5d16cad2 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/dsrouting/ClientDatabaseContextHolder.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientDatabaseContextHolder.java
@@ -1,4 +1,4 @@
-package org.baeldung.dsrouting;
+package com.baeldung.dsrouting;
import org.springframework.util.Assert;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/dsrouting/ClientService.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientService.java
similarity index 94%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/dsrouting/ClientService.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientService.java
index 4b63c6333c..59b3d1660a 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/dsrouting/ClientService.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/dsrouting/ClientService.java
@@ -1,4 +1,4 @@
-package org.baeldung.dsrouting;
+package com.baeldung.dsrouting;
/**
* Service layer code for datasource routing example. Here, the service methods are responsible
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/dao/ManyStudentRepository.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/dao/ManyStudentRepository.java
similarity index 68%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/dao/ManyStudentRepository.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/dao/ManyStudentRepository.java
index a03b2950a0..a2aa0c5780 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/dao/ManyStudentRepository.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/dao/ManyStudentRepository.java
@@ -1,6 +1,6 @@
-package org.baeldung.inmemory.persistence.dao;
+package com.baeldung.inmemory.persistence.dao;
-import org.baeldung.inmemory.persistence.model.ManyStudent;
+import com.baeldung.inmemory.persistence.model.ManyStudent;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/dao/ManyTagRepository.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/dao/ManyTagRepository.java
similarity index 57%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/dao/ManyTagRepository.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/dao/ManyTagRepository.java
index b7d991de32..63337f3cb9 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/dao/ManyTagRepository.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/dao/ManyTagRepository.java
@@ -1,6 +1,6 @@
-package org.baeldung.inmemory.persistence.dao;
+package com.baeldung.inmemory.persistence.dao;
-import org.baeldung.inmemory.persistence.model.ManyTag;
+import com.baeldung.inmemory.persistence.model.ManyTag;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ManyTagRepository extends JpaRepository {
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/dao/StudentRepository.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/dao/StudentRepository.java
similarity index 90%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/dao/StudentRepository.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/dao/StudentRepository.java
index ffe1a68558..8ac91fbf0c 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/dao/StudentRepository.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/dao/StudentRepository.java
@@ -1,6 +1,6 @@
-package org.baeldung.inmemory.persistence.dao;
+package com.baeldung.inmemory.persistence.dao;
-import org.baeldung.inmemory.persistence.model.Student;
+import com.baeldung.inmemory.persistence.model.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/KVTag.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/KVTag.java
similarity index 91%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/KVTag.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/KVTag.java
index 1522744116..1fc186f4ce 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/KVTag.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/KVTag.java
@@ -1,4 +1,4 @@
-package org.baeldung.inmemory.persistence.model;
+package com.baeldung.inmemory.persistence.model;
import javax.persistence.Embeddable;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/LocationTag.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/LocationTag.java
similarity index 92%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/LocationTag.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/LocationTag.java
index 3acdbbe6fe..b12ad9fbd1 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/LocationTag.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/LocationTag.java
@@ -1,4 +1,4 @@
-package org.baeldung.inmemory.persistence.model;
+package com.baeldung.inmemory.persistence.model;
import javax.persistence.Embeddable;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/ManyStudent.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/ManyStudent.java
similarity index 94%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/ManyStudent.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/ManyStudent.java
index 8343edc9cd..190740d582 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/ManyStudent.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/ManyStudent.java
@@ -1,4 +1,4 @@
-package org.baeldung.inmemory.persistence.model;
+package com.baeldung.inmemory.persistence.model;
import javax.persistence.*;
import java.util.HashSet;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/ManyTag.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/ManyTag.java
similarity index 93%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/ManyTag.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/ManyTag.java
index e820506544..5af898f7df 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/ManyTag.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/ManyTag.java
@@ -1,4 +1,4 @@
-package org.baeldung.inmemory.persistence.model;
+package com.baeldung.inmemory.persistence.model;
import javax.persistence.*;
import java.util.HashSet;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/SkillTag.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/SkillTag.java
similarity index 90%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/SkillTag.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/SkillTag.java
index 490ee0a18e..738b5d0b36 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/SkillTag.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/SkillTag.java
@@ -1,4 +1,4 @@
-package org.baeldung.inmemory.persistence.model;
+package com.baeldung.inmemory.persistence.model;
import javax.persistence.Embeddable;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/Student.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/Student.java
similarity index 96%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/Student.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/Student.java
index 07aa3ef9ef..f0e824e165 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/Student.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/inmemory/persistence/model/Student.java
@@ -1,4 +1,4 @@
-package org.baeldung.inmemory.persistence.model;
+package com.baeldung.inmemory.persistence.model;
import java.util.ArrayList;
import java.util.List;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/AbstractJpaDAO.java
similarity index 96%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/AbstractJpaDAO.java
index 13007d9fcc..b4827cc7e1 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/AbstractJpaDAO.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/AbstractJpaDAO.java
@@ -1,4 +1,4 @@
-package org.baeldung.persistence.dao;
+package com.baeldung.persistence.dao;
import java.io.Serializable;
import java.util.List;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepository.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepository.java
similarity index 76%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepository.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepository.java
index 114cf48c7c..48620f4ff1 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepository.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepository.java
@@ -1,6 +1,6 @@
-package org.baeldung.persistence.dao;
+package com.baeldung.persistence.dao;
-import org.baeldung.persistence.model.Book;
+import com.baeldung.persistence.model.Book;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepositoryCustom.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java
similarity index 65%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepositoryCustom.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java
index b939907572..1b46d0ecc3 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepositoryCustom.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java
@@ -1,8 +1,8 @@
-package org.baeldung.persistence.dao;
+package com.baeldung.persistence.dao;
import java.util.List;
-import org.baeldung.persistence.model.Book;
+import com.baeldung.persistence.model.Book;
public interface BookRepositoryCustom {
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepositoryImpl.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java
similarity index 93%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepositoryImpl.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java
index 6e9aa998d7..241a4c05aa 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepositoryImpl.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java
@@ -1,4 +1,4 @@
-package org.baeldung.persistence.dao;
+package com.baeldung.persistence.dao;
import java.util.ArrayList;
import java.util.List;
@@ -10,7 +10,7 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
-import org.baeldung.persistence.model.Book;
+import com.baeldung.persistence.model.Book;
import org.springframework.stereotype.Repository;
@Repository
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookService.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookService.java
similarity index 71%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookService.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookService.java
index 88b769e9bf..f02f9daa11 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookService.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookService.java
@@ -1,12 +1,12 @@
-package org.baeldung.persistence.dao;
+package com.baeldung.persistence.dao;
-import static org.baeldung.persistence.dao.BookSpecifications.hasAuthor;
-import static org.baeldung.persistence.dao.BookSpecifications.titleContains;
+import static com.baeldung.persistence.dao.BookSpecifications.hasAuthor;
+import static com.baeldung.persistence.dao.BookSpecifications.titleContains;
import static org.springframework.data.jpa.domain.Specifications.where;
import java.util.List;
-import org.baeldung.persistence.model.Book;
+import com.baeldung.persistence.model.Book;
import org.springframework.stereotype.Service;
@Service
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookSpecifications.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookSpecifications.java
similarity index 82%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookSpecifications.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookSpecifications.java
index ed9540060d..16646a5b4b 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookSpecifications.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookSpecifications.java
@@ -1,6 +1,6 @@
-package org.baeldung.persistence.dao;
+package com.baeldung.persistence.dao;
-import org.baeldung.persistence.model.Book;
+import com.baeldung.persistence.model.Book;
import org.springframework.data.jpa.domain.Specification;
public class BookSpecifications {
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/FooDao.java
similarity index 73%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/FooDao.java
index 77978c5cf2..a4ed7d97b4 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/FooDao.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/FooDao.java
@@ -1,6 +1,6 @@
-package org.baeldung.persistence.dao;
+package com.baeldung.persistence.dao;
-import org.baeldung.persistence.model.Foo;
+import com.baeldung.persistence.model.Foo;
import org.springframework.stereotype.Repository;
@Repository
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/IFooDao.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/IFooDao.java
similarity index 74%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/IFooDao.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/IFooDao.java
index f5799522e2..8a4877aa79 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/IFooDao.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/IFooDao.java
@@ -1,8 +1,8 @@
-package org.baeldung.persistence.dao;
+package com.baeldung.persistence.dao;
import java.util.List;
-import org.baeldung.persistence.model.Foo;
+import com.baeldung.persistence.model.Foo;
public interface IFooDao {
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/model/Bar.java
similarity index 98%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/model/Bar.java
index b602e57562..5a88ecc6cf 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/model/Bar.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/model/Bar.java
@@ -1,4 +1,4 @@
-package org.baeldung.persistence.model;
+package com.baeldung.persistence.model;
import java.io.Serializable;
import java.util.List;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/model/Book.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/model/Book.java
similarity index 92%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/model/Book.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/model/Book.java
index 754bd179d1..507043dd56 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/model/Book.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/model/Book.java
@@ -1,4 +1,4 @@
-package org.baeldung.persistence.model;
+package com.baeldung.persistence.model;
import javax.persistence.Entity;
import javax.persistence.Id;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/model/Foo.java
similarity index 98%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/model/Foo.java
index 5294860311..7897bba4e4 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/model/Foo.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/model/Foo.java
@@ -1,4 +1,4 @@
-package org.baeldung.persistence.model;
+package com.baeldung.persistence.model;
import org.hibernate.annotations.CacheConcurrencyStrategy;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/multiple/model/user/Possession.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/multiple/model/user/Possession.java
similarity index 96%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/multiple/model/user/Possession.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/multiple/model/user/Possession.java
index 7aff5f51d0..6ad6b8e603 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/multiple/model/user/Possession.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/multiple/model/user/Possession.java
@@ -1,4 +1,4 @@
-package org.baeldung.persistence.multiple.model.user;
+package com.baeldung.persistence.multiple.model.user;
import javax.persistence.*;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/multiple/model/user/User.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/multiple/model/user/User.java
similarity index 96%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/multiple/model/user/User.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/multiple/model/user/User.java
index 6fb9de4a47..3ebb1e0156 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/multiple/model/user/User.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/multiple/model/user/User.java
@@ -1,4 +1,4 @@
-package org.baeldung.persistence.multiple.model.user;
+package com.baeldung.persistence.multiple.model.user;
import javax.persistence.*;
import java.util.List;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/service/FooService.java
similarity index 81%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/service/FooService.java
index 6d1bb0adbe..ace36dd03b 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/service/FooService.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/service/FooService.java
@@ -1,9 +1,9 @@
-package org.baeldung.persistence.service;
+package com.baeldung.persistence.service;
import java.util.List;
-import org.baeldung.persistence.dao.IFooDao;
-import org.baeldung.persistence.model.Foo;
+import com.baeldung.persistence.dao.IFooDao;
+import com.baeldung.persistence.model.Foo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/sqlfiles/Country.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/sqlfiles/Country.java
similarity index 95%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/sqlfiles/Country.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/sqlfiles/Country.java
index 922f55cbf6..f2be33adfd 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/sqlfiles/Country.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/sqlfiles/Country.java
@@ -1,4 +1,4 @@
-package org.baeldung.sqlfiles;
+package com.baeldung.sqlfiles;
import static javax.persistence.GenerationType.IDENTITY;
diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/web/MainController.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/web/MainController.java
similarity index 85%
rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/web/MainController.java
rename to persistence-modules/spring-jpa/src/main/java/com/baeldung/web/MainController.java
index 6900482de8..c0d4743ae7 100644
--- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/web/MainController.java
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/web/MainController.java
@@ -1,6 +1,6 @@
-package org.baeldung.web;
+package com.baeldung.web;
-import org.baeldung.persistence.service.FooService;
+import com.baeldung.persistence.service.FooService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
diff --git a/persistence-modules/spring-jpa/src/main/resources/persistence.xml b/persistence-modules/spring-jpa/src/main/resources/persistence.xml
index 6304fa0a65..57687c306d 100644
--- a/persistence-modules/spring-jpa/src/main/resources/persistence.xml
+++ b/persistence-modules/spring-jpa/src/main/resources/persistence.xml
@@ -11,7 +11,7 @@
-
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Bike.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/Bike.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Bike.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/Bike.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Biker.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/Biker.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Biker.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/Biker.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Car.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/Car.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Car.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/Car.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/CarMechanic.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/CarMechanic.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/CarMechanic.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/CarMechanic.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/CarUtility.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/CarUtility.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/CarUtility.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/CarUtility.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/CustomException.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/CustomException.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/CustomException.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/CustomException.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Driver.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/Driver.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Driver.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/Driver.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Engine.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/Engine.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Engine.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/Engine.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/PerformanceAspect.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/PerformanceAspect.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/PerformanceAspect.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/PerformanceAspect.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Vehicle.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/Vehicle.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Vehicle.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/Vehicle.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleController.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/VehicleController.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleController.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/VehicleController.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryApplication.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/VehicleFactoryApplication.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryApplication.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/VehicleFactoryApplication.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryConfig.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/VehicleFactoryConfig.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryConfig.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/VehicleFactoryConfig.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRepository.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/VehicleRepository.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRepository.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/VehicleRepository.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRestController.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/VehicleRestController.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRestController.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/VehicleRestController.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleService.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/VehicleService.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleService.java
rename to spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/VehicleService.java
diff --git a/spring-boot-modules/spring-boot-mvc/README.md b/spring-boot-modules/spring-boot-mvc/README.md
index a83ea3ee25..b4f87d1d40 100644
--- a/spring-boot-modules/spring-boot-mvc/README.md
+++ b/spring-boot-modules/spring-boot-mvc/README.md
@@ -6,16 +6,8 @@ This module contains articles about Spring Web MVC in Spring Boot projects.
- [Guide to the Favicon in Spring Boot](https://www.baeldung.com/spring-boot-favicon)
- [Custom Validation MessageSource in Spring Boot](https://www.baeldung.com/spring-custom-validation-message-source)
-- [Spring Boot Annotations](https://www.baeldung.com/spring-boot-annotations)
-- [Spring Scheduling Annotations](https://www.baeldung.com/spring-scheduling-annotations)
-- [Spring Web Annotations](https://www.baeldung.com/spring-mvc-annotations)
-- [Spring Core Annotations](https://www.baeldung.com/spring-core-annotations)
- [Display RSS Feed with Spring MVC](https://www.baeldung.com/spring-mvc-rss-feed)
- [A Controller, Service and DAO Example with Spring Boot and JSF](https://www.baeldung.com/jsf-spring-boot-controller-service-dao)
-- [Cache Eviction in Spring Boot](https://www.baeldung.com/spring-boot-evict-cache)
- [Setting Up Swagger 2 with a Spring REST API](https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api)
-- [Conditionally Enable Scheduled Jobs in Spring](https://www.baeldung.com/spring-scheduled-enabled-conditionally)
-- [Accessing Spring MVC Model Objects in JavaScript](https://www.baeldung.com/spring-mvc-model-objects-js)
- [Using Spring ResponseEntity to Manipulate the HTTP Response](https://www.baeldung.com/spring-response-entity)
-- [Spring Bean Annotations](https://www.baeldung.com/spring-bean-annotations)
- More articles: [[next -->]](/spring-boot-mvc-2)
diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/build.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/build.properties
index f3d2e9b15b..5bd0a50a17 100644
--- a/spring-boot-modules/spring-boot-properties/src/main/resources/build.properties
+++ b/spring-boot-modules/spring-boot-properties/src/main/resources/build.properties
@@ -1 +1,2 @@
-application-version=@project.version@
\ No newline at end of file
+application-version=@project.version@
+application-description=@project.description@
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/buildproperties/BuildInfoServiceIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/buildproperties/BuildInfoServiceIntegrationTest.java
index cb056fe56d..2cb27e1844 100644
--- a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/buildproperties/BuildInfoServiceIntegrationTest.java
+++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/buildproperties/BuildInfoServiceIntegrationTest.java
@@ -18,7 +18,7 @@ class BuildInfoServiceIntegrationTest {
@Test
void whenGetApplicationDescription_thenSuccess() {
- assertThat(service.getApplicationDescription(), Matchers.is("This is simple boot application for Spring boot actuator test"));
+ assertThat(service.getApplicationDescription(), Matchers.is("Spring Boot Properties Module"));
assertThat(service.getApplicationVersion(), Matchers.is("0.0.1-SNAPSHOT"));
}
}
diff --git a/spring-boot-rest/pom.xml b/spring-boot-rest/pom.xml
index 2483aab6be..10dacf99e8 100644
--- a/spring-boot-rest/pom.xml
+++ b/spring-boot-rest/pom.xml
@@ -95,7 +95,6 @@
27.0.1-jre
1.4.11.1
2.3.5
- 2.1.9.RELEASE
diff --git a/spring-boot-rest/src/main/java/com/baeldung/persistence/config/CustomH2Dialect.java b/spring-boot-rest/src/main/java/com/baeldung/persistence/config/CustomH2Dialect.java
new file mode 100644
index 0000000000..0108f92b2c
--- /dev/null
+++ b/spring-boot-rest/src/main/java/com/baeldung/persistence/config/CustomH2Dialect.java
@@ -0,0 +1,26 @@
+package com.baeldung.persistence.config;
+
+import org.hibernate.dialect.H2Dialect;
+
+/**
+ * Since H2 1.4.200. the behavior of the drop table commands has changed.
+ * Tables are not dropped in a correct order.
+ * Until this is properly fixed directly in Hibernate project,
+ * let's use this custom H2Dialect class to solve this issue.
+ *
+ * @see https://hibernate.atlassian.net/browse/HHH-13711
+ * @see https://github.com/hibernate/hibernate-orm/pull/3093
+ */
+public class CustomH2Dialect extends H2Dialect {
+
+ @Override
+ public boolean dropConstraints() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsIfExistsAfterAlterTable() {
+ return true;
+ }
+
+}
diff --git a/spring-boot-rest/src/main/java/com/baeldung/persistence/model/Customer.java b/spring-boot-rest/src/main/java/com/baeldung/persistence/model/Customer.java
index 10da2e10f0..06b2485c7b 100644
--- a/spring-boot-rest/src/main/java/com/baeldung/persistence/model/Customer.java
+++ b/spring-boot-rest/src/main/java/com/baeldung/persistence/model/Customer.java
@@ -1,14 +1,13 @@
package com.baeldung.persistence.model;
-import java.util.Map;
-
-import org.springframework.hateoas.ResourceSupport;
-
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import org.springframework.hateoas.RepresentationModel;
+
+import java.util.Map;
@JsonInclude(Include.NON_NULL)
-public class Customer extends ResourceSupport {
+public class Customer extends RepresentationModel {
private String customerId;
private String customerName;
private String companyName;
diff --git a/spring-boot-rest/src/main/java/com/baeldung/persistence/model/Order.java b/spring-boot-rest/src/main/java/com/baeldung/persistence/model/Order.java
index 7aea9bce5c..b5e1a2cee2 100644
--- a/spring-boot-rest/src/main/java/com/baeldung/persistence/model/Order.java
+++ b/spring-boot-rest/src/main/java/com/baeldung/persistence/model/Order.java
@@ -1,8 +1,8 @@
package com.baeldung.persistence.model;
-import org.springframework.hateoas.ResourceSupport;
+import org.springframework.hateoas.RepresentationModel;
-public class Order extends ResourceSupport {
+public class Order extends RepresentationModel {
private String orderId;
private double price;
private int quantity;
diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/controller/CustomerController.java b/spring-boot-rest/src/main/java/com/baeldung/web/controller/CustomerController.java
index 91aa9f2144..2b7dc1eee1 100644
--- a/spring-boot-rest/src/main/java/com/baeldung/web/controller/CustomerController.java
+++ b/spring-boot-rest/src/main/java/com/baeldung/web/controller/CustomerController.java
@@ -1,13 +1,13 @@
package com.baeldung.web.controller;
-import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
-import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
+import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
+import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.Link;
-import org.springframework.hateoas.Resources;
+import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.web.bind.annotation.GetMapping;
@@ -41,7 +41,7 @@ public class CustomerController {
}
@GetMapping(value = "/{customerId}/orders", produces = { "application/hal+json" })
- public Resources getOrdersForCustomer(@PathVariable final String customerId) {
+ public CollectionModel getOrdersForCustomer(@PathVariable final String customerId) {
final List orders = orderService.getAllOrdersForCustomer(customerId);
for (final Order order : orders) {
final Link selfLink = linkTo(
@@ -50,12 +50,12 @@ public class CustomerController {
}
Link link = linkTo(methodOn(CustomerController.class).getOrdersForCustomer(customerId)).withSelfRel();
- Resources result = new Resources<>(orders, link);
+ CollectionModel result = new CollectionModel<>(orders, link);
return result;
}
@GetMapping(produces = { "application/hal+json" })
- public Resources getAllCustomers() {
+ public CollectionModel getAllCustomers() {
final List allCustomers = customerService.allCustomers();
for (final Customer customer : allCustomers) {
@@ -72,7 +72,7 @@ public class CustomerController {
}
Link link = linkTo(CustomerController.class).withSelfRel();
- Resources result = new Resources<>(allCustomers, link);
+ CollectionModel result = new CollectionModel<>(allCustomers, link);
return result;
}
diff --git a/spring-boot-rest/src/main/resources/persistence-h2.properties b/spring-boot-rest/src/main/resources/persistence-h2.properties
index 839a466533..efbf3f7db7 100644
--- a/spring-boot-rest/src/main/resources/persistence-h2.properties
+++ b/spring-boot-rest/src/main/resources/persistence-h2.properties
@@ -17,6 +17,6 @@ jdbc.user=sa
jdbc.pass=
# hibernate.X
-hibernate.dialect=org.hibernate.dialect.H2Dialect
+hibernate.dialect=com.baeldung.persistence.config.CustomH2Dialect
hibernate.show_sql=false
hibernate.hbm2ddl.auto=create-drop
diff --git a/spring-boot-rest/src/test/java/com/baeldung/test/JacksonMarshaller.java b/spring-boot-rest/src/test/java/com/baeldung/test/JacksonMarshaller.java
index 23b5d60b6b..0f89e0a9de 100644
--- a/spring-boot-rest/src/test/java/com/baeldung/test/JacksonMarshaller.java
+++ b/spring-boot-rest/src/test/java/com/baeldung/test/JacksonMarshaller.java
@@ -60,7 +60,7 @@ public final class JacksonMarshaller implements IMarshaller {
List entities = null;
try {
if (clazz.equals(Foo.class)) {
- entities = objectMapper.readValue(resourcesAsString, new TypeReference>() {
+ entities = objectMapper.readValue(resourcesAsString, new TypeReference>() {
// ...
});
} else {
diff --git a/spring-caching/README.md b/spring-caching/README.md
index 14dfe94041..3efbfe3eaa 100644
--- a/spring-caching/README.md
+++ b/spring-caching/README.md
@@ -2,3 +2,4 @@
- [Introduction To Ehcache](http://www.baeldung.com/ehcache)
- [A Guide To Caching in Spring](http://www.baeldung.com/spring-cache-tutorial)
- [Spring Cache – Creating a Custom KeyGenerator](http://www.baeldung.com/spring-cache-custom-keygenerator)
+- [Cache Eviction in Spring Boot](https://www.baeldung.com/spring-boot-evict-cache)
diff --git a/spring-cloud/spring-cloud-zuul/spring-zuul-post-filter/src/main/java/com/baeldung/filters/ResponseLogFilter.java b/spring-cloud/spring-cloud-zuul/spring-zuul-post-filter/src/main/java/com/baeldung/filters/ResponseLogFilter.java
index 1fdd89c7f7..b0e4f7e313 100644
--- a/spring-cloud/spring-cloud-zuul/spring-zuul-post-filter/src/main/java/com/baeldung/filters/ResponseLogFilter.java
+++ b/spring-cloud/spring-cloud-zuul/spring-zuul-post-filter/src/main/java/com/baeldung/filters/ResponseLogFilter.java
@@ -12,6 +12,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.POST_TYPE;
+import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
@Component
public class ResponseLogFilter extends ZuulFilter {
@@ -50,7 +51,7 @@ public class ResponseLogFilter extends ZuulFilter {
context.setResponseBody(responseData);
}
catch (Exception e) {
- logger.error("error occurred at response log filter", e);
+ throw new ZuulException(e, INTERNAL_SERVER_ERROR.value(), e.getMessage());
}
return null;
diff --git a/spring-ejb/ejb-beans/pom.xml b/spring-ejb/ejb-beans/pom.xml
index b8978a0cc3..eecf8c1d23 100644
--- a/spring-ejb/ejb-beans/pom.xml
+++ b/spring-ejb/ejb-beans/pom.xml
@@ -37,6 +37,42 @@
tomee-embedded
${tomee-embedded.version}
+
+ org.springframework
+ spring-context
+ ${springframework.version}
+
+
+
+ javax.ejb
+ javax.ejb-api
+ ${javax.ejb-api.version}
+ provided
+
+
+
+ org.springframework
+ spring-jms
+ ${springframework.version}
+
+
+ commons-logging
+ commons-logging
+
+
+
+
+
+ org.apache.activemq
+ activemq-broker
+ ${activemq.broker.version}
+
+
+ org.apache.activemq.tooling
+ activemq-junit
+ ${activemq.junit.version}
+ test
+
org.jboss.arquillian.junit
arquillian-junit-container
@@ -81,6 +117,10 @@
1.7.5
3.1.2
1.0.0.CR4
+ 3.2
+ 5.2.3.RELEASE
+ 5.10.2
+ 5.13.1
diff --git a/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/messagedriven/RecieverMDB.java b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/messagedriven/RecieverMDB.java
new file mode 100644
index 0000000000..7a6b750ce5
--- /dev/null
+++ b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/messagedriven/RecieverMDB.java
@@ -0,0 +1,63 @@
+package com.baeldung.ejb.spring.comparison.ejb.messagedriven;
+
+import javax.annotation.Resource;
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destination", propertyValue = "myQueue"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") })
+public class RecieverMDB implements MessageListener {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "ackQueue")
+ private Queue ackQueue;
+
+ public void onMessage(Message message) {
+ try {
+
+ TextMessage textMessage = (TextMessage) message;
+ String producerPing = textMessage.getText();
+
+ if (producerPing.equals("marco")) {
+ acknowledge("polo");
+ }
+ } catch (JMSException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private void acknowledge(String text) throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer ackSender = session.createProducer(ackQueue);
+ ackSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ TextMessage message = session.createTextMessage(text);
+
+ ackSender.send(message);
+ } finally {
+ session.close();
+ connection.close();
+ }
+ }
+
+}
diff --git a/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/singleton/CounterEJB.java b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/singleton/CounterEJB.java
new file mode 100644
index 0000000000..b64005aed8
--- /dev/null
+++ b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/singleton/CounterEJB.java
@@ -0,0 +1,14 @@
+package com.baeldung.ejb.spring.comparison.ejb.singleton;
+
+import javax.ejb.Singleton;
+
+@Singleton
+public class CounterEJB implements CounterEJBRemote {
+
+ private int count = 1;
+
+ public int count() {
+ return count++;
+ }
+
+}
\ No newline at end of file
diff --git a/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/singleton/CounterEJBRemote.java b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/singleton/CounterEJBRemote.java
new file mode 100644
index 0000000000..ec3b9e9f6b
--- /dev/null
+++ b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/singleton/CounterEJBRemote.java
@@ -0,0 +1,8 @@
+package com.baeldung.ejb.spring.comparison.ejb.singleton;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface CounterEJBRemote {
+ int count();
+}
diff --git a/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/stateful/ShoppingCartEJB.java b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/stateful/ShoppingCartEJB.java
new file mode 100644
index 0000000000..5bdccea994
--- /dev/null
+++ b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/stateful/ShoppingCartEJB.java
@@ -0,0 +1,25 @@
+package com.baeldung.ejb.spring.comparison.ejb.stateful;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Stateful;
+
+@Stateful
+public class ShoppingCartEJB implements ShoppingCartEJBRemote {
+
+ private List shoppingCart;
+
+ public ShoppingCartEJB() {
+ shoppingCart = new ArrayList();
+ }
+
+ public void addItem(String item) {
+ shoppingCart.add(item);
+ }
+
+ public List getItems() {
+ return shoppingCart;
+ }
+
+}
diff --git a/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/stateful/ShoppingCartEJBRemote.java b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/stateful/ShoppingCartEJBRemote.java
new file mode 100644
index 0000000000..a8d7a15d25
--- /dev/null
+++ b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/stateful/ShoppingCartEJBRemote.java
@@ -0,0 +1,13 @@
+package com.baeldung.ejb.spring.comparison.ejb.stateful;
+
+import java.util.List;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface ShoppingCartEJBRemote {
+
+ void addItem(String item);
+
+ List getItems();
+}
diff --git a/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/stateless/FinderEJB.java b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/stateless/FinderEJB.java
new file mode 100644
index 0000000000..fb45e4e7ce
--- /dev/null
+++ b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/stateless/FinderEJB.java
@@ -0,0 +1,25 @@
+package com.baeldung.ejb.spring.comparison.ejb.stateless;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class FinderEJB implements FinderEJBRemote {
+
+ private Map alphabet;
+
+ public FinderEJB() {
+ alphabet = new HashMap();
+ alphabet.put("A", "Apple");
+ alphabet.put("B", "Ball");
+ alphabet.put("C", "Cat");
+ alphabet.put("D", "Dog");
+ }
+
+ public String search(String keyword) {
+ return alphabet.get(keyword);
+ }
+
+}
diff --git a/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/stateless/FinderEJBRemote.java b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/stateless/FinderEJBRemote.java
new file mode 100644
index 0000000000..36b4c9ae04
--- /dev/null
+++ b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/ejb/stateless/FinderEJBRemote.java
@@ -0,0 +1,9 @@
+package com.baeldung.ejb.spring.comparison.ejb.stateless;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface FinderEJBRemote {
+
+ String search(String keyword);
+}
diff --git a/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/spring/config/ApplicationConfig.java b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/spring/config/ApplicationConfig.java
new file mode 100644
index 0000000000..6ec14dc098
--- /dev/null
+++ b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/spring/config/ApplicationConfig.java
@@ -0,0 +1,36 @@
+package com.baeldung.ejb.spring.comparison.spring.config;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.jms.annotation.EnableJms;
+import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
+import org.springframework.jms.core.JmsTemplate;
+
+@Configuration
+@ComponentScan(basePackages = "com.baeldung.ejb.spring.comparison.spring")
+@EnableJms
+public class ApplicationConfig {
+
+ @Bean
+ public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
+ DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
+ factory.setConnectionFactory(connectionFactory());
+ return factory;
+ }
+
+ @Bean
+ public ConnectionFactory connectionFactory() {
+ return new ActiveMQConnectionFactory("tcp://localhost:61616");
+ }
+
+ @Bean
+ public JmsTemplate jmsTemplate() {
+ JmsTemplate template = new JmsTemplate(connectionFactory());
+ template.setConnectionFactory(connectionFactory());
+ return template;
+ }
+}
diff --git a/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/spring/messagedriven/Producer.java b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/spring/messagedriven/Producer.java
new file mode 100644
index 0000000000..a60dc4db8e
--- /dev/null
+++ b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/spring/messagedriven/Producer.java
@@ -0,0 +1,19 @@
+package com.baeldung.ejb.spring.comparison.spring.messagedriven;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jms.core.JmsTemplate;
+import org.springframework.stereotype.Component;
+
+@Component
+public class Producer {
+ @Autowired
+ private JmsTemplate jmsTemplate;
+
+ public void sendMessageToDefaultDestination(final String message) {
+ jmsTemplate.convertAndSend("myQueue", message);
+ }
+
+ public String receiveAck() {
+ return (String) jmsTemplate.receiveAndConvert("ackQueue");
+ }
+}
\ No newline at end of file
diff --git a/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/spring/messagedriven/Receiver.java b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/spring/messagedriven/Receiver.java
new file mode 100644
index 0000000000..a3b36dd587
--- /dev/null
+++ b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/spring/messagedriven/Receiver.java
@@ -0,0 +1,22 @@
+package com.baeldung.ejb.spring.comparison.spring.messagedriven;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jms.annotation.JmsListener;
+import org.springframework.jms.core.JmsTemplate;
+import org.springframework.stereotype.Component;
+
+@Component
+public class Receiver {
+ @Autowired
+ private JmsTemplate jmsTemplate;
+
+ @JmsListener(destination = "myQueue")
+ public void receiveMessage(String msg) {
+ sendAck();
+ }
+
+ private void sendAck() {
+ jmsTemplate.convertAndSend("ackQueue", "polo");
+ }
+
+}
\ No newline at end of file
diff --git a/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/spring/singleton/CounterBean.java b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/spring/singleton/CounterBean.java
new file mode 100644
index 0000000000..6456cfc007
--- /dev/null
+++ b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/spring/singleton/CounterBean.java
@@ -0,0 +1,12 @@
+package com.baeldung.ejb.spring.comparison.spring.singleton;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class CounterBean {
+ private int count = 1;
+
+ public int count() {
+ return count++;
+ }
+}
diff --git a/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/spring/stateful/ShoppingCartBean.java b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/spring/stateful/ShoppingCartBean.java
new file mode 100644
index 0000000000..9286ff9950
--- /dev/null
+++ b/spring-ejb/ejb-beans/src/main/java/com/baeldung/ejb/spring/comparison/spring/stateful/ShoppingCartBean.java
@@ -0,0 +1,28 @@
+package com.baeldung.ejb.spring.comparison.spring.stateful;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class ShoppingCartBean {
+
+ private List shoppingCart;
+
+ public ShoppingCartBean() {
+ shoppingCart = new ArrayList();
+ }
+
+ public void addItem(String item) {
+ shoppingCart.add(item);
+ }
+
+ public List getItems() {
+ return shoppingCart;
+ }
+
+}
diff --git a/spring-ejb/ejb-beans/src/test/java/com/baeldung/ejb/spring/comparison/ejb/EJBUnitTest.java b/spring-ejb/ejb-beans/src/test/java/com/baeldung/ejb/spring/comparison/ejb/EJBUnitTest.java
new file mode 100644
index 0000000000..1f0f1bf8a4
--- /dev/null
+++ b/spring-ejb/ejb-beans/src/test/java/com/baeldung/ejb/spring/comparison/ejb/EJBUnitTest.java
@@ -0,0 +1,142 @@
+package com.baeldung.ejb.spring.comparison.ejb;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.baeldung.ejb.spring.comparison.ejb.singleton.CounterEJBRemote;
+import com.baeldung.ejb.spring.comparison.ejb.stateful.ShoppingCartEJBRemote;
+import com.baeldung.ejb.spring.comparison.ejb.stateless.FinderEJBRemote;
+
+public class EJBUnitTest {
+
+ private static EJBContainer ejbContainer = null;
+
+ private static Context context = null;
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @EJB
+ private FinderEJBRemote alphabetFinder;
+
+ @Resource(name = "myQueue")
+ private Queue myQueue;
+
+ @Resource(name = "ackQueue")
+ private Queue ackQueue;
+
+ @BeforeClass
+ public static void start() throws NamingException {
+ ejbContainer = EJBContainer.createEJBContainer();
+ }
+
+ @Before
+ public void initializeContext() throws NamingException {
+ context = ejbContainer.getContext();
+ context.bind("inject", this);
+ }
+
+ @Test
+ public void givenSingletonBean_whenCounterInvoked_thenCountIsIncremented() throws NamingException {
+
+ int count = 0;
+ CounterEJBRemote counterEJB = (CounterEJBRemote) context.lookup("java:global/ejb-beans/CounterEJB");
+
+ for (int i = 0; i < 10; i++)
+ count = counterEJB.count();
+
+ assertThat(count, is(not(1)));
+ }
+
+ @Test
+ public void givenSingletonBean_whenCounterInvokedAgain_thenCountIsIncremented() throws NamingException {
+
+ CounterEJBRemote counterEJB = (CounterEJBRemote) context.lookup("java:global/ejb-beans/CounterEJB");
+
+ int count = 0;
+ for (int i = 0; i < 10; i++)
+ count = counterEJB.count();
+
+ assertThat(count, is(not(1)));
+ }
+
+ @Test
+ public void givenStatefulBean_whenBathingCartWithThreeItemsAdded_thenItemsSizeIsThree() throws NamingException {
+ ShoppingCartEJBRemote bathingCart = (ShoppingCartEJBRemote) context.lookup("java:global/ejb-beans/ShoppingCartEJB");
+
+ bathingCart.addItem("soap");
+ bathingCart.addItem("shampoo");
+ bathingCart.addItem("oil");
+
+ assertEquals(3, bathingCart.getItems()
+ .size());
+ }
+
+ @Test
+ public void givenStatefulBean_whenFruitCartWithTwoItemsAdded_thenItemsSizeIsTwo() throws NamingException {
+ ShoppingCartEJBRemote fruitCart = (ShoppingCartEJBRemote) context.lookup("java:global/ejb-beans/ShoppingCartEJB");
+
+ fruitCart.addItem("apples");
+ fruitCart.addItem("oranges");
+
+ assertEquals(2, fruitCart.getItems()
+ .size());
+ }
+
+ @Test
+ public void givenStatelessBean_whenSearchForA_thenApple() throws NamingException {
+
+ assertEquals("Apple", alphabetFinder.search("A"));
+ }
+
+ @Test
+ public void givenMDB_whenMessageSent_thenAcknowledgementReceived() throws InterruptedException, JMSException, NamingException {
+
+ Connection connection = connectionFactory.createConnection();
+ connection.start();
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = session.createProducer(myQueue);
+ producer.send(session.createTextMessage("marco"));
+ MessageConsumer response = session.createConsumer(ackQueue);
+
+ assertEquals("polo", ((TextMessage) response.receive(1000)).getText());
+
+ }
+
+ @After
+ public void reset() throws NamingException {
+ context.unbind("inject");
+ }
+
+ @AfterClass
+ public static void checkTotalCountAndcloseContext() throws NamingException {
+ CounterEJBRemote counterEJB = (CounterEJBRemote) context.lookup("java:global/ejb-beans/CounterEJB");
+ assertEquals(21, counterEJB.count());
+
+ context.close();
+ ejbContainer.close();
+ }
+
+}
diff --git a/spring-ejb/ejb-beans/src/test/java/com/baeldung/ejb/spring/comparison/spring/SpringUnitTest.java b/spring-ejb/ejb-beans/src/test/java/com/baeldung/ejb/spring/comparison/spring/SpringUnitTest.java
new file mode 100644
index 0000000000..a346baba38
--- /dev/null
+++ b/spring-ejb/ejb-beans/src/test/java/com/baeldung/ejb/spring/comparison/spring/SpringUnitTest.java
@@ -0,0 +1,108 @@
+package com.baeldung.ejb.spring.comparison.spring;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import javax.naming.NamingException;
+
+import org.apache.activemq.junit.EmbeddedActiveMQBroker;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+import com.baeldung.ejb.spring.comparison.spring.config.ApplicationConfig;
+import com.baeldung.ejb.spring.comparison.spring.messagedriven.Producer;
+import com.baeldung.ejb.spring.comparison.spring.singleton.CounterBean;
+import com.baeldung.ejb.spring.comparison.spring.stateful.ShoppingCartBean;
+
+public class SpringUnitTest {
+
+ private static AnnotationConfigApplicationContext context = null;
+
+ @ClassRule
+ public static EmbeddedActiveMQBroker broker = new EmbeddedActiveMQBroker() {
+ @Override
+ protected void configure() {
+ this.getBrokerService()
+ .setUseJmx(true);
+ try {
+ this.getBrokerService()
+ .addConnector("tcp://localhost:61616");
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+ };
+
+ @BeforeClass
+ public static void init() {
+ context = new AnnotationConfigApplicationContext(ApplicationConfig.class);
+ }
+
+ @Test
+ public void whenCounterInvoked_thenCountIsIncremented() throws NamingException {
+ CounterBean counterBean = context.getBean(CounterBean.class);
+
+ int count = 0;
+ for (int i = 0; i < 10; i++)
+ count = counterBean.count();
+
+ assertThat(count, is(not(1)));
+ }
+
+ @Test
+ public void whenCounterInvokedAgain_thenCountIsIncremented() throws NamingException {
+ CounterBean counterBean = context.getBean(CounterBean.class);
+
+ int count = 0;
+ for (int i = 0; i < 10; i++)
+ count = counterBean.count();
+
+ assertThat(count, is(not(1)));
+ }
+
+ @Test
+ public void whenBathingCartWithThreeItemsAdded_thenItemsSizeIsThree() throws NamingException {
+ ShoppingCartBean bathingCart = context.getBean(ShoppingCartBean.class);
+
+ bathingCart.addItem("soap");
+ bathingCart.addItem("shampoo");
+ bathingCart.addItem("oil");
+
+ assertEquals(3, bathingCart.getItems()
+ .size());
+ }
+
+ @Test
+ public void whenFruitCartWithTwoItemsAdded_thenItemsSizeIsTwo() throws NamingException {
+ ShoppingCartBean fruitCart = context.getBean(ShoppingCartBean.class);
+
+ fruitCart.addItem("apples");
+ fruitCart.addItem("oranges");
+
+ assertEquals(2, fruitCart.getItems()
+ .size());
+ }
+
+ @Test
+ public void givenJMSBean_whenMessageSent_thenAcknowledgementReceived() throws NamingException {
+ Producer producer = context.getBean(Producer.class);
+ producer.sendMessageToDefaultDestination("marco");
+
+ assertEquals("polo", producer.receiveAck());
+ }
+
+ @AfterClass
+ public static void checkTotalCountAndcloseContext() throws NamingException {
+ CounterBean counterBean = context.getBean(CounterBean.class);
+ int count = counterBean.count();
+ assertEquals(21, count);
+ context.close();
+ }
+
+}
diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md
index ff1f7830b6..f1263860f9 100644
--- a/spring-mvc-java/README.md
+++ b/spring-mvc-java/README.md
@@ -16,3 +16,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [Spring MVC @PathVariable with a dot (.) gets truncated](https://www.baeldung.com/spring-mvc-pathvariable-dot)
- [Working with Date Parameters in Spring](https://www.baeldung.com/spring-date-parameters)
- [A Java Web Application Without a web.xml](https://www.baeldung.com/java-web-app-without-web-xml)
+- [Accessing Spring MVC Model Objects in JavaScript](https://www.baeldung.com/spring-mvc-model-objects-js)
diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml
index 0f3a1d65b9..079a664a5d 100644
--- a/spring-mvc-java/pom.xml
+++ b/spring-mvc-java/pom.xml
@@ -223,8 +223,6 @@
- 2.1.9.RELEASE
-
3.0.9.RELEASE
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/App.java b/spring-mvc-java/src/main/java/com/baeldung/accessparamsjs/App.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/App.java
rename to spring-mvc-java/src/main/java/com/baeldung/accessparamsjs/App.java
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/Controller.java b/spring-mvc-java/src/main/java/com/baeldung/accessparamsjs/Controller.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/Controller.java
rename to spring-mvc-java/src/main/java/com/baeldung/accessparamsjs/Controller.java
index 8759f1bcd6..157dcf54da 100644
--- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/Controller.java
+++ b/spring-mvc-java/src/main/java/com/baeldung/accessparamsjs/Controller.java
@@ -1,11 +1,11 @@
package com.baeldung.accessparamsjs;
-import java.util.Map;
-
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
+import java.util.Map;
+
/**
* Sample rest controller for the tutorial article
* "Access Spring MVC Model object in JavaScript".
diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/CustomWebMvcConfigurationSupport.java b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/CustomWebMvcConfigurationSupport.java
index 4a9f6a3431..a0dd7358d0 100644
--- a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/CustomWebMvcConfigurationSupport.java
+++ b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/CustomWebMvcConfigurationSupport.java
@@ -1,17 +1,17 @@
package com.baeldung.spring.web.config;
-import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
-import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
@Configuration
public class CustomWebMvcConfigurationSupport extends WebMvcConfigurationSupport {
- @Bean
- public RequestMappingHandlerMapping requestMappingHandlerMapping() {
- RequestMappingHandlerMapping handlerMapping = super.requestMappingHandlerMapping();
- handlerMapping.setUseSuffixPatternMatch(false);
- return handlerMapping;
+ @Override
+ protected PathMatchConfigurer getPathMatchConfigurer() {
+ PathMatchConfigurer pathMatchConfigurer = super.getPathMatchConfigurer();
+ pathMatchConfigurer.setUseSuffixPatternMatch(false);
+
+ return pathMatchConfigurer;
}
}
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/resources/templates/thymeleaf/index.html b/spring-mvc-java/src/main/resources/templates/thymeleaf/index.html
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/resources/templates/thymeleaf/index.html
rename to spring-mvc-java/src/main/resources/templates/thymeleaf/index.html
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/webapp/js/jquery.js b/spring-mvc-java/src/main/webapp/js/jquery.js
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/webapp/js/jquery.js
rename to spring-mvc-java/src/main/webapp/js/jquery.js
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/webapp/js/script-async-jquery.js b/spring-mvc-java/src/main/webapp/js/script-async-jquery.js
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/webapp/js/script-async-jquery.js
rename to spring-mvc-java/src/main/webapp/js/script-async-jquery.js
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/webapp/js/script-async.js b/spring-mvc-java/src/main/webapp/js/script-async.js
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/webapp/js/script-async.js
rename to spring-mvc-java/src/main/webapp/js/script-async.js
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/webapp/js/script.js b/spring-mvc-java/src/main/webapp/js/script.js
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/main/webapp/js/script.js
rename to spring-mvc-java/src/main/webapp/js/script.js
diff --git a/spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java b/spring-mvc-java/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java
similarity index 100%
rename from spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java
rename to spring-mvc-java/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java
index 2dc62a20f6..f05d34b654 100644
--- a/spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java
+++ b/spring-mvc-java/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java
@@ -1,7 +1,5 @@
package com.baeldung.accessparamsjs;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -12,6 +10,8 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java
index 079ea3e5cd..3d34a46791 100644
--- a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java
+++ b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java
@@ -32,7 +32,7 @@ public class GreetControllerIntegrationTest {
private MockMvc mockMvc;
- private static final String CONTENT_TYPE = "application/json;charset=UTF-8";
+ private static final String CONTENT_TYPE = "application/json";
@Before
public void setup() throws Exception {
diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerUnitTest.java b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerUnitTest.java
index 0475bd933d..eacd256438 100644
--- a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerUnitTest.java
+++ b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerUnitTest.java
@@ -16,7 +16,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
public class GreetControllerUnitTest {
private MockMvc mockMvc;
- private static final String CONTENT_TYPE = "application/json;charset=UTF-8";
+ private static final String CONTENT_TYPE = "application/json";
@Before
public void setup() {
diff --git a/spring-mvc-xml/pom.xml b/spring-mvc-xml/pom.xml
index c389e41e29..4812d5c979 100644
--- a/spring-mvc-xml/pom.xml
+++ b/spring-mvc-xml/pom.xml
@@ -92,8 +92,8 @@
${spring-boot.version}
test
-
-
+
+
org.crashub
crash.embed.spring
@@ -101,16 +101,22 @@
org.crashub
- crash.cli
+ crash.cli
${crash.version}
org.crashub
crash.connectors.telnet
${crash.version}
+
+
+ log4j
+ log4j
+
+
-
-
+
+
org.codehaus.groovy
groovy
@@ -161,7 +167,7 @@
1.6.1
-
+
1.3.2
3.0.0-rc-3
diff --git a/spring-scheduling/README.md b/spring-scheduling/README.md
index 2e3bb2b5e5..ddc540bafb 100644
--- a/spring-scheduling/README.md
+++ b/spring-scheduling/README.md
@@ -3,4 +3,5 @@
- [The @Scheduled Annotation in Spring](https://www.baeldung.com/spring-scheduled-tasks)
- [Guide to Spring Retry](http://www.baeldung.com/spring-retry)
- [How To Do @Async in Spring](http://www.baeldung.com/spring-async)
+- [Conditionally Enable Scheduled Jobs in Spring](https://www.baeldung.com/spring-scheduled-enabled-conditionally)
diff --git a/spring-scheduling/pom.xml b/spring-scheduling/pom.xml
index 8726fea438..b27f33196d 100644
--- a/spring-scheduling/pom.xml
+++ b/spring-scheduling/pom.xml
@@ -27,6 +27,10 @@
org.springframework
spring-aspects
+
+ org.springframework.boot
+ spring-boot-starter-web
+
javax.annotation
javax.annotation-api
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/ScheduleJobsByProfile.java
similarity index 91%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java
rename to spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/ScheduleJobsByProfile.java
index 33cd44331f..7783d0e6ff 100644
--- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java
+++ b/spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/ScheduleJobsByProfile.java
@@ -1,4 +1,4 @@
-package com.baeldung.scheduling;
+package com.baeldung.scheduling.conditional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJob.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/ScheduledJob.java
similarity index 91%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJob.java
rename to spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/ScheduledJob.java
index df7cefcd3c..b56cb9ed5b 100644
--- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJob.java
+++ b/spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/ScheduledJob.java
@@ -1,4 +1,4 @@
-package com.baeldung.scheduling;
+package com.baeldung.scheduling.conditional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/ScheduledJobsWithBoolean.java
similarity index 94%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java
rename to spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/ScheduledJobsWithBoolean.java
index b03de61641..69c0efb7b2 100644
--- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java
+++ b/spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/ScheduledJobsWithBoolean.java
@@ -1,4 +1,4 @@
-package com.baeldung.scheduling;
+package com.baeldung.scheduling.conditional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/ScheduledJobsWithConditional.java
similarity index 93%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java
rename to spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/ScheduledJobsWithConditional.java
index 081c8d990a..2a90300c20 100644
--- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java
+++ b/spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/ScheduledJobsWithConditional.java
@@ -1,4 +1,4 @@
-package com.baeldung.scheduling;
+package com.baeldung.scheduling.conditional;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/ScheduledJobsWithExpression.java
similarity index 93%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java
rename to spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/ScheduledJobsWithExpression.java
index 577a01f241..4842e649c7 100644
--- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java
+++ b/spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/ScheduledJobsWithExpression.java
@@ -1,4 +1,4 @@
-package com.baeldung.scheduling;
+package com.baeldung.scheduling.conditional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/SchedulingApplication.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/SchedulingApplication.java
similarity index 89%
rename from spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/SchedulingApplication.java
rename to spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/SchedulingApplication.java
index 913e2137f8..4777230341 100644
--- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/SchedulingApplication.java
+++ b/spring-scheduling/src/main/java/com/baeldung/scheduling/conditional/SchedulingApplication.java
@@ -1,4 +1,4 @@
-package com.baeldung.scheduling;
+package com.baeldung.scheduling.conditional;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
diff --git a/spring-security-modules/pom.xml b/spring-security-modules/pom.xml
index 7de3009f47..85b86f00fc 100644
--- a/spring-security-modules/pom.xml
+++ b/spring-security-modules/pom.xml
@@ -25,13 +25,12 @@
spring-security-mvc-custom
spring-security-mvc-digest-auth
spring-security-mvc-jsonview
- spring-security-mvc-ldap
+ spring-security-ldap
spring-security-mvc-login
spring-security-mvc-persisted-remember-me
spring-security-mvc-socket
spring-security-oidc
spring-security-react
-
spring-security-rest
spring-security-rest-basic-auth
spring-security-rest-custom
diff --git a/spring-security-modules/spring-security-mvc-ldap/README.md b/spring-security-modules/spring-security-ldap/README.md
similarity index 100%
rename from spring-security-modules/spring-security-mvc-ldap/README.md
rename to spring-security-modules/spring-security-ldap/README.md
diff --git a/spring-security-modules/spring-security-mvc-ldap/pom.xml b/spring-security-modules/spring-security-ldap/pom.xml
similarity index 95%
rename from spring-security-modules/spring-security-mvc-ldap/pom.xml
rename to spring-security-modules/spring-security-ldap/pom.xml
index 2f227d7908..f5e8856648 100644
--- a/spring-security-modules/spring-security-mvc-ldap/pom.xml
+++ b/spring-security-modules/spring-security-ldap/pom.xml
@@ -2,9 +2,9 @@
4.0.0
- spring-security-mvc-ldap
+ spring-security-ldap
0.1-SNAPSHOT
- spring-security-mvc-ldap
+ spring-security-ldap
war
diff --git a/spring-security-modules/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java b/spring-security-modules/spring-security-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java
similarity index 100%
rename from spring-security-modules/spring-security-mvc-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java
rename to spring-security-modules/spring-security-ldap/src/main/java/org/baeldung/SampleLDAPApplication.java
diff --git a/spring-security-modules/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/MyController.java b/spring-security-modules/spring-security-ldap/src/main/java/org/baeldung/controller/MyController.java
similarity index 100%
rename from spring-security-modules/spring-security-mvc-ldap/src/main/java/org/baeldung/controller/MyController.java
rename to spring-security-modules/spring-security-ldap/src/main/java/org/baeldung/controller/MyController.java
diff --git a/spring-security-modules/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java b/spring-security-modules/spring-security-ldap/src/main/java/org/baeldung/security/SecurityConfig.java
similarity index 100%
rename from spring-security-modules/spring-security-mvc-ldap/src/main/java/org/baeldung/security/SecurityConfig.java
rename to spring-security-modules/spring-security-ldap/src/main/java/org/baeldung/security/SecurityConfig.java
diff --git a/spring-security-modules/spring-security-mvc-ldap/src/main/resources/logback.xml b/spring-security-modules/spring-security-ldap/src/main/resources/logback.xml
similarity index 100%
rename from spring-security-modules/spring-security-mvc-ldap/src/main/resources/logback.xml
rename to spring-security-modules/spring-security-ldap/src/main/resources/logback.xml
diff --git a/spring-security-modules/spring-security-mvc-ldap/src/main/resources/static/css/bootstrap.min.css b/spring-security-modules/spring-security-ldap/src/main/resources/static/css/bootstrap.min.css
similarity index 100%
rename from spring-security-modules/spring-security-mvc-ldap/src/main/resources/static/css/bootstrap.min.css
rename to spring-security-modules/spring-security-ldap/src/main/resources/static/css/bootstrap.min.css
diff --git a/spring-security-modules/spring-security-mvc-ldap/src/main/resources/templates/error.html b/spring-security-modules/spring-security-ldap/src/main/resources/templates/error.html
similarity index 100%
rename from spring-security-modules/spring-security-mvc-ldap/src/main/resources/templates/error.html
rename to spring-security-modules/spring-security-ldap/src/main/resources/templates/error.html
diff --git a/spring-security-modules/spring-security-mvc-ldap/src/main/resources/templates/home.html b/spring-security-modules/spring-security-ldap/src/main/resources/templates/home.html
similarity index 100%
rename from spring-security-modules/spring-security-mvc-ldap/src/main/resources/templates/home.html
rename to spring-security-modules/spring-security-ldap/src/main/resources/templates/home.html
diff --git a/spring-security-modules/spring-security-mvc-ldap/src/main/resources/templates/login.html b/spring-security-modules/spring-security-ldap/src/main/resources/templates/login.html
similarity index 100%
rename from spring-security-modules/spring-security-mvc-ldap/src/main/resources/templates/login.html
rename to spring-security-modules/spring-security-ldap/src/main/resources/templates/login.html
diff --git a/spring-security-modules/spring-security-mvc-ldap/src/main/resources/users.ldif b/spring-security-modules/spring-security-ldap/src/main/resources/users.ldif
similarity index 100%
rename from spring-security-modules/spring-security-mvc-ldap/src/main/resources/users.ldif
rename to spring-security-modules/spring-security-ldap/src/main/resources/users.ldif
diff --git a/spring-security-modules/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml b/spring-security-modules/spring-security-ldap/src/main/resources/webSecurityConfig.xml
similarity index 100%
rename from spring-security-modules/spring-security-mvc-ldap/src/main/resources/webSecurityConfig.xml
rename to spring-security-modules/spring-security-ldap/src/main/resources/webSecurityConfig.xml
diff --git a/spring-security-modules/spring-security-mvc-ldap/src/test/java/org/baeldung/SpringContextTest.java b/spring-security-modules/spring-security-ldap/src/test/java/org/baeldung/SpringContextTest.java
similarity index 100%
rename from spring-security-modules/spring-security-mvc-ldap/src/test/java/org/baeldung/SpringContextTest.java
rename to spring-security-modules/spring-security-ldap/src/test/java/org/baeldung/SpringContextTest.java
diff --git a/spring-security-modules/spring-security-mvc-ldap/src/test/resources/.gitignore b/spring-security-modules/spring-security-ldap/src/test/resources/.gitignore
similarity index 100%
rename from spring-security-modules/spring-security-mvc-ldap/src/test/resources/.gitignore
rename to spring-security-modules/spring-security-ldap/src/test/resources/.gitignore