简体   繁体   English

如何在MongoDB中存储Apache Sling内容?

[英]How to store Apache Sling content in MongoDB?

I am new to Java and Apache Sling as well. 我也是Java和Apache Sling的新手。 I've been trying to link Sling with MongoDB and these are what I've done so far: 我一直在尝试将Sling与MongoDB链接,这是我到目前为止所做的:

  1. I configured NoSQL MongoDB Resource Provider in Sling console: 我在Sling控制台中配置了NoSQL MongoDB Resource Provider

NoSQL配置

  1. Then the Oak Document Node Store Service : 然后, Oak Document Node Store Service

橡木配置

  1. And finally I ran java -Dsling.run.modes=oak_mongo -jar org.apache .sling.launchpad-9.jar -c sling -f - to run the sling launchpad in mongodb mode. 最后,我运行了java -Dsling.run.modes=oak_mongo -jar org.apache .sling.launchpad-9.jar -c sling -f -在mongodb模式下运行sling启动板。 This was the results: 结果是:

命令提示符

As a result, a database named "sling" was created in MongoDB which I could see via Robo-3T (a MongoDB management tool): 结果,在MongoDB中创建了一个名为“ sling”的数据库,我可以通过Robo-3T(一种MongoDB管理工具)看到该数据库:

MongoDB的

After creating some content through my maven application using the below plugin and deploying it on Sling, I was able to see my newly created nodes and resources in the Sling browser ( http://localhost:8080/bin/browser.html ): 在使用以下插件通过我的maven应用程序创建了一些内容并将其部署在Sling上之后,我能够在Sling浏览器( 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>

However, I need to to store everything inside the MongoDB database but currently, nothing stored in the database. 但是,我需要将所有内容都存储在MongoDB数据库中,但目前没有任何内容存储在数据库中。 How can I achieve this? 我该如何实现?

The simplest way is to start the Sling Launchpad with the following argument: -Dsling.run.modes=oak-mongo . 最简单的方法是使用以下参数启动Sling Launchpad: -Dsling.run.modes=oak-mongo This will ensure that the Oak is configured to use Mongo. 这将确保将Oak配置为使用Mongo。 You must remove the sling directory, otherwise the run modes will not be changes. 您必须删除sling目录,否则运行模式将不会更改。


What you've done with your attempts is to: 您所做的尝试是:

  1. add a new resource provider which shadows the current one at the repository root. 添加一个新的资源提供程序,该资源提供程序将当前资源提供程序隐藏在存储库根目录中。 I am not sure of the actual effects, it is probably rejected - please see the sling error log 我不确定实际效果,可能已被拒绝-请参阅吊索错误日志
  2. configure a new Oak NodeStoreService which uses Mongo - but it's probably not picked up since there is already a NodeStoreService in action - Sling requires one to start up. 配置一个使用Mongo的新的Oak NodeStoreService-但由于已经有一个NodeStoreService在使用中,因此可能无法使用它-Sling需要一个来启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM