Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
EhCache作为spring缓存和hibernate二级缓存_Spring_Spring Boot_Hibernate_Ehcache_Hibernate Cache - Fatal编程技术网

EhCache作为spring缓存和hibernate二级缓存

EhCache作为spring缓存和hibernate二级缓存,spring,spring-boot,hibernate,ehcache,hibernate-cache,Spring,Spring Boot,Hibernate,Ehcache,Hibernate Cache,存在这样的maven依赖关系 <dependency> <groupId>javax.cache</groupId> <artifactId>cache-api</artifactId> </dependency> <dependency> <groupId>org.ehcache

存在这样的maven依赖关系

        <dependency>
            <groupId>javax.cache</groupId>
            <artifactId>cache-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.ehcache</groupId>
            <artifactId>ehcache</artifactId>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-jcache</artifactId>
        </dependency>

        <dependency>
            <groupId>org.ehcache</groupId>
            <artifactId>ehcache-transactions</artifactId>
        </dependency>
所以问题是:我可以为spring缓存和hibernate缓存使用单个ehcache配置吗。 所以如果我启用

spring.cache.jcache.config=classpath:ehcache.xml

这会导致OverlappingFileLockException。

那么,当您启用ehCache时,是否会出现OverlappingFileLockException?我不太理解这里的问题。请解释,谢谢。是的,我得到了异常:
原因:java.lang.RuntimeException:持久性目录已被此进程锁定:~/spring boot ehcache/cache
嵌套异常:
原因:java.nio.channels.OverlappingFileLockException:null
。据我所知,发生这种情况是因为EhCacheManager初始化了两次。请在这里拿点东西article@Charlie谢谢我知道在现实中我有
spring.cache.type=jcache-spring.cache.jcache.config=classpath:ehcache.xml-spring.cache.jcache.provider=org.ehcache.jsr107.EhcacheCachingProvider-spring.jpa.properties.hibernate.cache.region.factory\u class=jcache-spring.jpa.properties.hibernate.javax.cachecachecachingprovider=org.ehcache.jsr107.ehcachegproviderspring.jpa.properties.hibernate.javax.cache.uri=classpath:ehcache.xml
我认为hibernate有自己的EhcacheCachingProvider,spring有自己的。
spring.cache.jcache.config=classpath:ehcache.xml