A component required a bean named 'cacheManager' that could not be found.

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean named 'cacheManager' that could not be found.


Action:

Consider defining a bean named 'cacheManager' in your configuration.

在使用springboot集成hazelcast时候,启动时候报错。

需要在启动类中加入一个bean

    @Bean
    public CacheManager cacheManager() {
        return new HazelcastCacheManager();
    }

这样启动后,可以进行正常启动

或者添加配置文件为:

@Configuration
public class HazelcaseConfig {

    /**
     * @description 3.创建Hazelcase的Config类
     */
    @Bean
    public Config getConfig() {
        Config hazelcaseConfig = new Config();
//        MapConfig mapConfig = new MapConfig();
//        mapConfig.setName("myMap");// 设置当前的mapConfig的名称
        hazelcaseConfig.setInstanceName("test-hazelcase");// 设置当前创建的实例的名称
//                .addMapConfig(mapConfig);//添加当前的map
        return hazelcaseConfig;
    }
}

可以进行实现

posted @ 2020-02-16 23:14  King-DA  阅读(5218)  评论(0编辑  收藏  举报