diff --git a/algorithms-miscellaneous-2/README.md b/algorithms-miscellaneous-2/README.md index 7560fc4fe7..26737b61f0 100644 --- a/algorithms-miscellaneous-2/README.md +++ b/algorithms-miscellaneous-2/README.md @@ -13,4 +13,5 @@ This module contains articles about algorithms. Some classes of algorithms, e.g. - [Create a Sudoku Solver in Java](https://www.baeldung.com/java-sudoku) - [Displaying Money Amounts in Words](https://www.baeldung.com/java-money-into-words) - [A Collaborative Filtering Recommendation System in Java](https://www.baeldung.com/java-collaborative-filtering-recommendations) +- [Implementing A* Pathfinding in Java](https://www.baeldung.com/java-a-star-pathfinding) - More articles: [[<-- prev]](/../algorithms-miscellaneous-1) [[next -->]](/../algorithms-miscellaneous-3) diff --git a/algorithms-miscellaneous-5/README.md b/algorithms-miscellaneous-5/README.md index 3c49b5f01c..682a11b967 100644 --- a/algorithms-miscellaneous-5/README.md +++ b/algorithms-miscellaneous-5/README.md @@ -12,4 +12,5 @@ This module contains articles about algorithms. Some classes of algorithms, e.g. - [How to Determine if a Binary Tree is Balanced](https://www.baeldung.com/java-balanced-binary-tree) - [The Caesar Cipher in Java](https://www.baeldung.com/java-caesar-cipher) - [Overview of Combinatorial Problems in Java](https://www.baeldung.com/java-combinatorial-algorithms) +- [Prim’s Algorithm](https://www.baeldung.com/java-prim-algorithm) - More articles: [[<-- prev]](/../algorithms-miscellaneous-4) diff --git a/apache-spark/README.md b/apache-spark/README.md index 52313d66bf..c60b556d51 100644 --- a/apache-spark/README.md +++ b/apache-spark/README.md @@ -7,4 +7,4 @@ This module contains articles about Apache Spark - [Introduction to Apache Spark](https://www.baeldung.com/apache-spark) - [Building a Data Pipeline with Kafka, Spark Streaming and Cassandra](https://www.baeldung.com/kafka-spark-data-pipeline) - [Machine Learning with Spark MLlib](https://www.baeldung.com/spark-mlib-machine-learning) - +- [Introduction to Spark Graph Processing with GraphFrames](https://www.baeldung.com/spark-graph-graphframes) diff --git a/apache-tapestry/README.md b/apache-tapestry/README.md new file mode 100644 index 0000000000..e41345bada --- /dev/null +++ b/apache-tapestry/README.md @@ -0,0 +1,3 @@ +### Relevant Articles + +- [Intro to Apache Tapestry](https://www.baeldung.com/apache-tapestry) diff --git a/core-groovy-2/src/test/groovy/com/baeldung/category/CategoryUnitTest.groovy b/core-groovy-2/src/test/groovy/com/baeldung/category/CategoryUnitTest.groovy index 5ba7a2347c..a1f67b1e2e 100644 --- a/core-groovy-2/src/test/groovy/com/baeldung/category/CategoryUnitTest.groovy +++ b/core-groovy-2/src/test/groovy/com/baeldung/category/CategoryUnitTest.groovy @@ -28,17 +28,16 @@ class CategoryUnitTest extends GroovyTestCase { } } -// http://team.baeldung.com/browse/BAEL-20687 -// void test_whenUsingTimeCategory_thenOperationOnNumber() { -// SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy") -// use (TimeCategory) { -// assert sdf.format(5.days.from.now) == sdf.format(new Date() + 5.days) -// -// sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss") -// assert sdf.format(10.minutes.from.now) == sdf.format(new Date() + 10.minutes) -// assert sdf.format(2.hours.ago) == sdf.format(new Date() - 2.hours) -// } -// } + void test_whenUsingTimeCategory_thenOperationOnNumber() { + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy") + use (TimeCategory) { + assert sdf.format(5.days.from.now) == sdf.format(new Date() + 5.days) + + sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss") + assert sdf.format(10.minutes.from.now) == sdf.format(new Date() + 10.minutes) + assert sdf.format(2.hours.ago) == sdf.format(new Date() - 2.hours) + } + } void test_whenUsingDOMCategory_thenOperationOnXML() { diff --git a/core-groovy-2/src/test/groovy/com/baeldung/webservice/WebserviceUnitTest.groovy b/core-groovy-2/src/test/groovy/com/baeldung/webservice/WebserviceUnitTest.groovy index 144d5720c8..b8417b8ac1 100644 --- a/core-groovy-2/src/test/groovy/com/baeldung/webservice/WebserviceUnitTest.groovy +++ b/core-groovy-2/src/test/groovy/com/baeldung/webservice/WebserviceUnitTest.groovy @@ -75,7 +75,6 @@ class WebserviceManualTest extends GroovyTestCase { assert stories.size() == 5 } - /* see BAEL-3753 void test_whenConsumingSoap_thenReceiveResponse() { def url = "http://www.dataaccess.com/webservicesserver/numberconversion.wso" def soapClient = new SOAPClient(url) @@ -90,7 +89,6 @@ class WebserviceManualTest extends GroovyTestCase { def words = response.NumberToWordsResponse assert words == "one thousand two hundred and thirty four " } - */ void test_whenConsumingRestGet_thenReceiveResponse() { def path = "/get" diff --git a/core-java-modules/core-java-13/README.md b/core-java-modules/core-java-13/README.md new file mode 100644 index 0000000000..c339520a19 --- /dev/null +++ b/core-java-modules/core-java-13/README.md @@ -0,0 +1,3 @@ +### Relevant articles: + +- [Java Switch Statement](https://www.baeldung.com/java-switch) diff --git a/core-java-modules/core-java-9/README.md b/core-java-modules/core-java-9/README.md index e2bea5f7e2..bfd426b9c1 100644 --- a/core-java-modules/core-java-9/README.md +++ b/core-java-modules/core-java-9/README.md @@ -9,6 +9,7 @@ This module contains articles about Java 9 core features - [Iterate Through a Range of Dates in Java](https://www.baeldung.com/java-iterate-date-range) - [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap) - [Immutable Set in Java](https://www.baeldung.com/java-immutable-set) +- [Immutable ArrayList in Java](https://www.baeldung.com/java-immutable-list) Note: also contains part of the code for the article [How to Filter a Collection in Java](https://www.baeldung.com/java-collection-filtering). diff --git a/core-java-modules/core-java-9/pom.xml b/core-java-modules/core-java-9/pom.xml index 23a465caa1..a90ad0a740 100644 --- a/core-java-modules/core-java-9/pom.xml +++ b/core-java-modules/core-java-9/pom.xml @@ -37,6 +37,11 @@ ${junit.platform.version} test + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + @@ -69,6 +74,7 @@ 1.9 1.9 25.1-jre + 4.1 diff --git a/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/list/immutable/ImmutableArrayListUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/list/immutable/ImmutableArrayListUnitTest.java new file mode 100644 index 0000000000..f148b66dad --- /dev/null +++ b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/list/immutable/ImmutableArrayListUnitTest.java @@ -0,0 +1,48 @@ +package com.baeldung.java9.list.immutable; + +import com.google.common.collect.ImmutableList; +import org.apache.commons.collections4.ListUtils; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class ImmutableArrayListUnitTest { + + @Test(expected = UnsupportedOperationException.class) + public final void givenUsingTheJdk_whenUnmodifiableListIsCreated_thenNotModifiable() { + final List list = new ArrayList<>(Arrays.asList("one", "two", "three")); + final List unmodifiableList = Collections.unmodifiableList(list); + unmodifiableList.add("four"); + } + + @Test(expected = UnsupportedOperationException.class) + public final void givenUsingTheJava9_whenUnmodifiableListIsCreated_thenNotModifiable() { + final List list = new ArrayList<>(Arrays.asList("one", "two", "three")); + final List unmodifiableList = List.of(list.toArray(new String[]{})); + unmodifiableList.add("four"); + } + + @Test(expected = UnsupportedOperationException.class) + public final void givenUsingGuava_whenUnmodifiableListIsCreated_thenNotModifiable() { + final List list = new ArrayList<>(Arrays.asList("one", "two", "three")); + final List unmodifiableList = ImmutableList.copyOf(list); + unmodifiableList.add("four"); + } + + @Test(expected = UnsupportedOperationException.class) + public final void givenUsingGuavaBuilder_whenUnmodifiableListIsCreated_thenNoLongerModifiable() { + final List list = new ArrayList<>(Arrays.asList("one", "two", "three")); + final ImmutableList unmodifiableList = ImmutableList.builder().addAll(list).build(); + unmodifiableList.add("four"); + } + + @Test(expected = UnsupportedOperationException.class) + public final void givenUsingCommonsCollections_whenUnmodifiableListIsCreated_thenNotModifiable() { + final List list = new ArrayList<>(Arrays.asList("one", "two", "three")); + final List unmodifiableList = ListUtils.unmodifiableList(list); + unmodifiableList.add("four"); + } +} diff --git a/core-java-modules/core-java-collections-array-list/README.md b/core-java-modules/core-java-collections-array-list/README.md index 302ea82130..3637f835cf 100644 --- a/core-java-modules/core-java-collections-array-list/README.md +++ b/core-java-modules/core-java-collections-array-list/README.md @@ -3,9 +3,8 @@ This module contains articles about the Java ArrayList collection ### Relevant Articles: -- [Immutable ArrayList in Java](http://www.baeldung.com/java-immutable-list) -- [Guide to the Java ArrayList](http://www.baeldung.com/java-arraylist) -- [Add Multiple Items to an Java ArrayList](http://www.baeldung.com/java-add-items-array-list) +- [Guide to the Java ArrayList](https://www.baeldung.com/java-arraylist) +- [Add Multiple Items to an Java ArrayList](https://www.baeldung.com/java-add-items-array-list) - [ClassCastException: Arrays$ArrayList cannot be cast to ArrayList](https://www.baeldung.com/java-classcastexception-arrays-arraylist) - [Multi Dimensional ArrayList in Java](https://www.baeldung.com/java-multi-dimensional-arraylist) - [Removing an Element From an ArrayList](https://www.baeldung.com/java-arraylist-remove-element) diff --git a/core-java-modules/core-java-collections-array-list/src/test/java/com/baeldung/collections/CoreJavaCollectionsUnitTest.java b/core-java-modules/core-java-collections-array-list/src/test/java/com/baeldung/collections/CoreJavaCollectionsUnitTest.java index 019a569a65..5fd0e605dd 100644 --- a/core-java-modules/core-java-collections-array-list/src/test/java/com/baeldung/collections/CoreJavaCollectionsUnitTest.java +++ b/core-java-modules/core-java-collections-array-list/src/test/java/com/baeldung/collections/CoreJavaCollectionsUnitTest.java @@ -15,42 +15,11 @@ public class CoreJavaCollectionsUnitTest { private static final Logger LOG = LoggerFactory.getLogger(CoreJavaCollectionsUnitTest.class); - - // tests - - @Test public final void givenUsingTheJdk_whenArrayListIsSynchronized_thenCorrect() { - final List list = new ArrayList(Arrays.asList("one", "two", "three")); + final List list = new ArrayList<>(Arrays.asList("one", "two", "three")); final List synchronizedList = Collections.synchronizedList(list); LOG.debug("Synchronized List is: " + synchronizedList); } - @Test(expected = UnsupportedOperationException.class) - public final void givenUsingTheJdk_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { - final List list = new ArrayList(Arrays.asList("one", "two", "three")); - final List unmodifiableList = Collections.unmodifiableList(list); - unmodifiableList.add("four"); - } - - @Test(expected = UnsupportedOperationException.class) - public final void givenUsingGuava_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { - final List list = new ArrayList(Arrays.asList("one", "two", "three")); - final List unmodifiableList = ImmutableList.copyOf(list); - unmodifiableList.add("four"); - } - - @Test(expected = UnsupportedOperationException.class) - public final void givenUsingGuavaBuilder_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { - final List list = new ArrayList(Arrays.asList("one", "two", "three")); - final ImmutableList unmodifiableList = ImmutableList.builder().addAll(list).build(); - unmodifiableList.add("four"); - } - - @Test(expected = UnsupportedOperationException.class) - public final void givenUsingCommonsCollections_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { - final List list = new ArrayList(Arrays.asList("one", "two", "three")); - final List unmodifiableList = ListUtils.unmodifiableList(list); - unmodifiableList.add("four"); - } - } diff --git a/core-java-modules/core-java-exceptions-2/README.md b/core-java-modules/core-java-exceptions-2/README.md index 3ad5189b5e..d3537edb40 100644 --- a/core-java-modules/core-java-exceptions-2/README.md +++ b/core-java-modules/core-java-exceptions-2/README.md @@ -2,4 +2,6 @@ This module contains articles about core java exceptions -### +### Relevant Articles: + +- [Is It a Bad Practice to Catch Throwable?](https://www.baeldung.com/java-catch-throwable-bad-practice) diff --git a/core-java-modules/core-java-io/README.md b/core-java-modules/core-java-io/README.md index 5c4978722f..2c6c3363cb 100644 --- a/core-java-modules/core-java-io/README.md +++ b/core-java-modules/core-java-io/README.md @@ -13,4 +13,5 @@ This module contains articles about core Java input and output (IO) - [Getting a File’s Mime Type in Java](https://www.baeldung.com/java-file-mime-type) - [How to Write to a CSV File in Java](https://www.baeldung.com/java-csv) - [How to Avoid the Java FileNotFoundException When Loading Resources](https://www.baeldung.com/java-classpath-resource-cannot-be-opened) +- [Create a Directory in Java](https://www.baeldung.com/java-create-directory) - [[More -->]](/core-java-modules/core-java-io-2) diff --git a/core-java-modules/core-java-jvm/README.md b/core-java-modules/core-java-jvm/README.md index 89600ad924..2f80ea7372 100644 --- a/core-java-modules/core-java-jvm/README.md +++ b/core-java-modules/core-java-jvm/README.md @@ -10,3 +10,5 @@ This module contains articles about working with the Java Virtual Machine (JVM). - [Class Loaders in Java](https://www.baeldung.com/java-classloaders) - [A Guide to System.exit()](https://www.baeldung.com/java-system-exit) - [Guide to System.gc()](https://www.baeldung.com/java-system-gc) +- [Runtime.getRuntime().halt() vs System.exit() in Java](https://www.baeldung.com/java-runtime-halt-vs-system-exit) +- [Adding Shutdown Hooks for JVM Applications](https://www.baeldung.com/jvm-shutdown-hooks) diff --git a/core-java-modules/core-java-lang-oop-3/README.md b/core-java-modules/core-java-lang-oop-3/README.md index b1ca877ae0..3a0e588ad4 100644 --- a/core-java-modules/core-java-lang-oop-3/README.md +++ b/core-java-modules/core-java-lang-oop-3/README.md @@ -8,9 +8,9 @@ This module contains articles about Object-oriented programming (OOP) in Java - [Guide to the super Java Keyword](https://www.baeldung.com/java-super) - [Guide to the this Java Keyword](https://www.baeldung.com/java-this) - [Java ‘public’ Access Modifier](https://www.baeldung.com/java-public-keyword) -- [Composition, Aggregation and Association in Java](https://www.baeldung.com/java-composition-aggregation-association) +- [Composition, Aggregation, and Association in Java](https://www.baeldung.com/java-composition-aggregation-association) - [Nested Classes in Java](https://www.baeldung.com/java-nested-classes) - [A Guide to Inner Interfaces in Java](https://www.baeldung.com/java-inner-interfaces) - [Java Classes and Objects](https://www.baeldung.com/java-classes-objects) - [Java Interfaces](https://www.baeldung.com/java-interfaces) -- [[<-- Prev]](/core-java-modules/core-java-lang-oop-2)[[More -->]](/core-java-modules/core-java-lang-oop-4) \ No newline at end of file +- [[<-- Prev]](/core-java-modules/core-java-lang-oop-2)[[More -->]](/core-java-modules/core-java-lang-oop-4) diff --git a/core-java-modules/core-java-perf/README.md b/core-java-modules/core-java-perf/README.md index d1d646ac7f..4204c2b012 100644 --- a/core-java-modules/core-java-perf/README.md +++ b/core-java-modules/core-java-perf/README.md @@ -9,3 +9,4 @@ This module contains articles about performance of Java applications - [OutOfMemoryError: GC Overhead Limit Exceeded](http://www.baeldung.com/java-gc-overhead-limit-exceeded) - [Basic Introduction to JMX](http://www.baeldung.com/java-management-extensions) - [Monitoring Java Applications with Flight Recorder](https://www.baeldung.com/java-flight-recorder-monitoring) +- [Branch Prediction in Java](https://www.baeldung.com/java-branch-prediction) diff --git a/core-java-modules/core-java-string-algorithms-3/README.md b/core-java-modules/core-java-string-algorithms-3/README.md index 3aa31cea53..c7b17a6720 100644 --- a/core-java-modules/core-java-string-algorithms-3/README.md +++ b/core-java-modules/core-java-string-algorithms-3/README.md @@ -3,3 +3,5 @@ This module contains articles about string-related algorithms. ### Relevant Articles: + +- [Check if Two Strings are Anagrams in Java](https://www.baeldung.com/java-strings-anagrams) diff --git a/data-structures/README.md b/data-structures/README.md index 7eeda7c64f..fe81f4d2be 100644 --- a/data-structures/README.md +++ b/data-structures/README.md @@ -6,3 +6,4 @@ This module contains articles about data structures in Java - [The Trie Data Structure in Java](https://www.baeldung.com/trie-java) - [Implementing a Binary Tree in Java](https://www.baeldung.com/java-binary-tree) +- [Circular Linked List Java Implementation](https://www.baeldung.com/java-circular-linked-list) diff --git a/intelliJ/remote-debugging/README.adoc b/intelliJ/remote-debugging/README.adoc deleted file mode 100644 index 7110a5d7b9..0000000000 --- a/intelliJ/remote-debugging/README.adoc +++ /dev/null @@ -1,85 +0,0 @@ -:toc: -:spring_version: current -:icons: font -:source-highlighter: prettify -:project_id: gs-scheduling-tasks -This guide walks you through the steps for scheduling tasks with Spring. - -== What you'll build - -You'll build an application that prints out the current time every five seconds using Spring's `@Scheduled` annotation. - -== What you'll need - -:java_version: 1.8 -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/prereq_editor_jdk_buildtools.adoc[] - - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/how_to_complete_this_guide.adoc[] - - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/hide-show-gradle.adoc[] - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/hide-show-maven.adoc[] - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/hide-show-sts.adoc[] - - - -[[initial]] -== Create a scheduled task -Now that you've set up your project, you can create a scheduled task. - -`src/main/java/hello/ScheduledTasks.java` -[source,java] ----- -include::complete/src/main/java/hello/ScheduledTasks.java[] ----- - -The `Scheduled` annotation defines when a particular method runs. -NOTE: This example uses `fixedRate`, which specifies the interval between method invocations measured from the start time of each invocation. There are https://docs.spring.io/spring/docs/{spring_version}/spring-framework-reference/html/scheduling.html#scheduling-annotation-support-scheduled[other options], like `fixedDelay`, which specifies the interval between invocations measured from the completion of the task. You can also https://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/scheduling/support/CronSequenceGenerator.html[use `@Scheduled(cron=". . .")` expressions for more sophisticated task scheduling]. - -== Enable Scheduling - -Although scheduled tasks can be embedded in web apps and WAR files, the simpler approach demonstrated below creates a standalone application. You package everything in a single, executable JAR file, driven by a good old Java `main()` method. - -`src/main/java/hello/Application.java` -[source,java] ----- -include::complete/src/main/java/hello/Application.java[] ----- - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/spring-boot-application.adoc[] - -https://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#scheduling-enable-annotation-support[`@EnableScheduling`] ensures that a background task executor is created. Without it, nothing gets scheduled. - - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/build_an_executable_jar_subhead.adoc[] - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/build_an_executable_jar_with_both.adoc[] - - - -Logging output is displayed and you can see from the logs that it is on a background thread. You should see your scheduled task fire every 5 seconds: - -.... -[...] -2016-08-25 13:10:00.143 INFO 31565 --- [pool-1-thread-1] hello.ScheduledTasks : The time is now 13:10:00 -2016-08-25 13:10:05.143 INFO 31565 --- [pool-1-thread-1] hello.ScheduledTasks : The time is now 13:10:05 -2016-08-25 13:10:10.143 INFO 31565 --- [pool-1-thread-1] hello.ScheduledTasks : The time is now 13:10:10 -2016-08-25 13:10:15.143 INFO 31565 --- [pool-1-thread-1] hello.ScheduledTasks : The time is now 13:10:15 -.... - -== Summary - -Congratulations! You created an application with a scheduled task. Heck, the actual code was shorter than the build file! This technique works in any type of application. - -== See Also - -The following guides may also be helpful: - -* https://spring.io/guides/gs/spring-boot/[Building an Application with Spring Boot] -* https://spring.io/guides/gs/batch-processing/[Creating a Batch Service] - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/footer.adoc[] - diff --git a/intelliJ/remote-debugging/README.md b/intelliJ/remote-debugging/README.md new file mode 100644 index 0000000000..54e3e00ace --- /dev/null +++ b/intelliJ/remote-debugging/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Remote Debugging with IntelliJ IDEA](https://www.baeldung.com/intellij-remote-debugging) diff --git a/java-ee-8-security-api/README.md b/java-ee-8-security-api/README.md index b01a073e35..17142f8102 100644 --- a/java-ee-8-security-api/README.md +++ b/java-ee-8-security-api/README.md @@ -4,4 +4,4 @@ This module contains articles about the Security API in Java EE 8. ### Relevant articles - - [Java EE 8 Security API](https://www.baeldung.com/java-ee-8-security) + - [Jakarta EE 8 Security API](https://www.baeldung.com/java-ee-8-security) diff --git a/java-numbers-2/README.md b/java-numbers-2/README.md index e200c4aa03..2d0d5443b1 100644 --- a/java-numbers-2/README.md +++ b/java-numbers-2/README.md @@ -15,4 +15,5 @@ This module contains articles about numbers in Java. - [Binary Numbers in Java](https://www.baeldung.com/java-binary-numbers) - [Generating Random Numbers in a Range in Java](https://www.baeldung.com/java-generating-random-numbers) - [Listing Numbers Within a Range in Java](https://www.baeldung.com/java-listing-numbers-within-a-range) +- [Fibonacci Series in Java](https://www.baeldung.com/java-fibonacci) - More articles: [[<-- prev]](/../java-numbers) diff --git a/javax-servlets/README.md b/javax-servlets/README.md index 085cc04f87..7dbe1a02ad 100644 --- a/javax-servlets/README.md +++ b/javax-servlets/README.md @@ -9,6 +9,6 @@ This module contains articles about Servlets. - [Uploading Files with Servlets and JSP](https://www.baeldung.com/upload-file-servlet) - [Example of Downloading File in a Servlet](https://www.baeldung.com/servlet-download-file) - [Returning a JSON Response from a Servlet](https://www.baeldung.com/servlet-json-response) -- [Java EE Servlet Exception Handling](https://www.baeldung.com/servlet-exceptions) +- [Jakarta EE Servlet Exception Handling](https://www.baeldung.com/servlet-exceptions) - [Context and Servlet Initialization Parameters](https://www.baeldung.com/context-servlet-initialization-param) - [The Difference between getRequestURI and getPathInfo in HttpServletRequest](https://www.baeldung.com/http-servlet-request-requesturi-pathinfo) diff --git a/jee-7-security/README.md b/jee-7-security/README.md index ced2beec46..0d95d81474 100644 --- a/jee-7-security/README.md +++ b/jee-7-security/README.md @@ -3,4 +3,4 @@ This module contains articles about security in JEE 7. ### Relevant Articles: -- [Securing Java EE with Spring Security](https://www.baeldung.com/java-ee-spring-security) +- [Securing Jakarta EE with Spring Security](https://www.baeldung.com/java-ee-spring-security) diff --git a/jee-7/README.md b/jee-7/README.md index 2c45fe2c67..adaee67d74 100644 --- a/jee-7/README.md +++ b/jee-7/README.md @@ -3,7 +3,7 @@ This module contains articles about JEE 7. ### Relevant Articles: -- [Scheduling in Java EE](https://www.baeldung.com/scheduling-in-java-enterprise-edition) +- [Scheduling in Jakarta EE](https://www.baeldung.com/scheduling-in-java-enterprise-edition) - [JSON Processing in Java EE 7](https://www.baeldung.com/jee7-json) - [Converters, Listeners and Validators in Java EE 7](https://www.baeldung.com/java-ee7-converter-listener-validator) - [Introduction to JAX-WS](https://www.baeldung.com/jax-ws) diff --git a/jee-kotlin/README.md b/jee-kotlin/README.md index aa3aa58b4e..e8975a7f62 100644 --- a/jee-kotlin/README.md +++ b/jee-kotlin/README.md @@ -3,4 +3,4 @@ This module contains articles about Java EE with Kotlin. ### Relevant Articles: -- [Java EE Application with Kotlin](https://www.baeldung.com/java-ee-kotlin-app) +- [Jakarta EE Application with Kotlin](https://www.baeldung.com/java-ee-kotlin-app) diff --git a/jta/README.md b/jta/README.md index 0351177a0d..202019118d 100644 --- a/jta/README.md +++ b/jta/README.md @@ -3,4 +3,4 @@ This module contains articles about the Java Transaction API (JTA). ### Relevant Articles: -- [Guide to Java EE JTA](https://www.baeldung.com/jee-jta) +- [Guide to Jakarta EE JTA](https://www.baeldung.com/jee-jta) diff --git a/libraries-http/README.md b/libraries-http/README.md index f5afb2d277..4c27ec1c8d 100644 --- a/libraries-http/README.md +++ b/libraries-http/README.md @@ -12,3 +12,4 @@ This module contains articles about HTTP libraries. - [Introduction to Retrofit](https://www.baeldung.com/retrofit) - [A Guide to Unirest](https://www.baeldung.com/unirest) - [Creating REST Microservices with Javalin](https://www.baeldung.com/javalin-rest-microservices) +- [A Quick Guide to Timeouts in OkHttp](https://www.baeldung.com/okhttp-timeouts) diff --git a/libraries-security/README.md b/libraries-security/README.md index 819bc866cf..580ebdeab0 100644 --- a/libraries-security/README.md +++ b/libraries-security/README.md @@ -9,4 +9,4 @@ This module contains articles about security libraries. - [Guide to Google Tink](https://www.baeldung.com/google-tink) - [Introduction to BouncyCastle with Java](https://www.baeldung.com/java-bouncy-castle) - [Intro to Jasypt](https://www.baeldung.com/jasypt) -- [Digital Signature in Java](https://www.baeldung.com/java-digital-signature) +- [Digital Signatures in Java](https://www.baeldung.com/java-digital-signature) diff --git a/maven-all/maven-custom-plugin/README.md b/maven-all/maven-custom-plugin/README.md new file mode 100644 index 0000000000..55d147c337 --- /dev/null +++ b/maven-all/maven-custom-plugin/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [How to Create a Maven Plugin](https://www.baeldung.com/maven-plugin) diff --git a/oauth2-framework-impl/README.md b/oauth2-framework-impl/README.md index ea9686b451..ae28c1b511 100644 --- a/oauth2-framework-impl/README.md +++ b/oauth2-framework-impl/README.md @@ -4,4 +4,4 @@ This module contains articles about the implementation of OAuth2 with Java EE. ### Relevant Articles -- [Implementing The OAuth 2.0 Authorization Framework Using Java EE](https://www.baeldung.com/java-ee-oauth2-implementation) +- [Implementing The OAuth 2.0 Authorization Framework Using Jakarta EE](https://www.baeldung.com/java-ee-oauth2-implementation) diff --git a/persistence-modules/hibernate5-2/README.md b/persistence-modules/hibernate5-2/README.md index c41b5307d0..d409f99a3a 100644 --- a/persistence-modules/hibernate5-2/README.md +++ b/persistence-modules/hibernate5-2/README.md @@ -6,4 +6,5 @@ This module contains articles about Hibernate 5. - [Hibernate Error “Not all named parameters have been set”](https://www.baeldung.com/hibernate-error-named-parameters-not-set) - [FetchMode in Spring Data JPA](https://www.baeldung.com/spring-data-jpa-fetchmode) - [JPA/Hibernate Persistence Context](https://www.baeldung.com/jpa-hibernate-persistence-context) +- [FetchMode in Hibernate](https://www.baeldung.com/hibernate-fetchmode) - [[<-- Prev]](/hibernate5) diff --git a/persistence-modules/sirix/README.md b/persistence-modules/sirix/README.md index ab7fb65e44..923b111e7a 100644 --- a/persistence-modules/sirix/README.md +++ b/persistence-modules/sirix/README.md @@ -1,4 +1,3 @@ ## Relevant articles: -- [Introduction to Sirix](https://www.baeldung.com/introduction-to-sirix) - [A Guide to SirixDB](https://www.baeldung.com/sirix) diff --git a/pom.xml b/pom.xml index 566394eeff..88aec587a0 100644 --- a/pom.xml +++ b/pom.xml @@ -642,13 +642,9 @@ spring-boot-modules spring-boot-angular spring-boot-bootstrap - spring-boot-camel spring-boot-client spring-boot-config-jpa-error - spring-boot-crud - spring-boot-custom-starter - spring-boot-ctx-fluent spring-boot-deployment spring-boot-di spring-boot-environment @@ -656,10 +652,9 @@ spring-boot-jasypt spring-boot-kotlin spring-boot-libraries - spring-boot-logging-log4j2 spring-boot-mvc-2 - spring-boot-nashorn spring-boot-parent + spring-boot-performance spring-boot-property-exp spring-boot-rest @@ -1170,13 +1165,9 @@ spring-boot-modules spring-boot-angular spring-boot-bootstrap - spring-boot-camel spring-boot-client spring-boot-config-jpa-error - spring-boot-crud - spring-boot-custom-starter - spring-boot-ctx-fluent spring-boot-deployment spring-boot-di spring-boot-environment @@ -1184,11 +1175,10 @@ spring-boot-jasypt spring-boot-kotlin spring-boot-libraries - spring-boot-logging-log4j2 spring-boot-mvc spring-boot-mvc-2 - spring-boot-nashorn spring-boot-parent + spring-boot-performance spring-boot-property-exp spring-boot-rest diff --git a/quarkus-extension/README.md b/quarkus-extension/README.md new file mode 100644 index 0000000000..782ec75957 --- /dev/null +++ b/quarkus-extension/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [How to Implement a Quarkus Extension](https://www.baeldung.com/quarkus-extension-java) diff --git a/rxjava-core/README.md b/rxjava-core/README.md index 2773bd9423..95a374668d 100644 --- a/rxjava-core/README.md +++ b/rxjava-core/README.md @@ -13,4 +13,5 @@ This module contains articles about RxJava. - [RxJava Maybe](https://www.baeldung.com/rxjava-maybe) - [Combining RxJava Completables](https://www.baeldung.com/rxjava-completable) - [RxJava Hooks](https://www.baeldung.com/rxjava-hooks) +- [Introduction to rxjava-jdbc](https://www.baeldung.com/rxjava-jdbc) - More articles: [[next -->]](/rxjava-2) diff --git a/spring-amqp/README.md b/spring-amqp/README.md index 0ae4eda12e..6b09aec10a 100644 --- a/spring-amqp/README.md +++ b/spring-amqp/README.md @@ -5,4 +5,5 @@ This module contains articles about Spring with the AMQP messaging system ## Relevant articles: - [Messaging With Spring AMQP](https://www.baeldung.com/spring-amqp) -- [RabbitMQ Message Dispatching with Spring AMQP](https://www.baeldung.com/rabbitmq-spring-amqp) \ No newline at end of file +- [RabbitMQ Message Dispatching with Spring AMQP](https://www.baeldung.com/rabbitmq-spring-amqp) +- [Error Handling with Spring AMQP](https://www.baeldung.com/spring-amqp-error-handling) diff --git a/spring-boot-kotlin/README.md b/spring-boot-kotlin/README.md index d393805ed1..fb91fdee15 100644 --- a/spring-boot-kotlin/README.md +++ b/spring-boot-kotlin/README.md @@ -3,4 +3,4 @@ This module contains articles about Kotlin in Spring Boot projects. ### Relevant Articles: -- [Non-blocking Spring Boot with Kotlin Coroutines](https://www.baeldung.com/non-blocking-spring-boot-with-kotlin-coroutines) +- [Non-blocking Spring Boot with Kotlin Coroutines](https://www.baeldung.com/spring-boot-kotlin-coroutines) diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 5261662b7b..f5d697fdf1 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -15,15 +15,18 @@ spring-boot-admin - spring-boot-custom-starter spring-boot-artifacts spring-boot-ctx-fluent spring-boot-autoconfiguration + spring-boot-camel + spring-boot-custom-starter + spring-boot-crud spring-boot-data spring-boot-keycloak + spring-boot-logging-log4j2 spring-boot-mvc-birt - spring-boot-performance + spring-boot-nashorn spring-boot-properties spring-boot-springdoc spring-boot-testing diff --git a/spring-boot-camel/README.md b/spring-boot-modules/spring-boot-camel/README.md similarity index 100% rename from spring-boot-camel/README.md rename to spring-boot-modules/spring-boot-camel/README.md diff --git a/spring-boot-camel/pom.xml b/spring-boot-modules/spring-boot-camel/pom.xml similarity index 95% rename from spring-boot-camel/pom.xml rename to spring-boot-modules/spring-boot-camel/pom.xml index 8bab0ed5c8..7c1e28b3ee 100644 --- a/spring-boot-camel/pom.xml +++ b/spring-boot-modules/spring-boot-camel/pom.xml @@ -8,8 +8,8 @@ spring-boot-camel - com.baeldung - parent-modules + com.baeldung.spring-boot-modules + spring-boot-modules 1.0.0-SNAPSHOT diff --git a/spring-boot-camel/src/main/java/com/baeldung/camel/Application.java b/spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/Application.java similarity index 100% rename from spring-boot-camel/src/main/java/com/baeldung/camel/Application.java rename to spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/Application.java diff --git a/spring-boot-camel/src/main/java/com/baeldung/camel/ExampleServices.java b/spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/ExampleServices.java similarity index 100% rename from spring-boot-camel/src/main/java/com/baeldung/camel/ExampleServices.java rename to spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/ExampleServices.java diff --git a/spring-boot-camel/src/main/java/com/baeldung/camel/MyBean.java b/spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/MyBean.java similarity index 100% rename from spring-boot-camel/src/main/java/com/baeldung/camel/MyBean.java rename to spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/MyBean.java diff --git a/spring-boot-camel/src/main/resources/application.properties b/spring-boot-modules/spring-boot-camel/src/main/resources/application.properties similarity index 100% rename from spring-boot-camel/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-camel/src/main/resources/application.properties diff --git a/spring-boot-camel/src/main/resources/application.yml b/spring-boot-modules/spring-boot-camel/src/main/resources/application.yml similarity index 100% rename from spring-boot-camel/src/main/resources/application.yml rename to spring-boot-modules/spring-boot-camel/src/main/resources/application.yml diff --git a/spring-boot-camel/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-camel/src/main/resources/logback.xml similarity index 100% rename from spring-boot-camel/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-camel/src/main/resources/logback.xml diff --git a/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-crud/README.md b/spring-boot-modules/spring-boot-crud/README.md similarity index 100% rename from spring-boot-crud/README.md rename to spring-boot-modules/spring-boot-crud/README.md diff --git a/spring-boot-crud/pom.xml b/spring-boot-modules/spring-boot-crud/pom.xml similarity index 95% rename from spring-boot-crud/pom.xml rename to spring-boot-modules/spring-boot-crud/pom.xml index e78e939f0c..676d522f84 100644 --- a/spring-boot-crud/pom.xml +++ b/spring-boot-modules/spring-boot-crud/pom.xml @@ -1,86 +1,86 @@ - - - 4.0.0 - spring-boot-crud - spring-boot-crud - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../parent-boot-2 - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-test - - - org.mockito - mockito-core - test - - - com.h2database - h2 - runtime - - - - - spring-boot-crud - - - src/main/resources - true - - - - - org.springframework.boot - spring-boot-maven-plugin - - exec - - - - org.apache.maven.plugins - maven-assembly-plugin - - - jar-with-dependencies - - - - - make-assembly - package - - single - - - - - - - - - UTF-8 - - - + + + 4.0.0 + spring-boot-crud + spring-boot-crud + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-test + + + org.mockito + mockito-core + test + + + com.h2database + h2 + runtime + + + + + spring-boot-crud + + + src/main/resources + true + + + + + org.springframework.boot + spring-boot-maven-plugin + + exec + + + + org.apache.maven.plugins + maven-assembly-plugin + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + + + + UTF-8 + + + diff --git a/spring-boot-crud/src/main/java/com/baeldung/crud/Application.java b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/Application.java similarity index 97% rename from spring-boot-crud/src/main/java/com/baeldung/crud/Application.java rename to spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/Application.java index 0b686e90e9..a56a2a04c0 100644 --- a/spring-boot-crud/src/main/java/com/baeldung/crud/Application.java +++ b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/Application.java @@ -1,23 +1,23 @@ -package com.baeldung.crud; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -@SpringBootApplication -@EnableAutoConfiguration -@ComponentScan(basePackages={"com.baeldung.crud"}) -@EnableJpaRepositories(basePackages="com.baeldung.crud.repositories") -@EnableTransactionManagement -@EntityScan(basePackages="com.baeldung.crud.entities") -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} +package com.baeldung.crud; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@SpringBootApplication +@EnableAutoConfiguration +@ComponentScan(basePackages={"com.baeldung.crud"}) +@EnableJpaRepositories(basePackages="com.baeldung.crud.repositories") +@EnableTransactionManagement +@EntityScan(basePackages="com.baeldung.crud.entities") +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java similarity index 97% rename from spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java rename to spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java index 9a6cb477aa..726be6a384 100644 --- a/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java +++ b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java @@ -1,68 +1,68 @@ -package com.baeldung.crud.controllers; - -import javax.validation.Valid; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; - -import com.baeldung.crud.entities.User; -import com.baeldung.crud.repositories.UserRepository; - -@Controller -public class UserController { - - private final UserRepository userRepository; - - @Autowired - public UserController(UserRepository userRepository) { - this.userRepository = userRepository; - } - - @GetMapping("/signup") - public String showSignUpForm(User user) { - return "add-user"; - } - - @PostMapping("/adduser") - public String addUser(@Valid User user, BindingResult result, Model model) { - if (result.hasErrors()) { - return "add-user"; - } - - userRepository.save(user); - model.addAttribute("users", userRepository.findAll()); - return "index"; - } - - @GetMapping("/edit/{id}") - public String showUpdateForm(@PathVariable("id") long id, Model model) { - User user = userRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("Invalid user Id:" + id)); - model.addAttribute("user", user); - return "update-user"; - } - - @PostMapping("/update/{id}") - public String updateUser(@PathVariable("id") long id, @Valid User user, BindingResult result, Model model) { - if (result.hasErrors()) { - user.setId(id); - return "update-user"; - } - - userRepository.save(user); - model.addAttribute("users", userRepository.findAll()); - return "index"; - } - - @GetMapping("/delete/{id}") - public String deleteUser(@PathVariable("id") long id, Model model) { - User user = userRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("Invalid user Id:" + id)); - userRepository.delete(user); - model.addAttribute("users", userRepository.findAll()); - return "index"; - } -} +package com.baeldung.crud.controllers; + +import javax.validation.Valid; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; + +import com.baeldung.crud.entities.User; +import com.baeldung.crud.repositories.UserRepository; + +@Controller +public class UserController { + + private final UserRepository userRepository; + + @Autowired + public UserController(UserRepository userRepository) { + this.userRepository = userRepository; + } + + @GetMapping("/signup") + public String showSignUpForm(User user) { + return "add-user"; + } + + @PostMapping("/adduser") + public String addUser(@Valid User user, BindingResult result, Model model) { + if (result.hasErrors()) { + return "add-user"; + } + + userRepository.save(user); + model.addAttribute("users", userRepository.findAll()); + return "index"; + } + + @GetMapping("/edit/{id}") + public String showUpdateForm(@PathVariable("id") long id, Model model) { + User user = userRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("Invalid user Id:" + id)); + model.addAttribute("user", user); + return "update-user"; + } + + @PostMapping("/update/{id}") + public String updateUser(@PathVariable("id") long id, @Valid User user, BindingResult result, Model model) { + if (result.hasErrors()) { + user.setId(id); + return "update-user"; + } + + userRepository.save(user); + model.addAttribute("users", userRepository.findAll()); + return "index"; + } + + @GetMapping("/delete/{id}") + public String deleteUser(@PathVariable("id") long id, Model model) { + User user = userRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("Invalid user Id:" + id)); + userRepository.delete(user); + model.addAttribute("users", userRepository.findAll()); + return "index"; + } +} diff --git a/spring-boot-crud/src/main/java/com/baeldung/crud/entities/User.java b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/entities/User.java similarity index 95% rename from spring-boot-crud/src/main/java/com/baeldung/crud/entities/User.java rename to spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/entities/User.java index 2074268179..372327532f 100644 --- a/spring-boot-crud/src/main/java/com/baeldung/crud/entities/User.java +++ b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/entities/User.java @@ -1,56 +1,56 @@ -package com.baeldung.crud.entities; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.validation.constraints.NotBlank; - -@Entity -public class User { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - @NotBlank(message = "Name is mandatory") - private String name; - - @NotBlank(message = "Email is mandatory") - private String email; - - public User() {} - - public User(String name, String email) { - this.name = name; - this.email = email; - } - - public void setId(long id) { - this.id = id; - } - - public long getId() { - return id; - } - - public void setName(String name) { - this.name = name; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getName() { - return name; - } - - public String getEmail() { - return email; - } - - @Override - public String toString() { - return "User{" + "id=" + id + ", name=" + name + ", email=" + email + '}'; - } -} +package com.baeldung.crud.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.validation.constraints.NotBlank; + +@Entity +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + @NotBlank(message = "Name is mandatory") + private String name; + + @NotBlank(message = "Email is mandatory") + private String email; + + public User() {} + + public User(String name, String email) { + this.name = name; + this.email = email; + } + + public void setId(long id) { + this.id = id; + } + + public long getId() { + return id; + } + + public void setName(String name) { + this.name = name; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getName() { + return name; + } + + public String getEmail() { + return email; + } + + @Override + public String toString() { + return "User{" + "id=" + id + ", name=" + name + ", email=" + email + '}'; + } +} diff --git a/spring-boot-crud/src/main/java/com/baeldung/crud/repositories/UserRepository.java b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/repositories/UserRepository.java similarity index 96% rename from spring-boot-crud/src/main/java/com/baeldung/crud/repositories/UserRepository.java rename to spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/repositories/UserRepository.java index 72348463f2..c17ebc56ba 100644 --- a/spring-boot-crud/src/main/java/com/baeldung/crud/repositories/UserRepository.java +++ b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/repositories/UserRepository.java @@ -1,13 +1,13 @@ -package com.baeldung.crud.repositories; - -import com.baeldung.crud.entities.User; -import java.util.List; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface UserRepository extends CrudRepository { - - List findByName(String name); - -} +package com.baeldung.crud.repositories; + +import com.baeldung.crud.entities.User; +import java.util.List; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface UserRepository extends CrudRepository { + + List findByName(String name); + +} diff --git a/spring-boot-crud/src/main/resources/css/shards.min.css b/spring-boot-modules/spring-boot-crud/src/main/resources/css/shards.min.css similarity index 100% rename from spring-boot-crud/src/main/resources/css/shards.min.css rename to spring-boot-modules/spring-boot-crud/src/main/resources/css/shards.min.css diff --git a/spring-boot-crud/src/main/resources/templates/add-user.html b/spring-boot-modules/spring-boot-crud/src/main/resources/templates/add-user.html similarity index 100% rename from spring-boot-crud/src/main/resources/templates/add-user.html rename to spring-boot-modules/spring-boot-crud/src/main/resources/templates/add-user.html diff --git a/spring-boot-crud/src/main/resources/templates/index.html b/spring-boot-modules/spring-boot-crud/src/main/resources/templates/index.html similarity index 100% rename from spring-boot-crud/src/main/resources/templates/index.html rename to spring-boot-modules/spring-boot-crud/src/main/resources/templates/index.html diff --git a/spring-boot-crud/src/main/resources/templates/update-user.html b/spring-boot-modules/spring-boot-crud/src/main/resources/templates/update-user.html similarity index 100% rename from spring-boot-crud/src/main/resources/templates/update-user.html rename to spring-boot-modules/spring-boot-crud/src/main/resources/templates/update-user.html diff --git a/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java b/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java similarity index 97% rename from spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java rename to spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java index 2de0828ae5..033108c195 100644 --- a/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java +++ b/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java @@ -1,83 +1,83 @@ -package com.baeldung.crud; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.springframework.ui.Model; -import org.springframework.validation.BindingResult; - -import com.baeldung.crud.controllers.UserController; -import com.baeldung.crud.entities.User; -import com.baeldung.crud.repositories.UserRepository; - -public class UserControllerUnitTest { - - private static UserController userController; - private static UserRepository mockedUserRepository; - private static BindingResult mockedBindingResult; - private static Model mockedModel; - - @BeforeClass - public static void setUpUserControllerInstance() { - mockedUserRepository = mock(UserRepository.class); - mockedBindingResult = mock(BindingResult.class); - mockedModel = mock(Model.class); - userController = new UserController(mockedUserRepository); - } - - @Test - public void whenCalledshowSignUpForm_thenCorrect() { - User user = new User("John", "john@domain.com"); - - assertThat(userController.showSignUpForm(user)).isEqualTo("add-user"); - } - - @Test - public void whenCalledaddUserAndValidUser_thenCorrect() { - User user = new User("John", "john@domain.com"); - - when(mockedBindingResult.hasErrors()).thenReturn(false); - - assertThat(userController.addUser(user, mockedBindingResult, mockedModel)).isEqualTo("index"); - } - - @Test - public void whenCalledaddUserAndInValidUser_thenCorrect() { - User user = new User("John", "john@domain.com"); - - when(mockedBindingResult.hasErrors()).thenReturn(true); - - assertThat(userController.addUser(user, mockedBindingResult, mockedModel)).isEqualTo("add-user"); - } - - @Test(expected = IllegalArgumentException.class) - public void whenCalledshowUpdateForm_thenIllegalArgumentException() { - assertThat(userController.showUpdateForm(0, mockedModel)).isEqualTo("update-user"); - } - - @Test - public void whenCalledupdateUserAndValidUser_thenCorrect() { - User user = new User("John", "john@domain.com"); - - when(mockedBindingResult.hasErrors()).thenReturn(false); - - assertThat(userController.updateUser(1l, user, mockedBindingResult, mockedModel)).isEqualTo("index"); - } - - @Test - public void whenCalledupdateUserAndInValidUser_thenCorrect() { - User user = new User("John", "john@domain.com"); - - when(mockedBindingResult.hasErrors()).thenReturn(true); - - assertThat(userController.updateUser(1l, user, mockedBindingResult, mockedModel)).isEqualTo("update-user"); - } - - @Test(expected = IllegalArgumentException.class) - public void whenCalleddeleteUser_thenIllegalArgumentException() { - assertThat(userController.deleteUser(1l, mockedModel)).isEqualTo("index"); - } -} +package com.baeldung.crud; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; + +import com.baeldung.crud.controllers.UserController; +import com.baeldung.crud.entities.User; +import com.baeldung.crud.repositories.UserRepository; + +public class UserControllerUnitTest { + + private static UserController userController; + private static UserRepository mockedUserRepository; + private static BindingResult mockedBindingResult; + private static Model mockedModel; + + @BeforeClass + public static void setUpUserControllerInstance() { + mockedUserRepository = mock(UserRepository.class); + mockedBindingResult = mock(BindingResult.class); + mockedModel = mock(Model.class); + userController = new UserController(mockedUserRepository); + } + + @Test + public void whenCalledshowSignUpForm_thenCorrect() { + User user = new User("John", "john@domain.com"); + + assertThat(userController.showSignUpForm(user)).isEqualTo("add-user"); + } + + @Test + public void whenCalledaddUserAndValidUser_thenCorrect() { + User user = new User("John", "john@domain.com"); + + when(mockedBindingResult.hasErrors()).thenReturn(false); + + assertThat(userController.addUser(user, mockedBindingResult, mockedModel)).isEqualTo("index"); + } + + @Test + public void whenCalledaddUserAndInValidUser_thenCorrect() { + User user = new User("John", "john@domain.com"); + + when(mockedBindingResult.hasErrors()).thenReturn(true); + + assertThat(userController.addUser(user, mockedBindingResult, mockedModel)).isEqualTo("add-user"); + } + + @Test(expected = IllegalArgumentException.class) + public void whenCalledshowUpdateForm_thenIllegalArgumentException() { + assertThat(userController.showUpdateForm(0, mockedModel)).isEqualTo("update-user"); + } + + @Test + public void whenCalledupdateUserAndValidUser_thenCorrect() { + User user = new User("John", "john@domain.com"); + + when(mockedBindingResult.hasErrors()).thenReturn(false); + + assertThat(userController.updateUser(1l, user, mockedBindingResult, mockedModel)).isEqualTo("index"); + } + + @Test + public void whenCalledupdateUserAndInValidUser_thenCorrect() { + User user = new User("John", "john@domain.com"); + + when(mockedBindingResult.hasErrors()).thenReturn(true); + + assertThat(userController.updateUser(1l, user, mockedBindingResult, mockedModel)).isEqualTo("update-user"); + } + + @Test(expected = IllegalArgumentException.class) + public void whenCalleddeleteUser_thenIllegalArgumentException() { + assertThat(userController.deleteUser(1l, mockedModel)).isEqualTo("index"); + } +} diff --git a/spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java b/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java similarity index 96% rename from spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java rename to spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java index 565f6727c3..3e33e868ad 100644 --- a/spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java +++ b/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java @@ -1,48 +1,48 @@ -package com.baeldung.crud; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Test; - -import com.baeldung.crud.entities.User; - -public class UserUnitTest { - - @Test - public void whenCalledGetName_thenCorrect() { - User user = new User("Julie", "julie@domain.com"); - - assertThat(user.getName()).isEqualTo("Julie"); - } - - @Test - public void whenCalledGetEmail_thenCorrect() { - User user = new User("Julie", "julie@domain.com"); - - assertThat(user.getEmail()).isEqualTo("julie@domain.com"); - } - - @Test - public void whenCalledSetName_thenCorrect() { - User user = new User("Julie", "julie@domain.com"); - - user.setName("John"); - - assertThat(user.getName()).isEqualTo("John"); - } - - @Test - public void whenCalledSetEmail_thenCorrect() { - User user = new User("Julie", "julie@domain.com"); - - user.setEmail("john@domain.com"); - - assertThat(user.getEmail()).isEqualTo("john@domain.com"); - } - - @Test - public void whenCalledtoString_thenCorrect() { - User user = new User("Julie", "julie@domain.com"); - assertThat(user.toString()).isEqualTo("User{id=0, name=Julie, email=julie@domain.com}"); - } -} +package com.baeldung.crud; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +import com.baeldung.crud.entities.User; + +public class UserUnitTest { + + @Test + public void whenCalledGetName_thenCorrect() { + User user = new User("Julie", "julie@domain.com"); + + assertThat(user.getName()).isEqualTo("Julie"); + } + + @Test + public void whenCalledGetEmail_thenCorrect() { + User user = new User("Julie", "julie@domain.com"); + + assertThat(user.getEmail()).isEqualTo("julie@domain.com"); + } + + @Test + public void whenCalledSetName_thenCorrect() { + User user = new User("Julie", "julie@domain.com"); + + user.setName("John"); + + assertThat(user.getName()).isEqualTo("John"); + } + + @Test + public void whenCalledSetEmail_thenCorrect() { + User user = new User("Julie", "julie@domain.com"); + + user.setEmail("john@domain.com"); + + assertThat(user.getEmail()).isEqualTo("john@domain.com"); + } + + @Test + public void whenCalledtoString_thenCorrect() { + User user = new User("Julie", "julie@domain.com"); + assertThat(user.toString()).isEqualTo("User{id=0, name=Julie, email=julie@domain.com}"); + } +} diff --git a/spring-boot-logging-log4j2/.gitignore b/spring-boot-modules/spring-boot-logging-log4j2/.gitignore similarity index 100% rename from spring-boot-logging-log4j2/.gitignore rename to spring-boot-modules/spring-boot-logging-log4j2/.gitignore diff --git a/spring-boot-logging-log4j2/README.md b/spring-boot-modules/spring-boot-logging-log4j2/README.md similarity index 100% rename from spring-boot-logging-log4j2/README.md rename to spring-boot-modules/spring-boot-logging-log4j2/README.md diff --git a/spring-boot-logging-log4j2/pom.xml b/spring-boot-modules/spring-boot-logging-log4j2/pom.xml similarity index 98% rename from spring-boot-logging-log4j2/pom.xml rename to spring-boot-modules/spring-boot-logging-log4j2/pom.xml index a7065bc925..6e709230dd 100644 --- a/spring-boot-logging-log4j2/pom.xml +++ b/spring-boot-modules/spring-boot-logging-log4j2/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 2.2.1.RELEASE + 2.2.2.RELEASE diff --git a/spring-boot-logging-log4j2/src/main/java/com/baeldung/graylog/GraylogDemoApplication.java b/spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/graylog/GraylogDemoApplication.java similarity index 100% rename from spring-boot-logging-log4j2/src/main/java/com/baeldung/graylog/GraylogDemoApplication.java rename to spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/graylog/GraylogDemoApplication.java diff --git a/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LoggingController.java b/spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LoggingController.java similarity index 100% rename from spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LoggingController.java rename to spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LoggingController.java diff --git a/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LombokLoggingController.java b/spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LombokLoggingController.java similarity index 100% rename from spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LombokLoggingController.java rename to spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LombokLoggingController.java diff --git a/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/SpringBootLoggingApplication.java b/spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/SpringBootLoggingApplication.java similarity index 100% rename from spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/SpringBootLoggingApplication.java rename to spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/SpringBootLoggingApplication.java diff --git a/spring-boot-logging-log4j2/src/main/resources/application.properties b/spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/application.properties similarity index 100% rename from spring-boot-logging-log4j2/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/application.properties diff --git a/spring-boot-logging-log4j2/src/main/resources/log4j.xml b/spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/log4j.xml similarity index 100% rename from spring-boot-logging-log4j2/src/main/resources/log4j.xml rename to spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/log4j.xml diff --git a/spring-boot-logging-log4j2/src/main/resources/log4j2-spring.xml b/spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/log4j2-spring.xml similarity index 100% rename from spring-boot-logging-log4j2/src/main/resources/log4j2-spring.xml rename to spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/log4j2-spring.xml diff --git a/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-nashorn/README.md b/spring-boot-modules/spring-boot-nashorn/README.md similarity index 100% rename from spring-boot-nashorn/README.md rename to spring-boot-modules/spring-boot-nashorn/README.md diff --git a/spring-boot-nashorn/pom.xml b/spring-boot-modules/spring-boot-nashorn/pom.xml similarity index 96% rename from spring-boot-nashorn/pom.xml rename to spring-boot-modules/spring-boot-nashorn/pom.xml index af11f14fdc..c60997005d 100644 --- a/spring-boot-nashorn/pom.xml +++ b/spring-boot-modules/spring-boot-nashorn/pom.xml @@ -13,7 +13,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/Application.java b/spring-boot-modules/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/Application.java similarity index 100% rename from spring-boot-nashorn/src/main/java/com/baeldung/nashorn/Application.java rename to spring-boot-modules/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/Application.java diff --git a/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyRestController.java b/spring-boot-modules/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyRestController.java similarity index 100% rename from spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyRestController.java rename to spring-boot-modules/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyRestController.java diff --git a/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyWebController.java b/spring-boot-modules/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyWebController.java similarity index 100% rename from spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyWebController.java rename to spring-boot-modules/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyWebController.java diff --git a/spring-boot-nashorn/src/main/resources/application.properties b/spring-boot-modules/spring-boot-nashorn/src/main/resources/application.properties similarity index 100% rename from spring-boot-nashorn/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-nashorn/src/main/resources/application.properties diff --git a/spring-boot-nashorn/src/main/resources/static/app.js b/spring-boot-modules/spring-boot-nashorn/src/main/resources/static/app.js similarity index 100% rename from spring-boot-nashorn/src/main/resources/static/app.js rename to spring-boot-modules/spring-boot-nashorn/src/main/resources/static/app.js diff --git a/spring-boot-nashorn/src/main/resources/static/js/react-dom-server.js b/spring-boot-modules/spring-boot-nashorn/src/main/resources/static/js/react-dom-server.js similarity index 100% rename from spring-boot-nashorn/src/main/resources/static/js/react-dom-server.js rename to spring-boot-modules/spring-boot-nashorn/src/main/resources/static/js/react-dom-server.js diff --git a/spring-boot-nashorn/src/main/resources/static/js/react-dom.js b/spring-boot-modules/spring-boot-nashorn/src/main/resources/static/js/react-dom.js similarity index 100% rename from spring-boot-nashorn/src/main/resources/static/js/react-dom.js rename to spring-boot-modules/spring-boot-nashorn/src/main/resources/static/js/react-dom.js diff --git a/spring-boot-nashorn/src/main/resources/static/js/react.js b/spring-boot-modules/spring-boot-nashorn/src/main/resources/static/js/react.js similarity index 100% rename from spring-boot-nashorn/src/main/resources/static/js/react.js rename to spring-boot-modules/spring-boot-nashorn/src/main/resources/static/js/react.js diff --git a/spring-boot-nashorn/src/main/webapp/WEB-INF/jsp/index.jsp b/spring-boot-modules/spring-boot-nashorn/src/main/webapp/WEB-INF/jsp/index.jsp similarity index 100% rename from spring-boot-nashorn/src/main/webapp/WEB-INF/jsp/index.jsp rename to spring-boot-modules/spring-boot-nashorn/src/main/webapp/WEB-INF/jsp/index.jsp diff --git a/spring-boot-mvc-2/README.md b/spring-boot-mvc-2/README.md index 81a969bf87..dae815a1c1 100644 --- a/spring-boot-mvc-2/README.md +++ b/spring-boot-mvc-2/README.md @@ -5,5 +5,5 @@ This module contains articles about Spring Web MVC in Spring Boot projects. ### Relevant Articles: - [Functional Controllers in Spring MVC](https://www.baeldung.com/spring-mvc-functional-controllers) -- [Specify an array of strings as body parameter in Swagger API](https://www.baeldung.com/array-of-strings-as-body-parameter-in-swagger-api) +- [Specify an array of strings as body parameter in Swagger API](https://www.baeldung.com/swagger-body-array-of-strings) - More articles: [[prev -->]](/spring-boot-mvc) diff --git a/spring-boot-modules/spring-boot-performance/README.md b/spring-boot-performance/README.md similarity index 100% rename from spring-boot-modules/spring-boot-performance/README.md rename to spring-boot-performance/README.md diff --git a/spring-boot-modules/spring-boot-performance/pom.xml b/spring-boot-performance/pom.xml similarity index 96% rename from spring-boot-modules/spring-boot-performance/pom.xml rename to spring-boot-performance/pom.xml index 882763f0bc..7bf3885618 100644 --- a/spring-boot-modules/spring-boot-performance/pom.xml +++ b/spring-boot-performance/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../../parent-boot-2 + ../parent-boot-2 diff --git a/spring-boot-modules/spring-boot-performance/src/main/java/com/baeldung/lazyinitialization/Application.java b/spring-boot-performance/src/main/java/com/baeldung/lazyinitialization/Application.java similarity index 100% rename from spring-boot-modules/spring-boot-performance/src/main/java/com/baeldung/lazyinitialization/Application.java rename to spring-boot-performance/src/main/java/com/baeldung/lazyinitialization/Application.java diff --git a/spring-boot-modules/spring-boot-performance/src/main/java/com/baeldung/lazyinitialization/services/Writer.java b/spring-boot-performance/src/main/java/com/baeldung/lazyinitialization/services/Writer.java similarity index 100% rename from spring-boot-modules/spring-boot-performance/src/main/java/com/baeldung/lazyinitialization/services/Writer.java rename to spring-boot-performance/src/main/java/com/baeldung/lazyinitialization/services/Writer.java diff --git a/spring-boot-modules/spring-boot-performance/src/main/resources/application.yml b/spring-boot-performance/src/main/resources/application.yml similarity index 100% rename from spring-boot-modules/spring-boot-performance/src/main/resources/application.yml rename to spring-boot-performance/src/main/resources/application.yml diff --git a/spring-core-2/README.md b/spring-core-2/README.md index 0ed303162d..1fb591f693 100644 --- a/spring-core-2/README.md +++ b/spring-core-2/README.md @@ -16,5 +16,5 @@ This module contains articles about core Spring functionality - [Spring Null-Safety Annotations](https://www.baeldung.com/spring-null-safety-annotations) - [Using @Autowired in Abstract Classes](https://www.baeldung.com/spring-autowired-abstract-class) - [Guide to the Spring BeanFactory](https://www.baeldung.com/spring-beanfactory) -- [Read HttpServletRequest Multiple Times](https://www.baeldung.com/spring-reading-httpservletrequest-multiple-times) -- More articles: [[<-- prev]](/spring-core)[[next -->]](/spring-core-3) \ No newline at end of file +- [Reading HttpServletRequest Multiple Times in Spring](https://www.baeldung.com/spring-reading-httpservletrequest-multiple-times) +- More articles: [[<-- prev]](/spring-core)[[next -->]](/spring-core-3) diff --git a/spring-ejb/README.md b/spring-ejb/README.md index 423d55ea22..8f6522266c 100644 --- a/spring-ejb/README.md +++ b/spring-ejb/README.md @@ -8,5 +8,5 @@ This module contains articles about Spring with EJB - [Java EE Session Beans](https://www.baeldung.com/ejb-session-beans) - [A Guide to Message Driven Beans in EJB](https://www.baeldung.com/ejb-message-driven-beans) - [Integration Guide for Spring and EJB](https://www.baeldung.com/spring-ejb) -- [Singleton Session Bean in Java EE](https://www.baeldung.com/java-ee-singleton-session-bean) +- [Singleton Session Bean in Jakarta EE](https://www.baeldung.com/java-ee-singleton-session-bean) diff --git a/spring-mvc-basics-3/README.md b/spring-mvc-basics-3/README.md index b21f7b686a..180cee498b 100644 --- a/spring-mvc-basics-3/README.md +++ b/spring-mvc-basics-3/README.md @@ -11,5 +11,5 @@ This module contains articles about Spring MVC - [Using Enums as Request Parameters in Spring](https://www.baeldung.com/spring-enum-request-param) - [Excluding URLs for a Filter in a Spring Web Application](https://www.baeldung.com/spring-exclude-filter) - [Guide to Flash Attributes in a Spring Web Application](https://www.baeldung.com/spring-web-flash-attributes) -- More articles: [[more -->]](/spring-mvc-basics-4) -- More articles: [[<-- prev]](/spring-mvc-basics-2) +- [Handling URL Encoded Form Data in Spring REST](https://www.baeldung.com/spring-url-encoded-form-data) +- More articles: [[<-- prev]](/spring-mvc-basics-2)[[more -->]](/spring-mvc-basics-4) diff --git a/spring-mvc-views/README.md b/spring-mvc-views/README.md new file mode 100644 index 0000000000..7aa05699f3 --- /dev/null +++ b/spring-mvc-views/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Spring MVC Themes](https://www.baeldung.com/spring-mvc-themes) diff --git a/spring-rest-angular/pom.xml b/spring-rest-angular/pom.xml index 1c6ab77a2d..1d50b4c76c 100644 --- a/spring-rest-angular/pom.xml +++ b/spring-rest-angular/pom.xml @@ -74,7 +74,7 @@ 19.0 - org.baeldung.web.main.Application + com.baeldung.web.main.Application diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/dao/StudentRepository.java b/spring-rest-angular/src/main/java/com/baeldung/web/dao/StudentRepository.java similarity index 66% rename from spring-rest-angular/src/main/java/org/baeldung/web/dao/StudentRepository.java rename to spring-rest-angular/src/main/java/com/baeldung/web/dao/StudentRepository.java index 566d95da00..b69cf6f552 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/dao/StudentRepository.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/dao/StudentRepository.java @@ -1,6 +1,6 @@ -package org.baeldung.web.dao; +package com.baeldung.web.dao; -import org.baeldung.web.entity.Student; +import com.baeldung.web.entity.Student; import org.springframework.data.jpa.repository.JpaRepository; public interface StudentRepository extends JpaRepository diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/entity/Student.java b/spring-rest-angular/src/main/java/com/baeldung/web/entity/Student.java similarity index 97% rename from spring-rest-angular/src/main/java/org/baeldung/web/entity/Student.java rename to spring-rest-angular/src/main/java/com/baeldung/web/entity/Student.java index 0a0b60d87d..849b35cf24 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/entity/Student.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/entity/Student.java @@ -1,4 +1,4 @@ -package org.baeldung.web.entity; +package com.baeldung.web.entity; import java.io.Serializable; diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java b/spring-rest-angular/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java similarity index 93% rename from spring-rest-angular/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java rename to spring-rest-angular/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java index 740caec59e..ae9c4543ec 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java @@ -1,4 +1,4 @@ -package org.baeldung.web.exception; +package com.baeldung.web.exception; public class MyResourceNotFoundException extends RuntimeException { diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/main/Application.java b/spring-rest-angular/src/main/java/com/baeldung/web/main/Application.java similarity index 96% rename from spring-rest-angular/src/main/java/org/baeldung/web/main/Application.java rename to spring-rest-angular/src/main/java/com/baeldung/web/main/Application.java index fd10643c53..1f3f0aec39 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/main/Application.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/main/Application.java @@ -1,4 +1,4 @@ -package org.baeldung.web.main; +package com.baeldung.web.main; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/main/PersistenceConfig.java b/spring-rest-angular/src/main/java/com/baeldung/web/main/PersistenceConfig.java similarity index 85% rename from spring-rest-angular/src/main/java/org/baeldung/web/main/PersistenceConfig.java rename to spring-rest-angular/src/main/java/com/baeldung/web/main/PersistenceConfig.java index 0fc6b74892..b964c753d2 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/main/PersistenceConfig.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/main/PersistenceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.web.main; +package com.baeldung.web.main; import javax.sql.DataSource; @@ -12,9 +12,9 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -@EnableJpaRepositories("org.baeldung.web.dao") -@ComponentScan(basePackages = { "org.baeldung.web" }) -@EntityScan("org.baeldung.web.entity") +@EnableJpaRepositories("com.baeldung.web.dao") +@ComponentScan(basePackages = { "com.baeldung.web" }) +@EntityScan("com.baeldung.web.entity") @Configuration public class PersistenceConfig { diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/rest/StudentDirectoryRestController.java b/spring-rest-angular/src/main/java/com/baeldung/web/rest/StudentDirectoryRestController.java similarity index 83% rename from spring-rest-angular/src/main/java/org/baeldung/web/rest/StudentDirectoryRestController.java rename to spring-rest-angular/src/main/java/com/baeldung/web/rest/StudentDirectoryRestController.java index dc295a3d97..6197279384 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/rest/StudentDirectoryRestController.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/rest/StudentDirectoryRestController.java @@ -1,8 +1,8 @@ -package org.baeldung.web.rest; +package com.baeldung.web.rest; -import org.baeldung.web.entity.Student; -import org.baeldung.web.exception.MyResourceNotFoundException; -import org.baeldung.web.service.StudentService; +import com.baeldung.web.entity.Student; +import com.baeldung.web.exception.MyResourceNotFoundException; +import com.baeldung.web.service.StudentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/service/IOperations.java b/spring-rest-angular/src/main/java/com/baeldung/web/service/IOperations.java similarity index 81% rename from spring-rest-angular/src/main/java/org/baeldung/web/service/IOperations.java rename to spring-rest-angular/src/main/java/com/baeldung/web/service/IOperations.java index 2176c0bb70..60cb4382f4 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/service/IOperations.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/service/IOperations.java @@ -1,4 +1,4 @@ -package org.baeldung.web.service; +package com.baeldung.web.service; import org.springframework.data.domain.Page; diff --git a/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentService.java b/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentService.java new file mode 100644 index 0000000000..65eb791904 --- /dev/null +++ b/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentService.java @@ -0,0 +1,7 @@ +package com.baeldung.web.service; + +import com.baeldung.web.entity.Student; + +public interface StudentService extends IOperations { + +} diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/service/StudentServiceImpl.java b/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentServiceImpl.java similarity index 79% rename from spring-rest-angular/src/main/java/org/baeldung/web/service/StudentServiceImpl.java rename to spring-rest-angular/src/main/java/com/baeldung/web/service/StudentServiceImpl.java index fdba0c0c2c..cacb0e7840 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/service/StudentServiceImpl.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentServiceImpl.java @@ -1,7 +1,7 @@ -package org.baeldung.web.service; +package com.baeldung.web.service; -import org.baeldung.web.dao.StudentRepository; -import org.baeldung.web.entity.Student; +import com.baeldung.web.dao.StudentRepository; +import com.baeldung.web.entity.Student; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/service/StudentService.java b/spring-rest-angular/src/main/java/org/baeldung/web/service/StudentService.java deleted file mode 100644 index 1b194f76e2..0000000000 --- a/spring-rest-angular/src/main/java/org/baeldung/web/service/StudentService.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.baeldung.web.service; - -import org.baeldung.web.entity.Student; - -public interface StudentService extends IOperations { - -} diff --git a/spring-rest-angular/src/test/java/org/baeldung/SpringContextTest.java b/spring-rest-angular/src/test/java/com/baeldung/SpringContextTest.java similarity index 85% rename from spring-rest-angular/src/test/java/org/baeldung/SpringContextTest.java rename to spring-rest-angular/src/test/java/com/baeldung/SpringContextTest.java index 9136ce43eb..ee8c553c76 100644 --- a/spring-rest-angular/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-rest-angular/src/test/java/com/baeldung/SpringContextTest.java @@ -1,6 +1,6 @@ -package org.baeldung; +package com.baeldung; -import org.baeldung.web.main.Application; +import com.baeldung.web.main.Application; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; diff --git a/spring-rest-angular/src/test/java/org/baeldung/web/service/StudentServiceIntegrationTest.java b/spring-rest-angular/src/test/java/com/baeldung/web/service/StudentServiceIntegrationTest.java similarity index 97% rename from spring-rest-angular/src/test/java/org/baeldung/web/service/StudentServiceIntegrationTest.java rename to spring-rest-angular/src/test/java/com/baeldung/web/service/StudentServiceIntegrationTest.java index 1473d44b92..654c4ef647 100644 --- a/spring-rest-angular/src/test/java/org/baeldung/web/service/StudentServiceIntegrationTest.java +++ b/spring-rest-angular/src/test/java/com/baeldung/web/service/StudentServiceIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.web.service; +package com.baeldung.web.service; import static io.restassured.RestAssured.given; import static org.hamcrest.core.Is.is; @@ -6,7 +6,7 @@ import static org.hamcrest.core.IsCollectionContaining.hasItems; import static org.hamcrest.core.IsEqual.equalTo; import org.apache.commons.lang3.RandomStringUtils; -import org.baeldung.web.main.Application; +import com.baeldung.web.main.Application; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; diff --git a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/CompressingClientHttpRequestInterceptor.java b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/CompressingClientHttpRequestInterceptor.java similarity index 96% rename from spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/CompressingClientHttpRequestInterceptor.java rename to spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/CompressingClientHttpRequestInterceptor.java index 7d5326246d..78b77256af 100644 --- a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/CompressingClientHttpRequestInterceptor.java +++ b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/CompressingClientHttpRequestInterceptor.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/GzipUtils.java b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/GzipUtils.java similarity index 96% rename from spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/GzipUtils.java rename to spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/GzipUtils.java index 75420ca6d8..b9731535b2 100644 --- a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/GzipUtils.java +++ b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/GzipUtils.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.apache.commons.codec.Charsets; import org.apache.commons.io.IOUtils; diff --git a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/JettyWebServerConfiguration.java b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/JettyWebServerConfiguration.java similarity index 96% rename from spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/JettyWebServerConfiguration.java rename to spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/JettyWebServerConfiguration.java index 784814b04d..8de8e5b523 100644 --- a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/JettyWebServerConfiguration.java +++ b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/JettyWebServerConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.server.handler.gzip.GzipHandler; diff --git a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/Message.java b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/Message.java similarity index 92% rename from spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/Message.java rename to spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/Message.java index d3450b227c..24272a4fca 100644 --- a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/Message.java +++ b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/Message.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; public class Message { diff --git a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/MessageController.java b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/MessageController.java similarity index 96% rename from spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/MessageController.java rename to spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/MessageController.java index 657c3cfec8..2fc2ca8272 100644 --- a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/MessageController.java +++ b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/MessageController.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/RestTemplateConfiguration.java b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/RestTemplateConfiguration.java similarity index 92% rename from spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/RestTemplateConfiguration.java rename to spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/RestTemplateConfiguration.java index e1d0f985d9..c1e3c89ae9 100644 --- a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/RestTemplateConfiguration.java +++ b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/RestTemplateConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/SpringCompressRequestApplication.java b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/SpringCompressRequestApplication.java similarity index 90% rename from spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/SpringCompressRequestApplication.java rename to spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/SpringCompressRequestApplication.java index 3082e3c277..9b1b71979d 100644 --- a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/SpringCompressRequestApplication.java +++ b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/SpringCompressRequestApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; diff --git a/spring-rest-compress/src/test/java/org/baeldung/spring/rest/compress/GzipUtilsUnitTest.java b/spring-rest-compress/src/test/java/com/baeldung/spring/rest/compress/GzipUtilsUnitTest.java similarity index 92% rename from spring-rest-compress/src/test/java/org/baeldung/spring/rest/compress/GzipUtilsUnitTest.java rename to spring-rest-compress/src/test/java/com/baeldung/spring/rest/compress/GzipUtilsUnitTest.java index d238c9ec7c..431758d358 100644 --- a/spring-rest-compress/src/test/java/org/baeldung/spring/rest/compress/GzipUtilsUnitTest.java +++ b/spring-rest-compress/src/test/java/com/baeldung/spring/rest/compress/GzipUtilsUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.junit.Test; diff --git a/spring-rest-compress/src/test/java/org/baeldung/spring/rest/compress/MessageControllerUnitTest.java b/spring-rest-compress/src/test/java/com/baeldung/spring/rest/compress/MessageControllerUnitTest.java similarity index 97% rename from spring-rest-compress/src/test/java/org/baeldung/spring/rest/compress/MessageControllerUnitTest.java rename to spring-rest-compress/src/test/java/com/baeldung/spring/rest/compress/MessageControllerUnitTest.java index 9658204917..50b2b7ccd7 100644 --- a/spring-rest-compress/src/test/java/org/baeldung/spring/rest/compress/MessageControllerUnitTest.java +++ b/spring-rest-compress/src/test/java/com/baeldung/spring/rest/compress/MessageControllerUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-rest-http/README.md b/spring-rest-http/README.md index 51f5ed4000..54b31e80c4 100644 --- a/spring-rest-http/README.md +++ b/spring-rest-http/README.md @@ -10,5 +10,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Guide to UriComponentsBuilder in Spring](https://www.baeldung.com/spring-uricomponentsbuilder) - [How to Set a Header on a Response with Spring 5](https://www.baeldung.com/spring-response-header) - The tests contained for this article rely on the sample application within the [spring-resttemplate](/spring-resttemplate) module - [Returning Custom Status Codes from Spring Controllers](https://www.baeldung.com/spring-mvc-controller-custom-http-status-code) -- [Spring @RequestMapping](https://www.baeldung.com/spring-requestmapping) -- [Guide to DeferredResult in Spring](https://www.baeldung.com/spring-deferred-result) \ No newline at end of file +- [Spring RequestMapping](https://www.baeldung.com/spring-requestmapping) +- [Guide to DeferredResult in Spring](https://www.baeldung.com/spring-deferred-result) diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/dto/FooProtos.java b/spring-rest-simple/src/main/java/com/baeldung/web/dto/FooProtos.java index db7cb66f87..0e8f9caf03 100644 --- a/spring-rest-simple/src/main/java/com/baeldung/web/dto/FooProtos.java +++ b/spring-rest-simple/src/main/java/com/baeldung/web/dto/FooProtos.java @@ -331,7 +331,7 @@ public final class FooProtos { return com.baeldung.web.dto.FooProtos.internal_static_baeldung_Foo_fieldAccessorTable.ensureFieldAccessorsInitialized(com.baeldung.web.dto.FooProtos.Foo.class, com.baeldung.web.dto.FooProtos.Foo.Builder.class); } - // Construct using org.baeldung.web.dto.FooProtos.Foo.newBuilder() + // Construct using com.baeldung.web.dto.FooProtos.Foo.newBuilder() private Builder() { maybeForceBuilderInitialization(); } @@ -581,7 +581,7 @@ public final class FooProtos { private static com.google.protobuf.Descriptors.FileDescriptor descriptor; static { - java.lang.String[] descriptorData = { "\n\017FooProtos.proto\022\010baeldung\"\037\n\003Foo\022\n\n\002id" + "\030\001 \002(\003\022\014\n\004name\030\002 \002(\tB!\n\024org.baeldung.web" + ".dtoB\tFooProtos" }; + java.lang.String[] descriptorData = { "\n\017FooProtos.proto\022\010baeldung\"\037\n\003Foo\022\n\n\002id" + "\030\001 \002(\003\022\014\n\004name\030\002 \002(\tB!\n\024com.baeldung.web" + ".dtoB\tFooProtos" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { public com.google.protobuf.ExtensionRegistry assignDescriptors(com.google.protobuf.Descriptors.FileDescriptor root) { descriptor = root; diff --git a/spring-rest-simple/src/test/java/org/baeldung/SpringContextTest.java b/spring-rest-simple/src/test/java/org/baeldung/SpringContextTest.java deleted file mode 100644 index 5e68a8e64f..0000000000 --- a/spring-rest-simple/src/test/java/org/baeldung/SpringContextTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -import com.baeldung.Application; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class) -public class SpringContextTest { - - @Test - public void whenSpringContextIsBootstrapped_thenNoExceptions() { - } -} diff --git a/spring-security-modules/spring-security-mvc-boot/src/main/java/com/baeldung/models/Tweet.java b/spring-security-modules/spring-security-mvc-boot/src/main/java/com/baeldung/models/Tweet.java index b2e45009f6..54a96deaf3 100644 --- a/spring-security-modules/spring-security-mvc-boot/src/main/java/com/baeldung/models/Tweet.java +++ b/spring-security-modules/spring-security-mvc-boot/src/main/java/com/baeldung/models/Tweet.java @@ -3,14 +3,17 @@ package com.baeldung.models; import java.util.HashSet; import java.util.Set; +import javax.persistence.CollectionTable; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.Table; @Entity +@Table(name = "Tweet") public class Tweet { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) @@ -18,7 +21,8 @@ public class Tweet { private String tweet; private String owner; @ElementCollection(targetClass = String.class, fetch = FetchType.EAGER) - private Set likes = new HashSet(); + @CollectionTable(name = "Tweet_Likes") + private Set likes = new HashSet<>(); public long getId() { return id; diff --git a/spring-security-modules/spring-security-mvc-boot/src/test/java/com/baeldung/relationships/SpringDataWithSecurityIntegrationTest.java b/spring-security-modules/spring-security-mvc-boot/src/test/java/com/baeldung/relationships/SpringDataWithSecurityIntegrationTest.java index 41f220df6f..b2def82c51 100644 --- a/spring-security-modules/spring-security-mvc-boot/src/test/java/com/baeldung/relationships/SpringDataWithSecurityIntegrationTest.java +++ b/spring-security-modules/spring-security-mvc-boot/src/test/java/com/baeldung/relationships/SpringDataWithSecurityIntegrationTest.java @@ -1,29 +1,5 @@ package com.baeldung.relationships; -import static org.springframework.util.Assert.isTrue; - -import java.util.Date; -import java.util.List; - -import javax.servlet.ServletContext; - -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; - import com.baeldung.AppConfig; import com.baeldung.data.repositories.TweetRepository; import com.baeldung.data.repositories.UserRepository; @@ -31,6 +7,30 @@ import com.baeldung.models.AppUser; import com.baeldung.models.Tweet; import com.baeldung.security.AppUserPrincipal; import com.baeldung.util.DummyContentUtil; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.InvalidDataAccessApiUsageException; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.jdbc.JdbcTestUtils; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; + +import javax.servlet.ServletContext; +import java.util.Date; +import java.util.List; + +import static org.springframework.util.Assert.isTrue; @RunWith(SpringRunner.class) @WebAppConfiguration @@ -54,10 +54,22 @@ public class SpringDataWithSecurityIntegrationTest { tweetRepository.saveAll(DummyContentUtil.generateDummyTweets(appUsers)); } - @AfterClass - public static void tearDown() { - tweetRepository.deleteAll(); - userRepository.deleteAll(); + /** + * This is to ensure the tables are dropped in proper order. + * After the Spring Boot 2.2.2 upgrade, DDL statements generated automatically try to drop Tweet table first. + * As a result we get org.h2.jdbc.JdbcSQLSyntaxErrorException because Tweet_Likes table depends on Tweet. + * + * @see + * StackOverflow#59364212 + * + * @see + * StackOverflow#59561551 + * + */ + @After + public void tearDown() { + JdbcTemplate jdbcTemplate = ctx.getBean(JdbcTemplate.class); + JdbcTestUtils.dropTables(jdbcTemplate, "Tweet_Likes", "Tweet"); } @Test diff --git a/testing-modules/junit-4/README.md b/testing-modules/junit-4/README.md index d19a0a1e47..6cc3981ed4 100644 --- a/testing-modules/junit-4/README.md +++ b/testing-modules/junit-4/README.md @@ -4,3 +4,4 @@ - [Custom JUnit 4 Test Runners](http://www.baeldung.com/junit-4-custom-runners) - [Introduction to JUnitParams](http://www.baeldung.com/junit-params) - [Running JUnit Tests Programmatically, from a Java Application](https://www.baeldung.com/junit-tests-run-programmatically-from-java) +- [Introduction to Lambda Behave](https://www.baeldung.com/lambda-behave)