【发布时间】:2014-05-22 01:33:23
【问题描述】:
我在为索引设置正确路径时遇到问题。如果它在我的 spring 应用程序中会很棒,因为我猜即使在我将应用程序部署到 Cloudbees 之后它也可以工作。
这是我试图索引的对象:
@Entity
@Table(name="educations")
@Indexed(index="educations")
public class Education {
我在 servlet-context.xml 中有以下内容:
<resources mapping="/resources/**" location="/resources/"/>
我这样指定lucene索引路径:
Properties props = new Properties();
props.put("hibernate.search.default.indexBase", "resources/lucene/indexes");
entityManagerFactory.setJpaProperties(props);
这没有给我任何错误,但我也找不到文件夹,我不明白。我试着搜索它。
我也试过了:
props.put("hibernate.search.default.indexBase", "classpath:/lucene/indexes");
和
props.put("hibernate.search.default.indexBase", "/resources/lucene/indexes");
但还是找不到文件夹。然而,经过一段时间的努力,我尝试将它放在我的主目录中。 (这可能会在稍后部署到云时给我带来问题):
props.put("hibernate.search.default.indexBase", "/lucene/indexes");
我得到以下信息
Cannot write into index directory: /lucene/indexes for index educations
所以我认为这是一个权限错误。我在终端(OSX)中尝试以下操作:
sudo chmod -R u+rwX /lucene/indexes/
和
sudo chmod -R 755 /lucene/indexes/
但仍然是同样的错误。有人可以对此有所了解吗?
谢谢!
编辑: 经过更多调查,我确定这是权限问题。如果我指定 Spring 应用程序根目录的完整路径,它就可以工作。如果不给出完整路径,我仍然不知道如何指定它。
【问题讨论】:
标签: spring hibernate spring-mvc lucene hibernate-search