带有hazelcast的春季会议,无法自动连线HazelcastInstance

时间:2019-07-09 14:20:15

标签: java spring hazelcast spring-session

除带有hazelcast之外,无法运行spring-session:

org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.session.hazelcast.config.annotation.web.http.HazelcastHttpSessionConfiguration': 
Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException: 
Could not autowire method: public void org.springframework.session.hazelcast.config.annotation.web.http.HazelcastHttpSessionConfiguration.setHazelcastInstance(org.springframework.beans.factory.ObjectProvider,org.springframework.beans.factory.ObjectProvider);
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No qualifying bean of type [org.springframework.beans.factory.ObjectProvider] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. 
Dependency annotations: {@org.springframework.session.hazelcast.config.annotation.SpringSessionHazelcastInstance()}

我在春季课程reference中使用了相同的示例,但是使用XML转换,并且已经有了 appContext.xml中的<context:annotation-config />

@EnableHazelcastHttpSession 
@Configuration
public class SessionConfig {
    @Bean
    public HazelcastInstance hazelcastInstance() {
        MapAttributeConfig attributeConfig = new MapAttributeConfig()
                .setName(HazelcastSessionRepository.PRINCIPAL_NAME_ATTRIBUTE)
                .setExtractor(PrincipalNameExtractor.class.getName());

        Config config = new Config();
        config.getMapConfig(HazelcastSessionRepository.DEFAULT_SESSION_MAP_NAME) 
                .addMapAttributeConfig(attributeConfig)
                .addMapIndexConfig(new MapIndexConfig(
                        HazelcastSessionRepository.PRINCIPAL_NAME_ATTRIBUTE, false));
        return Hazelcast.newHazelcastInstance(config); 
    }
}

版本: Java 1.8-Spring 4.3.3-spring-session 2.0.2-Hazelcast 3.9

谢谢

0 个答案:

没有答案