spring-boot
Master Spring Boot with auto-configuration, REST APIs, JPA, security, testing, and production-ready features for enterprise applications.
When & Why to Use This Skill
This Claude skill serves as a comprehensive guide and accelerator for building enterprise-grade Java applications using Spring Boot. It streamlines the development process by providing standardized patterns for RESTful APIs, data persistence with JPA, and robust security configurations, ensuring developers follow industry best practices for scalable and maintainable microservices.
Use Cases
- Rapidly scaffolding RESTful API endpoints with standardized Controller-Service-Repository patterns.
- Implementing efficient data access layers using Spring Data JPA and custom repository queries.
- Refactoring legacy Java code to modern Spring Boot standards using constructor injection and DTOs.
- Setting up production-ready application configurations, including environment profiles and validation logic.
- Developing secure and testable microservices with built-in best practices for exception handling and logging.
| name | spring-boot |
|---|---|
| description | Master Spring Boot with auto-configuration, REST APIs, JPA, security, testing, and production-ready features for enterprise applications. |
Spring Boot Development
Build production-ready Spring Boot applications with REST APIs, data access, security, and microservices patterns.
Core Patterns
REST Controller
@RestController
@RequestMapping("/api/users")
public class UserController {
@Autowired
private UserService userService;
@GetMapping
public List<User> getAllUsers() {
return userService.findAll();
}
@GetMapping("/{id}")
public ResponseEntity<User> getUserById(@PathVariable Long id) {
return userService.findById(id)
.map(ResponseEntity::ok)
.orElse(ResponseEntity.notFound().build());
}
@PostMapping
public ResponseEntity<User> createUser(@Valid @RequestBody UserDto userDto) {
User user = userService.create(userDto);
return ResponseEntity.status(HttpStatus.CREATED).body(user);
}
}
Service Layer
@Service
@Transactional
public class UserService {
@Autowired
private UserRepository userRepository;
public List<User> findAll() {
return userRepository.findAll();
}
public Optional<User> findById(Long id) {
return userRepository.findById(id);
}
public User create(UserDto dto) {
User user = new User();
user.setName(dto.getName());
user.setEmail(dto.getEmail());
return userRepository.save(user);
}
}
Repository
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
Optional<User> findByEmail(String email);
List<User> findByNameContaining(String name);
}
Configuration
@Configuration
public class AppConfig {
@Bean
public ModelMapper modelMapper() {
return new ModelMapper();
}
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
}
Best Practices
- Use constructor injection
- Implement proper exception handling
- Use DTOs for API contracts
- Leverage Spring Boot starters
- Use profiles for environments
- Implement proper logging
- Write integration tests
- Use validation annotations