This is a simple Spring Boot command line runner project, which creates a Spark Context, connects to a MongoDB database, and loads the data into a SparkJavaContext. From there, it's the regular JavaRDD stuff.
The Mongo Spark Connector Dependency
mongo-spark-connector dependency is available in the central maven repository. You can find the source code and the usage here.