From 53474daeaa67450c550f87519c092ecd77d5ae54 Mon Sep 17 00:00:00 2001 From: Sampada <46674082+sampada07@users.noreply.github.com> Date: Wed, 23 Sep 2020 23:34:51 +0530 Subject: [PATCH] JAVA-2421: Merge spring-ehcache module into spring-caching module (#10072) * JAVA-2421: Moved 1 article from spring-ehcache to spring-caching * JAVA-2421: Removed module spring-ehcache * JAVA-2421: Removed module spring-ehcache from main pom --- pom.xml | 2 - spring-caching/README.md | 1 + spring-caching/pom.xml | 4 + .../com/baeldung/cachetest/Application.java | 0 .../cachetest/config/CacheConfig.java | 0 .../cachetest/config/CacheEventLogger.java | 0 .../cachetest/rest/NumberController.java | 0 .../cachetest/service/NumberService.java | 0 .../springdatacaching/model/Book.java | 4 +- .../src/main/resources/application.properties | 5 +- .../src/main/resources/ehcache.xml | 23 +++++ spring-ehcache/.gitignore | 13 --- spring-ehcache/README.md | 8 -- spring-ehcache/checkstyle.xml | 11 --- spring-ehcache/pom.xml | 87 ------------------- .../src/main/resources/application.properties | 1 - 16 files changed, 35 insertions(+), 124 deletions(-) rename {spring-ehcache => spring-caching}/src/main/java/com/baeldung/cachetest/Application.java (100%) rename {spring-ehcache => spring-caching}/src/main/java/com/baeldung/cachetest/config/CacheConfig.java (100%) rename {spring-ehcache => spring-caching}/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java (100%) rename {spring-ehcache => spring-caching}/src/main/java/com/baeldung/cachetest/rest/NumberController.java (100%) rename {spring-ehcache => spring-caching}/src/main/java/com/baeldung/cachetest/service/NumberService.java (100%) rename {spring-ehcache => spring-caching}/src/main/resources/ehcache.xml (58%) delete mode 100644 spring-ehcache/.gitignore delete mode 100644 spring-ehcache/README.md delete mode 100644 spring-ehcache/checkstyle.xml delete mode 100644 spring-ehcache/pom.xml delete mode 100644 spring-ehcache/src/main/resources/application.properties diff --git a/pom.xml b/pom.xml index 9fd8f65a61..6553716d63 100644 --- a/pom.xml +++ b/pom.xml @@ -651,7 +651,6 @@ spring-dispatcher-servlet spring-drools - spring-ehcache spring-ejb spring-exceptions @@ -1152,7 +1151,6 @@ spring-dispatcher-servlet spring-drools - spring-ehcache spring-ejb spring-exceptions diff --git a/spring-caching/README.md b/spring-caching/README.md index 705d998b1e..e10d6080e8 100644 --- a/spring-caching/README.md +++ b/spring-caching/README.md @@ -5,3 +5,4 @@ - [Cache Eviction in Spring Boot](https://www.baeldung.com/spring-boot-evict-cache) - [Using Multiple Cache Managers in Spring](https://www.baeldung.com/spring-multiple-cache-managers) - [Testing @Cacheable on Spring Data Repositories](https://www.baeldung.com/spring-data-testing-cacheable) +- [Spring Boot Ehcache Example](https://www.baeldung.com/spring-boot-ehcache) diff --git a/spring-caching/pom.xml b/spring-caching/pom.xml index b13755dafd..f58be35a76 100644 --- a/spring-caching/pom.xml +++ b/spring-caching/pom.xml @@ -36,6 +36,10 @@ org.springframework spring-webmvc + + javax.cache + cache-api + org.ehcache ehcache diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/Application.java b/spring-caching/src/main/java/com/baeldung/cachetest/Application.java similarity index 100% rename from spring-ehcache/src/main/java/com/baeldung/cachetest/Application.java rename to spring-caching/src/main/java/com/baeldung/cachetest/Application.java diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheConfig.java b/spring-caching/src/main/java/com/baeldung/cachetest/config/CacheConfig.java similarity index 100% rename from spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheConfig.java rename to spring-caching/src/main/java/com/baeldung/cachetest/config/CacheConfig.java diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java b/spring-caching/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java similarity index 100% rename from spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java rename to spring-caching/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/rest/NumberController.java b/spring-caching/src/main/java/com/baeldung/cachetest/rest/NumberController.java similarity index 100% rename from spring-ehcache/src/main/java/com/baeldung/cachetest/rest/NumberController.java rename to spring-caching/src/main/java/com/baeldung/cachetest/rest/NumberController.java diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/service/NumberService.java b/spring-caching/src/main/java/com/baeldung/cachetest/service/NumberService.java similarity index 100% rename from spring-ehcache/src/main/java/com/baeldung/cachetest/service/NumberService.java rename to spring-caching/src/main/java/com/baeldung/cachetest/service/NumberService.java diff --git a/spring-caching/src/main/java/com/baeldung/springdatacaching/model/Book.java b/spring-caching/src/main/java/com/baeldung/springdatacaching/model/Book.java index 7de567f0db..02285e3894 100644 --- a/spring-caching/src/main/java/com/baeldung/springdatacaching/model/Book.java +++ b/spring-caching/src/main/java/com/baeldung/springdatacaching/model/Book.java @@ -6,13 +6,15 @@ import lombok.NoArgsConstructor; import javax.persistence.Entity; import javax.persistence.Id; + +import java.io.Serializable; import java.util.UUID; @Data @Entity @NoArgsConstructor @AllArgsConstructor -public class Book { +public class Book implements Serializable { @Id private UUID id; diff --git a/spring-caching/src/main/resources/application.properties b/spring-caching/src/main/resources/application.properties index ee7b5e62c0..1039f85a42 100644 --- a/spring-caching/src/main/resources/application.properties +++ b/spring-caching/src/main/resources/application.properties @@ -1,4 +1,4 @@ -spring.datasource.url=jdbc:h2:mem:testdb +spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE spring.datasource.driverClassName=org.h2.Driver spring.datasource.username=sa spring.datasource.password= @@ -6,3 +6,6 @@ spring.datasource.password= # Enabling H2 Console spring.h2.console.enabled=true spring.h2.console.path=/h2 + +#ehcache +spring.cache.jcache.config=classpath:ehcache.xml diff --git a/spring-ehcache/src/main/resources/ehcache.xml b/spring-caching/src/main/resources/ehcache.xml similarity index 58% rename from spring-ehcache/src/main/resources/ehcache.xml rename to spring-caching/src/main/resources/ehcache.xml index caba0f2cc4..4b24394170 100644 --- a/spring-ehcache/src/main/resources/ehcache.xml +++ b/spring-caching/src/main/resources/ehcache.xml @@ -27,5 +27,28 @@ 10 + + + java.lang.String + com.baeldung.springdatacaching.model.Book + + 30 + + + + + com.baeldung.cachetest.config.CacheEventLogger + ASYNCHRONOUS + UNORDERED + CREATED + EXPIRED + + + + + 2 + 10 + + \ No newline at end of file diff --git a/spring-ehcache/.gitignore b/spring-ehcache/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/spring-ehcache/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.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-ehcache/README.md b/spring-ehcache/README.md deleted file mode 100644 index da7376e476..0000000000 --- a/spring-ehcache/README.md +++ /dev/null @@ -1,8 +0,0 @@ -## Spring Ehcache - -This module contains articles about Spring with Ehcache - -### Relevant Articles: - -- [Spring Boot Ehcache Example](https://www.baeldung.com/spring-boot-ehcache) - diff --git a/spring-ehcache/checkstyle.xml b/spring-ehcache/checkstyle.xml deleted file mode 100644 index 85063a7570..0000000000 --- a/spring-ehcache/checkstyle.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/spring-ehcache/pom.xml b/spring-ehcache/pom.xml deleted file mode 100644 index bf78e1392c..0000000000 --- a/spring-ehcache/pom.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - 4.0.0 - spring-ehcache - 0.1-SNAPSHOT - spring-ehcache - jar - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../parent-boot-2 - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-cache - - - javax.cache - cache-api - - - org.ehcache - ehcache - - - - - spring-ehcache - - - src/main/resources - true - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-checkstyle-plugin - ${checkstyle-maven-plugin.version} - - checkstyle.xml - - - - - check - - - - - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - ${checkstyle-maven-plugin.version} - - checkstyle.xml - - - - - - - - 3.0.0 - false - - - diff --git a/spring-ehcache/src/main/resources/application.properties b/spring-ehcache/src/main/resources/application.properties deleted file mode 100644 index a5c2964d32..0000000000 --- a/spring-ehcache/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -spring.cache.jcache.config=classpath:ehcache.xml \ No newline at end of file