diff --git a/.gitignore b/.gitignore index be3bc420c5..248cbeae5d 100644 --- a/.gitignore +++ b/.gitignore @@ -83,4 +83,5 @@ jta/transaction-logs/ software-security/sql-injection-samples/derby.log spring-soap/src/main/java/com/baeldung/springsoap/gen/ /report-*.json -transaction.log \ No newline at end of file +transaction.log +*-shell.log \ No newline at end of file diff --git a/libraries-2/README.md b/libraries-2/README.md index ea95b18d72..fd1f73c386 100644 --- a/libraries-2/README.md +++ b/libraries-2/README.md @@ -18,4 +18,6 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Key Value Store with Chronicle Map](https://www.baeldung.com/java-chronicle-map) - [Guide to MapDB](https://www.baeldung.com/mapdb) - [A Guide to Apache Mesos](https://www.baeldung.com/apache-mesos) +- [JasperReports with Spring](https://www.baeldung.com/spring-jasper) - More articles [[<-- prev]](/libraries) + diff --git a/libraries-2/pom.xml b/libraries-2/pom.xml index 708006fa15..1ffaf0bbd7 100644 --- a/libraries-2/pom.xml +++ b/libraries-2/pom.xml @@ -1,7 +1,7 @@ + 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 libraries-2 libraries-2 @@ -112,10 +112,36 @@ mesos ${mesos.library.version} + + net.sf.jasperreports + jasperreports + ${jasperreports.version} + + + commons-logging + commons-logging + + + + + org.hsqldb + hsqldb + ${hsqldb.version} + + + org.springframework + spring-context + ${spring.version} + + + org.springframework + spring-jdbc + ${spring.version} + - 3.0.7 + 3.0.7 3.6.2 4.8.28 6.0.0.Final @@ -129,5 +155,8 @@ 2.8.5 3.14.2 4.1.2 + 6.6.0 + 5.1.9.RELEASE + 2.5.0 diff --git a/spring-all/src/main/java/org/baeldung/jasperreports/Main.java b/libraries-2/src/main/java/com/baeldung/jasperreports/Main.java similarity index 93% rename from spring-all/src/main/java/org/baeldung/jasperreports/Main.java rename to libraries-2/src/main/java/com/baeldung/jasperreports/Main.java index 79aee100a6..1c75c161fb 100644 --- a/spring-all/src/main/java/org/baeldung/jasperreports/Main.java +++ b/libraries-2/src/main/java/com/baeldung/jasperreports/Main.java @@ -1,9 +1,10 @@ -package org.baeldung.jasperreports; +package com.baeldung.jasperreports; + +import com.baeldung.jasperreports.config.JasperRerportsSimpleConfig; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; import java.util.HashMap; import java.util.Map; -import org.baeldung.jasperreports.config.JasperRerportsSimpleConfig; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; public class Main { public static void main(String[] args) { diff --git a/spring-all/src/main/java/org/baeldung/jasperreports/SimpleReportExporter.java b/libraries-2/src/main/java/com/baeldung/jasperreports/SimpleReportExporter.java similarity index 87% rename from spring-all/src/main/java/org/baeldung/jasperreports/SimpleReportExporter.java rename to libraries-2/src/main/java/com/baeldung/jasperreports/SimpleReportExporter.java index 103bb37eb4..fa4b25707b 100644 --- a/spring-all/src/main/java/org/baeldung/jasperreports/SimpleReportExporter.java +++ b/libraries-2/src/main/java/com/baeldung/jasperreports/SimpleReportExporter.java @@ -1,22 +1,17 @@ -package org.baeldung.jasperreports; +package com.baeldung.jasperreports; -import java.util.logging.Level; -import java.util.logging.Logger; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.export.HtmlExporter; import net.sf.jasperreports.engine.export.JRCsvExporter; import net.sf.jasperreports.engine.export.JRPdfExporter; import net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter; -import net.sf.jasperreports.export.SimpleExporterInput; -import net.sf.jasperreports.export.SimpleHtmlExporterOutput; -import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput; -import net.sf.jasperreports.export.SimplePdfExporterConfiguration; -import net.sf.jasperreports.export.SimplePdfReportConfiguration; -import net.sf.jasperreports.export.SimpleWriterExporterOutput; -import net.sf.jasperreports.export.SimpleXlsxReportConfiguration; +import net.sf.jasperreports.export.*; import org.springframework.stereotype.Component; +import java.util.logging.Level; +import java.util.logging.Logger; + @Component public class SimpleReportExporter { diff --git a/spring-all/src/main/java/org/baeldung/jasperreports/SimpleReportFiller.java b/libraries-2/src/main/java/com/baeldung/jasperreports/SimpleReportFiller.java similarity index 88% rename from spring-all/src/main/java/org/baeldung/jasperreports/SimpleReportFiller.java rename to libraries-2/src/main/java/com/baeldung/jasperreports/SimpleReportFiller.java index 08891d940a..5f0f7e1345 100644 --- a/spring-all/src/main/java/org/baeldung/jasperreports/SimpleReportFiller.java +++ b/libraries-2/src/main/java/com/baeldung/jasperreports/SimpleReportFiller.java @@ -1,20 +1,17 @@ -package org.baeldung.jasperreports; +package com.baeldung.jasperreports; +import net.sf.jasperreports.engine.*; +import net.sf.jasperreports.engine.util.JRSaver; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.sql.DataSource; import java.io.InputStream; import java.sql.SQLException; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import javax.sql.DataSource; -import net.sf.jasperreports.engine.JRException; -import net.sf.jasperreports.engine.JasperCompileManager; -import net.sf.jasperreports.engine.JasperFillManager; -import net.sf.jasperreports.engine.JasperPrint; -import net.sf.jasperreports.engine.JasperReport; -import net.sf.jasperreports.engine.util.JRSaver; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; @Component public class SimpleReportFiller { diff --git a/spring-all/src/main/java/org/baeldung/jasperreports/config/JasperRerportsSimpleConfig.java b/libraries-2/src/main/java/com/baeldung/jasperreports/config/JasperRerportsSimpleConfig.java similarity index 83% rename from spring-all/src/main/java/org/baeldung/jasperreports/config/JasperRerportsSimpleConfig.java rename to libraries-2/src/main/java/com/baeldung/jasperreports/config/JasperRerportsSimpleConfig.java index 5cc2d894c9..10bae0052f 100644 --- a/spring-all/src/main/java/org/baeldung/jasperreports/config/JasperRerportsSimpleConfig.java +++ b/libraries-2/src/main/java/com/baeldung/jasperreports/config/JasperRerportsSimpleConfig.java @@ -1,13 +1,14 @@ -package org.baeldung.jasperreports.config; +package com.baeldung.jasperreports.config; -import javax.sql.DataSource; -import org.baeldung.jasperreports.SimpleReportExporter; -import org.baeldung.jasperreports.SimpleReportFiller; +import com.baeldung.jasperreports.SimpleReportExporter; +import com.baeldung.jasperreports.SimpleReportFiller; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; +import javax.sql.DataSource; + @Configuration public class JasperRerportsSimpleConfig { diff --git a/libraries-2/src/main/resources/META-INF/kmodule.xml b/libraries-2/src/main/resources/META-INF/kmodule.xml index 1b9ce1ce71..9e2597d5de 100644 --- a/libraries-2/src/main/resources/META-INF/kmodule.xml +++ b/libraries-2/src/main/resources/META-INF/kmodule.xml @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/spring-all/src/main/resources/employee-schema.sql b/libraries-2/src/main/resources/employee-schema.sql similarity index 100% rename from spring-all/src/main/resources/employee-schema.sql rename to libraries-2/src/main/resources/employee-schema.sql diff --git a/libraries-2/src/main/resources/employeeEmailReport.jrxml b/libraries-2/src/main/resources/employeeEmailReport.jrxml new file mode 100644 index 0000000000..1e60344e47 --- /dev/null +++ b/libraries-2/src/main/resources/employeeEmailReport.jrxml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + diff --git a/spring-all/src/main/resources/employeeReport.jrxml b/libraries-2/src/main/resources/employeeReport.jrxml similarity index 78% rename from spring-all/src/main/resources/employeeReport.jrxml rename to libraries-2/src/main/resources/employeeReport.jrxml index 3d2be226fb..434c3e1338 100644 --- a/spring-all/src/main/resources/employeeReport.jrxml +++ b/libraries-2/src/main/resources/employeeReport.jrxml @@ -1,12 +1,16 @@ - + - = $P{minSalary} AND $P!{condition}]]> + = $P{minSalary} AND $P!{condition}]]> @@ -44,7 +48,8 @@ - + + diff --git a/pom.xml b/pom.xml index 2349d3642f..c5a9959573 100644 --- a/pom.xml +++ b/pom.xml @@ -599,6 +599,7 @@ spring-boot-performance spring-boot-properties + spring-security-kerberos oauth2-framework-impl @@ -667,7 +668,6 @@ spring-activiti spring-akka - spring-all spring-amqp spring-aop spring-apache-camel @@ -714,6 +714,7 @@ spring-core spring-core-2 + spring-core-3 spring-cucumber spring-data-rest @@ -1390,7 +1391,6 @@ spring-5-security-cognito spring-activiti spring-akka - spring-all spring-amqp spring-aop spring-apache-camel @@ -1424,7 +1424,7 @@ spring-boot-property-exp spring-boot-security spring-boot-vue - + spring-caching spring-cloud spring-cloud-bus @@ -1463,6 +1463,7 @@ spring-mobile spring-mockito + spring-mvc-basics-2 spring-mvc-forms-jsp spring-mvc-forms-thymeleaf spring-mvc-java @@ -1492,6 +1493,7 @@ spring-resttemplate spring-roo + spring-scheduling spring-security-acl spring-security-angular/server spring-security-cache-control @@ -1514,6 +1516,7 @@ spring-security-thymeleaf spring-security-x509 spring-session + spring-shell spring-sleuth spring-soap spring-social-login diff --git a/spring-4/README.md b/spring-4/README.md index d44eed915e..46d9b71e5c 100644 --- a/spring-4/README.md +++ b/spring-4/README.md @@ -6,3 +6,4 @@ This module contains articles about Spring 4 - [A Guide to Flips for Spring](https://www.baeldung.com/flips-spring) - [Configuring a Hikari Connection Pool with Spring Boot](https://www.baeldung.com/spring-boot-hikari) - [Spring JSON-P with Jackson](https://www.baeldung.com/spring-jackson-jsonp) +- [What’s New in Spring 4.3?](https://www.baeldung.com/whats-new-in-spring-4-3) diff --git a/spring-4/pom.xml b/spring-4/pom.xml index 59b74782ec..6c282b76a0 100644 --- a/spring-4/pom.xml +++ b/spring-4/pom.xml @@ -67,6 +67,27 @@ tomcat-embed-jasper provided + + org.apache.logging.log4j + log4j-api + + + org.apache.logging.log4j + log4j-core + + + org.easymock + easymock + ${easymock.version} + test + + + + org.hsqldb + hsqldb + ${hsqldb.version} + test + @@ -88,6 +109,8 @@ com.baeldung.flips.ApplicationConfig 1.0.1 + 3.6 + 2.4.0 diff --git a/spring-all/src/main/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationsTestController.java b/spring-4/src/main/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationsTestController.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationsTestController.java rename to spring-4/src/main/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationsTestController.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/attributeannotations/ParamInterceptor.java b/spring-4/src/main/java/org/baeldung/spring43/attributeannotations/ParamInterceptor.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/attributeannotations/ParamInterceptor.java rename to spring-4/src/main/java/org/baeldung/spring43/attributeannotations/ParamInterceptor.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/cache/Foo.java b/spring-4/src/main/java/org/baeldung/spring43/cache/Foo.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/cache/Foo.java rename to spring-4/src/main/java/org/baeldung/spring43/cache/Foo.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/cache/FooService.java b/spring-4/src/main/java/org/baeldung/spring43/cache/FooService.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/cache/FooService.java rename to spring-4/src/main/java/org/baeldung/spring43/cache/FooService.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/composedmapping/Appointment.java b/spring-4/src/main/java/org/baeldung/spring43/composedmapping/Appointment.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/composedmapping/Appointment.java rename to spring-4/src/main/java/org/baeldung/spring43/composedmapping/Appointment.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/composedmapping/AppointmentService.java b/spring-4/src/main/java/org/baeldung/spring43/composedmapping/AppointmentService.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/composedmapping/AppointmentService.java rename to spring-4/src/main/java/org/baeldung/spring43/composedmapping/AppointmentService.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/composedmapping/AppointmentsController.java b/spring-4/src/main/java/org/baeldung/spring43/composedmapping/AppointmentsController.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/composedmapping/AppointmentsController.java rename to spring-4/src/main/java/org/baeldung/spring43/composedmapping/AppointmentsController.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/ctor/FooRepository.java b/spring-4/src/main/java/org/baeldung/spring43/ctor/FooRepository.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/ctor/FooRepository.java rename to spring-4/src/main/java/org/baeldung/spring43/ctor/FooRepository.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/ctor/FooService.java b/spring-4/src/main/java/org/baeldung/spring43/ctor/FooService.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/ctor/FooService.java rename to spring-4/src/main/java/org/baeldung/spring43/ctor/FooService.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/defaultmethods/DateHolder.java b/spring-4/src/main/java/org/baeldung/spring43/defaultmethods/DateHolder.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/defaultmethods/DateHolder.java rename to spring-4/src/main/java/org/baeldung/spring43/defaultmethods/DateHolder.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/defaultmethods/IDateHolder.java b/spring-4/src/main/java/org/baeldung/spring43/defaultmethods/IDateHolder.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/defaultmethods/IDateHolder.java rename to spring-4/src/main/java/org/baeldung/spring43/defaultmethods/IDateHolder.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/depresolution/FooRepository.java b/spring-4/src/main/java/org/baeldung/spring43/depresolution/FooRepository.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/depresolution/FooRepository.java rename to spring-4/src/main/java/org/baeldung/spring43/depresolution/FooRepository.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/depresolution/FooService.java b/spring-4/src/main/java/org/baeldung/spring43/depresolution/FooService.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/depresolution/FooService.java rename to spring-4/src/main/java/org/baeldung/spring43/depresolution/FooService.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/scopeannotations/AppPreferences.java b/spring-4/src/main/java/org/baeldung/spring43/scopeannotations/AppPreferences.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/scopeannotations/AppPreferences.java rename to spring-4/src/main/java/org/baeldung/spring43/scopeannotations/AppPreferences.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/scopeannotations/InstanceCountingService.java b/spring-4/src/main/java/org/baeldung/spring43/scopeannotations/InstanceCountingService.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/scopeannotations/InstanceCountingService.java rename to spring-4/src/main/java/org/baeldung/spring43/scopeannotations/InstanceCountingService.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/scopeannotations/LoginAction.java b/spring-4/src/main/java/org/baeldung/spring43/scopeannotations/LoginAction.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/scopeannotations/LoginAction.java rename to spring-4/src/main/java/org/baeldung/spring43/scopeannotations/LoginAction.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/scopeannotations/ScopeTestController.java b/spring-4/src/main/java/org/baeldung/spring43/scopeannotations/ScopeTestController.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/scopeannotations/ScopeTestController.java rename to spring-4/src/main/java/org/baeldung/spring43/scopeannotations/ScopeTestController.java diff --git a/spring-all/src/main/java/org/baeldung/spring43/scopeannotations/UserPreferences.java b/spring-4/src/main/java/org/baeldung/spring43/scopeannotations/UserPreferences.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring43/scopeannotations/UserPreferences.java rename to spring-4/src/main/java/org/baeldung/spring43/scopeannotations/UserPreferences.java diff --git a/spring-all/src/main/resources/defaultmethods-context.xml b/spring-4/src/main/resources/defaultmethods-context.xml similarity index 100% rename from spring-all/src/main/resources/defaultmethods-context.xml rename to spring-4/src/main/resources/defaultmethods-context.xml diff --git a/spring-all/src/main/resources/implicit-ctor-context.xml b/spring-4/src/main/resources/implicit-ctor-context.xml similarity index 100% rename from spring-all/src/main/resources/implicit-ctor-context.xml rename to spring-4/src/main/resources/implicit-ctor-context.xml diff --git a/spring-all/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationConfiguration.java b/spring-4/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationConfiguration.java similarity index 91% rename from spring-all/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationConfiguration.java rename to spring-4/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationConfiguration.java index 347dd399e2..97ae651473 100644 --- a/spring-all/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationConfiguration.java +++ b/spring-4/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationConfiguration.java @@ -6,13 +6,13 @@ import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.view.InternalResourceViewResolver; @Configuration @ComponentScan @EnableWebMvc -public class AttributeAnnotationConfiguration implements WebMvcConfigurer { +public class AttributeAnnotationConfiguration extends WebMvcConfigurerAdapter { @Bean public ViewResolver viewResolver() { diff --git a/spring-all/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationIntegrationTest.java b/spring-4/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationIntegrationTest.java rename to spring-4/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/spring43/cache/CacheRefinementsConfiguration.java b/spring-4/src/test/java/org/baeldung/spring43/cache/CacheRefinementsConfiguration.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/cache/CacheRefinementsConfiguration.java rename to spring-4/src/test/java/org/baeldung/spring43/cache/CacheRefinementsConfiguration.java diff --git a/spring-all/src/test/java/org/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java b/spring-4/src/test/java/org/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java rename to spring-4/src/test/java/org/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingConfiguration.java b/spring-4/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingConfiguration.java similarity index 97% rename from spring-all/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingConfiguration.java rename to spring-4/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingConfiguration.java index eddd56a11b..f1028ebefb 100644 --- a/spring-all/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingConfiguration.java +++ b/spring-4/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingConfiguration.java @@ -14,7 +14,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.context.annotation.Scope; -import static org.easymock.EasyMock.*; +import static org.easymock.EasyMock.replay; @Configuration @ComponentScan diff --git a/spring-all/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingIntegrationTest.java b/spring-4/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingIntegrationTest.java rename to spring-4/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/spring43/ctor/ConfigurationConstructorInjectionIntegrationTest.java b/spring-4/src/test/java/org/baeldung/spring43/ctor/ConfigurationConstructorInjectionIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/ctor/ConfigurationConstructorInjectionIntegrationTest.java rename to spring-4/src/test/java/org/baeldung/spring43/ctor/ConfigurationConstructorInjectionIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/spring43/ctor/FooRepositoryConfiguration.java b/spring-4/src/test/java/org/baeldung/spring43/ctor/FooRepositoryConfiguration.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/ctor/FooRepositoryConfiguration.java rename to spring-4/src/test/java/org/baeldung/spring43/ctor/FooRepositoryConfiguration.java diff --git a/spring-all/src/test/java/org/baeldung/spring43/ctor/FooServiceConfiguration.java b/spring-4/src/test/java/org/baeldung/spring43/ctor/FooServiceConfiguration.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/ctor/FooServiceConfiguration.java rename to spring-4/src/test/java/org/baeldung/spring43/ctor/FooServiceConfiguration.java diff --git a/spring-all/src/test/java/org/baeldung/spring43/ctor/ImplicitConstructorIntegrationTest.java b/spring-4/src/test/java/org/baeldung/spring43/ctor/ImplicitConstructorIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/ctor/ImplicitConstructorIntegrationTest.java rename to spring-4/src/test/java/org/baeldung/spring43/ctor/ImplicitConstructorIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/spring43/defaultmethods/DefaultMethodsInjectionIntegrationTest.java b/spring-4/src/test/java/org/baeldung/spring43/defaultmethods/DefaultMethodsInjectionIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/defaultmethods/DefaultMethodsInjectionIntegrationTest.java rename to spring-4/src/test/java/org/baeldung/spring43/defaultmethods/DefaultMethodsInjectionIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/spring43/defaultmethods/ITransactionalUnitTest.java b/spring-4/src/test/java/org/baeldung/spring43/defaultmethods/ITransactionalUnitTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/defaultmethods/ITransactionalUnitTest.java rename to spring-4/src/test/java/org/baeldung/spring43/defaultmethods/ITransactionalUnitTest.java diff --git a/spring-all/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalIntegrationTest.java b/spring-4/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalIntegrationTest.java rename to spring-4/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalTestConfiguration.java b/spring-4/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalTestConfiguration.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalTestConfiguration.java rename to spring-4/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalTestConfiguration.java diff --git a/spring-all/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderConfiguration.java b/spring-4/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderConfiguration.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderConfiguration.java rename to spring-4/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderConfiguration.java diff --git a/spring-all/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderIntegrationTest.java b/spring-4/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderIntegrationTest.java rename to spring-4/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsConfiguration.java b/spring-4/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsConfiguration.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsConfiguration.java rename to spring-4/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsConfiguration.java diff --git a/spring-all/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsIntegrationTest.java b/spring-4/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsIntegrationTest.java rename to spring-4/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsIntegrationTest.java diff --git a/spring-all/README.md b/spring-all/README.md deleted file mode 100644 index 1d6cb0bfad..0000000000 --- a/spring-all/README.md +++ /dev/null @@ -1,33 +0,0 @@ -## Spring General Example Project - -This project is used to replicate Spring Exceptions only. - -### The Course - -The "REST With Spring" Classes: http://bit.ly/restwithspring - -### Relevant articles: - -- [Guide to Spring @Autowired](https://www.baeldung.com/spring-autowire) -- [Spring Profiles](https://www.baeldung.com/spring-profiles) -- [A Spring Custom Annotation for a Better DAO](https://www.baeldung.com/spring-annotation-bean-pre-processor) -- [What’s New in Spring 4.3?](https://www.baeldung.com/whats-new-in-spring-4-3) -- [Running Setup Data on Startup in Spring](https://www.baeldung.com/running-setup-logic-on-startup-in-spring) -- [Quick Guide to Spring Controllers](https://www.baeldung.com/spring-controllers) -- [Quick Guide to Spring Bean Scopes](https://www.baeldung.com/spring-bean-scopes) -- [Introduction To Ehcache](https://www.baeldung.com/ehcache) -- [A Guide to the Spring Task Scheduler](https://www.baeldung.com/spring-task-scheduler) -- [Guide to Spring Retry](https://www.baeldung.com/spring-retry) -- [Custom Scope in Spring](https://www.baeldung.com/spring-custom-scope) -- [A CLI with Spring Shell](https://www.baeldung.com/spring-shell-cli) -- [JasperReports with Spring](https://www.baeldung.com/spring-jasper) -- [Model, ModelMap, and ModelView in Spring MVC](https://www.baeldung.com/spring-mvc-model-model-map-model-view) -- [A Guide To Caching in Spring](https://www.baeldung.com/spring-cache-tutorial) -- [How To Do @Async in Spring](https://www.baeldung.com/spring-async) -- [@Order in Spring](https://www.baeldung.com/spring-order) -- [Spring Web Contexts](https://www.baeldung.com/spring-web-contexts) -- [Spring Cache – Creating a Custom KeyGenerator](https://www.baeldung.com/spring-cache-custom-keygenerator) -- [Spring @Primary Annotation](https://www.baeldung.com/spring-primary) -- [Spring Events](https://www.baeldung.com/spring-events) -- [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) diff --git a/spring-all/pom.xml b/spring-all/pom.xml deleted file mode 100644 index 8c88efb970..0000000000 --- a/spring-all/pom.xml +++ /dev/null @@ -1,254 +0,0 @@ - - 4.0.0 - spring-all - 0.1-SNAPSHOT - spring-all - war - - - parent-boot-2 - com.baeldung - 0.0.1-SNAPSHOT - ../parent-boot-2 - - - - - com.fasterxml.jackson.core - jackson-databind - - - - org.springframework - spring-web - - - org.springframework - spring-webmvc - - - org.springframework - spring-orm - - - org.springframework - spring-context - - - org.springframework.retry - spring-retry - - - org.springframework.shell - spring-shell - ${org.springframework.shell.version} - - - org.springframework - spring-websocket - - - org.springframework - spring-messaging - - - javax.annotation - javax.annotation-api - ${annotation-api.version} - - - - org.springframework - spring-aspects - - - - org.hibernate - hibernate-core - - - org.javassist - javassist - ${javassist.version} - - - mysql - mysql-connector-java - runtime - - - org.hsqldb - hsqldb - - - - org.hibernate - hibernate-validator - ${hibernate.version} - - - - javax.servlet - javax.servlet-api - provided - - - javax.servlet - jstl - runtime - - - - com.google.guava - guava - ${guava.version} - - - net.sf.jasperreports - jasperreports - ${jasperreports.version} - - - commons-logging - commons-logging - - - - - - org.springframework - spring-test - test - - - org.assertj - assertj-core - test - - - org.hamcrest - hamcrest-core - test - - - org.hamcrest - hamcrest-library - test - - - org.mockito - mockito-core - test - - - org.easymock - easymock - ${easymock.version} - test - - - org.ehcache - ehcache - - - org.apache.logging.log4j - log4j-api - - - org.apache.logging.log4j - log4j-core - - - - - net.javacrumbs.shedlock - shedlock-spring - ${shedlock.version} - - - net.javacrumbs.shedlock - shedlock-provider-jdbc-template - ${shedlock.version} - - - - - - - org.springframework - spring-framework-bom - ${org.springframework.version} - pom - import - - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework.boot - spring-boot-starter-thymeleaf - ${org.springframework.version} - - - - - - spring-all - - - src/main/resources - true - - - - - org.apache.maven.plugins - maven-war-plugin - 3.2.2 - - false - - - - - - - dev - - true - - - dev - - - - prod - - prod - - - - - - org.baeldung.sample.App - - 5.0.6.RELEASE - 1.2.0.RELEASE - 1.3.2 - - 5.2.5.Final - - - 25.1-jre - 3.5.2 - 3.6 - 3.6.1 - 6.6.0 - 2.1.0 - 3.22.0-GA - - - diff --git a/spring-all/src/main/resources/beanInjection-constructor.xml b/spring-all/src/main/resources/beanInjection-constructor.xml deleted file mode 100644 index a0713fd9f8..0000000000 --- a/spring-all/src/main/resources/beanInjection-constructor.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-all/src/main/resources/beanInjection-setter.xml b/spring-all/src/main/resources/beanInjection-setter.xml deleted file mode 100644 index b2d3a05594..0000000000 --- a/spring-all/src/main/resources/beanInjection-setter.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/spring-all/src/main/resources/employeeEmailReport.jrxml b/spring-all/src/main/resources/employeeEmailReport.jrxml deleted file mode 100644 index ad4aaaac90..0000000000 --- a/spring-all/src/main/resources/employeeEmailReport.jrxml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/spring-all/src/main/webapp/WEB-INF/greeting.xml b/spring-all/src/main/webapp/WEB-INF/greeting.xml deleted file mode 100644 index 3f0ae83455..0000000000 --- a/spring-all/src/main/webapp/WEB-INF/greeting.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/normal-webapp-servlet.xml b/spring-all/src/main/webapp/WEB-INF/normal-webapp-servlet.xml deleted file mode 100644 index 0a7a0919a8..0000000000 --- a/spring-all/src/main/webapp/WEB-INF/normal-webapp-servlet.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/rootApplicationContext.xml b/spring-all/src/main/webapp/WEB-INF/rootApplicationContext.xml deleted file mode 100644 index af03661ebc..0000000000 --- a/spring-all/src/main/webapp/WEB-INF/rootApplicationContext.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/secure-webapp-servlet.xml b/spring-all/src/main/webapp/WEB-INF/secure-webapp-servlet.xml deleted file mode 100644 index 6cdd3971bf..0000000000 --- a/spring-all/src/main/webapp/WEB-INF/secure-webapp-servlet.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/view/sample.jsp b/spring-all/src/main/webapp/WEB-INF/view/sample.jsp deleted file mode 100644 index 7cc14b5dcd..0000000000 --- a/spring-all/src/main/webapp/WEB-INF/view/sample.jsp +++ /dev/null @@ -1,7 +0,0 @@ - - - - -

This is the body of the sample view

- - \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/view/scopesExample.jsp b/spring-all/src/main/webapp/WEB-INF/view/scopesExample.jsp deleted file mode 100644 index 0946f1b5ef..0000000000 --- a/spring-all/src/main/webapp/WEB-INF/view/scopesExample.jsp +++ /dev/null @@ -1,10 +0,0 @@ - - - - -

Bean Scopes Examples

-
Previous Message: ${previousMessage } -
Current Message: ${currentMessage } -
- - \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/view/welcome.jsp b/spring-all/src/main/webapp/WEB-INF/view/welcome.jsp deleted file mode 100644 index 6a82fb1d5a..0000000000 --- a/spring-all/src/main/webapp/WEB-INF/view/welcome.jsp +++ /dev/null @@ -1,11 +0,0 @@ - - - Spring Web Contexts - - -
-
- Normal Web Application : ${message} -
- - \ No newline at end of file diff --git a/spring-all/src/test/java/org/baeldung/caching/test/CacheEvictAnnotationIntegrationTest.java b/spring-all/src/test/java/org/baeldung/caching/test/CacheEvictAnnotationIntegrationTest.java deleted file mode 100644 index f24cdef917..0000000000 --- a/spring-all/src/test/java/org/baeldung/caching/test/CacheEvictAnnotationIntegrationTest.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.baeldung.caching.test; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import java.util.ArrayList; -import java.util.List; - -import org.baeldung.caching.eviction.service.CachingService; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.Cache; -import org.springframework.cache.CacheManager; -import org.springframework.cache.annotation.EnableCaching; -import org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean; -import org.springframework.cache.support.SimpleCacheManager; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration -public class CacheEvictAnnotationIntegrationTest { - - @Configuration - @EnableCaching - static class ContextConfiguration { - - @Bean - public CachingService cachingService() { - return new CachingService(); - } - - @Bean - public CacheManager cacheManager(){ - SimpleCacheManager cacheManager = new SimpleCacheManager(); - List caches = new ArrayList<>(); - caches.add(cacheBean().getObject()); - cacheManager.setCaches(caches ); - return cacheManager; - } - - @Bean - public ConcurrentMapCacheFactoryBean cacheBean(){ - ConcurrentMapCacheFactoryBean cacheFactoryBean = new ConcurrentMapCacheFactoryBean(); - cacheFactoryBean.setName("first"); - return cacheFactoryBean; - } - } - - @Autowired - CachingService cachingService; - - @Before - public void before() { - cachingService.putToCache("first", "key1", "Baeldung"); - cachingService.putToCache("first", "key2", "Article"); - } - - @Test - public void givenFirstCache_whenSingleCacheValueEvictRequested_thenEmptyCacheValue() { - cachingService.evictSingleCacheValue("key1"); - String key1 = cachingService.getFromCache("first", "key1"); - assertThat(key1, is(nullValue())); - } - - @Test - public void givenFirstCache_whenAllCacheValueEvictRequested_thenEmptyCache() { - cachingService.evictAllCacheValues(); - String key1 = cachingService.getFromCache("first", "key1"); - String key2 = cachingService.getFromCache("first", "key2"); - assertThat(key1, is(nullValue())); - assertThat(key2, is(nullValue())); - } -} diff --git a/spring-boot/src/main/java/org/baeldung/model/User.java b/spring-boot/src/main/java/org/baeldung/model/User.java index eb886338a0..049b118b12 100644 --- a/spring-boot/src/main/java/org/baeldung/model/User.java +++ b/spring-boot/src/main/java/org/baeldung/model/User.java @@ -1,4 +1,4 @@ -package org.baeldung.model; +package org.baeldung.caching.model; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java b/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java index 7335af2616..0113c4c5d4 100644 --- a/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java +++ b/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java @@ -1,6 +1,6 @@ package org.baeldung.repository; -import org.baeldung.model.User; +import org.baeldung.caching.model.User; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; diff --git a/spring-boot/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java b/spring-boot/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java index 04bb1170f8..54ce3b4bf3 100644 --- a/spring-boot/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java +++ b/spring-boot/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java @@ -1,7 +1,7 @@ package org.baeldung.repository; import org.baeldung.boot.config.H2JpaConfig; -import org.baeldung.model.User; +import org.baeldung.caching.model.User; import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-caching/README.md b/spring-caching/README.md new file mode 100644 index 0000000000..14dfe94041 --- /dev/null +++ b/spring-caching/README.md @@ -0,0 +1,4 @@ +### Relevant articles: +- [Introduction To Ehcache](http://www.baeldung.com/ehcache) +- [A Guide To Caching in Spring](http://www.baeldung.com/spring-cache-tutorial) +- [Spring Cache – Creating a Custom KeyGenerator](http://www.baeldung.com/spring-cache-custom-keygenerator) diff --git a/spring-caching/pom.xml b/spring-caching/pom.xml new file mode 100644 index 0000000000..3329cd5f77 --- /dev/null +++ b/spring-caching/pom.xml @@ -0,0 +1,43 @@ + + 4.0.0 + spring-caching + 0.1-SNAPSHOT + spring-caching + war + + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + + + org.springframework + spring-context + + + org.springframework + spring-web + + + org.springframework + spring-webmvc + + + org.ehcache + ehcache + + + org.springframework + spring-test + test + + + + + 3.5.2 + + \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/caching/config/ApplicationCacheConfig.java b/spring-caching/src/main/java/org/baeldung/caching/config/ApplicationCacheConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/caching/config/ApplicationCacheConfig.java rename to spring-caching/src/main/java/org/baeldung/caching/config/ApplicationCacheConfig.java diff --git a/spring-all/src/main/java/org/baeldung/caching/config/CachingConfig.java b/spring-caching/src/main/java/org/baeldung/caching/config/CachingConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/caching/config/CachingConfig.java rename to spring-caching/src/main/java/org/baeldung/caching/config/CachingConfig.java diff --git a/spring-all/src/main/java/org/baeldung/caching/config/CustomKeyGenerator.java b/spring-caching/src/main/java/org/baeldung/caching/config/CustomKeyGenerator.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/caching/config/CustomKeyGenerator.java rename to spring-caching/src/main/java/org/baeldung/caching/config/CustomKeyGenerator.java diff --git a/spring-all/src/main/java/org/baeldung/caching/eviction/controllers/CachingController.java b/spring-caching/src/main/java/org/baeldung/caching/eviction/controllers/CachingController.java similarity index 96% rename from spring-all/src/main/java/org/baeldung/caching/eviction/controllers/CachingController.java rename to spring-caching/src/main/java/org/baeldung/caching/eviction/controllers/CachingController.java index 675cb7a516..aaaf8a5918 100644 --- a/spring-all/src/main/java/org/baeldung/caching/eviction/controllers/CachingController.java +++ b/spring-caching/src/main/java/org/baeldung/caching/eviction/controllers/CachingController.java @@ -1,18 +1,18 @@ -package org.baeldung.caching.eviction.controllers; - -import org.baeldung.caching.eviction.service.CachingService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class CachingController { - - @Autowired - CachingService cachingService; - - @GetMapping("clearAllCaches") - public void clearAllCaches() { - cachingService.evictAllCaches(); - } -} +package org.baeldung.caching.eviction.controllers; + +import org.baeldung.caching.eviction.service.CachingService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class CachingController { + + @Autowired + CachingService cachingService; + + @GetMapping("clearAllCaches") + public void clearAllCaches() { + cachingService.evictAllCaches(); + } +} diff --git a/spring-all/src/main/java/org/baeldung/caching/eviction/service/CachingService.java b/spring-caching/src/main/java/org/baeldung/caching/eviction/service/CachingService.java similarity index 96% rename from spring-all/src/main/java/org/baeldung/caching/eviction/service/CachingService.java rename to spring-caching/src/main/java/org/baeldung/caching/eviction/service/CachingService.java index 7e37215954..a0dd30c329 100644 --- a/spring-all/src/main/java/org/baeldung/caching/eviction/service/CachingService.java +++ b/spring-caching/src/main/java/org/baeldung/caching/eviction/service/CachingService.java @@ -1,53 +1,53 @@ -package org.baeldung.caching.eviction.service; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.CacheManager; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -@Component -public class CachingService { - - @Autowired - CacheManager cacheManager; - - public void putToCache(String cacheName, String key, String value) { - cacheManager.getCache(cacheName).put(key, value); - } - - public String getFromCache(String cacheName, String key) { - String value = null; - if (cacheManager.getCache(cacheName).get(key) != null) { - value = cacheManager.getCache(cacheName).get(key).get().toString(); - } - return value; - } - - @CacheEvict(value = "first", key = "#cacheKey") - public void evictSingleCacheValue(String cacheKey) { - } - - @CacheEvict(value = "first", allEntries = true) - public void evictAllCacheValues() { - } - - public void evictSingleCacheValue(String cacheName, String cacheKey) { - cacheManager.getCache(cacheName).evict(cacheKey); - } - - public void evictAllCacheValues(String cacheName) { - cacheManager.getCache(cacheName).clear(); - } - - public void evictAllCaches() { - cacheManager.getCacheNames() - .parallelStream() - .forEach(cacheName -> cacheManager.getCache(cacheName).clear()); - } - - @Scheduled(fixedRate = 6000) - public void evictAllcachesAtIntervals() { - evictAllCaches(); - } -} +package org.baeldung.caching.eviction.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +@Component +public class CachingService { + + @Autowired + CacheManager cacheManager; + + public void putToCache(String cacheName, String key, String value) { + cacheManager.getCache(cacheName).put(key, value); + } + + public String getFromCache(String cacheName, String key) { + String value = null; + if (cacheManager.getCache(cacheName).get(key) != null) { + value = cacheManager.getCache(cacheName).get(key).get().toString(); + } + return value; + } + + @CacheEvict(value = "first", key = "#cacheKey") + public void evictSingleCacheValue(String cacheKey) { + } + + @CacheEvict(value = "first", allEntries = true) + public void evictAllCacheValues() { + } + + public void evictSingleCacheValue(String cacheName, String cacheKey) { + cacheManager.getCache(cacheName).evict(cacheKey); + } + + public void evictAllCacheValues(String cacheName) { + cacheManager.getCache(cacheName).clear(); + } + + public void evictAllCaches() { + cacheManager.getCacheNames() + .parallelStream() + .forEach(cacheName -> cacheManager.getCache(cacheName).clear()); + } + + @Scheduled(fixedRate = 6000) + public void evictAllcachesAtIntervals() { + evictAllCaches(); + } +} diff --git a/spring-all/src/main/java/org/baeldung/caching/example/AbstractService.java b/spring-caching/src/main/java/org/baeldung/caching/example/AbstractService.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/caching/example/AbstractService.java rename to spring-caching/src/main/java/org/baeldung/caching/example/AbstractService.java diff --git a/spring-all/src/main/java/org/baeldung/caching/example/BookService.java b/spring-caching/src/main/java/org/baeldung/caching/example/BookService.java similarity index 93% rename from spring-all/src/main/java/org/baeldung/caching/example/BookService.java rename to spring-caching/src/main/java/org/baeldung/caching/example/BookService.java index 26118d61de..9f3aaf89cf 100644 --- a/spring-all/src/main/java/org/baeldung/caching/example/BookService.java +++ b/spring-caching/src/main/java/org/baeldung/caching/example/BookService.java @@ -1,6 +1,6 @@ package org.baeldung.caching.example; -import org.baeldung.model.Book; +import org.baeldung.caching.model.Book; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Component; diff --git a/spring-all/src/main/java/org/baeldung/caching/example/Customer.java b/spring-caching/src/main/java/org/baeldung/caching/example/Customer.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/caching/example/Customer.java rename to spring-caching/src/main/java/org/baeldung/caching/example/Customer.java diff --git a/spring-all/src/main/java/org/baeldung/caching/example/CustomerDataService.java b/spring-caching/src/main/java/org/baeldung/caching/example/CustomerDataService.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/caching/example/CustomerDataService.java rename to spring-caching/src/main/java/org/baeldung/caching/example/CustomerDataService.java diff --git a/spring-all/src/main/java/org/baeldung/caching/example/CustomerServiceWithParent.java b/spring-caching/src/main/java/org/baeldung/caching/example/CustomerServiceWithParent.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/caching/example/CustomerServiceWithParent.java rename to spring-caching/src/main/java/org/baeldung/caching/example/CustomerServiceWithParent.java diff --git a/spring-all/src/main/java/org/baeldung/model/Book.java b/spring-caching/src/main/java/org/baeldung/caching/model/Book.java similarity index 94% rename from spring-all/src/main/java/org/baeldung/model/Book.java rename to spring-caching/src/main/java/org/baeldung/caching/model/Book.java index 9305ce9653..c110c79db0 100644 --- a/spring-all/src/main/java/org/baeldung/model/Book.java +++ b/spring-caching/src/main/java/org/baeldung/caching/model/Book.java @@ -1,4 +1,4 @@ -package org.baeldung.model; +package org.baeldung.caching.model; public class Book { diff --git a/spring-all/src/main/java/org/baeldung/ehcache/calculator/SquaredCalculator.java b/spring-caching/src/main/java/org/baeldung/ehcache/calculator/SquaredCalculator.java old mode 100755 new mode 100644 similarity index 100% rename from spring-all/src/main/java/org/baeldung/ehcache/calculator/SquaredCalculator.java rename to spring-caching/src/main/java/org/baeldung/ehcache/calculator/SquaredCalculator.java diff --git a/spring-all/src/main/java/org/baeldung/ehcache/config/CacheHelper.java b/spring-caching/src/main/java/org/baeldung/ehcache/config/CacheHelper.java old mode 100755 new mode 100644 similarity index 100% rename from spring-all/src/main/java/org/baeldung/ehcache/config/CacheHelper.java rename to spring-caching/src/main/java/org/baeldung/ehcache/config/CacheHelper.java diff --git a/spring-all/src/main/resources/config.xml b/spring-caching/src/main/resources/config.xml similarity index 100% rename from spring-all/src/main/resources/config.xml rename to spring-caching/src/main/resources/config.xml diff --git a/spring-caching/src/test/java/org/baeldung/caching/test/CacheEvictAnnotationIntegrationTest.java b/spring-caching/src/test/java/org/baeldung/caching/test/CacheEvictAnnotationIntegrationTest.java new file mode 100644 index 0000000000..28b0d26bed --- /dev/null +++ b/spring-caching/src/test/java/org/baeldung/caching/test/CacheEvictAnnotationIntegrationTest.java @@ -0,0 +1,79 @@ +package org.baeldung.caching.test; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; + +import java.util.ArrayList; +import java.util.List; + +import org.baeldung.caching.eviction.service.CachingService; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean; +import org.springframework.cache.support.SimpleCacheManager; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration +public class CacheEvictAnnotationIntegrationTest { + + @Configuration + @EnableCaching + static class ContextConfiguration { + + @Bean + public CachingService cachingService() { + return new CachingService(); + } + + @Bean + public CacheManager cacheManager() { + SimpleCacheManager cacheManager = new SimpleCacheManager(); + List caches = new ArrayList<>(); + caches.add(cacheBean().getObject()); + cacheManager.setCaches(caches); + return cacheManager; + } + + @Bean + public ConcurrentMapCacheFactoryBean cacheBean() { + ConcurrentMapCacheFactoryBean cacheFactoryBean = new ConcurrentMapCacheFactoryBean(); + cacheFactoryBean.setName("first"); + return cacheFactoryBean; + } + } + + @Autowired + CachingService cachingService; + + @Before + public void before() { + cachingService.putToCache("first", "key1", "Baeldung"); + cachingService.putToCache("first", "key2", "Article"); + } + + @Test + public void givenFirstCache_whenSingleCacheValueEvictRequested_thenEmptyCacheValue() { + cachingService.evictSingleCacheValue("key1"); + String key1 = cachingService.getFromCache("first", "key1"); + assertThat(key1, is(nullValue())); + } + + @Test + public void givenFirstCache_whenAllCacheValueEvictRequested_thenEmptyCache() { + cachingService.evictAllCacheValues(); + String key1 = cachingService.getFromCache("first", "key1"); + String key2 = cachingService.getFromCache("first", "key2"); + assertThat(key1, is(nullValue())); + assertThat(key2, is(nullValue())); + } +} diff --git a/spring-all/src/test/java/org/baeldung/caching/test/CacheManagerEvictIntegrationTest.java b/spring-caching/src/test/java/org/baeldung/caching/test/CacheManagerEvictIntegrationTest.java similarity index 67% rename from spring-all/src/test/java/org/baeldung/caching/test/CacheManagerEvictIntegrationTest.java rename to spring-caching/src/test/java/org/baeldung/caching/test/CacheManagerEvictIntegrationTest.java index 9c6aaea892..ffcc88febc 100644 --- a/spring-all/src/test/java/org/baeldung/caching/test/CacheManagerEvictIntegrationTest.java +++ b/spring-caching/src/test/java/org/baeldung/caching/test/CacheManagerEvictIntegrationTest.java @@ -1,96 +1,96 @@ -package org.baeldung.caching.test; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import java.util.ArrayList; -import java.util.List; - -import org.baeldung.caching.eviction.service.CachingService; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.Cache; -import org.springframework.cache.CacheManager; -import org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean; -import org.springframework.cache.support.SimpleCacheManager; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration -public class CacheManagerEvictIntegrationTest { - - @Configuration - static class ContextConfiguration { - - @Bean - public CachingService cachingService() { - return new CachingService(); - } - - @Bean - public CacheManager cacheManager(){ - SimpleCacheManager cacheManager = new SimpleCacheManager(); - List caches = new ArrayList<>(); - caches.add(cacheBeanFirst().getObject()); - caches.add(cacheBeanSecond().getObject()); - cacheManager.setCaches(caches ); - return cacheManager; - } - - @Bean - public ConcurrentMapCacheFactoryBean cacheBeanFirst(){ - ConcurrentMapCacheFactoryBean cacheFactoryBean = new ConcurrentMapCacheFactoryBean(); - cacheFactoryBean.setName("first"); - return cacheFactoryBean; - } - - @Bean - public ConcurrentMapCacheFactoryBean cacheBeanSecond(){ - ConcurrentMapCacheFactoryBean cacheFactoryBean = new ConcurrentMapCacheFactoryBean(); - cacheFactoryBean.setName("second"); - return cacheFactoryBean; - } - } - - @Autowired - CachingService cachingService; - - @Before - public void before() { - cachingService.putToCache("first", "key1", "Baeldung"); - cachingService.putToCache("first", "key2", "Article"); - cachingService.putToCache("second", "key", "Article"); - } - - @Test - public void givenFirstCache_whenSingleCacheValueEvictRequested_thenEmptyCacheValue() { - cachingService.evictSingleCacheValue("first", "key1"); - String key1 = cachingService.getFromCache("first", "key1"); - assertThat(key1, is(nullValue())); - } - - @Test - public void givenFirstCache_whenAllCacheValueEvictRequested_thenEmptyCache() { - cachingService.evictAllCacheValues("first"); - String key1 = cachingService.getFromCache("first", "key1"); - String key2 = cachingService.getFromCache("first", "key2"); - assertThat(key1, is(nullValue())); - assertThat(key2, is(nullValue())); - } - - @Test - public void givenAllCaches_whenAllCacheEvictRequested_thenEmptyAllCaches() { - cachingService.evictAllCaches(); - String key1 = cachingService.getFromCache("first", "key1"); - assertThat(key1, is(nullValue())); - - String key = cachingService.getFromCache("second", "key"); - assertThat(key, is(nullValue())); - } -} +package org.baeldung.caching.test; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; + +import java.util.ArrayList; +import java.util.List; + +import org.baeldung.caching.eviction.service.CachingService; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean; +import org.springframework.cache.support.SimpleCacheManager; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration +public class CacheManagerEvictIntegrationTest { + + @Configuration + static class ContextConfiguration { + + @Bean + public CachingService cachingService() { + return new CachingService(); + } + + @Bean + public CacheManager cacheManager() { + SimpleCacheManager cacheManager = new SimpleCacheManager(); + List caches = new ArrayList<>(); + caches.add(cacheBeanFirst().getObject()); + caches.add(cacheBeanSecond().getObject()); + cacheManager.setCaches(caches); + return cacheManager; + } + + @Bean + public ConcurrentMapCacheFactoryBean cacheBeanFirst() { + ConcurrentMapCacheFactoryBean cacheFactoryBean = new ConcurrentMapCacheFactoryBean(); + cacheFactoryBean.setName("first"); + return cacheFactoryBean; + } + + @Bean + public ConcurrentMapCacheFactoryBean cacheBeanSecond() { + ConcurrentMapCacheFactoryBean cacheFactoryBean = new ConcurrentMapCacheFactoryBean(); + cacheFactoryBean.setName("second"); + return cacheFactoryBean; + } + } + + @Autowired + CachingService cachingService; + + @Before + public void before() { + cachingService.putToCache("first", "key1", "Baeldung"); + cachingService.putToCache("first", "key2", "Article"); + cachingService.putToCache("second", "key", "Article"); + } + + @Test + public void givenFirstCache_whenSingleCacheValueEvictRequested_thenEmptyCacheValue() { + cachingService.evictSingleCacheValue("first", "key1"); + String key1 = cachingService.getFromCache("first", "key1"); + assertThat(key1, is(nullValue())); + } + + @Test + public void givenFirstCache_whenAllCacheValueEvictRequested_thenEmptyCache() { + cachingService.evictAllCacheValues("first"); + String key1 = cachingService.getFromCache("first", "key1"); + String key2 = cachingService.getFromCache("first", "key2"); + assertThat(key1, is(nullValue())); + assertThat(key2, is(nullValue())); + } + + @Test + public void givenAllCaches_whenAllCacheEvictRequested_thenEmptyAllCaches() { + cachingService.evictAllCaches(); + String key1 = cachingService.getFromCache("first", "key1"); + assertThat(key1, is(nullValue())); + + String key = cachingService.getFromCache("second", "key"); + assertThat(key, is(nullValue())); + } +} diff --git a/spring-all/src/test/java/org/baeldung/caching/test/SpringCachingIntegrationTest.java b/spring-caching/src/test/java/org/baeldung/caching/test/SpringCachingIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/caching/test/SpringCachingIntegrationTest.java rename to spring-caching/src/test/java/org/baeldung/caching/test/SpringCachingIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/ehcache/SquareCalculatorUnitTest.java b/spring-caching/src/test/java/org/baeldung/ehcache/SquareCalculatorUnitTest.java similarity index 97% rename from spring-all/src/test/java/org/baeldung/ehcache/SquareCalculatorUnitTest.java rename to spring-caching/src/test/java/org/baeldung/ehcache/SquareCalculatorUnitTest.java index 96265c11f5..0e6ac6fd8e 100644 --- a/spring-all/src/test/java/org/baeldung/ehcache/SquareCalculatorUnitTest.java +++ b/spring-caching/src/test/java/org/baeldung/ehcache/SquareCalculatorUnitTest.java @@ -1,40 +1,40 @@ -package org.baeldung.ehcache; - -import org.baeldung.ehcache.calculator.SquaredCalculator; -import org.baeldung.ehcache.config.CacheHelper; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class SquareCalculatorUnitTest { - private SquaredCalculator squaredCalculator = new SquaredCalculator(); - private CacheHelper cacheHelper = new CacheHelper(); - - @Before - public void setup() { - squaredCalculator.setCache(cacheHelper); - } - - @Test - public void whenCalculatingSquareValueOnce_thenCacheDontHaveValues() { - for (int i = 10; i < 15; i++) { - assertFalse(cacheHelper.getSquareNumberCache().containsKey(i)); - System.out.println("Square value of " + i + " is: " + squaredCalculator.getSquareValueOfNumber(i) + "\n"); - } - } - - @Test - public void whenCalculatingSquareValueAgain_thenCacheHasAllValues() { - for (int i = 10; i < 15; i++) { - assertFalse(cacheHelper.getSquareNumberCache().containsKey(i)); - System.out.println("Square value of " + i + " is: " + squaredCalculator.getSquareValueOfNumber(i) + "\n"); - } - - for (int i = 10; i < 15; i++) { - assertTrue(cacheHelper.getSquareNumberCache().containsKey(i)); - System.out.println("Square value of " + i + " is: " + squaredCalculator.getSquareValueOfNumber(i) + "\n"); - } - } -} +package org.baeldung.ehcache; + +import org.baeldung.ehcache.calculator.SquaredCalculator; +import org.baeldung.ehcache.config.CacheHelper; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class SquareCalculatorUnitTest { + private SquaredCalculator squaredCalculator = new SquaredCalculator(); + private CacheHelper cacheHelper = new CacheHelper(); + + @Before + public void setup() { + squaredCalculator.setCache(cacheHelper); + } + + @Test + public void whenCalculatingSquareValueOnce_thenCacheDontHaveValues() { + for (int i = 10; i < 15; i++) { + assertFalse(cacheHelper.getSquareNumberCache().containsKey(i)); + System.out.println("Square value of " + i + " is: " + squaredCalculator.getSquareValueOfNumber(i) + "\n"); + } + } + + @Test + public void whenCalculatingSquareValueAgain_thenCacheHasAllValues() { + for (int i = 10; i < 15; i++) { + assertFalse(cacheHelper.getSquareNumberCache().containsKey(i)); + System.out.println("Square value of " + i + " is: " + squaredCalculator.getSquareValueOfNumber(i) + "\n"); + } + + for (int i = 10; i < 15; i++) { + assertTrue(cacheHelper.getSquareNumberCache().containsKey(i)); + System.out.println("Square value of " + i + " is: " + squaredCalculator.getSquareValueOfNumber(i) + "\n"); + } + } +} diff --git a/spring-all/.gitignore b/spring-core-2/.gitignore similarity index 100% rename from spring-all/.gitignore rename to spring-core-2/.gitignore diff --git a/spring-core-2/README.md b/spring-core-2/README.md index 910d27583f..bcb1ce1fb4 100644 --- a/spring-core-2/README.md +++ b/spring-core-2/README.md @@ -4,8 +4,15 @@ This module contains articles about core Spring functionality ## Relevant Articles: -- [Understanding getBean() in Spring](https://www.baeldung.com/spring-getbean) -- [Exploring the Spring BeanFactory API](https://www.baeldung.com/spring-beanfactory) -- [How to use the Spring FactoryBean?](https://www.baeldung.com/spring-factorybean) -- [Spring – Injecting Collections](https://www.baeldung.com/spring-injecting-collections) -- More articles: [[<-- prev]](/spring-core) +- [Guide to Spring @Autowired](http://www.baeldung.com/spring-autowire) +- [Spring Profiles](http://www.baeldung.com/spring-profiles) +- [A Spring Custom Annotation for a Better DAO](http://www.baeldung.com/spring-annotation-bean-pre-processor) +- [Running Setup Data on Startup in Spring](http://www.baeldung.com/running-setup-logic-on-startup-in-spring) +- [Quick Guide to Spring Bean Scopes](http://www.baeldung.com/spring-bean-scopes) +- [Custom Scope in Spring](http://www.baeldung.com/spring-custom-scope) +- [@Order in Spring](http://www.baeldung.com/spring-order) +- [Spring @Primary Annotation](http://www.baeldung.com/spring-primary) +- [Spring Events](https://www.baeldung.com/spring-events) +- [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) +- More articles: [[<-- prev]](/spring-core) \ No newline at end of file diff --git a/spring-core-2/pom.xml b/spring-core-2/pom.xml index c9334e3d38..032f6a05fc 100644 --- a/spring-core-2/pom.xml +++ b/spring-core-2/pom.xml @@ -1,65 +1,217 @@ - - 4.0.0 spring-core-2 + 0.1-SNAPSHOT spring-core-2 + war + parent-boot-2 com.baeldung - parent-spring-5 0.0.1-SNAPSHOT - ../parent-spring-5 + ../parent-boot-2 + + com.fasterxml.jackson.core + jackson-databind + + org.springframework - spring-test - ${spring.version} + spring-web org.springframework - spring-beans - ${spring.version} + spring-webmvc + + + org.springframework + spring-orm org.springframework spring-context - ${spring.version} + + + org.springframework.retry + spring-retry org.springframework - spring-core - ${spring.version} + spring-websocket - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} + org.springframework + spring-messaging + + + javax.annotation + javax.annotation-api + ${annotation-api.version} + + + + org.springframework + spring-aspects + + + + org.hibernate + hibernate-core + + + org.javassist + javassist + ${javassist.version} + + + mysql + mysql-connector-java + runtime + + + org.hsqldb + hsqldb + + + + org.hibernate + hibernate-validator + ${hibernate.version} + + + + javax.servlet + javax.servlet-api + provided + + + javax.servlet + jstl + runtime + + + + com.google.guava + guava + ${guava.version} + + + + org.springframework + spring-test test - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} + org.assertj + assertj-core test + + org.hamcrest + hamcrest-core + test + + + org.hamcrest + hamcrest-library + test + + + org.mockito + mockito-core + test + + + + + net.javacrumbs.shedlock + shedlock-spring + ${shedlock.version} + + + net.javacrumbs.shedlock + shedlock-provider-jdbc-template + ${shedlock.version} + + + + + org.springframework + spring-framework-bom + ${org.springframework.version} + pom + import + + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework.boot + spring-boot-starter-thymeleaf + ${org.springframework.version} + + + + + spring-all + + + src/main/resources + true + + org.apache.maven.plugins - maven-surefire-plugin - ${maven.surefire.version} + maven-war-plugin + 3.2.2 + + false + + + + dev + + true + + + dev + + + + prod + + prod + + + - 2.22.1 + org.baeldung.sample.App + + 5.0.6.RELEASE + 1.3.2 + + 5.2.5.Final + + + 25.1-jre + 3.6 + 3.6.1 + 2.1.0 + 3.22.0-GA - \ No newline at end of file + diff --git a/spring-all/src/main/java/org/baeldung/autowire/sample/App.java b/spring-core-2/src/main/java/org/baeldung/autowire/sample/App.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/autowire/sample/App.java rename to spring-core-2/src/main/java/org/baeldung/autowire/sample/App.java diff --git a/spring-all/src/main/java/org/baeldung/autowire/sample/AppConfig.java b/spring-core-2/src/main/java/org/baeldung/autowire/sample/AppConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/autowire/sample/AppConfig.java rename to spring-core-2/src/main/java/org/baeldung/autowire/sample/AppConfig.java diff --git a/spring-all/src/main/java/org/baeldung/autowire/sample/BarFormatter.java b/spring-core-2/src/main/java/org/baeldung/autowire/sample/BarFormatter.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/autowire/sample/BarFormatter.java rename to spring-core-2/src/main/java/org/baeldung/autowire/sample/BarFormatter.java diff --git a/spring-all/src/main/java/org/baeldung/autowire/sample/FooDAO.java b/spring-core-2/src/main/java/org/baeldung/autowire/sample/FooDAO.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/autowire/sample/FooDAO.java rename to spring-core-2/src/main/java/org/baeldung/autowire/sample/FooDAO.java diff --git a/spring-all/src/main/java/org/baeldung/autowire/sample/FooFormatter.java b/spring-core-2/src/main/java/org/baeldung/autowire/sample/FooFormatter.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/autowire/sample/FooFormatter.java rename to spring-core-2/src/main/java/org/baeldung/autowire/sample/FooFormatter.java diff --git a/spring-all/src/main/java/org/baeldung/autowire/sample/FooService.java b/spring-core-2/src/main/java/org/baeldung/autowire/sample/FooService.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/autowire/sample/FooService.java rename to spring-core-2/src/main/java/org/baeldung/autowire/sample/FooService.java diff --git a/spring-all/src/main/java/org/baeldung/autowire/sample/Formatter.java b/spring-core-2/src/main/java/org/baeldung/autowire/sample/Formatter.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/autowire/sample/Formatter.java rename to spring-core-2/src/main/java/org/baeldung/autowire/sample/Formatter.java diff --git a/spring-all/src/main/java/org/baeldung/autowire/sample/FormatterType.java b/spring-core-2/src/main/java/org/baeldung/autowire/sample/FormatterType.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/autowire/sample/FormatterType.java rename to spring-core-2/src/main/java/org/baeldung/autowire/sample/FormatterType.java diff --git a/spring-all/src/main/java/org/baeldung/bean/config/ConstructorBasedShipConfig.java b/spring-core-2/src/main/java/org/baeldung/bean/config/ConstructorBasedShipConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/bean/config/ConstructorBasedShipConfig.java rename to spring-core-2/src/main/java/org/baeldung/bean/config/ConstructorBasedShipConfig.java diff --git a/spring-all/src/main/java/org/baeldung/bean/config/SetterBasedShipConfig.java b/spring-core-2/src/main/java/org/baeldung/bean/config/SetterBasedShipConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/bean/config/SetterBasedShipConfig.java rename to spring-core-2/src/main/java/org/baeldung/bean/config/SetterBasedShipConfig.java diff --git a/spring-all/src/main/java/org/baeldung/bean/injection/Helm.java b/spring-core-2/src/main/java/org/baeldung/bean/injection/Helm.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/bean/injection/Helm.java rename to spring-core-2/src/main/java/org/baeldung/bean/injection/Helm.java diff --git a/spring-all/src/main/java/org/baeldung/bean/injection/Ship.java b/spring-core-2/src/main/java/org/baeldung/bean/injection/Ship.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/bean/injection/Ship.java rename to spring-core-2/src/main/java/org/baeldung/bean/injection/Ship.java diff --git a/spring-all/src/main/java/org/baeldung/customannotation/CustomAnnotationConfiguration.java b/spring-core-2/src/main/java/org/baeldung/customannotation/CustomAnnotationConfiguration.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/customannotation/CustomAnnotationConfiguration.java rename to spring-core-2/src/main/java/org/baeldung/customannotation/CustomAnnotationConfiguration.java diff --git a/spring-all/src/main/java/org/baeldung/customannotation/DataAccess.java b/spring-core-2/src/main/java/org/baeldung/customannotation/DataAccess.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/customannotation/DataAccess.java rename to spring-core-2/src/main/java/org/baeldung/customannotation/DataAccess.java diff --git a/spring-all/src/main/java/org/baeldung/customannotation/DataAccessAnnotationProcessor.java b/spring-core-2/src/main/java/org/baeldung/customannotation/DataAccessAnnotationProcessor.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/customannotation/DataAccessAnnotationProcessor.java rename to spring-core-2/src/main/java/org/baeldung/customannotation/DataAccessAnnotationProcessor.java diff --git a/spring-all/src/main/java/org/baeldung/customannotation/DataAccessFieldCallback.java b/spring-core-2/src/main/java/org/baeldung/customannotation/DataAccessFieldCallback.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/customannotation/DataAccessFieldCallback.java rename to spring-core-2/src/main/java/org/baeldung/customannotation/DataAccessFieldCallback.java diff --git a/spring-all/src/main/java/org/baeldung/customannotation/GenericDAO.java b/spring-core-2/src/main/java/org/baeldung/customannotation/GenericDAO.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/customannotation/GenericDAO.java rename to spring-core-2/src/main/java/org/baeldung/customannotation/GenericDAO.java diff --git a/spring-all/src/main/java/org/baeldung/customscope/TenantBean.java b/spring-core-2/src/main/java/org/baeldung/customscope/TenantBean.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/customscope/TenantBean.java rename to spring-core-2/src/main/java/org/baeldung/customscope/TenantBean.java diff --git a/spring-all/src/main/java/org/baeldung/customscope/TenantBeanFactoryPostProcessor.java b/spring-core-2/src/main/java/org/baeldung/customscope/TenantBeanFactoryPostProcessor.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/customscope/TenantBeanFactoryPostProcessor.java rename to spring-core-2/src/main/java/org/baeldung/customscope/TenantBeanFactoryPostProcessor.java diff --git a/spring-all/src/main/java/org/baeldung/customscope/TenantBeansConfig.java b/spring-core-2/src/main/java/org/baeldung/customscope/TenantBeansConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/customscope/TenantBeansConfig.java rename to spring-core-2/src/main/java/org/baeldung/customscope/TenantBeansConfig.java diff --git a/spring-all/src/main/java/org/baeldung/customscope/TenantScope.java b/spring-core-2/src/main/java/org/baeldung/customscope/TenantScope.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/customscope/TenantScope.java rename to spring-core-2/src/main/java/org/baeldung/customscope/TenantScope.java diff --git a/spring-all/src/main/java/org/baeldung/customscope/TenantScopeConfig.java b/spring-core-2/src/main/java/org/baeldung/customscope/TenantScopeConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/customscope/TenantScopeConfig.java rename to spring-core-2/src/main/java/org/baeldung/customscope/TenantScopeConfig.java diff --git a/spring-all/src/main/java/org/baeldung/nullibility/Person.java b/spring-core-2/src/main/java/org/baeldung/nullibility/Person.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/nullibility/Person.java rename to spring-core-2/src/main/java/org/baeldung/nullibility/Person.java diff --git a/spring-all/src/main/java/org/baeldung/nullibility/package-info.java b/spring-core-2/src/main/java/org/baeldung/nullibility/package-info.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/nullibility/package-info.java rename to spring-core-2/src/main/java/org/baeldung/nullibility/package-info.java diff --git a/spring-all/src/main/java/org/baeldung/order/Average.java b/spring-core-2/src/main/java/org/baeldung/order/Average.java similarity index 95% rename from spring-all/src/main/java/org/baeldung/order/Average.java rename to spring-core-2/src/main/java/org/baeldung/order/Average.java index d1d9117fb1..3deffaf1ae 100644 --- a/spring-all/src/main/java/org/baeldung/order/Average.java +++ b/spring-core-2/src/main/java/org/baeldung/order/Average.java @@ -1,15 +1,15 @@ -package org.baeldung.order; - -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -@Component -@Order(Ordered.LOWEST_PRECEDENCE) -public class Average implements Rating { - - @Override - public int getRating() { - return 3; - } -} +package org.baeldung.order; + +import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +@Component +@Order(Ordered.LOWEST_PRECEDENCE) +public class Average implements Rating { + + @Override + public int getRating() { + return 3; + } +} diff --git a/spring-all/src/main/java/org/baeldung/order/Excellent.java b/spring-core-2/src/main/java/org/baeldung/order/Excellent.java similarity index 94% rename from spring-all/src/main/java/org/baeldung/order/Excellent.java rename to spring-core-2/src/main/java/org/baeldung/order/Excellent.java index e5f125593f..96fea4ac9b 100644 --- a/spring-all/src/main/java/org/baeldung/order/Excellent.java +++ b/spring-core-2/src/main/java/org/baeldung/order/Excellent.java @@ -1,14 +1,14 @@ -package org.baeldung.order; - -import org.springframework.stereotype.Component; -import org.springframework.core.annotation.Order; - -@Component -@Order(1) -public class Excellent implements Rating { - - @Override - public int getRating() { - return 1; - } -} +package org.baeldung.order; + +import org.springframework.stereotype.Component; +import org.springframework.core.annotation.Order; + +@Component +@Order(1) +public class Excellent implements Rating { + + @Override + public int getRating() { + return 1; + } +} diff --git a/spring-all/src/main/java/org/baeldung/order/Good.java b/spring-core-2/src/main/java/org/baeldung/order/Good.java similarity index 94% rename from spring-all/src/main/java/org/baeldung/order/Good.java rename to spring-core-2/src/main/java/org/baeldung/order/Good.java index 3dd9852cc4..4b3e268504 100644 --- a/spring-all/src/main/java/org/baeldung/order/Good.java +++ b/spring-core-2/src/main/java/org/baeldung/order/Good.java @@ -1,14 +1,14 @@ -package org.baeldung.order; - -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -@Component -@Order(2) -public class Good implements Rating { - - @Override - public int getRating() { - return 2; - } -} +package org.baeldung.order; + +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +@Component +@Order(2) +public class Good implements Rating { + + @Override + public int getRating() { + return 2; + } +} diff --git a/spring-all/src/main/java/org/baeldung/order/Rating.java b/spring-core-2/src/main/java/org/baeldung/order/Rating.java similarity index 93% rename from spring-all/src/main/java/org/baeldung/order/Rating.java rename to spring-core-2/src/main/java/org/baeldung/order/Rating.java index dd0391a3d9..10f2780522 100644 --- a/spring-all/src/main/java/org/baeldung/order/Rating.java +++ b/spring-core-2/src/main/java/org/baeldung/order/Rating.java @@ -1,6 +1,6 @@ -package org.baeldung.order; - -public interface Rating { - - int getRating(); -} +package org.baeldung.order; + +public interface Rating { + + int getRating(); +} diff --git a/spring-all/src/main/java/org/baeldung/persistence/Setup.java b/spring-core-2/src/main/java/org/baeldung/persistence/Setup.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/persistence/Setup.java rename to spring-core-2/src/main/java/org/baeldung/persistence/Setup.java diff --git a/spring-all/src/main/java/org/baeldung/primary/Config.java b/spring-core-2/src/main/java/org/baeldung/primary/Config.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/primary/Config.java rename to spring-core-2/src/main/java/org/baeldung/primary/Config.java diff --git a/spring-all/src/main/java/org/baeldung/primary/DepartmentManager.java b/spring-core-2/src/main/java/org/baeldung/primary/DepartmentManager.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/primary/DepartmentManager.java rename to spring-core-2/src/main/java/org/baeldung/primary/DepartmentManager.java diff --git a/spring-all/src/main/java/org/baeldung/primary/Employee.java b/spring-core-2/src/main/java/org/baeldung/primary/Employee.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/primary/Employee.java rename to spring-core-2/src/main/java/org/baeldung/primary/Employee.java diff --git a/spring-all/src/main/java/org/baeldung/primary/GeneralManager.java b/spring-core-2/src/main/java/org/baeldung/primary/GeneralManager.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/primary/GeneralManager.java rename to spring-core-2/src/main/java/org/baeldung/primary/GeneralManager.java diff --git a/spring-all/src/main/java/org/baeldung/primary/Manager.java b/spring-core-2/src/main/java/org/baeldung/primary/Manager.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/primary/Manager.java rename to spring-core-2/src/main/java/org/baeldung/primary/Manager.java diff --git a/spring-all/src/main/java/org/baeldung/primary/ManagerService.java b/spring-core-2/src/main/java/org/baeldung/primary/ManagerService.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/primary/ManagerService.java rename to spring-core-2/src/main/java/org/baeldung/primary/ManagerService.java diff --git a/spring-all/src/main/java/org/baeldung/primary/PrimaryApplication.java b/spring-core-2/src/main/java/org/baeldung/primary/PrimaryApplication.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/primary/PrimaryApplication.java rename to spring-core-2/src/main/java/org/baeldung/primary/PrimaryApplication.java diff --git a/spring-all/src/main/java/org/baeldung/profiles/DatasourceConfig.java b/spring-core-2/src/main/java/org/baeldung/profiles/DatasourceConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/profiles/DatasourceConfig.java rename to spring-core-2/src/main/java/org/baeldung/profiles/DatasourceConfig.java diff --git a/spring-all/src/main/java/org/baeldung/profiles/DevDatasourceConfig.java b/spring-core-2/src/main/java/org/baeldung/profiles/DevDatasourceConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/profiles/DevDatasourceConfig.java rename to spring-core-2/src/main/java/org/baeldung/profiles/DevDatasourceConfig.java diff --git a/spring-all/src/main/java/org/baeldung/profiles/ProductionDatasourceConfig.java b/spring-core-2/src/main/java/org/baeldung/profiles/ProductionDatasourceConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/profiles/ProductionDatasourceConfig.java rename to spring-core-2/src/main/java/org/baeldung/profiles/ProductionDatasourceConfig.java diff --git a/spring-all/src/main/java/org/baeldung/profiles/ProfileManager.java b/spring-core-2/src/main/java/org/baeldung/profiles/ProfileManager.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/profiles/ProfileManager.java rename to spring-core-2/src/main/java/org/baeldung/profiles/ProfileManager.java diff --git a/spring-all/src/main/java/org/baeldung/profiles/SpringProfilesConfig.java b/spring-core-2/src/main/java/org/baeldung/profiles/SpringProfilesConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/profiles/SpringProfilesConfig.java rename to spring-core-2/src/main/java/org/baeldung/profiles/SpringProfilesConfig.java diff --git a/spring-all/src/main/java/org/baeldung/sample/Bar.java b/spring-core-2/src/main/java/org/baeldung/sample/Bar.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/sample/Bar.java rename to spring-core-2/src/main/java/org/baeldung/sample/Bar.java diff --git a/spring-all/src/main/java/org/baeldung/sample/Foo.java b/spring-core-2/src/main/java/org/baeldung/sample/Foo.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/sample/Foo.java rename to spring-core-2/src/main/java/org/baeldung/sample/Foo.java diff --git a/spring-all/src/main/java/org/baeldung/sampleabstract/BallService.java b/spring-core-2/src/main/java/org/baeldung/sampleabstract/BallService.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/sampleabstract/BallService.java rename to spring-core-2/src/main/java/org/baeldung/sampleabstract/BallService.java diff --git a/spring-all/src/main/java/org/baeldung/sampleabstract/BasketballService.java b/spring-core-2/src/main/java/org/baeldung/sampleabstract/BasketballService.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/sampleabstract/BasketballService.java rename to spring-core-2/src/main/java/org/baeldung/sampleabstract/BasketballService.java diff --git a/spring-all/src/main/java/org/baeldung/sampleabstract/DemoApp.java b/spring-core-2/src/main/java/org/baeldung/sampleabstract/DemoApp.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/sampleabstract/DemoApp.java rename to spring-core-2/src/main/java/org/baeldung/sampleabstract/DemoApp.java diff --git a/spring-all/src/main/java/org/baeldung/sampleabstract/LogRepository.java b/spring-core-2/src/main/java/org/baeldung/sampleabstract/LogRepository.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/sampleabstract/LogRepository.java rename to spring-core-2/src/main/java/org/baeldung/sampleabstract/LogRepository.java diff --git a/spring-all/src/main/java/org/baeldung/sampleabstract/RuleRepository.java b/spring-core-2/src/main/java/org/baeldung/sampleabstract/RuleRepository.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/sampleabstract/RuleRepository.java rename to spring-core-2/src/main/java/org/baeldung/sampleabstract/RuleRepository.java diff --git a/spring-all/src/main/java/org/baeldung/scopes/HelloMessageGenerator.java b/spring-core-2/src/main/java/org/baeldung/scopes/HelloMessageGenerator.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/scopes/HelloMessageGenerator.java rename to spring-core-2/src/main/java/org/baeldung/scopes/HelloMessageGenerator.java diff --git a/spring-all/src/main/java/org/baeldung/scopes/Person.java b/spring-core-2/src/main/java/org/baeldung/scopes/Person.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/scopes/Person.java rename to spring-core-2/src/main/java/org/baeldung/scopes/Person.java diff --git a/spring-all/src/main/java/org/baeldung/scopes/ScopesController.java b/spring-core-2/src/main/java/org/baeldung/scopes/ScopesController.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/scopes/ScopesController.java rename to spring-core-2/src/main/java/org/baeldung/scopes/ScopesController.java diff --git a/spring-all/src/main/java/org/baeldung/spring/config/CleanupBean.java b/spring-core-2/src/main/java/org/baeldung/spring/config/CleanupBean.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring/config/CleanupBean.java rename to spring-core-2/src/main/java/org/baeldung/spring/config/CleanupBean.java diff --git a/spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java b/spring-core-2/src/main/java/org/baeldung/spring/config/CoreConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring/config/CoreConfig.java rename to spring-core-2/src/main/java/org/baeldung/spring/config/CoreConfig.java diff --git a/spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java b/spring-core-2/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java rename to spring-core-2/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java diff --git a/spring-all/src/main/java/org/baeldung/spring/config/MvcConfig.java b/spring-core-2/src/main/java/org/baeldung/spring/config/MvcConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring/config/MvcConfig.java rename to spring-core-2/src/main/java/org/baeldung/spring/config/MvcConfig.java diff --git a/spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-core-2/src/main/java/org/baeldung/spring/config/PersistenceConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java rename to spring-core-2/src/main/java/org/baeldung/spring/config/PersistenceConfig.java diff --git a/spring-core-2/src/main/java/org/baeldung/spring/config/ScopesConfig.java b/spring-core-2/src/main/java/org/baeldung/spring/config/ScopesConfig.java new file mode 100644 index 0000000000..e69de29bb2 diff --git a/spring-all/src/main/java/org/baeldung/springevents/asynchronous/AsynchronousSpringEventsConfig.java b/spring-core-2/src/main/java/org/baeldung/springevents/asynchronous/AsynchronousSpringEventsConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/springevents/asynchronous/AsynchronousSpringEventsConfig.java rename to spring-core-2/src/main/java/org/baeldung/springevents/asynchronous/AsynchronousSpringEventsConfig.java diff --git a/spring-all/src/main/java/org/baeldung/springevents/synchronous/AnnotationDrivenEventListener.java b/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/AnnotationDrivenEventListener.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/springevents/synchronous/AnnotationDrivenEventListener.java rename to spring-core-2/src/main/java/org/baeldung/springevents/synchronous/AnnotationDrivenEventListener.java diff --git a/spring-all/src/main/java/org/baeldung/springevents/synchronous/ContextRefreshedListener.java b/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/ContextRefreshedListener.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/springevents/synchronous/ContextRefreshedListener.java rename to spring-core-2/src/main/java/org/baeldung/springevents/synchronous/ContextRefreshedListener.java diff --git a/spring-all/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEvent.java b/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEvent.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEvent.java rename to spring-core-2/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEvent.java diff --git a/spring-all/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEventListener.java b/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEventListener.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEventListener.java rename to spring-core-2/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEventListener.java diff --git a/spring-all/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEventPublisher.java b/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEventPublisher.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEventPublisher.java rename to spring-core-2/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEventPublisher.java diff --git a/spring-all/src/main/java/org/baeldung/springevents/synchronous/GenericSpringAppEvent.java b/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericSpringAppEvent.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/springevents/synchronous/GenericSpringAppEvent.java rename to spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericSpringAppEvent.java diff --git a/spring-all/src/main/java/org/baeldung/springevents/synchronous/GenericSpringEvent.java b/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericSpringEvent.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/springevents/synchronous/GenericSpringEvent.java rename to spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericSpringEvent.java diff --git a/spring-all/src/main/java/org/baeldung/springevents/synchronous/GenericSpringEventListener.java b/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericSpringEventListener.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/springevents/synchronous/GenericSpringEventListener.java rename to spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericSpringEventListener.java diff --git a/spring-all/src/main/java/org/baeldung/springevents/synchronous/GenericStringSpringAppEvent.java b/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericStringSpringAppEvent.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/springevents/synchronous/GenericStringSpringAppEvent.java rename to spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericStringSpringAppEvent.java diff --git a/spring-all/src/main/java/org/baeldung/springevents/synchronous/GenericStringSpringEvent.java b/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericStringSpringEvent.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/springevents/synchronous/GenericStringSpringEvent.java rename to spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericStringSpringEvent.java diff --git a/spring-all/src/main/java/org/baeldung/springevents/synchronous/SynchronousSpringEventsConfig.java b/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/SynchronousSpringEventsConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/springevents/synchronous/SynchronousSpringEventsConfig.java rename to spring-core-2/src/main/java/org/baeldung/springevents/synchronous/SynchronousSpringEventsConfig.java diff --git a/spring-all/src/main/java/org/baeldung/startup/AllStrategiesExampleBean.java b/spring-core-2/src/main/java/org/baeldung/startup/AllStrategiesExampleBean.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/startup/AllStrategiesExampleBean.java rename to spring-core-2/src/main/java/org/baeldung/startup/AllStrategiesExampleBean.java diff --git a/spring-all/src/main/java/org/baeldung/startup/EventListenerExampleBean.java b/spring-core-2/src/main/java/org/baeldung/startup/EventListenerExampleBean.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/startup/EventListenerExampleBean.java rename to spring-core-2/src/main/java/org/baeldung/startup/EventListenerExampleBean.java diff --git a/spring-all/src/main/java/org/baeldung/startup/InitMethodExampleBean.java b/spring-core-2/src/main/java/org/baeldung/startup/InitMethodExampleBean.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/startup/InitMethodExampleBean.java rename to spring-core-2/src/main/java/org/baeldung/startup/InitMethodExampleBean.java diff --git a/spring-all/src/main/java/org/baeldung/startup/InitializingBeanExampleBean.java b/spring-core-2/src/main/java/org/baeldung/startup/InitializingBeanExampleBean.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/startup/InitializingBeanExampleBean.java rename to spring-core-2/src/main/java/org/baeldung/startup/InitializingBeanExampleBean.java diff --git a/spring-all/src/main/java/org/baeldung/startup/InvalidInitExampleBean.java b/spring-core-2/src/main/java/org/baeldung/startup/InvalidInitExampleBean.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/startup/InvalidInitExampleBean.java rename to spring-core-2/src/main/java/org/baeldung/startup/InvalidInitExampleBean.java diff --git a/spring-all/src/main/java/org/baeldung/startup/LogicInConstructorExampleBean.java b/spring-core-2/src/main/java/org/baeldung/startup/LogicInConstructorExampleBean.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/startup/LogicInConstructorExampleBean.java rename to spring-core-2/src/main/java/org/baeldung/startup/LogicInConstructorExampleBean.java diff --git a/spring-all/src/main/java/org/baeldung/startup/PostConstructExampleBean.java b/spring-core-2/src/main/java/org/baeldung/startup/PostConstructExampleBean.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/startup/PostConstructExampleBean.java rename to spring-core-2/src/main/java/org/baeldung/startup/PostConstructExampleBean.java diff --git a/spring-all/src/main/java/org/baeldung/startup/SpringStartupConfig.java b/spring-core-2/src/main/java/org/baeldung/startup/SpringStartupConfig.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/startup/SpringStartupConfig.java rename to spring-core-2/src/main/java/org/baeldung/startup/SpringStartupConfig.java diff --git a/spring-all/src/main/java/org/baeldung/startup/StartupApplicationListenerExample.java b/spring-core-2/src/main/java/org/baeldung/startup/StartupApplicationListenerExample.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/startup/StartupApplicationListenerExample.java rename to spring-core-2/src/main/java/org/baeldung/startup/StartupApplicationListenerExample.java diff --git a/spring-all/src/main/resources/application.properties b/spring-core-2/src/main/resources/application.properties similarity index 100% rename from spring-all/src/main/resources/application.properties rename to spring-core-2/src/main/resources/application.properties diff --git a/spring-core-2/src/main/resources/beanInjection-constructor.xml b/spring-core-2/src/main/resources/beanInjection-constructor.xml new file mode 100644 index 0000000000..5a2ffe767c --- /dev/null +++ b/spring-core-2/src/main/resources/beanInjection-constructor.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-core-2/src/main/resources/beanInjection-setter.xml b/spring-core-2/src/main/resources/beanInjection-setter.xml new file mode 100644 index 0000000000..0e82e3be1c --- /dev/null +++ b/spring-core-2/src/main/resources/beanInjection-setter.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/spring-all/src/main/resources/jdbc/schema.sql b/spring-core-2/src/main/resources/jdbc/schema.sql similarity index 100% rename from spring-all/src/main/resources/jdbc/schema.sql rename to spring-core-2/src/main/resources/jdbc/schema.sql diff --git a/spring-all/src/main/resources/jdbc/springJdbc-config.xml b/spring-core-2/src/main/resources/jdbc/springJdbc-config.xml similarity index 100% rename from spring-all/src/main/resources/jdbc/springJdbc-config.xml rename to spring-core-2/src/main/resources/jdbc/springJdbc-config.xml diff --git a/spring-all/src/main/resources/jdbc/test-data.sql b/spring-core-2/src/main/resources/jdbc/test-data.sql similarity index 100% rename from spring-all/src/main/resources/jdbc/test-data.sql rename to spring-core-2/src/main/resources/jdbc/test-data.sql diff --git a/spring-all/src/main/resources/log4j2.properties b/spring-core-2/src/main/resources/log4j2.properties similarity index 100% rename from spring-all/src/main/resources/log4j2.properties rename to spring-core-2/src/main/resources/log4j2.properties diff --git a/spring-all/src/main/resources/logback.xml b/spring-core-2/src/main/resources/logback.xml similarity index 74% rename from spring-all/src/main/resources/logback.xml rename to spring-core-2/src/main/resources/logback.xml index 56af2d397e..7bd5154680 100644 --- a/spring-all/src/main/resources/logback.xml +++ b/spring-core-2/src/main/resources/logback.xml @@ -7,13 +7,13 @@ - - + + - + - + \ No newline at end of file diff --git a/spring-all/src/main/resources/scopes.xml b/spring-core-2/src/main/resources/scopes.xml similarity index 58% rename from spring-all/src/main/resources/scopes.xml rename to spring-core-2/src/main/resources/scopes.xml index faecd727fa..8fdb186c28 100644 --- a/spring-all/src/main/resources/scopes.xml +++ b/spring-core-2/src/main/resources/scopes.xml @@ -1,10 +1,10 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + - + diff --git a/spring-all/src/main/resources/springProfiles-config.xml b/spring-core-2/src/main/resources/springProfiles-config.xml similarity index 66% rename from spring-all/src/main/resources/springProfiles-config.xml rename to spring-core-2/src/main/resources/springProfiles-config.xml index 5f71c02e20..985ab6ba86 100644 --- a/spring-all/src/main/resources/springProfiles-config.xml +++ b/spring-core-2/src/main/resources/springProfiles-config.xml @@ -1,6 +1,7 @@ - diff --git a/spring-all/src/main/resources/startupConfig.xml b/spring-core-2/src/main/resources/startupConfig.xml similarity index 100% rename from spring-all/src/main/resources/startupConfig.xml rename to spring-core-2/src/main/resources/startupConfig.xml diff --git a/spring-all/src/test/java/org/baeldung/autowire/sample/FooServiceIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/autowire/sample/FooServiceIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/autowire/sample/FooServiceIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/autowire/sample/FooServiceIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/customannotation/Account.java b/spring-core-2/src/test/java/org/baeldung/customannotation/Account.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/customannotation/Account.java rename to spring-core-2/src/test/java/org/baeldung/customannotation/Account.java diff --git a/spring-all/src/test/java/org/baeldung/customannotation/BeanWithGenericDAO.java b/spring-core-2/src/test/java/org/baeldung/customannotation/BeanWithGenericDAO.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/customannotation/BeanWithGenericDAO.java rename to spring-core-2/src/test/java/org/baeldung/customannotation/BeanWithGenericDAO.java diff --git a/spring-all/src/test/java/org/baeldung/customannotation/DataAccessAnnotationIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/customannotation/DataAccessAnnotationIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/customannotation/DataAccessAnnotationIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/customannotation/DataAccessAnnotationIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/customannotation/Person.java b/spring-core-2/src/test/java/org/baeldung/customannotation/Person.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/customannotation/Person.java rename to spring-core-2/src/test/java/org/baeldung/customannotation/Person.java diff --git a/spring-all/src/test/java/org/baeldung/customscope/TenantScopeIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/customscope/TenantScopeIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/customscope/TenantScopeIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/customscope/TenantScopeIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/order/RatingRetrieverUnitTest.java b/spring-core-2/src/test/java/org/baeldung/order/RatingRetrieverUnitTest.java similarity index 97% rename from spring-all/src/test/java/org/baeldung/order/RatingRetrieverUnitTest.java rename to spring-core-2/src/test/java/org/baeldung/order/RatingRetrieverUnitTest.java index a624f757fc..96993ccd7c 100644 --- a/spring-all/src/test/java/org/baeldung/order/RatingRetrieverUnitTest.java +++ b/spring-core-2/src/test/java/org/baeldung/order/RatingRetrieverUnitTest.java @@ -1,37 +1,37 @@ -package org.baeldung.order; - - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import java.util.List; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(loader = AnnotationConfigContextLoader.class) -public class RatingRetrieverUnitTest { - - @Configuration - @ComponentScan(basePackages = {"org.baeldung.order"}) - static class ContextConfiguration {} - - @Autowired - private List ratings; - - @Test - public void givenOrderOnComponents_whenInjected_thenAutowireByOrderValue() { - assertThat(ratings.get(0).getRating(), is(equalTo(1))); - assertThat(ratings.get(1).getRating(), is(equalTo(2))); - assertThat(ratings.get(2).getRating(), is(equalTo(3))); - } - -} +package org.baeldung.order; + + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(loader = AnnotationConfigContextLoader.class) +public class RatingRetrieverUnitTest { + + @Configuration + @ComponentScan(basePackages = {"org.baeldung.order"}) + static class ContextConfiguration {} + + @Autowired + private List ratings; + + @Test + public void givenOrderOnComponents_whenInjected_thenAutowireByOrderValue() { + assertThat(ratings.get(0).getRating(), is(equalTo(1))); + assertThat(ratings.get(1).getRating(), is(equalTo(2))); + assertThat(ratings.get(2).getRating(), is(equalTo(3))); + } + +} diff --git a/spring-all/src/test/java/org/baeldung/profiles/DevProfileWithAnnotationIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/profiles/DevProfileWithAnnotationIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/profiles/DevProfileWithAnnotationIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/profiles/DevProfileWithAnnotationIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/profiles/ProductionProfileWithAnnotationIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/profiles/ProductionProfileWithAnnotationIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/profiles/ProductionProfileWithAnnotationIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/profiles/ProductionProfileWithAnnotationIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/profiles/SpringProfilesWithMavenPropertiesIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/profiles/SpringProfilesWithMavenPropertiesIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/profiles/SpringProfilesWithMavenPropertiesIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/profiles/SpringProfilesWithMavenPropertiesIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/profiles/SpringProfilesWithXMLIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/profiles/SpringProfilesWithXMLIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/profiles/SpringProfilesWithXMLIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/profiles/SpringProfilesWithXMLIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/scopes/ScopesIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/scopes/ScopesIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/scopes/ScopesIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/scopes/ScopesIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/springevents/synchronous/ContextRefreshedListenerIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/springevents/synchronous/ContextRefreshedListenerIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/springevents/synchronous/ContextRefreshedListenerIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/springevents/synchronous/ContextRefreshedListenerIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/springevents/synchronous/GenericAppEventListenerIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/springevents/synchronous/GenericAppEventListenerIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/springevents/synchronous/GenericAppEventListenerIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/springevents/synchronous/GenericAppEventListenerIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/springevents/synchronous/SynchronousCustomSpringEventsIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/springevents/synchronous/SynchronousCustomSpringEventsIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/springevents/synchronous/SynchronousCustomSpringEventsIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/springevents/synchronous/SynchronousCustomSpringEventsIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/startup/SpringStartupIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/startup/SpringStartupIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/startup/SpringStartupIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/startup/SpringStartupIntegrationTest.java diff --git a/spring-all/src/test/java/org/baeldung/startup/SpringStartupXMLConfigIntegrationTest.java b/spring-core-2/src/test/java/org/baeldung/startup/SpringStartupXMLConfigIntegrationTest.java similarity index 100% rename from spring-all/src/test/java/org/baeldung/startup/SpringStartupXMLConfigIntegrationTest.java rename to spring-core-2/src/test/java/org/baeldung/startup/SpringStartupXMLConfigIntegrationTest.java diff --git a/spring-all/src/test/resources/.gitignore b/spring-core-2/src/test/resources/.gitignore similarity index 100% rename from spring-all/src/test/resources/.gitignore rename to spring-core-2/src/test/resources/.gitignore diff --git a/spring-core-3/README.md b/spring-core-3/README.md new file mode 100644 index 0000000000..7ca95ae78e --- /dev/null +++ b/spring-core-3/README.md @@ -0,0 +1,7 @@ +## Relevant Articles: + +- [Understanding getBean() in Spring](https://www.baeldung.com/spring-getbean) +- [Exploring the Spring BeanFactory API](https://www.baeldung.com/spring-beanfactory) +- [How to use the Spring FactoryBean?](https://www.baeldung.com/spring-factorybean) +- [Spring – Injecting Collections](https://www.baeldung.com/spring-injecting-collections) +- More articles: [[<-- prev]](/spring-core-2) \ No newline at end of file diff --git a/spring-core-3/pom.xml b/spring-core-3/pom.xml new file mode 100644 index 0000000000..cd82f23320 --- /dev/null +++ b/spring-core-3/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + spring-core-3 + spring-core-3 + + + com.baeldung + parent-spring-5 + 0.0.1-SNAPSHOT + ../parent-spring-5 + + + + + org.springframework + spring-beans + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + org.springframework + spring-core + ${spring.version} + + + javax.annotation + javax.annotation-api + ${annotation-api.version} + + + org.springframework + spring-test + ${spring.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven.surefire.version} + + + + + + 2.22.1 + 1.3.2 + + + \ No newline at end of file diff --git a/spring-core-2/src/main/java/com/baeldung/beanfactory/Employee.java b/spring-core-3/src/main/java/com/baeldung/beanfactory/Employee.java similarity index 100% rename from spring-core-2/src/main/java/com/baeldung/beanfactory/Employee.java rename to spring-core-3/src/main/java/com/baeldung/beanfactory/Employee.java diff --git a/spring-core-2/src/main/java/com/baeldung/collection/BaeldungBean.java b/spring-core-3/src/main/java/com/baeldung/collection/BaeldungBean.java similarity index 100% rename from spring-core-2/src/main/java/com/baeldung/collection/BaeldungBean.java rename to spring-core-3/src/main/java/com/baeldung/collection/BaeldungBean.java diff --git a/spring-core-2/src/main/java/com/baeldung/collection/CollectionConfig.java b/spring-core-3/src/main/java/com/baeldung/collection/CollectionConfig.java similarity index 100% rename from spring-core-2/src/main/java/com/baeldung/collection/CollectionConfig.java rename to spring-core-3/src/main/java/com/baeldung/collection/CollectionConfig.java diff --git a/spring-core-2/src/main/java/com/baeldung/collection/CollectionInjectionDemo.java b/spring-core-3/src/main/java/com/baeldung/collection/CollectionInjectionDemo.java similarity index 100% rename from spring-core-2/src/main/java/com/baeldung/collection/CollectionInjectionDemo.java rename to spring-core-3/src/main/java/com/baeldung/collection/CollectionInjectionDemo.java diff --git a/spring-core-2/src/main/java/com/baeldung/collection/CollectionsBean.java b/spring-core-3/src/main/java/com/baeldung/collection/CollectionsBean.java similarity index 100% rename from spring-core-2/src/main/java/com/baeldung/collection/CollectionsBean.java rename to spring-core-3/src/main/java/com/baeldung/collection/CollectionsBean.java diff --git a/spring-core-2/src/main/java/com/baeldung/factorybean/FactoryBeanAppConfig.java b/spring-core-3/src/main/java/com/baeldung/factorybean/FactoryBeanAppConfig.java similarity index 100% rename from spring-core-2/src/main/java/com/baeldung/factorybean/FactoryBeanAppConfig.java rename to spring-core-3/src/main/java/com/baeldung/factorybean/FactoryBeanAppConfig.java diff --git a/spring-core-2/src/main/java/com/baeldung/factorybean/NonSingleToolFactory.java b/spring-core-3/src/main/java/com/baeldung/factorybean/NonSingleToolFactory.java similarity index 100% rename from spring-core-2/src/main/java/com/baeldung/factorybean/NonSingleToolFactory.java rename to spring-core-3/src/main/java/com/baeldung/factorybean/NonSingleToolFactory.java diff --git a/spring-core-2/src/main/java/com/baeldung/factorybean/README.md b/spring-core-3/src/main/java/com/baeldung/factorybean/README.md similarity index 100% rename from spring-core-2/src/main/java/com/baeldung/factorybean/README.md rename to spring-core-3/src/main/java/com/baeldung/factorybean/README.md diff --git a/spring-core-2/src/main/java/com/baeldung/factorybean/SingleToolFactory.java b/spring-core-3/src/main/java/com/baeldung/factorybean/SingleToolFactory.java similarity index 100% rename from spring-core-2/src/main/java/com/baeldung/factorybean/SingleToolFactory.java rename to spring-core-3/src/main/java/com/baeldung/factorybean/SingleToolFactory.java diff --git a/spring-core-2/src/main/java/com/baeldung/factorybean/Tool.java b/spring-core-3/src/main/java/com/baeldung/factorybean/Tool.java similarity index 100% rename from spring-core-2/src/main/java/com/baeldung/factorybean/Tool.java rename to spring-core-3/src/main/java/com/baeldung/factorybean/Tool.java diff --git a/spring-core-2/src/main/java/com/baeldung/factorybean/ToolFactory.java b/spring-core-3/src/main/java/com/baeldung/factorybean/ToolFactory.java similarity index 100% rename from spring-core-2/src/main/java/com/baeldung/factorybean/ToolFactory.java rename to spring-core-3/src/main/java/com/baeldung/factorybean/ToolFactory.java diff --git a/spring-core-2/src/main/java/com/baeldung/getbean/AnnotationConfig.java b/spring-core-3/src/main/java/com/baeldung/getbean/AnnotationConfig.java similarity index 100% rename from spring-core-2/src/main/java/com/baeldung/getbean/AnnotationConfig.java rename to spring-core-3/src/main/java/com/baeldung/getbean/AnnotationConfig.java diff --git a/spring-core-2/src/main/java/com/baeldung/getbean/Lion.java b/spring-core-3/src/main/java/com/baeldung/getbean/Lion.java similarity index 100% rename from spring-core-2/src/main/java/com/baeldung/getbean/Lion.java rename to spring-core-3/src/main/java/com/baeldung/getbean/Lion.java diff --git a/spring-core-2/src/main/java/com/baeldung/getbean/Tiger.java b/spring-core-3/src/main/java/com/baeldung/getbean/Tiger.java similarity index 100% rename from spring-core-2/src/main/java/com/baeldung/getbean/Tiger.java rename to spring-core-3/src/main/java/com/baeldung/getbean/Tiger.java diff --git a/spring-core-2/src/main/resources/factorybean-abstract-spring-ctx.xml b/spring-core-3/src/main/resources/factorybean-abstract-spring-ctx.xml similarity index 100% rename from spring-core-2/src/main/resources/factorybean-abstract-spring-ctx.xml rename to spring-core-3/src/main/resources/factorybean-abstract-spring-ctx.xml diff --git a/spring-core-2/src/main/resources/factorybean-spring-ctx.xml b/spring-core-3/src/main/resources/factorybean-spring-ctx.xml similarity index 100% rename from spring-core-2/src/main/resources/factorybean-spring-ctx.xml rename to spring-core-3/src/main/resources/factorybean-spring-ctx.xml diff --git a/spring-core-2/src/test/java/com/baeldung/beanfactory/BeanFactoryWithClassPathResourceIntegrationTest.java b/spring-core-3/src/test/java/com/baeldung/beanfactory/BeanFactoryWithClassPathResourceIntegrationTest.java similarity index 100% rename from spring-core-2/src/test/java/com/baeldung/beanfactory/BeanFactoryWithClassPathResourceIntegrationTest.java rename to spring-core-3/src/test/java/com/baeldung/beanfactory/BeanFactoryWithClassPathResourceIntegrationTest.java diff --git a/spring-core-2/src/test/java/com/baeldung/beanfactory/README.md b/spring-core-3/src/test/java/com/baeldung/beanfactory/README.md similarity index 100% rename from spring-core-2/src/test/java/com/baeldung/beanfactory/README.md rename to spring-core-3/src/test/java/com/baeldung/beanfactory/README.md diff --git a/spring-core-2/src/test/java/com/baeldung/factorybean/AbstractFactoryBeanIntegrationTest.java b/spring-core-3/src/test/java/com/baeldung/factorybean/AbstractFactoryBeanIntegrationTest.java similarity index 100% rename from spring-core-2/src/test/java/com/baeldung/factorybean/AbstractFactoryBeanIntegrationTest.java rename to spring-core-3/src/test/java/com/baeldung/factorybean/AbstractFactoryBeanIntegrationTest.java diff --git a/spring-core-2/src/test/java/com/baeldung/factorybean/FactoryBeanJavaConfigIntegrationTest.java b/spring-core-3/src/test/java/com/baeldung/factorybean/FactoryBeanJavaConfigIntegrationTest.java similarity index 100% rename from spring-core-2/src/test/java/com/baeldung/factorybean/FactoryBeanJavaConfigIntegrationTest.java rename to spring-core-3/src/test/java/com/baeldung/factorybean/FactoryBeanJavaConfigIntegrationTest.java diff --git a/spring-core-2/src/test/java/com/baeldung/factorybean/FactoryBeanXmlConfigIntegrationTest.java b/spring-core-3/src/test/java/com/baeldung/factorybean/FactoryBeanXmlConfigIntegrationTest.java similarity index 100% rename from spring-core-2/src/test/java/com/baeldung/factorybean/FactoryBeanXmlConfigIntegrationTest.java rename to spring-core-3/src/test/java/com/baeldung/factorybean/FactoryBeanXmlConfigIntegrationTest.java diff --git a/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameAndTypeUnitTest.java b/spring-core-3/src/test/java/com/baeldung/getbean/GetBeanByNameAndTypeUnitTest.java similarity index 100% rename from spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameAndTypeUnitTest.java rename to spring-core-3/src/test/java/com/baeldung/getbean/GetBeanByNameAndTypeUnitTest.java diff --git a/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameUnitTest.java b/spring-core-3/src/test/java/com/baeldung/getbean/GetBeanByNameUnitTest.java similarity index 100% rename from spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameUnitTest.java rename to spring-core-3/src/test/java/com/baeldung/getbean/GetBeanByNameUnitTest.java diff --git a/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameWithConstructorParametersUnitTest.java b/spring-core-3/src/test/java/com/baeldung/getbean/GetBeanByNameWithConstructorParametersUnitTest.java similarity index 100% rename from spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameWithConstructorParametersUnitTest.java rename to spring-core-3/src/test/java/com/baeldung/getbean/GetBeanByNameWithConstructorParametersUnitTest.java diff --git a/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByTypeUnitTest.java b/spring-core-3/src/test/java/com/baeldung/getbean/GetBeanByTypeUnitTest.java similarity index 100% rename from spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByTypeUnitTest.java rename to spring-core-3/src/test/java/com/baeldung/getbean/GetBeanByTypeUnitTest.java diff --git a/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByTypeWithConstructorParametersUnitTest.java b/spring-core-3/src/test/java/com/baeldung/getbean/GetBeanByTypeWithConstructorParametersUnitTest.java similarity index 100% rename from spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByTypeWithConstructorParametersUnitTest.java rename to spring-core-3/src/test/java/com/baeldung/getbean/GetBeanByTypeWithConstructorParametersUnitTest.java diff --git a/spring-core-2/src/test/resources/beanfactory-example.xml b/spring-core-3/src/test/resources/beanfactory-example.xml similarity index 100% rename from spring-core-2/src/test/resources/beanfactory-example.xml rename to spring-core-3/src/test/resources/beanfactory-example.xml diff --git a/spring-mvc-basics-2/.gitignore b/spring-mvc-basics-2/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/spring-mvc-basics-2/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-mvc-basics-2/README.md b/spring-mvc-basics-2/README.md new file mode 100644 index 0000000000..8cf753bbdc --- /dev/null +++ b/spring-mvc-basics-2/README.md @@ -0,0 +1,11 @@ +========= + +## Spring MVC Basics with Java Configuration Example Project + +### The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring + +### Relevant Articles: +- [Quick Guide to Spring Controllers](http://www.baeldung.com/spring-controllers)- [The Spring @Controller and @RestController Annotations](http://www.baeldung.com/spring-controller-vs-restcontroller) +- [Model, ModelMap, and ModelView in Spring MVC](http://www.baeldung.com/spring-mvc-model-model-map-model-view) +- [Spring Web Contexts](http://www.baeldung.com/spring-web-contexts) \ No newline at end of file diff --git a/spring-mvc-basics-2/pom.xml b/spring-mvc-basics-2/pom.xml new file mode 100644 index 0000000000..706459a268 --- /dev/null +++ b/spring-mvc-basics-2/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + spring-mvc-basics-2 + spring-mvc-basics-2 + war + + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + + + com.fasterxml.jackson.core + jackson-databind + + + org.springframework + spring-web + + + javax.servlet + javax.servlet-api + provided + + + org.springframework + spring-webmvc + + + + \ No newline at end of file diff --git a/spring-all/src/main/java/com/baeldung/contexts/Greeting.java b/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/Greeting.java similarity index 100% rename from spring-all/src/main/java/com/baeldung/contexts/Greeting.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/contexts/Greeting.java diff --git a/spring-all/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationAndServletInitializer.java b/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationAndServletInitializer.java similarity index 94% rename from spring-all/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationAndServletInitializer.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationAndServletInitializer.java index 318dc5ea65..1dffad637a 100644 --- a/spring-all/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationAndServletInitializer.java +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationAndServletInitializer.java @@ -2,7 +2,6 @@ package com.baeldung.contexts.config; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer; public class AnnotationsBasedApplicationAndServletInitializer //extends AbstractDispatcherServletInitializer { diff --git a/spring-all/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationInitializer.java b/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationInitializer.java similarity index 89% rename from spring-all/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationInitializer.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationInitializer.java index b685d2fa83..ffa80d58bf 100644 --- a/spring-all/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationInitializer.java +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationInitializer.java @@ -1,6 +1,5 @@ package com.baeldung.contexts.config; -import org.springframework.web.context.AbstractContextLoaderInitializer; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; diff --git a/spring-all/src/main/java/com/baeldung/contexts/config/ApplicationInitializer.java b/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/ApplicationInitializer.java similarity index 100% rename from spring-all/src/main/java/com/baeldung/contexts/config/ApplicationInitializer.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/ApplicationInitializer.java diff --git a/spring-all/src/main/java/com/baeldung/contexts/config/NormalWebAppConfig.java b/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/NormalWebAppConfig.java similarity index 100% rename from spring-all/src/main/java/com/baeldung/contexts/config/NormalWebAppConfig.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/NormalWebAppConfig.java diff --git a/spring-all/src/main/java/com/baeldung/contexts/config/RootApplicationConfig.java b/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/RootApplicationConfig.java similarity index 100% rename from spring-all/src/main/java/com/baeldung/contexts/config/RootApplicationConfig.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/RootApplicationConfig.java diff --git a/spring-all/src/main/java/com/baeldung/contexts/config/SecureAnnotationsBasedApplicationAndServletInitializer.java b/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/SecureAnnotationsBasedApplicationAndServletInitializer.java similarity index 92% rename from spring-all/src/main/java/com/baeldung/contexts/config/SecureAnnotationsBasedApplicationAndServletInitializer.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/SecureAnnotationsBasedApplicationAndServletInitializer.java index d74d4a6c63..580e86d2b5 100644 --- a/spring-all/src/main/java/com/baeldung/contexts/config/SecureAnnotationsBasedApplicationAndServletInitializer.java +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/SecureAnnotationsBasedApplicationAndServletInitializer.java @@ -2,7 +2,6 @@ package com.baeldung.contexts.config; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer; public class SecureAnnotationsBasedApplicationAndServletInitializer// extends AbstractDispatcherServletInitializer { diff --git a/spring-all/src/main/java/com/baeldung/contexts/config/SecureWebAppConfig.java b/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/SecureWebAppConfig.java similarity index 100% rename from spring-all/src/main/java/com/baeldung/contexts/config/SecureWebAppConfig.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/SecureWebAppConfig.java diff --git a/spring-all/src/main/java/com/baeldung/contexts/normal/HelloWorldController.java b/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/normal/HelloWorldController.java similarity index 100% rename from spring-all/src/main/java/com/baeldung/contexts/normal/HelloWorldController.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/contexts/normal/HelloWorldController.java diff --git a/spring-all/src/main/java/com/baeldung/contexts/secure/HelloWorldSecureController.java b/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/secure/HelloWorldSecureController.java similarity index 100% rename from spring-all/src/main/java/com/baeldung/contexts/secure/HelloWorldSecureController.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/contexts/secure/HelloWorldSecureController.java diff --git a/spring-all/src/main/java/com/baeldung/contexts/services/ApplicationContextUtilService.java b/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/services/ApplicationContextUtilService.java similarity index 100% rename from spring-all/src/main/java/com/baeldung/contexts/services/ApplicationContextUtilService.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/contexts/services/ApplicationContextUtilService.java diff --git a/spring-all/src/main/java/com/baeldung/contexts/services/GreeterService.java b/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/services/GreeterService.java similarity index 100% rename from spring-all/src/main/java/com/baeldung/contexts/services/GreeterService.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/contexts/services/GreeterService.java diff --git a/spring-all/src/main/java/org/baeldung/controller/config/StudentControllerConfig.java b/spring-mvc-basics-2/src/main/java/org/baeldung/controller/config/StudentControllerConfig.java similarity index 77% rename from spring-all/src/main/java/org/baeldung/controller/config/StudentControllerConfig.java rename to spring-mvc-basics-2/src/main/java/org/baeldung/controller/config/StudentControllerConfig.java index 85305e057f..218418ecc8 100644 --- a/spring-all/src/main/java/org/baeldung/controller/config/StudentControllerConfig.java +++ b/spring-mvc-basics-2/src/main/java/org/baeldung/controller/config/StudentControllerConfig.java @@ -1,32 +1,28 @@ -package org.baeldung.controller.config; - -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletRegistration; - -import org.springframework.context.support.GenericApplicationContext; -import org.springframework.web.WebApplicationInitializer; -import org.springframework.web.context.ContextLoaderListener; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.web.context.support.GenericWebApplicationContext; -import org.springframework.web.servlet.DispatcherServlet; - -public class StudentControllerConfig //implements WebApplicationInitializer -{ - - //uncomment to run the student controller example - //@Override - public void onStartup(ServletContext sc) throws ServletException { - AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); - root.register(WebConfig.class); - root.setServletContext(sc); - sc.addListener(new ContextLoaderListener(root)); - - DispatcherServlet dv = new DispatcherServlet(root); - - ServletRegistration.Dynamic appServlet = sc.addServlet("test-mvc", dv); - appServlet.setLoadOnStartup(1); - appServlet.addMapping("/test/*"); - } -} +package org.baeldung.controller.config; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRegistration; + +import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import org.springframework.web.servlet.DispatcherServlet; + +public class StudentControllerConfig //implements WebApplicationInitializer +{ + + //uncomment to run the student controller example + //@Override + public void onStartup(ServletContext sc) throws ServletException { + AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); + root.register(WebConfig.class); + root.setServletContext(sc); + sc.addListener(new ContextLoaderListener(root)); + + DispatcherServlet dv = new DispatcherServlet(root); + + ServletRegistration.Dynamic appServlet = sc.addServlet("test-mvc", dv); + appServlet.setLoadOnStartup(1); + appServlet.addMapping("/test/*"); + } +} diff --git a/spring-all/src/main/java/org/baeldung/controller/config/WebConfig.java b/spring-mvc-basics-2/src/main/java/org/baeldung/controller/config/WebConfig.java similarity index 97% rename from spring-all/src/main/java/org/baeldung/controller/config/WebConfig.java rename to spring-mvc-basics-2/src/main/java/org/baeldung/controller/config/WebConfig.java index a17210f3b8..485c1d9032 100644 --- a/spring-all/src/main/java/org/baeldung/controller/config/WebConfig.java +++ b/spring-mvc-basics-2/src/main/java/org/baeldung/controller/config/WebConfig.java @@ -1,28 +1,28 @@ -package org.baeldung.controller.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.view.InternalResourceViewResolver; - -@Configuration -@EnableWebMvc -@ComponentScan(basePackages = { "org.baeldung.controller.controller", "org.baeldung.controller.config" }) -public class WebConfig implements WebMvcConfigurer { - @Override - public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { - configurer.enable(); - } - - @Bean - public ViewResolver viewResolver() { - InternalResourceViewResolver bean = new InternalResourceViewResolver(); - bean.setPrefix("/WEB-INF/"); - bean.setSuffix(".jsp"); - return bean; - } +package org.baeldung.controller.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.view.InternalResourceViewResolver; + +@Configuration +@EnableWebMvc +@ComponentScan(basePackages = { "org.baeldung.controller.controller", "org.baeldung.controller.config" }) +public class WebConfig implements WebMvcConfigurer { + @Override + public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { + configurer.enable(); + } + + @Bean + public ViewResolver viewResolver() { + InternalResourceViewResolver bean = new InternalResourceViewResolver(); + bean.setPrefix("/WEB-INF/"); + bean.setSuffix(".jsp"); + return bean; + } } \ No newline at end of file diff --git a/spring-all/src/main/java/org/baeldung/controller/controller/PassParametersController.java b/spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/PassParametersController.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/controller/controller/PassParametersController.java rename to spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/PassParametersController.java diff --git a/spring-all/src/main/java/org/baeldung/controller/controller/RestAnnotatedController.java b/spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/RestAnnotatedController.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/controller/controller/RestAnnotatedController.java rename to spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/RestAnnotatedController.java diff --git a/spring-all/src/main/java/org/baeldung/controller/controller/RestController.java b/spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/RestController.java similarity index 86% rename from spring-all/src/main/java/org/baeldung/controller/controller/RestController.java rename to spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/RestController.java index 4b38b4dd34..4e5d1d9e17 100644 --- a/spring-all/src/main/java/org/baeldung/controller/controller/RestController.java +++ b/spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/RestController.java @@ -10,7 +10,8 @@ import org.springframework.web.bind.annotation.ResponseBody; public class RestController { @GetMapping(value = "/student/{studentId}") - public @ResponseBody Student getTestData(@PathVariable Integer studentId) { + public @ResponseBody + Student getTestData(@PathVariable Integer studentId) { Student student = new Student(); student.setName("Peter"); student.setId(studentId); diff --git a/spring-all/src/main/java/org/baeldung/controller/controller/TestController.java b/spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/TestController.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/controller/controller/TestController.java rename to spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/TestController.java diff --git a/spring-all/src/main/java/org/baeldung/controller/student/Student.java b/spring-mvc-basics-2/src/main/java/org/baeldung/controller/student/Student.java similarity index 100% rename from spring-all/src/main/java/org/baeldung/controller/student/Student.java rename to spring-mvc-basics-2/src/main/java/org/baeldung/controller/student/Student.java diff --git a/spring-mvc-basics-2/src/main/resources/application.properties b/spring-mvc-basics-2/src/main/resources/application.properties new file mode 100644 index 0000000000..709574239b --- /dev/null +++ b/spring-mvc-basics-2/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.main.allow-bean-definition-overriding=true \ No newline at end of file diff --git a/spring-mvc-basics-2/src/main/resources/logback.xml b/spring-mvc-basics-2/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/spring-mvc-basics-2/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/spring-mvc-basics-2/src/main/resources/test-mvc.xml b/spring-mvc-basics-2/src/main/resources/test-mvc.xml new file mode 100644 index 0000000000..8013170379 --- /dev/null +++ b/spring-mvc-basics-2/src/main/resources/test-mvc.xml @@ -0,0 +1,24 @@ + + + + + + + + /WEB-INF/ + + + .jsp + + + \ No newline at end of file diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/greeting.xml b/spring-mvc-basics-2/src/main/webapp/WEB-INF/greeting.xml new file mode 100644 index 0000000000..1ad5484d80 --- /dev/null +++ b/spring-mvc-basics-2/src/main/webapp/WEB-INF/greeting.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/index.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/index.jsp similarity index 100% rename from spring-all/src/main/webapp/WEB-INF/index.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/index.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/normal-webapp-servlet.xml b/spring-mvc-basics-2/src/main/webapp/WEB-INF/normal-webapp-servlet.xml new file mode 100644 index 0000000000..8addbe3cf3 --- /dev/null +++ b/spring-mvc-basics-2/src/main/webapp/WEB-INF/normal-webapp-servlet.xml @@ -0,0 +1,16 @@ + + + + + + + + + + \ No newline at end of file diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/rootApplicationContext.xml b/spring-mvc-basics-2/src/main/webapp/WEB-INF/rootApplicationContext.xml new file mode 100644 index 0000000000..12e5d8f161 --- /dev/null +++ b/spring-mvc-basics-2/src/main/webapp/WEB-INF/rootApplicationContext.xml @@ -0,0 +1,14 @@ + + + + + + + + \ No newline at end of file diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/secure-webapp-servlet.xml b/spring-mvc-basics-2/src/main/webapp/WEB-INF/secure-webapp-servlet.xml new file mode 100644 index 0000000000..86797ad081 --- /dev/null +++ b/spring-mvc-basics-2/src/main/webapp/WEB-INF/secure-webapp-servlet.xml @@ -0,0 +1,16 @@ + + + + + + + + + + \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/secure/view/welcome.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/secure/view/welcome.jsp similarity index 100% rename from spring-all/src/main/webapp/WEB-INF/secure/view/welcome.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/secure/view/welcome.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/view/sample.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/view/sample.jsp new file mode 100644 index 0000000000..4c64bf97f2 --- /dev/null +++ b/spring-mvc-basics-2/src/main/webapp/WEB-INF/view/sample.jsp @@ -0,0 +1,7 @@ + + + + +

This is the body of the sample view

+ + \ No newline at end of file diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/view/scopesExample.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/view/scopesExample.jsp new file mode 100644 index 0000000000..e9abcf194c --- /dev/null +++ b/spring-mvc-basics-2/src/main/webapp/WEB-INF/view/scopesExample.jsp @@ -0,0 +1,10 @@ + + + + +

Bean Scopes Examples

+
Previous Message: ${previousMessage } +
Current Message: ${currentMessage } +
+ + \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/view/viewPage.html b/spring-mvc-basics-2/src/main/webapp/WEB-INF/view/viewPage.html similarity index 100% rename from spring-all/src/main/webapp/WEB-INF/view/viewPage.html rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/view/viewPage.html diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/view/welcome.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/view/welcome.jsp new file mode 100644 index 0000000000..4eda3c58e2 --- /dev/null +++ b/spring-mvc-basics-2/src/main/webapp/WEB-INF/view/welcome.jsp @@ -0,0 +1,11 @@ + + + Spring Web Contexts + + +
+
+ Normal Web Application : ${message} +
+ + \ No newline at end of file diff --git a/spring-all/src/main/webapp/WEB-INF/web-old.xml b/spring-mvc-basics-2/src/main/webapp/WEB-INF/web-old.xml similarity index 94% rename from spring-all/src/main/webapp/WEB-INF/web-old.xml rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/web-old.xml index 42020e75c4..03322279e2 100644 --- a/spring-all/src/main/webapp/WEB-INF/web-old.xml +++ b/spring-mvc-basics-2/src/main/webapp/WEB-INF/web-old.xml @@ -15,10 +15,10 @@ org.springframework.web.context.ContextLoaderListener --> - + - + - +