12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package com.jiayue.pfr;
- import org.mybatis.spring.annotation.MapperScan;
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- import net.sf.ehcache.CacheManager;
- import org.springframework.cache.annotation.EnableCaching;
- import org.springframework.cache.ehcache.EhCacheCacheManager;
- import org.springframework.cache.ehcache.EhCacheManagerFactoryBean;
- import org.springframework.context.annotation.Bean;
- import org.springframework.core.io.ClassPathResource;
- import org.springframework.scheduling.annotation.EnableScheduling;
- /**
- * 启动类
- *
- * @author xsl
- * @version 3.0
- */
- @SpringBootApplication
- @EnableScheduling
- @EnableCaching
- @MapperScan("com.jiayue.pfr.mapper.*")
- public class PfrApplication {
- public static void main(String[] args) {
- SpringApplication.run(PfrApplication.class, args);
- }
- /**
- * ecache缓存对象获取
- */
- @Bean
- public EhCacheCacheManager cacheManager(CacheManager cacheManagerFactory) {
- EhCacheCacheManager ehCacheCacheManager = new EhCacheCacheManager();
- ehCacheCacheManager.setCacheManager(cacheManagerFactory);
- return ehCacheCacheManager;
- }
- /**
- * ecache缓存配置加载
- */
- @Bean
- public EhCacheManagerFactoryBean cacheManagerFactory() {
- EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean();
- ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache-setting.xml"));
- return ehCacheManagerFactoryBean;
- }
- }
|