Konfiguration:Frühlings-Caching nicht funktioniert (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;
}
}
Initialisierung der Feder Kontext:
public class Main extends Application {
public static BorderPane borderPane;
ConfigurableApplicationContext context;
@Override
public void init() throws Exception {
super.init();
context = new AnnotationConfigApplicationContext(AppConfig.class);
}
und die Verwendung von Cache ist in BoxUtils Klasse:
@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;
}
Jedes Mal, Wenn die Methode getDefaultPane(String title)
aufgerufen wird, Programmausgabe in der Konsole "getDefaultPane(......) = [email protected]
", so arbeitete Methode jedes Mal, anstatt Ergebnisse zu cachen. Was mache ich falsch?
* In Stacktrace vor der Ausführung getDefaultPane
Cache-Proxy wird nicht aufgerufen!
** Nach der Einstellung TRACE-Ebene der Protokollierung (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']