A minimal, production-ready Kotlin multimodule template for Spring Boot applications. This template provides a clean foundation for building scalable microservices with proper module separation and Spring-Kotlin integration.
This template follows a simple two-module architecture:
- service-module: Contains business logic and services
- springboot-application: Contains REST controllers and application configuration
This template includes proper Kotlin allopen plugin configuration to solve the common issue where Spring cannot
create beans from Kotlin classes (since Kotlin classes are final by default).
The allopen plugin automatically makes Kotlin classes open (non-final) when annotated with:
- @Component,- @Service,- @Repository
- @Controller,- @RestController
- @Configuration,- @SpringBootApplication
- @Transactional
- ✅ Spring dependency injection works correctly
- ✅ Spring AOP and transaction proxies work
- ✅ No need to manually add openkeywords
- ✅ Your @Serviceand@Controllerclasses work out of the box
Click "Use this template" button on GitHub to create a new repository from this template.
Run the customization script or manually update:
# Linux/Mac
./customize.sh
# Windows PowerShell  
./customize.ps1Package Names: Replace io.programmernewbie.template with your desired package:
- Update package declarations in all .ktfiles
- Update scanBasePackagesinKotlinMultimoduleTemplateApplication.kt
- Update groupinbuild.gradle
Project Name:
- Update rootProject.nameinsettings.gradle
- Update artifact names in build.gradlefiles
# Build the project
./gradlew build
# Run the application
./gradlew :springboot-application:bootRun
# Run tests
./gradlew testOnce running, test the example endpoints:
# Health check
curl http://localhost:8080/api/example/health
# Welcome message
curl http://localhost:8080/api/example/welcome?name=YourName
# Async welcome message
curl http://localhost:8080/api/example/welcome-async?name=YourNamekotlin-multimodule-template/
├── service-module/                 # Business logic layer
│   └── src/main/kotlin/
│       └── io/programmernewbie/template/service/
│           └── ExampleService.kt   # Example service implementation
├── springboot-application/         # Application layer
│   └── src/main/kotlin/
│       └── io/programmernewbie/template/
│           ├── KotlinMultimoduleTemplateApplication.kt  # Main application
│           └── controller/
│               └── ExampleController.kt                 # Example REST controller
├── scripts/                        # Gradle build scripts
│   ├── kotlin.gradle              # Kotlin + allopen plugin config
│   ├── spring_library.gradle      # Spring library configuration
│   └── spring_boot.gradle         # Spring Boot application config
├── docs/                          # Documentation
├── build.gradle                   # Root build configuration
├── settings.gradle                # Module configuration
└── gradle.properties             # Dependency versions
- Create a new directory for your module
- Add a build.gradlefile
- The module will be automatically included (see settings.gradle)
Update gradle.properties with version numbers and reference them in module build.gradle files.
Services: Just use @Service - no need for open keyword:
@Service
@Transactional
class YourService {
    // Spring will create proxies correctly
}Controllers: Just use @RestController - works automatically:
@RestController
@RequestMapping("/api/your-resource")
class YourController(
    private val yourService: YourService  // Dependency injection works
) {
    // Your endpoints here
}The template includes:
- JaCoCo for code coverage
- OWASP dependency check
- License reporting
- Kotlin code style enforcement
Run quality checks:
./gradlew check
./gradlew jacocoTestReport
./gradlew dependencyCheckAnalyze
# Update dependency locks after adding new dependencies
./gradlew resolveAndLockAll --write-locks- SPRING_PROFILES_ACTIVE: Set active Spring profiles
- SERVER_PORT: Override default port (8080)
Configure in springboot-application/src/main/resources/application.yml
./gradlew :springboot-application:bootJarFROM openjdk:17-jre-slim
COPY springboot-application/build/libs/*.jar app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]- Fork this repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Check the HELP.md for troubleshooting
- Review CONTRIBUTING.md for contribution guidelines
- Open an issue for bugs or feature requests
Template Version: 1.0.0
Kotlin Version: 1.9.25
Spring Boot Version: 3.5.3