Migrating an Apache Table to MongoDB: Creating a Maven Project in Eclipse

Next, create a Java project in Eclipse IDE for migrating Cassandra database data to MongoDB database.

  1. Select File >■ New >■ Other.
  2. In the New window, select Maven ► Maven Project and click on Next as shown in Figure 6-3.

  1. The New Maven Project wizard gets started. Select the Create a simple project check box and the Use default Workspace location check box and click on Next as shown in Figure 6-4.

  1. In Configure project, specify the following and then click on Finish as shown in Figure 6-5.
  • Group Id: com.mongodb.migration
  • Artifact Id: CassandraToMongoDB
  • Version: 1.0.0
  • Packaging: jar
  • Name: CassandraToMongoDB

A Maven Project gets created in Eclipse IDE as shown in Figure 6-6.

Now we need to create two Java classes for the migration: one to create the initial data in Cassandra and the other to migrate the data to MongoDB.

  1. To create a Java class click on File ► New ► Other.
  2. In the New window, select Java ► Class and click on Next as shown in Figure 6-7.

  1. In New Java Class wizard select the Source folder as CassandraToMongoDB/ src/main/java and specify Package as mongodb and class name as CreateCassandraDatabase. Select the check box to create method stub public static void main(String[] args). Click on Finish as shown in Figure 6-8.

4. Similarly create a Java class MigrateCassandraToMongoDB as shown in Figure 6-9.

he two Java classes are shown in the Package Explorer in Figure 6-10.

We need to add some dependencies to the pom.xml. Add the following dependencies listed in Table 6-1; some of the dependencies are indicated as being included with the Apache Cassandra Project dependency and should not be added separately.

The pom.xml is listed below.

<project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/ XMLSchema-instance”

xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/ maven-4.0.0.xsd”>







































Some of these dependencies have further dependencies, which get added automatically and should not be added separately. To find the required Jars that get added from the dependencies, right-click on the project node in Package Explorer and select Properties. In Properties select Java Build Path. The Jars added to the migration project are shown in Figure 6-11.

Source: Vohra Deepak (2015), Pro MongoDB™ Development, Apress; 1st ed. edition.

Leave a Reply

Your email address will not be published. Required fields are marked *