2011-05-16 34 views
1

嗨,大家好 我使用Hibernate Search的 ,我想通过以下指定索引文件 现在我索引项目 内的位置:指定的索引文件位置在Hibernate Search的

@Indexed(index="indexes/myDomainClass") 

但我不知道如何指定索引的位置应用 我想是这样

@Indexed(index="/home/indexes/myDomainClass") 

之外,但它没有工作,任何想法?

回答

3

我使用hibernate.search.default.indexBase属性(在persistence.xml或hibernate.cfg.xml中)来指定索引的基础目录。

使用AnnotationSessionFactoryB­ean(或任何会话工厂bean),您可以通过设置各种属性:

<property name="hibernateProperties"> 
    <util:properties> 
      <prop key="hibernate.search.default.indexBase">value</prop> 
    </util:properties> 
</property> 

(你需要使用util:命名空间)

的xmlns:UTIL =” http://www.springframework.org/schema/util”

,并在模式位置:

http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd

+0

但我不既不使用也不persistence.xml中的hibernate.cfg.xml,我是使用hibernate注释配置我的域类。 – 2011-05-16 14:52:10

+0

@ sword101然后设置属性编程,您配置会话工厂 – Bozho 2011-05-16 15:03:30

+0

我设置我的会话工厂像下面的当我试图在其中添加hibernate.search.default.indexBase属性时,它不起作用,你能指导我把这个属性放在哪里吗? – 2011-05-16 16:15:41