Introduction
Four years ago, I introduced the cumulocity-microservice-archetype - a Maven archetype that helps developers quickly scaffold Cumulocity microservice projects. Since then, Iβve gathered feedback from the community and significantly enhanced the archetype with modern development practices, improved IDE integration, and automated setup workflows.
This updated archetype now delivers a production-ready microservice template in under 5 minutes, complete with automated credential management, pre-configured IDE launch configurations for both VS Code and IntelliJ IDEA, and industry best practices baked in from the start, including GitHub Actions and Copilot custom agents.
In this article, Iβll walk you through the revamped archetype and highlight the game-changing improvements that make microservice development faster, smoother, and more enjoyable.
Whatβs New? Major Improvements at a Glance
Automated Initialization Scripts
The biggest improvement is the addition of automated initializer scripts that handle the entire microservice bootstrap process for your local development environment. Two scripts are included in the generated project:
initializr.ps1(Windows/PowerShell)initializr.sh(Linux/macOS/Bash)
These scripts automatically:
Create the microservice in your Cumulocity tenant
Subscribe your tenant to the microservice
Retrieve bootstrap credentials
Store environment variables in .env/dev.envfor local development
Use your existing sessions from go-c8y-cli
No more manual credential hunting! The days of copying Base64-encoded credentials from browser Developer Tools are over. You can now directly use your go-c8y-cli sessions. The scripts are independent of the project build process and can be re-run anytime you need to refresh credentials.
The .env/dev.env file generated by the initializer scripts contains the microservice bootstrap credential and tenant configuration:
C8Y_BASEURL=https://your-tenant.cumulocity.com
C8Y_BOOTSTRAP_TENANT=t12345
C8Y_BOOTSTRAP_USER=servicebootstrap_microservice-name
C8Y_BOOTSTRAP_PASSWORD=********
C8Y_MICROSERVICE_ISOLATION=MULTI_TENANT
Full IDE Integration
The archetype now includes pre-configured launch configurations for the two most popular Java IDEs:
VS Code Integration
.vscode/launch.jsonwith Spring Boot run configuration- Automatic environment variable loading from
.env/dev.env - Pre-configured VM arguments for Logback logging
IntelliJ IDEA Integration
.idea/runConfigurations/Spring_Boot-App.xmlready to use- EnvFile plugin support for automatic
.env/dev.envloading - No manual run configuration needed - just open and run!
Both configurations point to the same .env/dev.env file, ensuring consistency across IDEs and team members.
GitHub Actions
The archetype now includes two sample GitHub Actions workflows for CI/CD. These workflows automate building, testing, and deploying your microservice to a Cumulocity tenant whenever you push changes to the main and develop branches or create a new pull request.
The workflow .github/workflows/maven_build_deploy.yml includes steps for packaging three different deployment sizes (Small, Medium, Large) and deploying them to your tenant using go-c8y-cli. It is best practice to provide different packages for different environments: small means fewer CPU and memory resources are requested and is suited for development tenants, while large is suited for production tenants. However, the appropriate version depends highly on your microservice implementation and the environment where it is deployed.
Copilot Custom Agents (Experimental)
The archetype now includes Copilot custom agents, enabling AI-assisted development. The custom agent contains best practices, URLs, and specific knowledge about Cumulocity microservices.
This allows you to use GitHub Copilot more effectively within your microservice project context, accelerating development while maintaining code quality standards.
Enhanced Project Structure
The generated project now includes additional resources and best practices:
project/
βββ pom.xml
βββ .gitignore # NEW: Comprehensive ignore rules
βββ README.md # NEW: Template for project documentation
βββ initializr.ps1 # NEW: Windows initializer
βββ initializr.sh # NEW: Linux/Mac initializer
βββ .vscode/ # NEW: VS Code configuration
β βββ launch.json
βββ .idea/ # NEW: IntelliJ configuration
β βββ runConfigurations/
β βββ Spring_Boot-App.xml
βββ .env/ # NEW: Environment variables
β βββ dev.env # Generated by initializer
βββ .github
β βββ agents
β β βββ ps-java-microservice.agent.md # NEW: Copilot custom agent
β βββ workflows
β βββ maven_build.yml # NEW: GitHub Action, CI workflow
β βββ maven_build_deploy.yml # NEW: GitHub Action, CD workflow
βββ src/
βββ main/
β βββ java/
β β βββ package/
β β βββ App.java
β β βββ controller/
β β β βββ ExampleController.java
β β βββ service/
β β βββ ExampleService.java
β βββ resources/
β β βββ application.properties
β β βββ application-dev.properties # Spring profile support
β β βββ application-test.properties
β β βββ application-prod.properties
β β βββ banner.txt # NEW: Fancy Cumulocity banner
β βββ configuration/
β β βββ cumulocity.json # Microservice manifest
β β βββ logging.xml # Logback configuration
β βββ docker/
β βββ Dockerfile
βββ test/
βββ java/
βββ AppTest.java # JUnit 5 + SpringBootTest
Updated Dependencies: Spring Boot and Cumulocity SDK Versions
The archetype now uses the latest stable versions of Spring Boot 3.4 and the Cumulocity Microservice SDK 2025.X, ensuring you start with the most up-to-date libraries and features.
- Java 17
- Spring Boot 3.4
- Cumulocity Microservice SDK 2025.X
Prerequisites
Before you begin, ensure you have:
Java 17+ installed
Maven 3.8+ installed
Cumulocity Tenant 2025.1.0+
go-c8y-cli installed and configured with a session to your development tenant
Step-by-Step Guide
Step 1: Install the Archetype
Clone and install the archetype in your local Maven repository:
git clone https://github.com/Cumulocity-IoT/cumulocity-microservice-archetype.git
cd cumulocity-microservice-archetype
mvn clean install
Step 2: Generate Your Project
Navigate to your workspace and run the archetype in interactive mode:
Most Terminals:
mvn archetype:generate \
-DarchetypeGroupId=cumulocity.microservice \
-DarchetypeArtifactId=cumulocity-microservice-archetype \
-DinteractiveMode=true
PowerShell:
mvn archetype:generate `
"-DarchetypeGroupId=cumulocity.microservice" `
"-DarchetypeArtifactId=cumulocity-microservice-archetype" `
"-DinteractiveMode=true"
Step 3: Define Your Microservice
The interactive mode will prompt you for:
-
Microservice Name: Use lowercase letters, digits, and dashes (max 23 characters)
- Example:
hello-devices
- Example:
-
Artifact ID: Default is
cumulocity-microservice-<name>- Press Enter to accept the default or provide your own
-
Package Name: Default is
cumulocity.microservice.<name>
Important: Replace dashes with underscores for valid Java packages- Example:
cumulocity.microservice.hello_devices
-
Confirm: Review your configuration and type
Yto generate the project
Step 4: Initialize with Bootstrap Credentials (NEW!)
This is where the magic happens! Navigate to your new project and run the initializer script:
Windows (PowerShell):
cd cumulocity-microservice-hello-devices
.\initializr.ps1
Linux/macOS (Bash):
cd cumulocity-microservice-hello-devices
. ./initializr.sh
The script will:
- Create the microservice in your Cumulocity tenant
- Retrieve bootstrap credentials
- Save them to
.env/dev.env - Display a confirmation message
Creating microservice 'hello-devices' and retrieving bootstrap credentials...
Wrote environment variables to .env/dev.env
Start your IDE! Run configurations already prepared for IntelliJ and VS Code.
Step 5: Start Developing
Option A: Using VS Code
- Open the project in VS Code:
code . - Press
F5or go to Run > Start Debugging - Select the Spring Boot-App configuration
- The microservice starts with credentials automatically loaded!
Option B: Using IntelliJ IDEA
- Open the project in IntelliJ IDEA
- Wait for Maven import to complete
- (Optional) Install the EnvFile plugin for automatic
.envloading - Click the Run button or press
Shift+F10 - Select the Spring Boot-App configuration
- The microservice starts immediately!
Option C: Command Line
mvn clean package
java -jar target/cumulocity-microservice-hello-devices-1.0.0-SNAPSHOT.jar
Be aware that a Docker image is also created during the build process. However, the Docker build can be skipped by changing the property in the pom.xml to <c8y.docker.skip>true</c8y.docker.skip>.
Step 6: Test Your Microservice
Open your browser and navigate to:
http://localhost:8080/api/hello/devices
When prompted for credentials:
- Username:
{tenant}/{username}(e.g.,t12345/alexander.pester@cumulocity.com) - Password: Your Cumulocity password
You should see a JSON array of all devices from your tenant. Congratulations! Your microservice is running locally and connected to Cumulocity!
Step 7: Push to GitHub and Enable CI/CD
- Initialize a Git repository:
git init - Create a remote repository on a platform like GitHub, GitLab, or Bitbucket
- Check the prepared
.gitignoreto ensure it meets your needs - Add and commit your code:
git add . && git commit -m "Initial commit" - Connect to your remote:
git remote add origin <your-repository-url> - Push your code to the remote repository:
git push -u origin main - If you use GitHub, the included GitHub Actions workflows will automatically run on pushes to
mainanddevelopbranches. However, you need to add the following secrets to your repository settings: Secrets and variables > Actions > New repository secret
secrets.C8Y_HOST
secrets.C8Y_USER
secrets.C8Y_PASSWORD
Key Differences from the 2022 Version
| Feature | 2022 Version | 2026 Version |
|---|---|---|
| Credential Setup | Manual Base64 copy from DevTools | Using go-c8y-cli sessions |
| Environment Variables | Set in property files | Automated .env/dev.env generation, added to .gitignore |
| VS Code Support | None | Pre-configured run configuration |
| IntelliJ Support | None | Pre-configured run configuration |
| Documentation | Minimal README | Comprehensive README with IDE instructions |
| GitHub Actions | None | CI/CD workflows included |
| Copilot Custom Agents | None | Included for AI-assisted development |
Conclusion
The enhanced cumulocity-microservice-archetype eliminates the friction from microservice development. With automated credential management, full IDE integration, and best practices built in, you can focus on what matters: building great features for your IoT platform.
The initializer scripts alone save 10-15 minutes of manual setup per project. Multiply that across your team and projects, and youβre saving hours with every new project.
Give it a try and share your feedback! The archetype is open-source and welcomes contributions. Please report issues or suggest improvements on the Github repository Issues
Useful Links
GitHub: cumulocity-microservice-archetype
Example generated project: cumulocity-microservice-hello-devices