Skills-4-SE spring-mvc-to-boot-migrator
Automatically migrate Spring MVC applications to Spring Boot. Use when you need to modernize a Spring MVC project to Spring Boot while preserving functionality. The skill analyzes the codebase, updates build configuration (Maven/Gradle), migrates annotations, converts XML configuration to Java/properties, updates controllers and tests, and creates the Spring Boot main application class. Creates git commits for each migration phase and generates a comprehensive summary. Supports both Maven and Gradle projects.
git clone https://github.com/ArabelaTso/Skills-4-SE
T=$(mktemp -d) && git clone --depth=1 https://github.com/ArabelaTso/Skills-4-SE "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/spring-mvc-to-boot-migrator" ~/.claude/skills/arabelatso-skills-4-se-spring-mvc-to-boot-migrator && rm -rf "$T"
skills/spring-mvc-to-boot-migrator/SKILL.mdSpring MVC to Spring Boot Migrator
Overview
This skill automatically migrates Spring MVC applications to Spring Boot, transforming build configuration, annotations, XML configuration, controllers, and tests while preserving existing functionality. It handles Maven and Gradle projects, creates incremental git commits, and generates detailed migration summaries.
Quick Start
Basic Usage
# Navigate to your Spring MVC project cd /path/to/spring-mvc-project # Run migration (auto-detects Maven or Gradle) python scripts/migrate.py . # Or specify build tool explicitly python scripts/migrate.py . --build-tool maven
The migration process will:
- Create a migration branch
- Analyze your codebase
- Update build configuration
- Migrate annotations
- Convert configuration files
- Update tests
- Generate a summary report
Example Migration
# Migrate Spring MVC project python scripts/migrate.py /path/to/project # Output: # ✓ Detected build tool: maven # ✓ Detected Spring version: 5.3.20 # ✓ Created migration branch: migrate-spring-mvc-to-boot # ✓ Analyzing codebase... # ✓ Found 8 controllers # ✓ Found 12 services # ✓ Found 15 test files # ✓ Migrating build configuration... # ✓ Migrating annotations... # ✓ Migrating configuration... # ✓ Migrating tests... # ✓ Migration completed successfully!
Supported Migration Paths
Spring MVC → Spring Boot
What gets migrated:
-
Build Configuration
- Maven: Add Spring Boot parent, update dependencies, add Spring Boot plugin
- Gradle: Add Spring Boot plugin, update dependencies
-
Annotations
+@Controller
→@ResponseBody@RestController
→@RequestMapping(method = RequestMethod.GET)@GetMapping- Similar for
,@PostMapping
,@PutMapping@DeleteMapping - Update imports from
tojavax.*jakarta.*
-
Configuration
- XML configuration → Java configuration + application.properties
- web.xml → Spring Boot auto-configuration
- Create Spring Boot main application class
-
Tests
- JUnit 4 → JUnit 5
→@RunWith(SpringRunner.class)@SpringBootTest- Manual MockMvc setup →
@AutoConfigureMockMvc
Example transformation:
Before (Spring MVC):
@Controller @RequestMapping("/users") public class UserController { @RequestMapping(method = RequestMethod.GET) @ResponseBody public List<User> getUsers() { return userService.findAll(); } }
After (Spring Boot):
@RestController @RequestMapping("/users") public class UserController { @GetMapping public List<User> getUsers() { return userService.findAll(); } }
Migration Process
Phase 1: Preparation
The migration tool automatically:
- Validates the repository is a git repo
- Detects build tool (Maven or Gradle)
- Detects current Spring version
- Creates a migration branch
- Analyzes codebase structure
Phase 2: Build Configuration Migration
Maven projects:
- Adds Spring Boot parent POM
- Replaces individual Spring dependencies with Spring Boot starters
- Adds Spring Boot Maven plugin
- Updates dependency versions
Gradle projects:
- Adds Spring Boot plugin
- Adds dependency management plugin
- Replaces dependencies with Spring Boot starters
- Updates build configuration
Phase 3: Annotation Migration
Updates Java annotations:
- Controller annotations (
)@RestController - Request mapping annotations (
,@GetMapping
, etc.)@PostMapping - Import statements (
→javax.*
)jakarta.* - Creates Spring Boot main application class with
@SpringBootApplication
Phase 4: Configuration Migration
Converts configuration:
- XML configuration → Java configuration classes
- web.xml → Spring Boot auto-configuration
- Creates
with common settingsapplication.properties - Identifies manual conversion needs for complex XML configs
Phase 5: Test Migration
Updates test files:
- JUnit 4 → JUnit 5 annotations
- Test runner annotations
- MockMvc setup
- Test context configuration
- Assertion methods
Phase 6: Summary Generation
Creates comprehensive report:
- Total changes made
- Files modified by category
- Migration plan executed
- Next steps for manual review
- Saved as
MIGRATION_SUMMARY.json
Using the Migration Scripts
Main Migration Script
python scripts/migrate.py <repo_path> [--build-tool <maven|gradle|auto>] # Options: # repo_path: Path to the Spring MVC repository # --build-tool: Build tool (default: auto-detect)
Individual Migration Modules
You can also run individual migration steps:
from migrate_build import BuildMigrator from migrate_annotations import AnnotationMigrator from migrate_config import ConfigMigrator from migrate_tests import TestMigrator # Run specific migration migrator = AnnotationMigrator(repo_path) migrator.migrate()
Post-Migration Steps
After migration completes:
-
Review the changes
git log --oneline git diff main..migrate-spring-mvc-to-boot -
Build the project
# Maven mvn clean package # Gradle gradle clean build -
Run the application
# Maven mvn spring-boot:run # Gradle gradle bootRun # Or run JAR directly java -jar target/myapp.jar -
Run tests
# Maven mvn test # Gradle gradle test -
Manual review needed for:
- Complex XML configuration (convert to Java config)
- Custom servlet filters
- Advanced security configuration
- Third-party integrations
- Custom view resolvers
-
Test endpoints
curl http://localhost:8080/users -
Merge when ready
git checkout main git merge migrate-spring-mvc-to-boot
Reference Documentation
- Comprehensive step-by-step migration guide covering all aspects from build configuration to testing, with detailed examples and troubleshootingreferences/migration_guide.md
- Detailed comparison of Spring MVC and Spring Boot including architecture, configuration, controllers, testing, and deploymentreferences/framework_comparison.md
Example Code
Example controller files are provided in
assets/:
- Spring MVC controller before migrationUserController_Before.java
- Spring Boot controller after migrationUserController_After.java
Compare these files to understand the transformations applied.
Migration Summary
After migration, review
MIGRATION_SUMMARY.json:
{ "source_framework": "Spring MVC", "target_framework": "Spring Boot", "build_tool": "maven", "total_changes": 35, "changes_by_type": { "build": 5, "annotation": 12, "config": 6, "test": 12 }, "files_modified": [...], "next_steps": [...] }
Tips
- Always backup your code before migration
- Review each migration commit individually
- Test thoroughly after migration
- Convert complex XML configs to Java configuration manually
- Update documentation to reflect Spring Boot conventions
- Enable Spring Boot Actuator for production monitoring
- Use Spring Boot DevTools for development
- Consult reference documentation for complex patterns
- Run tests frequently during manual adjustments
Troubleshooting
Issue: Application won't start
- Solution: Check for
annotation and correct package structure@SpringBootApplication
Issue: Controllers not found
- Solution: Ensure controllers are in same package or sub-package as Application class
Issue: Build fails
- Solution: Run
ormvn clean install
to refresh dependenciesgradle clean build
Issue: Tests fail
- Solution: Update JUnit 4 to JUnit 5, check test annotations
Issue: Database connection fails
- Solution: Update connection properties in application.properties
See
references/migration_guide.md for detailed troubleshooting.
Benefits of Migration
- Reduced Configuration: 80% less configuration code
- Faster Development: Quick setup and development cycles
- Production Ready: Built-in monitoring and health checks
- Modern Standards: Latest Spring features and best practices
- Easier Deployment: Self-contained executable JARs
- Better Testing: Simplified test configuration
- Microservices Ready: Perfect for microservices architecture