![]() We can represent different fields inside the Document using the annotation.represents a unique identifier for our Document.To define a Model Class as a MongoDB Document, we are going to use the where expense is the name of the Document.You can see that by adding the and we can generate the required Getter, Setter Methods and the Constructors at compile time.This is just a normal POJO class, which contains some interesting annotations, if you are not already aware of Lombok, it is an annotation library which helps us reduce the boiler plate code. Package .model ĮNTERTAINMENT, GROCERIES, RESTAURANT, UTILITIES, MISC You can define the MongoDB properties by either using the MongoURI or by defining the host, username, password and database details. Now it’s time to configure the MongoDB properties inside the application.properties file If you want to learn more about Maven, have a look at the comprehensive Blog Post I wrote Maven Complete Tutorial Define MongoDB properties Once you unzip and open the project in your favorite IDE, open the pom.xml file to have a look at the Maven dependencies which we are going to use in our project. Testcontainers: Provides lightweight instances of the Mongo Database which we can run inside a Docker Container.Īfter providing the Project Metadata, you can download the project to your machine, by clicking on the Generate button.Lombok: Java Annotation Library which helps to reduce boiler plate code.Spring Data MongoDB: To interact with MongoDB from the Spring Boot Application.Spring Web: To be able to build RESTful API using Spring MVC.In the Spring Initializr home page, I selected the following options: ![]() You can download the starter project with all the needed dependencies at Spring Initializr website. ![]() We are going to build a REST API for an Expense Manager application, where you can track your expenses. Now let’s go ahead and bootstrap the project we are going to use in this tutorial. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |