<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Coumarane COUPPANE</title>
    <description>The latest articles on DEV Community by Coumarane COUPPANE (@coumarane).</description>
    <link>https://dev.to/coumarane</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2801527%2Fe9427450-685e-4371-be91-d5a2598a370f.jpeg</url>
      <title>DEV Community: Coumarane COUPPANE</title>
      <link>https://dev.to/coumarane</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/coumarane"/>
    <language>en</language>
    <item>
      <title>🚀 How to Use CosmosDB with Java Spring Boot API – A Complete Guide</title>
      <dc:creator>Coumarane COUPPANE</dc:creator>
      <pubDate>Sat, 01 Feb 2025 14:10:45 +0000</pubDate>
      <link>https://dev.to/coumarane/how-to-use-cosmosdb-with-java-spring-boot-api-a-complete-guide-56j3</link>
      <guid>https://dev.to/coumarane/how-to-use-cosmosdb-with-java-spring-boot-api-a-complete-guide-56j3</guid>
      <description>&lt;p&gt;📌 Introduction&lt;br&gt;
If you're a Java developer looking for a practical way to integrate Azure CosmosDB into your Spring Boot API, this open-source project is for you! 🚀&lt;/p&gt;

&lt;p&gt;I built this project to help developers who need a working example of using Spring Boot with CosmosDB. Whether you're learning NoSQL databases, working with Azure Cloud, or just want to see how CosmosDB works in a real-world application, this repo will help you.&lt;/p&gt;



&lt;p&gt;🎯 Why I Built This Project&lt;br&gt;
While working with CosmosDB, I realized that many developers struggle with:&lt;br&gt;
✅ Setting up CosmosDB in a Spring Boot application&lt;br&gt;
✅ Configuring Reactive Spring Data CosmosDB properly&lt;br&gt;
✅ Handling CRUD operations in a scalable way&lt;/p&gt;

&lt;p&gt;So, I built this fully working API with CosmosDB to make it easy for developers to get started. The project is free, open-source, and easy to install!&lt;/p&gt;



&lt;p&gt;📌 Features&lt;br&gt;
✅ Spring Boot + Reactive CosmosDB Integration&lt;br&gt;
✅ CRUD API for Users (Create, Read, Update, Delete)&lt;br&gt;
✅ Pagination &amp;amp; Querying CosmosDB&lt;/p&gt;



&lt;p&gt;🛠️ Prerequisites&lt;br&gt;
Before you begin, ensure you have the following installed:&lt;br&gt;
✔️ Java: Version 21 or later&lt;br&gt;
✔️ Maven: Version 3.9.9 or later&lt;br&gt;
✔️ Azure Subscription: Required for creating &amp;amp; accessing Azure CosmosDB&lt;br&gt;
✔️ Azure CLI (az): Required for managing CosmosDB&lt;/p&gt;



&lt;p&gt;🚀 How to Install and Run Locally&lt;br&gt;
Follow these steps to clone and run the project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1️⃣ Clone the Repository&lt;/span&gt;
git clone https://github.com/coumarane/spring-boot-cosmosdb.git
&lt;span class="nb"&gt;cd &lt;/span&gt;spring-boot-cosmosdb

&lt;span class="c"&gt;# 2️⃣ Build the Project&lt;/span&gt;
./mvnw clean &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="c"&gt;# 3️⃣ Run the Application&lt;/span&gt;
./mvnw spring-boot:run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;🔌 Configure Azure CosmosDB Connection&lt;/p&gt;

&lt;p&gt;Create a CosmosDB account before continuing with the further steps.&lt;/p&gt;

&lt;p&gt;Use a Real CosmosDB Instance&lt;br&gt;
Update an application.properties file in src/main/resources/ :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;azure.cosmos.connection-string=&amp;lt;&amp;lt;PRIMARY CONNECTION STRING&amp;gt;&amp;gt;
azure.cosmos.database=&amp;lt;&amp;lt;COSMOSDB DATABASE&amp;gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;📡 API Endpoints &amp;amp; Testing&lt;/p&gt;

&lt;p&gt;Once the application is running, you can test the APIs:&lt;/p&gt;

&lt;p&gt;✅ Get All Users&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-i&lt;/span&gt; http://localhost:8080/users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Create a New User&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="nt"&gt;-X&lt;/span&gt; POST &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{"email":"john@gmail.com", "firstName":"John", "lastName":"Doe", "city":"New York"}'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  http://localhost:8080/users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Update a User&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="nt"&gt;-X&lt;/span&gt; PUT &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{"email":"john_updated@gmail.com", "firstName":"John", "lastName":"Doe", "city":"Los Angeles"}'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  http://localhost:8080/users/&lt;span class="o"&gt;{&lt;/span&gt;USER ID&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Delete a User&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="nt"&gt;-X&lt;/span&gt; DELETE http://localhost:8080/users/&lt;span class="o"&gt;{&lt;/span&gt;USER ID&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;🌟 GitHub Repo&lt;br&gt;
🔗 Check out the full code here:&lt;br&gt;
➡️ GitHub Repository: &lt;a href="https://github.com/coumarane/spring-boot-cosmosdb" rel="noopener noreferrer"&gt;https://github.com/coumarane/spring-boot-cosmosdb&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you find this useful, please ⭐ star the repo and share it with others! 😊🚀&lt;/p&gt;




&lt;p&gt;📝 Final Thoughts&lt;br&gt;
This project is open-source and meant to help developers quickly integrate CosmosDB with Spring Boot. If you're working on a cloud-based, NoSQL application, this will save you a lot of setup time!&lt;/p&gt;

&lt;p&gt;Let me know what you think in the comments! 💬&lt;/p&gt;

&lt;p&gt;🚀 Happy Coding!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
