diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java index a827d25e..9a714520 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java @@ -247,6 +247,7 @@ public class SpringBootCallable implements Callable { //config freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "ActionConfig.java"), option + "/java/config/ActionConfig.java", ctx); + freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "CacheConfig.java"), option + "/java/config/CacheConfig.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "FreeMarkerConfig.java"), option + "/java/config/FreeMarkerConfig.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "SecurityConfig.java"), option + "/java/config/SecurityConfig.java", ctx); freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "TaskConfig.java"), option + "/java/config/TaskConfig.java", ctx); diff --git a/src/main/resources/modules/SpringBoot/java/Application.ftl b/src/main/resources/modules/SpringBoot/java/Application.ftl index dcc81d81..969bb3b5 100644 --- a/src/main/resources/modules/SpringBoot/java/Application.ftl +++ b/src/main/resources/modules/SpringBoot/java/Application.ftl @@ -8,6 +8,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.cache.annotation.EnableCaching; @SpringBootApplication <#if multiDB> @@ -15,6 +16,7 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer <#else> @EnableAutoConfiguration +@EnableCaching public class Application extends SpringBootServletInitializer { @Override diff --git a/src/main/resources/modules/SpringBoot/java/config/CacheConfig.java b/src/main/resources/modules/SpringBoot/java/config/CacheConfig.java new file mode 100644 index 00000000..a425f4c3 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/config/CacheConfig.java @@ -0,0 +1,28 @@ +package ${basePackage}.config; + +import net.sf.ehcache.CacheManager; +import net.sf.ehcache.config.CacheConfiguration; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cache.ehcache.EhCacheCacheManager; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableCaching +public class CacheConfig { + + @Bean(name = "tokenCacheManager") + public EhCacheCacheManager tokenCacheManager() { + EhCacheCacheManager ehCacheCacheManager = new EhCacheCacheManager(); + net.sf.ehcache.config.Configuration configuration = new net.sf.ehcache.config.Configuration(); + configuration.setMaxBytesLocalHeap("2G"); + configuration.setUpdateCheck(false);//设置不检查更新 + CacheConfiguration cacheConfiguration = new CacheConfiguration(); + cacheConfiguration.setTimeToLiveSeconds(60 * 60);//一个小时有效缓存时间 + cacheConfiguration.setTimeToIdleSeconds(30 * 60);//30分钟不使用eternal为true会失效 + configuration.addDefaultCache(cacheConfiguration); + CacheManager cacheManager = CacheManager.create(configuration); + ehCacheCacheManager.setCacheManager(cacheManager); + return ehCacheCacheManager; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/system/mpr/MySQL_DictItemMapper.xml b/src/main/resources/modules/SpringBoot/java/module/system/mpr/MySQL_DictItemMapper.xml index 3285ed92..96d101b2 100644 --- a/src/main/resources/modules/SpringBoot/java/module/system/mpr/MySQL_DictItemMapper.xml +++ b/src/main/resources/modules/SpringBoot/java/module/system/mpr/MySQL_DictItemMapper.xml @@ -4,6 +4,9 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + + `SYS_DICT_ITEM` @@ -11,18 +14,18 @@ - - - - - - - - - - - - + + + + + + + + + + + +