I am new to Java and Apache Sling as well. I've been trying to link Sling with MongoDB and these are what I've done so far:
- I configured
NoSQL MongoDB Resource Provider
in Sling console:
- Then the
Oak Document Node Store Service
:
- 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. 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):
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):
<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. How can I achieve this?