2011-05-16 32 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