我有問題,爲我的索引設置正確的路徑。如果它位於我的Spring應用程序中,它會很好,因爲即使在我將應用程序部署到Cloudbees後,它也可以工作。用Hibernate Search和Spring指定索引路徑
這是我obejct,我試圖指數:
@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應用程序根目錄的完整路徑,它將起作用。如果沒有給出完整的路徑,我仍然不知道如何指定。