首页>代码>Spring Boot整合Ehcache的简单入门实例>/ehcache2/src/main/java/com/memorynotfound/springboot/Application.java
package com.memorynotfound.springboot;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;

@EnableCaching
@SpringBootApplication
public class Application implements CommandLineRunner {

    private static Logger log = LoggerFactory.getLogger(Application.class);

    @Autowired
    private MusicService musicService;

    @Autowired
    private CacheManager cacheManager;

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        log.info("Spring Boot Ehcache 2 Caching Example Configuration");
        log.info("using cache manager: " + cacheManager.getClass().getName());

        musicService.clearCache();


        play("zuidaima");
        play("trombone");
        play("guitar");
        play("trombone");
        play("zuidaima");
        play("bass");
        play("trombone");
        play("zuidaima");
    }

    private void play(String instrument){
        log.info("Calling: " + MusicService.class.getSimpleName() + ".play(\"" + instrument + "\");");
        musicService.play(instrument);
    }
}
最近下载更多
1798672867  LV21 2021年5月22日
13940562934  LV22 2021年4月29日
912299793  LV21 2021年4月21日
文成1116  LV21 2020年12月30日
最近浏览更多
woldxy  LV12 2023年9月28日
siximu912  LV10 2023年9月19日
EthanGrant 2023年7月31日
暂无贡献等级
tonghao  LV18 2023年6月17日
sixiongbin  LV8 2023年5月22日
GeminiLong  LV6 2023年4月27日
hhhhhz  LV7 2023年4月18日
hbsoft2008  LV16 2023年3月20日
mjx201  LV11 2023年2月28日
Brilion  LV6 2023年2月15日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友