Claude Skills Guide

Claude Code Struts to Spring Boot Migration Workflow

Legacy Struts applications served enterprises well for decades, but modern development demands Spring Boot’s agility, auto-configuration, and cloud-native capabilities. Migrating from Struts to Spring Boot is complex, requiring careful analysis of Action classes, XML configurations, and JSP views. This guide demonstrates how Claude Code skills transform a tedious manual migration into an automated, reliable workflow.

Understanding the Migration Challenge

Struts applications typically comprise Action classes extending ActionSupport, XML configuration files (struts.xml), JSP views, and form beans. Each component requires different transformation strategies:

Claude Code excels at analyzing existing codebases, identifying patterns, and generating equivalent Spring Boot implementations. The key lies in leveraging skills that combine code analysis tools with intelligent transformation capabilities.

Setting Up Claude Code for Migration

Begin by ensuring Claude Code has the necessary skills set up for comprehensive migration support. Place code-analysis.md, java-expert.md, and spring-framework.md skill files in your .claude/ directory and invoke them with /code-analysis, /java-expert, and /spring-framework.

These skills provide the foundation for analyzing Java code structures, understanding Spring patterns, and generating migration-aware transformations.

Step 1: Analyzing the Struts Application

The first phase involves inventorying your Struts application structure. Create a migration analysis skill that scans the codebase:

// Analyze Struts Action classes for migration planning
public class StrutsActionAnalyzer {
    public List<ActionMapping> analyzeActions(String basePath) {
        List<ActionMapping> mappings = new ArrayList<>();
        
        // Scan for Action class files
        FileScanner scanner = new FileScanner();
        List<File> actionFiles = scanner.findFiles(basePath, 
            "**/*Action.java");
        
        for (File actionFile : actionFiles) {
            ActionMapping mapping = parseActionClass(actionFile);
            mappings.add(mapping);
            
            // Identify key migration metrics
            System.out.println("Action: " + mapping.getName());
            System.out.println("  Methods: " + mapping.getMethods());
            System.out.println("  Form Bean: " + mapping.getFormBean());
        }
        
        return mappings;
    }
    
    private ActionMapping parseActionClass(File file) {
        // Extract action name, method, result type
        // Analyze dependencies and business logic complexity
    }
}

Claude Code can execute this analysis across your entire codebase, generating a comprehensive report mapping each Struts component to its Spring Boot equivalent.

Step 2: Converting Action Classes

The core transformation converts Struts Action classes to Spring MVC controllers. Claude Code applies pattern recognition to map:

Struts Component Spring Boot Equivalent
ActionSupport @Controller
execute() method @RequestMapping methods
ActionForward View name or @ResponseBody
ActionForm @ModelAttribute DTOs

Practical conversion example:

// Struts Original
public class UserAction extends ActionSupport {
    private UserForm userForm;
    
    public ActionForward execute(ActionMapping mapping, 
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response) {
        UserService service = new UserService();
        List<User> users = service.findAll();
        request.setAttribute("users", users);
        return mapping.findForward("success");
    }
}

// Spring Boot Converted
@Controller
@RequestMapping("/user")
public class UserController {
    
    @Autowired
    private UserService userService;
    
    @GetMapping("/list")
    public String listUsers(Model model) {
        List<User> users = userService.findAll();
        model.addAttribute("users", users);
        return "user/list";
    }
}

Claude Code’s transformation skills preserve business logic while updating the presentation layer. The skill identifies dependencies requiring injection and rewires the component accordingly.

Step 3: Configuration Migration

Struts XML configurations become Spring Boot’s annotation-driven approach. Claude Code parses struts.xml and generates equivalent Spring configurations:

// Configuration migration pattern
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        // Map Struts action forwards to view names
        registry.addViewController("/user/list")
                .setViewName("user/list");
    }
    
    @Bean
    public InternalResourceViewResolver viewResolver() {
        InternalResourceViewResolver resolver = 
            new InternalResourceViewResolver();
        resolver.setPrefix("/WEB-INF/views/");
        resolver.setSuffix(".jsp");
        return resolver;
    }
}

For properties previously in struts.xml, migrate to application.properties:

# Migration of Struts constants
struts.ui.theme=xhtml
struts.convention.result.path=/WEB-INF/views

# Spring Boot equivalents
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp

Step 4: Dependency and Build Migration

Update your build configuration from Struts to Spring Boot dependencies:

<!-- pom.xml Struts dependencies -->
<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>2.5.30</version>
</dependency>

<!-- Spring Boot equivalents -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-validation</artifactId>
</dependency>

Claude Code’s build analysis skill identifies all transitive dependencies requiring updates, preventing runtime conflicts that often plague manual migrations.

Step 5: Validation and Testing

The migration workflow concludes with comprehensive validation. Generate test cases that verify functional equivalence:

@SpringBootTest
@AutoConfigureMockMvc
public class UserControllerMigrationTest {
    
    @Autowired
    private MockMvc mockMvc;
    
    @Test
    public void testUserListEndpoint() throws Exception {
        mockMvc.perform(get("/user/list"))
               .andExpect(status().isOk())
               .andExpect(view().name("user/list"))
               .andExpect(model().attributeExists("users"));
    }
}

Run parallel testing comparing Struts and Spring Boot responses to ensure business logic preservation.

Automating the Complete Workflow

Chain these phases into a reproducible Claude Code skill:

# Migration workflow skill
name: struts-to-spring-boot-migration
description: Automated Struts to Spring Boot migration

Execute the complete migration by invoking the skill in a Claude Code session:

/struts-to-spring-boot-migration
Source path: ./src/main/java
Target path: ./src/main/java

Conclusion

Claude Code transforms the daunting Struts to Spring Boot migration from months of manual effort into a structured, automated workflow. By leveraging code analysis, pattern recognition, and intelligent transformation skills, you preserve business logic while modernizing your architecture. The key advantages include consistent code generation, comprehensive dependency management, and built-in validation ensuring functional equivalence. Start your migration today by installing the recommended skills and executing the workflow against your legacy Struts applications.

Built by theluckystrike — More at zovo.one