{"id":98522,"date":"2020-12-31T11:00:00","date_gmt":"2020-12-31T09:00:00","guid":{"rendered":"https:\/\/examples.javacodegeeks.com\/?p=98522"},"modified":"2020-12-22T15:17:44","modified_gmt":"2020-12-22T13:17:44","slug":"spring-boot-and-mongodb-sequence-id-generator","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/","title":{"rendered":"Spring Boot and MongoDB Sequence ID Generator"},"content":{"rendered":"<p>Welcome, in this tutorial, we will see how to generate a mongodb sequence id in a spring boot application.<\/p>\n<h2>1. Introduction<\/h2>\n<p>Before going further in this tutorial, we will look at the common terminology such as introduction to Spring Boot and mongodb.<\/p>\n<h3>1.1 Spring Boot<\/h3>\n<ul>\n<li><em>Spring boot<\/em> is a module that provides rapid application development feature to the spring framework including <strong>auto-configuration<\/strong>, <strong>standalone-code<\/strong>, and <strong>production-ready<\/strong> code<\/li>\n<li>It creates applications that are packaged as <em>jar<\/em> and are directly started using embedded servlet container (such as Tomcat, Jetty or, Undertow). Thus, no need to deploy the <em>war<\/em> files<\/li>\n<li>It simplifies the maven configuration by providing the starter template and helps to resolve the dependency conflicts. It automatically identifies the required dependencies and imports them into the application<\/li>\n<li>It helps in removing the boilerplate code, extra annotations, and xml configurations<\/li>\n<li>It provides powerful batch processing and manages the rest endpoints<\/li>\n<li>It provides an efficient <em>jpa-starter library<\/em> to effectively connect the application with the relational databases<\/li>\n<li>It offers a Microservice architecture and cloud configuration that manages all the application related configuration properties in a centralized manner<\/li>\n<\/ul>\n<h3>1.2 MongoDB<\/h3>\n<ul>\n<li>MongoDB is a high-performance <em>NoSQL database<\/em> where each database has collections which in turn have documents. Each document has a different number of fields, size, content, and is stored in a JSON-like format (i.e. Binary JSON (<a href=\"https:\/\/en.wikipedia.org\/wiki\/BSON\" target=\"_blank\" rel=\"noopener\">BSN<\/a>)<\/li>\n<li>The documents in MongoDB doesn\u2019t need to have a schema defined beforehand. Instead, the fields (i.e. <em>records<\/em>) can be created on the go<\/li>\n<li>Data model available within the MongoDB allows developers to represent the hierarchical relationships, store arrays, and other more complex structures easily<\/li>\n<li>This NoSQL solution often comes with embedding, auto-sharding, and onboard replication for better scalability and high availability<\/li>\n<\/ul>\n<h4>1.2.1 Why MongoDB?<\/h4>\n<ul>\n<li>As a NoSQL type database, MongoDB stores the data in the form of a document. Thus, MongoDB offers more flexibility<\/li>\n<li>This database supports search by field-name, range queries, and regular expressions. It often provides queries to return the particular fields inside the documents<\/li>\n<li>MongoDB offers <em>indexes<\/em> to improve the <em>search performance<\/em> within the NoSQL database<\/li>\n<li>To offer horizontal scalability, MongoDB uses sharding by splitting the data across the many MongoDB occurrences<\/li>\n<li><strong>Replication<\/strong>: MongoDB can give high availability with the replica sets<\/li>\n<\/ul>\n<p>Let us go ahead with the tutorial implementation but before going any further I\u2019m assuming that you\u2019re aware of the Spring boot basics.<\/p>\n<h2>2. Spring Boot and MongoDB Sequence ID Generator<\/h2>\n<h3>2.1 Application Pre-requisite<\/h3>\n<p>To start with this tutorial, I am hoping that you have the mongodb and mongodb graphical interface (i.e. <em>mongo-express<\/em>) up and running in your localhost environment. For easy setup, I have these both up and running on the docker environment. You can execute the below script using the <code>docker-compose<\/code> command to get both containers running on docker in minutes. If you\u2019re doing it for the first time the mongodb and mongo-express docker images will be downloaded from the docker hub.<\/p>\n<p><span style=\"text-decoration: underline\"><em>docker-compose.yml<\/em><\/span><\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">services:\n  mongodb:\n    container_name: mongodb\n    image: mongo\n    environment:\n      MONGO_INITDB_DATABASE: employees\n    ports:\n      - '27017:27017'\n  express:\n    container_name: express\n    image: mongo-express\n    ports:\n      - '9001:8081'\n    environment:\n      - ME_CONFIG_MONGODB_SERVER=mongodb\n      - ME_CONFIG_MONGODB_PORT=27017\n      - ME_CONFIG_MONGODB_ENABLE_ADMIN=true\n    depends_on:\n      - mongodb\nversion: '3'\n<\/pre>\n<p>If everything goes well the containers would be started successfully as shown in Fig. 1. You can use the <code>docker ps -a<\/code> command to confirm that both the containers are started successfully. For further information on docker basics, you can navigate to this <a href=\"https:\/\/examples.javacodegeeks.com\/docker-basic-commands\/\" target=\"_blank\" rel=\"noopener\">tutorial<\/a>.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/docker-mongodb-up-img1.jpg\"><img decoding=\"async\" width=\"818\" height=\"131\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/docker-mongodb-up-img1.jpg\" alt=\"Spring Boot MongoDB Sequence\" class=\"wp-image-98523\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/docker-mongodb-up-img1.jpg 818w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/docker-mongodb-up-img1-300x48.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/docker-mongodb-up-img1-768x123.jpg 768w\" sizes=\"(max-width: 818px) 100vw, 818px\" \/><\/a><figcaption>Fig.1: MongoDB and Mongo-express containers on Docker<\/figcaption><\/figure>\n<\/div>\n<p>Navigate to the following URL &#8211; <code>localhost:9001<\/code> to confirm that the <em>mongo-express<\/em> is running and can bind with the mongodb successfully.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/mongo-express-img1.jpg\"><img decoding=\"async\" width=\"818\" height=\"292\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/mongo-express-img1.jpg\" alt=\"Spring Boot MongoDB Sequence - mongo express\" class=\"wp-image-98524\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/mongo-express-img1.jpg 818w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/mongo-express-img1-300x107.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/mongo-express-img1-768x274.jpg 768w\" sizes=\"(max-width: 818px) 100vw, 818px\" \/><\/a><figcaption>Fig. 2: Mongo express<\/figcaption><\/figure>\n<\/div>\n<h3>2.2 Tools Used for Spring boot application and Project Structure<\/h3>\n<p>We are using Eclipse Kepler SR2, JDK 8, and Maven. In case you\u2019re confused about where you should create the corresponding files or folder, let us review the project structure of the spring boot application.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/springboot-and-mongodb-sequenceid-generator-project-guide-img1.jpg\"><img decoding=\"async\" width=\"367\" height=\"705\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/springboot-and-mongodb-sequenceid-generator-project-guide-img1.jpg\" alt=\"Spring Boot MongoDB Sequence - project structure\" class=\"wp-image-98531\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/springboot-and-mongodb-sequenceid-generator-project-guide-img1.jpg 367w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/springboot-and-mongodb-sequenceid-generator-project-guide-img1-156x300.jpg 156w\" sizes=\"(max-width: 367px) 100vw, 367px\" \/><\/a><figcaption>Fig. 3: Project structure<\/figcaption><\/figure>\n<\/div>\n<p>Let us start building the application!<\/p>\n<h2>3. Creating a Spring Boot application<\/h2>\n<p>Below are the steps involved in developing the application.<\/p>\n<h3>3.1 Maven Dependency<\/h3>\n<p>Here, we specify the dependency for the Spring boot (Web and MongoDB), Lombok, and Java faker (for generating the mock data). Maven will automatically resolve the other dependencies. The <strong>updated<\/strong> file will have the following code.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><span style=\"text-decoration: underline\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false;\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;project xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n         xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\"\n         xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt;\n    &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n    &lt;parent&gt;\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n        &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\n        &lt;version&gt;2.4.1&lt;\/version&gt;\n        &lt;relativePath\/&gt; &lt;!-- lookup parent from repository --&gt;\n    &lt;\/parent&gt;\n    &lt;groupId&gt;com.springboot.mongodb&lt;\/groupId&gt;\n    &lt;artifactId&gt;SpringbootandMongodbSequenceId&lt;\/artifactId&gt;\n    &lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\n    &lt;name&gt;SpringbootandMongodbSequenceId&lt;\/name&gt;\n    &lt;description&gt;Springboot and Mongodb SequenceId generator&lt;\/description&gt;\n\n    &lt;properties&gt;\n        &lt;java.version&gt;1.8&lt;\/java.version&gt;\n    &lt;\/properties&gt;\n\n    &lt;dependencies&gt;\n        &lt;dependency&gt;\n            &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n            &lt;artifactId&gt;spring-boot-starter-data-mongodb&lt;\/artifactId&gt;\n        &lt;\/dependency&gt;\n        &lt;dependency&gt;\n            &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n            &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;\n        &lt;\/dependency&gt;\n\n        &lt;dependency&gt;\n            &lt;groupId&gt;com.github.javafaker&lt;\/groupId&gt;\n            &lt;artifactId&gt;javafaker&lt;\/artifactId&gt;\n            &lt;version&gt;1.0.2&lt;\/version&gt;\n        &lt;\/dependency&gt;\n\n        &lt;dependency&gt;\n            &lt;groupId&gt;org.projectlombok&lt;\/groupId&gt;\n            &lt;artifactId&gt;lombok&lt;\/artifactId&gt;\n            &lt;optional&gt;true&lt;\/optional&gt;\n        &lt;\/dependency&gt;\n        &lt;dependency&gt;\n            &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n            &lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt;\n            &lt;scope&gt;test&lt;\/scope&gt;\n        &lt;\/dependency&gt;\n    &lt;\/dependencies&gt;\n\n    &lt;build&gt;\n        &lt;plugins&gt;\n            &lt;plugin&gt;\n                &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n                &lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt;\n                &lt;configuration&gt;\n                    &lt;excludes&gt;\n                        &lt;exclude&gt;\n                            &lt;groupId&gt;org.projectlombok&lt;\/groupId&gt;\n                            &lt;artifactId&gt;lombok&lt;\/artifactId&gt;\n                        &lt;\/exclude&gt;\n                    &lt;\/excludes&gt;\n                &lt;\/configuration&gt;\n            &lt;\/plugin&gt;\n        &lt;\/plugins&gt;\n    &lt;\/build&gt;\n\n&lt;\/project&gt;\n<\/pre>\n<h3>3.2 Application properties file<\/h3>\n<p>Create a new properties file at the location: <code>SpringbootandMongodbSequenceId\/src\/main\/resources\/<\/code> and add the following code to it. Here we will define the application and mongo database configuration.<\/p>\n<p><span style=\"text-decoration: underline\"><em>application.properties<\/em><\/span><\/p>\n<pre class=\"brush:plain; wrap-lines:false;\"># application configuration\nserver.port=9500\nspring.application.name=springboot-mongodb-sequence-id-example\n# spring boot and mongodb configuration\n# db name\nspring.data.mongodb.database=employees\n# hostname\nspring.data.mongodb.host=localhost\n# port number\nspring.data.mongodb.port=27017\n# sql query logging\nlogging.level.org.springframework.data.mongodb.core.MongoTemplate=debug\n<\/pre>\n<h3>3.3 Java Classes<\/h3>\n<p>Let us write the important java class(es) involved in this application. For brevity, we will skip the following classes \u2013<\/p>\n<ul>\n<li><code>Employee.java<\/code> &#8211; The class contain the employee properties, constructor to set the properties, and getter methods<\/li>\n<li><code>EmployeeRepo.java<\/code> &#8211; An interface that extends the <code>MongoRepository<\/code> interface for the database operations<\/li>\n<li><code>EmployeeService.java<\/code> &#8211; The class that calls the database layer methods<\/li>\n<li><code>BeanConfig.java<\/code> &#8211; The class used to create the object for the <code>Faker<\/code> class so that this class can be autowired<\/li>\n<\/ul>\n<h4>3.3.1 Implementation\/Main class<\/h4>\n<p>Add the following code to the main class to bootstrap the application from the main method. Always remember, the entry point of the spring boot application is the class containing <code>@SpringBootApplication<\/code> annotation and the static main method.<\/p>\n<p><span style=\"text-decoration: underline\"><em>SpringbootandMongodbSequenceIdApplication.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">package com.springboot.mongodb;\n\nimport lombok.extern.slf4j.Slf4j;\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\n\n\/\/ Lombok annotation for logger\n@Slf4j\n\/\/ Spring annotation\n@SpringBootApplication\npublic class SpringbootandMongodbSequenceIdApplication {\n\n    public static void main(String[] args) {\n        SpringApplication.run(SpringbootandMongodbSequenceIdApplication.class, args);\n        log.info(\"Springboot and mongodb sequence id generator started successfully.\");\n    }\n\n}\n<\/pre>\n<h4>3.3.2 Database sequence model class<\/h4>\n<p>Add the following code to the sequence model class which will help store the sequence number in the mongodb collection (named &#8211; <code>db_sequence<\/code>).<\/p>\n<p><span style=\"text-decoration: underline\"><em>DbSequence.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">package com.springboot.mongodb.entity;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Data;\nimport lombok.NoArgsConstructor;\nimport org.springframework.data.annotation.Id;\nimport org.springframework.data.mongodb.core.mapping.Document;\nimport org.springframework.data.mongodb.core.mapping.Field;\nimport org.springframework.stereotype.Component;\n\n\/\/ Mongodb annotation\n\/\/ marks a class for the domain object that we want to persist in the db\n@Document(collection = \"db_sequence\")\n\/\/ Lombok annotations\n@Data\n@NoArgsConstructor\n@AllArgsConstructor\n\/\/ Spring stereotype annotation\n@Component\npublic class DbSequence {\n\n    @Id\n    String id;\n    \/\/ describes the field name as it will be represented in mongodb bson document\n    \/\/ offers the name to be different than the field name of the class\n    @Field(\"sequence_number\")\n    int sequence;\n}\n<\/pre>\n<h4>3.3.3 Database sequence generator class<\/h4>\n<p>Add the following code to the service class which helps to generate the next <code>id<\/code> sequence for the employee record.<\/p>\n<p><span style=\"text-decoration: underline\"><em>DbSequenceGenr.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">package com.springboot.mongodb.service;\n\nimport com.springboot.mongodb.entity.DbSequence;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.data.mongodb.core.FindAndModifyOptions;\nimport org.springframework.data.mongodb.core.MongoOperations;\nimport org.springframework.data.mongodb.core.query.Criteria;\nimport org.springframework.data.mongodb.core.query.Query;\nimport org.springframework.data.mongodb.core.query.Update;\nimport org.springframework.stereotype.Service;\n\nimport java.util.Objects;\n\n@Service\npublic class DbSequenceGenr {\n\n    @Autowired\n    private MongoOperations operations;\n\n    public int getNextSequence(final String sequenceName) {\n        \/\/ get the sequence number\n        final Query q = new Query(Criteria.where(\"id\").is(sequenceName));\n        \/\/ increment the sequence number by 1\n        \/\/ \"sequence\" should match the attribute value specified in DbSequence.java class.\n        final Update u = new Update().inc(\"sequence\", 1);\n        \/\/ modify in document\n        final DbSequence counter = operations.findAndModify(q, u,\n                FindAndModifyOptions.options().returnNew(true).upsert(true), DbSequence.class);\n\n        return !Objects.isNull(counter) ? counter.getSequence() : 1;\n    }\n}\n<\/pre>\n<h4>3.3.4 Default bootstrap class<\/h4>\n<p>Add the following code to the bootstrap class which helps to store the employee data into the mongodb collection (named &#8211; <code>employees<\/code>) at the application bootstrap.<\/p>\n<p><span style=\"text-decoration: underline\"><em>DefaultEmployeeLoader.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">package com.springboot.mongodb.bootstrap;\n\nimport com.github.javafaker.Faker;\nimport com.springboot.mongodb.entity.Employee;\nimport com.springboot.mongodb.service.DbSequenceGenr;\nimport com.springboot.mongodb.service.EmployeeService;\nimport lombok.extern.slf4j.Slf4j;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.boot.CommandLineRunner;\nimport org.springframework.stereotype.Component;\n\nimport java.util.Random;\n\n\/\/ Lombok annotation for logger\n@Slf4j\n\/\/ Spring annotation\n@Component\npublic class DefaultEmployeesLoader implements CommandLineRunner {\n\n    private static final String[] GENDER = {\"Male\", \"Female\", \"Transgender\"};\n    private static final Random RANDOM = new Random();\n\n    @Autowired\n    private EmployeeService service;\n    @Autowired\n    private DbSequenceGenr sequenceGenr;\n    @Autowired\n    private Faker faker;\n\n    \/\/ will add the dummy employee data in the mongodb collection\n    \/\/ will be executed automatically on the application startup\n    @Override\n    public void run(String... args) {\n        if (service.getCollectionCount() == 0) {\n            log.info(\"Saving default employees in the collection\");\n            for (int i=0; i&lt;11; i++) {\n                persist();\n            }\n        } else {\n            log.info(\"Default employees are already present in the mongo collection\");\n        }\n    }\n\n    \/\/ calls the service layer method which in turn calls the dao layer method\n    \/\/ to save the employee record in the mongodb collection\n    private void persist() {\n        final Employee e = createEmployee();\n        service.save(e);\n    }\n\n    \/\/ using the faker library to create some mock data for the employee model\n    private Employee createEmployee() {\n        final String firstName = faker.name().firstName();\n        final String lastName = faker.name().lastName();\n        final String gender = GENDER[RANDOM.nextInt(GENDER.length)];\n        final String email = firstName.toLowerCase() + \".\" + lastName.toLowerCase() + \"@automation.com\";\n\n        return Employee.builder()\n                .id(sequenceGenr.getNextSequence(Employee.SEQUENCE_NUMBER))\n                .firstName(firstName)\n                .lastName(lastName)\n                .gender(gender)\n                .email(email)\n                .phoneNumber(faker.phoneNumber().cellPhone())\n                .homeAddress(faker.address().fullAddress())\n                .build();\n    }\n}\n<\/pre>\n<h4>3.3.5 Controller class<\/h4>\n<p>Add the following code to the controller class. The class has two methods that will fetch the employee&#8217;s information from the <code>employees<\/code> collection.<\/p>\n<p><span style=\"text-decoration: underline\"><em>EmployeeCtrl.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">package com.springboot.mongodb.controller;\n\nimport com.springboot.mongodb.entity.Employee;\nimport com.springboot.mongodb.service.EmployeeService;\nimport lombok.extern.slf4j.Slf4j;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.http.HttpStatus;\nimport org.springframework.http.ResponseEntity;\nimport org.springframework.web.bind.annotation.GetMapping;\nimport org.springframework.web.bind.annotation.PathVariable;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RestController;\n\nimport java.util.List;\n\n\/\/ Lombok annotation for logger\n@Slf4j\n\/\/ Spring annotations\n@RestController\n@RequestMapping(\"\/api\")\npublic class EmployeeCtrl {\n\n    @Autowired\n    private EmployeeService service;\n\n    \/\/ Url - http:\/\/localhost:9500\/api\/employees\n    @GetMapping(\"\/employees\")\n    public ResponseEntity&lt;List&lt;Employee&gt;&gt; getAll() {\n        log.info(\"Fetching all employees from the db\");\n        return new ResponseEntity&lt;&gt;(service.getEmployees(), HttpStatus.OK);\n    }\n\n    \/\/ Url - http:\/\/localhost:9500\/api\/employees\/gender\/Female\n    \/\/ where gender type can be - Male, Female, or Transgender\n    @GetMapping(\"\/employees\/gender\/{type}\")\n    public ResponseEntity&lt;List&lt;Employee&gt;&gt; getEmployeesByGender(@PathVariable(\"type\") String type) {\n        log.info(\"Fetching all employees from the db where gender type = {}\", type);\n        return new ResponseEntity&lt;&gt;(service.getEmployeesByGender(type), HttpStatus.OK);\n    }\n}\n<\/pre>\n<h2>4. Run the Application<\/h2>\n<p>To execute the application, right-click on the <code>SpringbootandMongodbSequenceIdApplication.java<\/code> class, <code>Run As -&gt; Java Application<\/code>.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/springboot-and-mongodb-sequenceid-generator-project-run-img1.jpg\"><img decoding=\"async\" width=\"785\" height=\"611\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/springboot-and-mongodb-sequenceid-generator-project-run-img1.jpg\" alt=\"Spring Boot MongoDB Sequence - run the application\" class=\"wp-image-98526\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/springboot-and-mongodb-sequenceid-generator-project-run-img1.jpg 785w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/springboot-and-mongodb-sequenceid-generator-project-run-img1-300x234.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/springboot-and-mongodb-sequenceid-generator-project-run-img1-768x598.jpg 768w\" sizes=\"(max-width: 785px) 100vw, 785px\" \/><\/a><figcaption>Fig. 4: Run the Application<\/figcaption><\/figure>\n<\/div>\n<h2>5. Project Demo<\/h2>\n<p>When the application is started, the default data will be pushed to the mongodb collection (named &#8211; <code>employees<\/code>). You can hit the following URL &#8211; <code>http:\/\/localhost:9001\/<\/code> to confirm that the default data has been successfully persisted in the mongodb collection.<\/p>\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/mongo-express-img2-1.jpg\"><img decoding=\"async\" width=\"818\" height=\"553\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/mongo-express-img2-1.jpg\" alt=\"\" class=\"wp-image-98527\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/mongo-express-img2-1.jpg 818w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/mongo-express-img2-1-300x203.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/mongo-express-img2-1-768x519.jpg 768w\" sizes=\"(max-width: 818px) 100vw, 818px\" \/><\/a><figcaption>Fig. 5: Default data persisted successfully in employees collection<\/figcaption><\/figure>\n<p>You are free to use <a href=\"https:\/\/www.getpostman.com\/\" target=\"_blank\" rel=\"noopener\">postman<\/a> or any other tool of your choice to make a post request to the endpoint.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Generate access token endpoint<\/em><\/span><\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">-- HTTP GET endpoint url \u2013\nhttp:\/\/localhost:9500\/api\/employees\n\n-- HTTP GET endpoint url (to fetch employees by gender)--\nhttp:\/\/localhost:9500\/api\/employees\/gender\/Female\n<\/pre>\n<p>That is all for this tutorial and I hope the article served you whatever you were looking for. Happy Learning and do not forget to share!<\/p>\n<h2>6. Summary<\/h2>\n<p>In this section, you learned,<\/p>\n<ul>\n<li>Spring boot and Mongodb introduction<\/li>\n<li>Steps to run mongodb and mongo-express on Docker using the <code>docker-compose<\/code> command<\/li>\n<li>Steps to implement mongodb sequence id generator in Spring Boot<\/li>\n<\/ul>\n<p>You can download the sample application as an Eclipse project in the <a href=\"#projectDownload\">Downloads<\/a> section.<\/p>\n<h2><a name=\"projectDownload\"><\/a>7. Download the Project<\/h2>\n<p>This was an example of implementing MongoDB sequence id generator in a Spring Boot application.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the full source code of this example here: <a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/12\/SpringbootandMongodbSequenceId.zip\" target=\"_blank\" rel=\"noopener\"><strong>Spring Boot and MongoDB Sequence ID Generator<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Welcome, in this tutorial, we will see how to generate a mongodb sequence id in a spring boot application. 1. Introduction Before going further in this tutorial, we will look at the common terminology such as introduction to Spring Boot and mongodb. 1.1 Spring Boot Spring boot is a module that provides rapid application development &hellip;<\/p>\n","protected":false},"author":119,"featured_media":1248,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1390],"tags":[1054,1386,1675],"class_list":["post-98522","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-boot","tag-spring","tag-spring-boot","tag-spring-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Spring Boot and MongoDB Sequence ID Generator - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Welcome, in this tutorial, we will see how to generate a mongodb sequence id in a spring boot application. 1. Introduction Before going further in this\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Boot and MongoDB Sequence ID Generator - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Welcome, in this tutorial, we will see how to generate a mongodb sequence id in a spring boot application. 1. Introduction Before going further in this\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-31T09:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/\"},\"author\":{\"name\":\"Yatin\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\"},\"headline\":\"Spring Boot and MongoDB Sequence ID Generator\",\"datePublished\":\"2020-12-31T09:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/\"},\"wordCount\":1119,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"keywords\":[\"spring\",\"spring boot\",\"spring tutorial\"],\"articleSection\":[\"Boot\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/\",\"name\":\"Spring Boot and MongoDB Sequence ID Generator - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"datePublished\":\"2020-12-31T09:00:00+00:00\",\"description\":\"Welcome, in this tutorial, we will see how to generate a mongodb sequence id in a spring boot application. 1. Introduction Before going further in this\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"spring\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/spring\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Boot\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/spring\/boot\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"Spring Boot and MongoDB Sequence ID Generator\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\",\"name\":\"Yatin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"caption\":\"Yatin\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Boot and MongoDB Sequence ID Generator - Java Code Geeks","description":"Welcome, in this tutorial, we will see how to generate a mongodb sequence id in a spring boot application. 1. Introduction Before going further in this","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/","og_locale":"en_US","og_type":"article","og_title":"Spring Boot and MongoDB Sequence ID Generator - Java Code Geeks","og_description":"Welcome, in this tutorial, we will see how to generate a mongodb sequence id in a spring boot application. 1. Introduction Before going further in this","og_url":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2020-12-31T09:00:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Yatin","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/"},"author":{"name":"Yatin","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13"},"headline":"Spring Boot and MongoDB Sequence ID Generator","datePublished":"2020-12-31T09:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/"},"wordCount":1119,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","keywords":["spring","spring boot","spring tutorial"],"articleSection":["Boot"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/","url":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/","name":"Spring Boot and MongoDB Sequence ID Generator - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","datePublished":"2020-12-31T09:00:00+00:00","description":"Welcome, in this tutorial, we will see how to generate a mongodb sequence id in a spring boot application. 1. Introduction Before going further in this","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/spring-boot-and-mongodb-sequence-id-generator\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/"},{"@type":"ListItem","position":4,"name":"spring","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/spring\/"},{"@type":"ListItem","position":5,"name":"Boot","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/spring\/boot\/"},{"@type":"ListItem","position":6,"name":"Spring Boot and MongoDB Sequence ID Generator"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13","name":"Yatin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","caption":"Yatin"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/98522","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/119"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=98522"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/98522\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1248"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=98522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=98522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=98522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}