PfrApplication.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package com.jiayue.pfr;
  2. import org.mybatis.spring.annotation.MapperScan;
  3. import org.springframework.boot.SpringApplication;
  4. import org.springframework.boot.autoconfigure.SpringBootApplication;
  5. import net.sf.ehcache.CacheManager;
  6. import org.springframework.cache.annotation.EnableCaching;
  7. import org.springframework.cache.ehcache.EhCacheCacheManager;
  8. import org.springframework.cache.ehcache.EhCacheManagerFactoryBean;
  9. import org.springframework.context.annotation.Bean;
  10. import org.springframework.core.io.ClassPathResource;
  11. import org.springframework.scheduling.annotation.EnableScheduling;
  12. /**
  13. * 启动类
  14. *
  15. * @author xsl
  16. * @version 3.0
  17. */
  18. @SpringBootApplication
  19. @EnableScheduling
  20. @EnableCaching
  21. @MapperScan("com.jiayue.pfr.mapper.*")
  22. public class PfrApplication {
  23. public static void main(String[] args) {
  24. SpringApplication.run(PfrApplication.class, args);
  25. }
  26. /**
  27. * ecache缓存对象获取
  28. */
  29. @Bean
  30. public EhCacheCacheManager cacheManager(CacheManager cacheManagerFactory) {
  31. EhCacheCacheManager ehCacheCacheManager = new EhCacheCacheManager();
  32. ehCacheCacheManager.setCacheManager(cacheManagerFactory);
  33. return ehCacheCacheManager;
  34. }
  35. /**
  36. * ecache缓存配置加载
  37. */
  38. @Bean
  39. public EhCacheManagerFactoryBean cacheManagerFactory() {
  40. EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean();
  41. ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache-setting.xml"));
  42. return ehCacheManagerFactoryBean;
  43. }
  44. }