Web应用程序结构层次问题

下面是我的项目层次结构的插图 项目层次结构http://a.yfrog.com/img809/3151/58400945.png 当我尝试将我的file_name.java文件连接到休眠时,我遇到了这些错误
Exception in thread "main" org.hibernate.HibernateException: Could not instantiate cache implementation
    at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:64)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:214)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
    at net.pkg.dao.FirstExample.main(FirstExample.java:17)
Caused by: org.hibernate.cache.NoCachingEnabledException: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache]
    at org.hibernate.cache.NoCacheProvider.buildCache(NoCacheProvider.java:21)
    at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:61)
问题与我的
hibernate.cfg.xml
有关...但我无法解决它。有任何想法吗?     
已邀请:
我怀疑你在你的实体上使用
@Cacheable
@Cache
而没有激活第二级缓存,因此错误信息:
o.h.c.NoCachingEnabledException: Second-level cache is not enabled for usage ...
你需要在
hibernate.cfg.xml
中使用二级缓存(我在这里使用EHCache作为缓存提供者):
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
是否真的需要二级缓存是另一个故事。     

要回复问题请先登录注册