0
구성 : 스프링 컨텍스트의봄 캐싱이 작동하지 않습니다 (SimpleCacheManager)
@Configuration
@EnableCaching
@ComponentScan("by.bsu.chemistry")
public class AppConfig {
@Bean
public CacheManager cacheManager() {
SimpleCacheManager manager = new SimpleCacheManager();
manager.setCaches(Collections.singleton(new ConcurrentMapCache("panes")));
return manager;
}
}
초기화 :
public class Main extends Application {
public static BorderPane borderPane;
ConfigurableApplicationContext context;
@Override
public void init() throws Exception {
super.init();
context = new AnnotationConfigApplicationContext(AppConfig.class);
}
그리고 캐시의 사용이 BoxUtils 클래스에 있습니다
@Component
public class BoxUtils {
//some code
@Cacheable(value = {"panes"})
public Pane getDefaultPane(String title){
VBox vBox = new VBox();
//some code
System.out.println("getDefaultPane(" + title + ") = " + vBox);
return vBox;
}
때마다 방법 getDefaultPane(String title)
이 호출되면 콘솔의 프로그램 출력 "getDefaultPane(......) = [email protected]
"따라서 캐싱 결과 대신 매번 메서드가 작동했습니다. 내가 뭘 잘못하고 있니?
* 실행 전에 스택 트레이스에서 getDefaultPane
캐시 프록시가 호출되지 않습니다!
** (org.springframework.cache를) 로그의 추적 레벨을 설정 한 후
DEBUG AnnotationCacheOperationSource [AbstractFallbackCacheOperationSource.java:101] Adding cacheable method 'getDefaultPane' with attribute: [Builder[public javafx.scene.layout.Pane by.bsu.chemistry.util.BoxUtils.getDefaultPane(java.lang.String)] caches=[panes] | key='' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false']