HazelCast Hibernate52 - 抛出无法解析名称 com.hazelcast.hibernate.HazelcastCacheRegionFactory

HazelCast Hibernate52 - Throws Unable to resolve name com.hazelcast.hibernate.HazelcastCacheRegionFactory

我正在尝试使用 hazelcast-hibernate52(它支持休眠 5.2。12.Final,我猜)创建二级缓存,当我 运行 它抛出以下异常时

Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [com.hazelcast.hibernate.HazelcastCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFactory]
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:126)
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveStrategy(StrategySelectorImpl.java:194)
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveStrategy(StrategySelectorImpl.java:161)
at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:67)
at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:28)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:259)
... 47 more

以下是我的 Spring 淡褐色配置

 <hz:hazelcast id="instance">
    <hz:config>
    <hz:instance-name>hazelcast</hz:instance-name>
   <!--  <hz:spring-aware /> -->
        <hz:group name="dev" password="dev-password"/>
        <hz:management-center enabled="true" url="http://localhost:9008/hazelcast-mancenter"/> 
        <hz:properties>
            <hz:property name="hazelcast.merge.first.run.delay.seconds">5</hz:property>
            <hz:property name="hazelcast.merge.next.run.delay.seconds">5</hz:property>
        </hz:properties>
        <hz:network port="5701" port-auto-increment="false" port-count="1">
            <hz:join>
            <!-- Enable for auto detection --> 
                <hz:multicast enabled="true" />
                <hz:tcp-ip enabled="false">
                 <hz:members>120.0.0.1</hz:members>
                </hz:tcp-ip>
            </hz:join>
            <hz:interfaces>
            <hz:interface>120.0.0.*</hz:interface>
            </hz:interfaces>
        </hz:network>

这些是我的 spring 休眠配置

<bean id="tpSessionFactory"
    class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
    <property name="dataSource" ref="tpDataSource"></property>
    <property name="hibernateProperties">
        <props>
            <!-- <prop key="hibernate.dialect">${db.dialect}</prop> -->
            <prop key="hibernate.show_sql">${db.show_sql}</prop>
            <prop key="hibernate.hbm2ddl.auto">${db.hbm2ddl.auto}</prop>
            <prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.region.factory_class">com.hazelcast.hibernate.HazelcastCacheRegionFactory</prop>
<prop key="hibernate.cache.hazelcast.instance_name">hazelcast</prop>
        </props>

使用的依赖项是:

<dependency>
        <groupId>com.hazelcast</groupId>
        <artifactId>hazelcast-all</artifactId>
        <version>3.10.4</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.hazelcast</groupId>
        <artifactId>hazelcast-spring</artifactId>
        <version>3.10.4</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>com.hazelcast</groupId>
        <artifactId>hazelcast-hibernate52</artifactId>
        <version>1.2</version>
    </dependency>

这里有什么我遗漏的吗?

@Clovrr,我能看到几件事:

  • hibernate 5.2.12 支持在 1.2.2 版本中添加。可以升级到1.2.2或者最新的1.2.3版本吗?

  • 不要添加 hazelcast-all,因为它包含用于 Hibernate 3.X 的 hazelcast-hibernate。只需使用 hazelcast-spring 依赖项,它将获得所有必要的 hazelcast 依赖项。

请检查这些并重试。

hazelcast-hibernate52 依赖性问题。

看起来依赖项没有更新或可能是其他原因。

我所做的是, 从这里查看 git code,用它构建一个 jar 并将其包含到我的类路径中。瞧!一切似乎都运作良好。