A Simple Todo List Application built w/ Java + Azure DocumentDB
The sample code in this Github repository demonstrates how to create a simple application using Java and Azure DocumentDB.
For a complete end-to-end walkthrough of creating the application, please visit the following Azure documentation page.
Before you begin this application development tutorial, you must have the following:
- An active Azure DocumentDB account.
- If you don't have an account, you can find instructions on how to create one on our Azure documentation page.
- Java Development Kit (JDK) 7+.
- Eclipse IDE for Java EE Developers.
If you're installing these tools for the first time, coreservlets.com provides a walk-through of the installation process in the Quick Start section of their Tutorial: Installing TomCat7 and Using it with Eclipse article.
All the samples in this tutorial are included in the documentdb-java-todoapp project on GitHub. To import the todo project into Eclipse, ensure you have the software and resources listed in the Requirements section, then do the following:
- Install Project Lombok. Lombok is used to generate constructors, getters, setters in the project. Once you have downloaded the lombok.jar file, double-click it to install it or install it from the command line.
- If Eclipse is open, close it and restart it to load Lombok.
- In Eclipse, on the File menu, click Import.
- In the Import window, click Git, click Projects from Git, and then click Next.
- On the Select Repository Source screen, click Clone URI.
- On the Source Git Repository screen, in the URI box, enter
https://github.com/Azure-Samples/documentdb-java-todoapp.git, and then click Next.
- On the Branch Selection screen, ensure that master is selected, and then click Next.
- On the Local Destination screen, click Browse to select a folder where the repository can be copied, and then click Next.
- On the Select a wizard to use for importing projects screen, ensure that Import existing projects is selected, and then click Next.
- On the Import Projects screen, unselect the DocumentDB project, and then click Finish. The DocumentDB project contains the DocumentDB Java SDK, which we will add as a dependency instead.
- In Project Explorer, navigate to
\src\com.microsoft.azure.documentdb.sample.dao\DocumentClientFactory.javaand replace the
MASTER_KEYvalues with the
PRIMARY KEYfor your DocumentDB account, and then save the file. For more information, see Step 1. Create a DocumentDB database account.
- In Project Explorer, right click the azure-documentdb-java-sample, click Build Path, and then click Configure Build Path.
- On the Java Build Path screen, in the right pane, select the Libraries tab, and then click Add External JARs. Navigate to the location of the lombok.jar file, and click Open, and then click OK.
- Use step 12 to open the Properties window again, and then in the left pane click Targeted Runtimes.
- On the Targeted Runtimes screen, click New, select Apache Tomcat v7.0, and then click OK.
- Use step 12 to open the Properties window again, and then in the left pane click Project Facets.
- On the Project Facets screen, select Dynamic Web Module and Java, and then click OK.
- On the Servers tab at the bottom of the screen, right-click Tomcat v7.0 Server at localhost and then click Add and Remove.
- On the Add and Remove window, move azure-documentdb-java-sample to the Configured box, and then click Finish.
- In the Server tab, right-click Tomcat v7.0 Server at localhost, and then click Restart.
- In a browser, navigate to
http://localhost:8080/azure-documentdb-java-sample/and start adding to your task list. Note that if you changed your default port values, change
8080to the value you selected.