如何在Apache MongoDB中存储Apache Sling内容?
问题描述:
我是Java和Apache Sling的新手。我一直在试图用MongoDB的链接吊带和这些是我迄今所做的:如何在Apache MongoDB中存储Apache Sling内容?
- 我在吊带控制台配置
NoSQL MongoDB Resource Provider
:
- 然后
Oak Document Node Store Service
: - 最后,我运行
java -Dsling.run.modes=oak_mongo -jar org.apache .sling.launchpad-9.jar -c sling -f -
以mongodb模式运行吊索启动板。这是结果:
其结果是,一个名为 “吊” 在MongoDB中被创造,我可以通过ROBO-3T(一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数据库中,但目前没有任何存储在数据库中。我怎样才能做到这一点?
答
最简单的方法是使用以下参数启动Sling Launchpad:-Dsling.run.modes=oak-mongo
。这将确保Oak被配置为使用Mongo。您必须删除sling
目录,否则运行模式将不会更改。
什么你与你试图做的是:
- 增加其阴影在库根当前一个新的资源提供者。我不确定实际的效果,它可能会被拒绝 - 请参阅吊索错误日志
- 配置一个使用Mongo的新的Oak NodeStoreService - 但它可能没有被拾取,因为已经有一个NodeStoreService正在运行 - 吊索需要一个启动。
非常感谢罗伯特,删除索具目录做到了这个把戏:) –
@Bahman_Aries很高兴听到它的工作,享受Sling ;-) –