From 238e75eec9e79dd09a269d6b921f76169247b3c0 Mon Sep 17 00:00:00 2001 From: Joel Juarez Date: Sun, 19 May 2019 22:03:12 +0200 Subject: [PATCH 1/7] added parent module for spring boot 2.2 added module for spring boot 2.2 added example for lazy initialization in spring boot 2.2 --- parent-boot-2-2/README.md | 2 + parent-boot-2-2/pom.xml | 91 +++++++++++++++++++ spring-boot-2-2/pom.xml | 45 +++++++++ .../lazyinitialization/Application.java | 32 +++++++ .../lazyinitialization/services/Writer.java | 16 ++++ .../src/main/resources/application.yml | 3 + 6 files changed, 189 insertions(+) create mode 100644 parent-boot-2-2/README.md create mode 100644 parent-boot-2-2/pom.xml create mode 100644 spring-boot-2-2/pom.xml create mode 100644 spring-boot-2-2/src/main/java/com/baeldung/lazyinitialization/Application.java create mode 100644 spring-boot-2-2/src/main/java/com/baeldung/lazyinitialization/services/Writer.java create mode 100644 spring-boot-2-2/src/main/resources/application.yml diff --git a/parent-boot-2-2/README.md b/parent-boot-2-2/README.md new file mode 100644 index 0000000000..d2bd6d660b --- /dev/null +++ b/parent-boot-2-2/README.md @@ -0,0 +1,2 @@ + +This is a parent module for all projects using Spring Boot 2.2. diff --git a/parent-boot-2-2/pom.xml b/parent-boot-2-2/pom.xml new file mode 100644 index 0000000000..59611c9044 --- /dev/null +++ b/parent-boot-2-2/pom.xml @@ -0,0 +1,91 @@ + + 4.0.0 + parent-boot-2-2 + 0.0.1-SNAPSHOT + parent-boot-2-2 + pom + Parent for all Spring Boot 2.2 modules + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + io.rest-assured + rest-assured + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + ${start-class} + + + + + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + + + + thin-jar + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.springframework.boot.experimental + spring-boot-thin-layout + ${thin.version} + + + + + + + + + + 3.1.0 + + 1.0.21.RELEASE + 2.2.0.M3 + + diff --git a/spring-boot-2-2/pom.xml b/spring-boot-2-2/pom.xml new file mode 100644 index 0000000000..4390e29b60 --- /dev/null +++ b/spring-boot-2-2/pom.xml @@ -0,0 +1,45 @@ + + 4.0.0 + spring-boot-2-2 + spring-boot-2-2 + war + This is simple boot application for Spring boot 2.2 + + + parent-boot-2-2 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-2-2 + + + + + org.springframework.boot + spring-boot-starter + + + + + spring-boot-2-2 + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-war-plugin + + + + + + + com.baeldung.lazyinitialization.Application + + \ No newline at end of file diff --git a/spring-boot-2-2/src/main/java/com/baeldung/lazyinitialization/Application.java b/spring-boot-2-2/src/main/java/com/baeldung/lazyinitialization/Application.java new file mode 100644 index 0000000000..195b260399 --- /dev/null +++ b/spring-boot-2-2/src/main/java/com/baeldung/lazyinitialization/Application.java @@ -0,0 +1,32 @@ +package com.baeldung.lazyinitialization; + +import com.baeldung.lazyinitialization.services.Writer; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; + +@SpringBootApplication +public class Application { + + @Bean("writer1") + public Writer getWriter1() { + return new Writer("Writer 1"); + } + + @Bean("writer2") + public Writer getWriter2() { + return new Writer("Writer 2"); + } + + public static void main(String[] args) { + ApplicationContext ctx = SpringApplication.run(Application.class, args); + System.out.println("Application context initialized!!!"); + + Writer writer1 = ctx.getBean("writer1", Writer.class); + writer1.write("First message"); + + Writer writer2 = ctx.getBean("writer2", Writer.class); + writer2.write("Second message"); + } +} diff --git a/spring-boot-2-2/src/main/java/com/baeldung/lazyinitialization/services/Writer.java b/spring-boot-2-2/src/main/java/com/baeldung/lazyinitialization/services/Writer.java new file mode 100644 index 0000000000..7c67fb7ea4 --- /dev/null +++ b/spring-boot-2-2/src/main/java/com/baeldung/lazyinitialization/services/Writer.java @@ -0,0 +1,16 @@ +package com.baeldung.lazyinitialization.services; + +public class Writer { + + private final String writerId; + + public Writer(String writerId) { + this.writerId = writerId; + System.out.println(writerId + " initialized!!!"); + } + + public void write(String message) { + System.out.println(writerId + ": " + message); + } + +} diff --git a/spring-boot-2-2/src/main/resources/application.yml b/spring-boot-2-2/src/main/resources/application.yml new file mode 100644 index 0000000000..25f03eed56 --- /dev/null +++ b/spring-boot-2-2/src/main/resources/application.yml @@ -0,0 +1,3 @@ +spring: + main: + lazy-initialization: true \ No newline at end of file From dfeadea6ae73c7cbed66f1bc1c5c0a42e1d39817 Mon Sep 17 00:00:00 2001 From: Joel Juarez Date: Mon, 3 Jun 2019 00:36:37 +0200 Subject: [PATCH 2/7] CHANGED: name of module for Spring Boot 2.2 --- {parent-boot-2-2 => parent-boot-performance}/README.md | 1 - {parent-boot-2-2 => parent-boot-performance}/pom.xml | 4 ++-- {spring-boot-2-2 => spring-boot-performance}/pom.xml | 10 +++++----- .../com/baeldung/lazyinitialization/Application.java | 0 .../baeldung/lazyinitialization/services/Writer.java | 0 .../src/main/resources/application.yml | 0 6 files changed, 7 insertions(+), 8 deletions(-) rename {parent-boot-2-2 => parent-boot-performance}/README.md (98%) rename {parent-boot-2-2 => parent-boot-performance}/pom.xml (97%) rename {spring-boot-2-2 => spring-boot-performance}/pom.xml (81%) rename {spring-boot-2-2 => spring-boot-performance}/src/main/java/com/baeldung/lazyinitialization/Application.java (100%) rename {spring-boot-2-2 => spring-boot-performance}/src/main/java/com/baeldung/lazyinitialization/services/Writer.java (100%) rename {spring-boot-2-2 => spring-boot-performance}/src/main/resources/application.yml (100%) diff --git a/parent-boot-2-2/README.md b/parent-boot-performance/README.md similarity index 98% rename from parent-boot-2-2/README.md rename to parent-boot-performance/README.md index d2bd6d660b..963176a5e3 100644 --- a/parent-boot-2-2/README.md +++ b/parent-boot-performance/README.md @@ -1,2 +1 @@ - This is a parent module for all projects using Spring Boot 2.2. diff --git a/parent-boot-2-2/pom.xml b/parent-boot-performance/pom.xml similarity index 97% rename from parent-boot-2-2/pom.xml rename to parent-boot-performance/pom.xml index 59611c9044..c7a0263716 100644 --- a/parent-boot-2-2/pom.xml +++ b/parent-boot-performance/pom.xml @@ -1,9 +1,9 @@ 4.0.0 - parent-boot-2-2 + parent-boot-performance 0.0.1-SNAPSHOT - parent-boot-2-2 + parent-boot-performance pom Parent for all Spring Boot 2.2 modules diff --git a/spring-boot-2-2/pom.xml b/spring-boot-performance/pom.xml similarity index 81% rename from spring-boot-2-2/pom.xml rename to spring-boot-performance/pom.xml index 4390e29b60..cb2dba359e 100644 --- a/spring-boot-2-2/pom.xml +++ b/spring-boot-performance/pom.xml @@ -2,16 +2,16 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - spring-boot-2-2 - spring-boot-2-2 + spring-boot-performance + spring-boot-performance war This is simple boot application for Spring boot 2.2 - parent-boot-2-2 + parent-boot-performance com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-2-2 + ../parent-boot-performance @@ -22,7 +22,7 @@ - spring-boot-2-2 + spring-boot-performance src/main/resources diff --git a/spring-boot-2-2/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-2-2/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-2-2/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-2-2/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-2-2/src/main/resources/application.yml b/spring-boot-performance/src/main/resources/application.yml similarity index 100% rename from spring-boot-2-2/src/main/resources/application.yml rename to spring-boot-performance/src/main/resources/application.yml From 2e383281a85ea2bbb0c5da0e71cf97e3707a8b1d Mon Sep 17 00:00:00 2001 From: Joel Juarez Date: Wed, 12 Jun 2019 23:14:04 +0200 Subject: [PATCH 3/7] Changed description for spring-boot-performance module --- parent-boot-performance/README.md | 2 +- parent-boot-performance/pom.xml | 2 +- spring-boot-performance/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/parent-boot-performance/README.md b/parent-boot-performance/README.md index 963176a5e3..4ac49c9070 100644 --- a/parent-boot-performance/README.md +++ b/parent-boot-performance/README.md @@ -1 +1 @@ -This is a parent module for all projects using Spring Boot 2.2. +This is a parent module for projects taht want to take advantage of the performance improvements introduced in Spring Boot from version 2.2. diff --git a/parent-boot-performance/pom.xml b/parent-boot-performance/pom.xml index c7a0263716..49cea2ad30 100644 --- a/parent-boot-performance/pom.xml +++ b/parent-boot-performance/pom.xml @@ -5,7 +5,7 @@ 0.0.1-SNAPSHOT parent-boot-performance pom - Parent for all Spring Boot 2.2 modules + Parent for all modules taht want to take advantage of the performance improvements introduced in Spring Boot from version 2.2 com.baeldung diff --git a/spring-boot-performance/pom.xml b/spring-boot-performance/pom.xml index cb2dba359e..8f4c08002d 100644 --- a/spring-boot-performance/pom.xml +++ b/spring-boot-performance/pom.xml @@ -5,7 +5,7 @@ spring-boot-performance spring-boot-performance war - This is simple boot application for Spring boot 2.2 + This is a simple Spring Boot application taking advantage of the performance improvements introduced from version 2.2 parent-boot-performance From 20e1e2583122597b5f3b439c02eba0d14cffd974 Mon Sep 17 00:00:00 2001 From: Joel Juarez Date: Wed, 12 Jun 2019 23:20:32 +0200 Subject: [PATCH 4/7] Changed description for spring-boot-performance module --- parent-boot-performance/README.md | 4 +++- parent-boot-performance/pom.xml | 2 +- spring-boot-performance/pom.xml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/parent-boot-performance/README.md b/parent-boot-performance/README.md index 4ac49c9070..e8eb056fe3 100644 --- a/parent-boot-performance/README.md +++ b/parent-boot-performance/README.md @@ -1 +1,3 @@ -This is a parent module for projects taht want to take advantage of the performance improvements introduced in Spring Boot from version 2.2. +This is a parent module for projects taht want to take advantage of the latests Spring Boot improvements/features. + +Current version: Spring Boot 2.2 diff --git a/parent-boot-performance/pom.xml b/parent-boot-performance/pom.xml index 49cea2ad30..078f002968 100644 --- a/parent-boot-performance/pom.xml +++ b/parent-boot-performance/pom.xml @@ -5,7 +5,7 @@ 0.0.1-SNAPSHOT parent-boot-performance pom - Parent for all modules taht want to take advantage of the performance improvements introduced in Spring Boot from version 2.2 + Parent for all modules taht want to take advantage of the latests Spring Boot improvements/features. Current version: 2.2 com.baeldung diff --git a/spring-boot-performance/pom.xml b/spring-boot-performance/pom.xml index 8f4c08002d..5368377d36 100644 --- a/spring-boot-performance/pom.xml +++ b/spring-boot-performance/pom.xml @@ -5,7 +5,7 @@ spring-boot-performance spring-boot-performance war - This is a simple Spring Boot application taking advantage of the performance improvements introduced from version 2.2 + This is a simple Spring Boot application taking advantage of the latests Spring Boot improvements/features. Current version: 2.2 parent-boot-performance From d6bd06ddd99127b7dba6c13fcb24f288681b1020 Mon Sep 17 00:00:00 2001 From: Joel Juarez Date: Wed, 12 Jun 2019 23:23:21 +0200 Subject: [PATCH 5/7] fixed typos --- parent-boot-performance/README.md | 2 +- parent-boot-performance/pom.xml | 2 +- spring-boot-performance/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/parent-boot-performance/README.md b/parent-boot-performance/README.md index e8eb056fe3..10775d9b00 100644 --- a/parent-boot-performance/README.md +++ b/parent-boot-performance/README.md @@ -1,3 +1,3 @@ -This is a parent module for projects taht want to take advantage of the latests Spring Boot improvements/features. +This is a parent module for projects taht want to take advantage of the latest Spring Boot improvements/features. Current version: Spring Boot 2.2 diff --git a/parent-boot-performance/pom.xml b/parent-boot-performance/pom.xml index 078f002968..0d39f0bb92 100644 --- a/parent-boot-performance/pom.xml +++ b/parent-boot-performance/pom.xml @@ -5,7 +5,7 @@ 0.0.1-SNAPSHOT parent-boot-performance pom - Parent for all modules taht want to take advantage of the latests Spring Boot improvements/features. Current version: 2.2 + Parent for all modules taht want to take advantage of the latest Spring Boot improvements/features. Current version: 2.2 com.baeldung diff --git a/spring-boot-performance/pom.xml b/spring-boot-performance/pom.xml index 5368377d36..207cd06f9b 100644 --- a/spring-boot-performance/pom.xml +++ b/spring-boot-performance/pom.xml @@ -5,7 +5,7 @@ spring-boot-performance spring-boot-performance war - This is a simple Spring Boot application taking advantage of the latests Spring Boot improvements/features. Current version: 2.2 + This is a simple Spring Boot application taking advantage of the latest Spring Boot improvements/features. Current version: 2.2 parent-boot-performance From 0ce2c744b367405985f6ff3c39ee21bdcb12c92f Mon Sep 17 00:00:00 2001 From: Joel Juarez Date: Wed, 12 Jun 2019 23:25:09 +0200 Subject: [PATCH 6/7] fixed typos --- parent-boot-performance/README.md | 2 +- parent-boot-performance/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/parent-boot-performance/README.md b/parent-boot-performance/README.md index 10775d9b00..24abd27048 100644 --- a/parent-boot-performance/README.md +++ b/parent-boot-performance/README.md @@ -1,3 +1,3 @@ -This is a parent module for projects taht want to take advantage of the latest Spring Boot improvements/features. +This is a parent module for projects that want to take advantage of the latest Spring Boot improvements/features. Current version: Spring Boot 2.2 diff --git a/parent-boot-performance/pom.xml b/parent-boot-performance/pom.xml index 0d39f0bb92..62a1689b7f 100644 --- a/parent-boot-performance/pom.xml +++ b/parent-boot-performance/pom.xml @@ -5,7 +5,7 @@ 0.0.1-SNAPSHOT parent-boot-performance pom - Parent for all modules taht want to take advantage of the latest Spring Boot improvements/features. Current version: 2.2 + Parent for all modules that want to take advantage of the latest Spring Boot improvements/features. Current version: 2.2 com.baeldung From f69f95d13d2a4a6b095e351ca1ea872d54b0a809 Mon Sep 17 00:00:00 2001 From: Joel Juarez Date: Sun, 16 Jun 2019 23:23:36 +0200 Subject: [PATCH 7/7] fixed styles in pom.xml --- parent-boot-performance/README.md | 4 +-- parent-boot-performance/pom.xml | 54 +++++++++++++++---------------- spring-boot-performance/pom.xml | 12 +++---- 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/parent-boot-performance/README.md b/parent-boot-performance/README.md index 24abd27048..fce9e101da 100644 --- a/parent-boot-performance/README.md +++ b/parent-boot-performance/README.md @@ -1,3 +1 @@ -This is a parent module for projects that want to take advantage of the latest Spring Boot improvements/features. - -Current version: Spring Boot 2.2 +This is a parent module for projects that want to take advantage of the latest Spring Boot improvements/features. \ No newline at end of file diff --git a/parent-boot-performance/pom.xml b/parent-boot-performance/pom.xml index 62a1689b7f..b1c6854eae 100644 --- a/parent-boot-performance/pom.xml +++ b/parent-boot-performance/pom.xml @@ -3,7 +3,7 @@ 4.0.0 parent-boot-performance 0.0.1-SNAPSHOT - parent-boot-performance + parent-boot-performance pom Parent for all modules that want to take advantage of the latest Spring Boot improvements/features. Current version: 2.2 @@ -13,7 +13,14 @@ 1.0.0-SNAPSHOT - + + 3.1.0 + + 1.0.21.RELEASE + 2.2.0.M3 + + + org.springframework.boot @@ -36,30 +43,30 @@ - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot.version} - - ${start-class} - - - - - - - - + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + ${start-class} + + + + + + + + spring-milestones Spring Milestones https://repo.spring.io/milestone - + thin-jar @@ -81,11 +88,4 @@ - - - 3.1.0 - - 1.0.21.RELEASE - 2.2.0.M3 - diff --git a/spring-boot-performance/pom.xml b/spring-boot-performance/pom.xml index 207cd06f9b..bbee7493cc 100644 --- a/spring-boot-performance/pom.xml +++ b/spring-boot-performance/pom.xml @@ -14,7 +14,12 @@ ../parent-boot-performance - + + + com.baeldung.lazyinitialization.Application + + + org.springframework.boot spring-boot-starter @@ -37,9 +42,4 @@ - - - - com.baeldung.lazyinitialization.Application - \ No newline at end of file