2017-11-11 142 views
1

我是Java和Apache Sling的新手。我一直在試圖用MongoDB的鏈接吊帶和這些是我迄今所做的:如何在Apache MongoDB中存儲Apache Sling內容?

  1. 我在吊帶控制檯配置NoSQL MongoDB Resource Provider

NoSQL config

  • 然後Oak Document Node Store Service
  • Oak config

    1. 最後,我運行java -Dsling.run.modes=oak_mongo -jar org.apache .sling.launchpad-9.jar -c sling -f -以mongodb模式運行吊索啓動板。這是結果:

    Command Prompt

    其結果是,一個名爲 「吊」 在MongoDB中被創造,我可以通過ROBO-3T(一MongoDB的管理工具)看到數據庫:

    MongoDB

    使用下面的插件,通過我的Maven的應用程序創建一些內容和吊帶部署之後,我能看到我的新創建的節點和資源的吊帶瀏覽器(http://localhost:8080/bin/browser.html):

    <build> 
        <plugins> 
         <plugin> 
          <groupId>org.apache.felix</groupId> 
          <artifactId>maven-bundle-plugin</artifactId> 
          <extensions>true</extensions> 
          <version>3.3.0</version> 
          <configuration> 
           <instructions> 
            <Sling-Nodetypes> 
             SLING-INF/nodetypes/nodetypes.cnd 
            </Sling-Nodetypes> 
            <Sling-Initial-Content> 
             SLING-INF/scripts;overwrite:=true;uninstall:=true;path:=/apps/test1/nodes, 
             SLING-INF/content;overwrite:=true;uninstall:=true;path:=/content/test1 
            </Sling-Initial-Content> 
           </instructions> 
          </configuration> 
         </plugin> 
        </plugins> 
    </build> 
    

    但是,我需要將所有內容存儲在MongoDB數據庫中,但目前沒有任何存儲在數據庫中。我怎樣才能做到這一點?

    回答

    1

    最簡單的方法是使用以下參數啓動Sling Launchpad:-Dsling.run.modes=oak-mongo。這將確保Oak被配置爲使用Mongo。您必須刪除sling目錄,否則運行模式將不會更改。


    什麼你與你試圖做的是:

    1. 增加其陰影在庫根當前一個新的資源提供者。我不確定實際的效果,它可能會被拒絕 - 請參閱吊索錯誤日誌
    2. 配置一個使用Mongo的新的Oak NodeStoreService - 但它可能沒有被拾取,因爲已經有一個NodeStoreService正在運行 - 吊索需要一個啓動。
    +0

    非常感謝羅伯特,刪除索具目錄做到了這個把戲:) –

    +0

    @Bahman_Aries很高興聽到它的工作,享受Sling ;-) –