diff --git a/samples/pom.xml b/samples/pom.xml index 88405e33..538254a2 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -38,17 +38,20 @@ org.slf4j slf4j-api - 1.7.36 + + 2.0.9 - org.slf4j - jcl-over-slf4j - 1.7.36 + ch.qos.logback + logback-classic + + 1.4.11 ch.qos.logback - logback-classic - 1.2.11 + logback-core + + 1.4.11 diff --git a/samples/spring-boot-sample/spring-boot-sample-codes/src/main/java/jetcache/samples/springboot/MyServiceImpl.java b/samples/spring-boot-sample/spring-boot-sample-codes/src/main/java/jetcache/samples/springboot/MyServiceImpl.java index 63fb8a8f..30a7714d 100644 --- a/samples/spring-boot-sample/spring-boot-sample-codes/src/main/java/jetcache/samples/springboot/MyServiceImpl.java +++ b/samples/spring-boot-sample/spring-boot-sample-codes/src/main/java/jetcache/samples/springboot/MyServiceImpl.java @@ -6,17 +6,17 @@ import com.alicp.jetcache.Cache; import com.alicp.jetcache.CacheManager; import com.alicp.jetcache.template.QuickConfig; +import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; import java.time.Duration; /** * @author huangli */ @Component -public class MyServiceImpl implements MyService { +public class MyServiceImpl implements MyService, InitializingBean { @Autowired private UserService userService; @@ -26,8 +26,8 @@ public class MyServiceImpl implements MyService { private Cache orderCache; - @PostConstruct - public void init() { + @Override + public void afterPropertiesSet() { QuickConfig quickConfig = QuickConfig.newBuilder("orderCache").expire(Duration.ofSeconds(100)).build(); orderCache = cacheManager.getOrCreateCache(quickConfig); } diff --git a/samples/spring-boot-sample/spring-boot-sample-codes/src/main/java/jetcache/samples/sync/CacheReader.java b/samples/spring-boot-sample/spring-boot-sample-codes/src/main/java/jetcache/samples/sync/CacheReader.java index ffe6d0c3..1629ff03 100644 --- a/samples/spring-boot-sample/spring-boot-sample-codes/src/main/java/jetcache/samples/sync/CacheReader.java +++ b/samples/spring-boot-sample/spring-boot-sample-codes/src/main/java/jetcache/samples/sync/CacheReader.java @@ -19,7 +19,7 @@ @SpringBootApplication public class CacheReader { public static void main(String[] args) throws Exception { - ConfigurableApplicationContext context = SpringApplication.run(CacheUpdater.class); + ConfigurableApplicationContext context = SpringApplication.run(CacheReader.class); CacheManager cm = context.getBean(CacheManager.class); QuickConfig qc = QuickConfig.newBuilder("spring-boot-sync-test") .cacheType(CacheType.BOTH) diff --git a/samples/spring-sample/src/main/java/jetcache/samples/spring/MyServiceImpl.java b/samples/spring-sample/src/main/java/jetcache/samples/spring/MyServiceImpl.java index 0483d89f..790216d2 100644 --- a/samples/spring-sample/src/main/java/jetcache/samples/spring/MyServiceImpl.java +++ b/samples/spring-sample/src/main/java/jetcache/samples/spring/MyServiceImpl.java @@ -6,17 +6,17 @@ import com.alicp.jetcache.Cache; import com.alicp.jetcache.CacheManager; import com.alicp.jetcache.template.QuickConfig; +import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; import java.time.Duration; /** * @author huangli */ @Component -public class MyServiceImpl implements MyService { +public class MyServiceImpl implements MyService, InitializingBean { @Autowired private UserService userService; @@ -25,8 +25,8 @@ public class MyServiceImpl implements MyService { private Cache orderCache; - @PostConstruct - public void init() { + @Override + public void afterPropertiesSet() { QuickConfig quickConfig = QuickConfig.newBuilder("orderCache").expire(Duration.ofSeconds(100)).build(); orderCache = cacheManager.getOrCreateCache(quickConfig); }