Common Issues
Port 8080 Already in Use
Port 8080 Already in Use
Error Message:Solution 1: Kill the ProcessFind and kill the process using port 8080:Solution 2: Change the PortUpdate Or via command line:
application.yaml or use an environment variable:application.yaml
Database Connection Failed
Database Connection Failed
Error Message:Cause: PostgreSQL is not running or not accessible.Solution 1: Start PostgreSQLSolution 2: Verify Connection SettingsCheck Solution 3: Use Docker Compose
application.yaml or environment variables:application.yaml
Java Version Mismatch
Java Version Mismatch
Error Message:orCause: This project requires Java 21. You’re using an older version.Solution:
- Check your Java version:
- Install Java 21:
- Set JAVA_HOME:
Flyway Migration Failed
Flyway Migration Failed
Error Message:Cause: Database schema is out of sync with migration files.Solution 1: Repair FlywaySolution 2: Clean and Rebuild (Development Only)Solution 3: Baseline Existing Database
application.yaml
MapStruct Generated Code Not Found
MapStruct Generated Code Not Found
Error Message:orCause: MapStruct annotation processor hasn’t generated implementation classes.Solution:
- Clean and rebuild the project:
- Verify annotation processors are enabled in your IDE:
- Settings → Build, Execution, Deployment → Compiler → Annotation Processors
- Check “Enable annotation processing”
- Right-click project → Properties → Java Compiler → Annotation Processing
- Check “Enable project specific settings”
- Rebuild the project:
Lombok Annotations Not Working
Lombok Annotations Not Working
Error Message:Cause: Lombok plugin not installed or annotation processing disabled.Solution:
- IntelliJ IDEA:
- Install Lombok plugin: Settings → Plugins → Search “Lombok” → Install
- Enable annotation processing: Settings → Build → Compiler → Annotation Processors → Enable
- Restart IDE
- Eclipse:
- Download lombok.jar from https://projectlombok.org/download
- Run:
java -jar lombok.jar - Select Eclipse installation directory
- Click “Install/Update”
- VS Code:
- Install “Lombok Annotations Support” extension
- Reload window
Build Errors
Dependency Resolution Failed
Dependency Resolution Failed
Error Message:Solution:
Gradle Daemon Failed to Start
Gradle Daemon Failed to Start
Error Message:Solution:
Test Failures
Test Failures
Error Message:Solution:
- Run tests with verbose output:
- Run specific test class:
- Skip tests temporarily (not recommended):
- Check test reports:
Runtime Errors
Bean Creation Exception
Bean Creation Exception
Error Message:Cause: Spring cannot find a bean to inject.Solution:
- Check
UserBeanConfiguration.java- ensure all required beans are defined:
src/main/java/com/fbaron/user/config/UserBeanConfiguration.java
-
Verify component scanning is enabled (it should be by default with
@SpringBootApplication). - Check for circular dependencies - use constructor injection, not field injection.
Validation Errors Not Returning 400
Validation Errors Not Returning 400
Error Message:
API returns 500 instead of 400 for invalid input.Cause: Missing
@Valid annotation on controller method parameter.Solution:Ensure @Valid is present on DTO parameters:src/main/java/com/fbaron/user/web/rest/UserRestAdapter.java
Swagger UI Not Loading
Swagger UI Not Loading
Error Message:
404 Not Found when accessing
/swagger-ui/index.htmlSolution:- Verify the dependency is present in
build.gradle:
- Access the correct URL:
- Check if OpenAPI is configured in
OpenApiConfig.java:
CORS Errors in Browser
CORS Errors in Browser
Error Message:Solution:Add CORS configuration:
src/main/java/com/fbaron/user/config/WebConfig.java
Docker Issues
Docker Build Fails
Docker Build Fails
Error Message:Solution:
- Ensure Dockerfile uses correct base image:
- Check
.dockerignoredoesn’t exclude necessary files:
- Build with no cache:
Container Exits Immediately
Container Exits Immediately
Error Message:Solution:
- Check container logs:
- Ensure database is accessible from container:
- Use Docker Compose for better networking:
Cannot Connect to Database from Container
Cannot Connect to Database from Container
Error Message:Cause: Container cannot reach PostgreSQL on localhost.Solution:Use Docker Compose and service names:
docker-compose.yml
Performance Issues
Slow Database Queries
Slow Database Queries
Solution:
- Enable SQL logging to identify slow queries:
application.yaml
- Add database indexes:
- Use pagination for large result sets:
High Memory Usage
High Memory Usage
Solution:
- Limit JVM heap size:
- Use streaming for large datasets:
- Enable connection pooling in
application.yaml:
Getting Help
Check Logs
Review application logs for detailed error messages:
Enable Debug Mode
Run with debug logging:
Review Documentation
Check the Spring Boot docs for framework-specific issues.
Community Support
Ask questions on Stack Overflow with the
spring-boot tag.Related Resources
Configuration Guide
Learn about application configuration options
Testing Guide
Write tests to catch issues early
Extending the App
Add new features correctly
Deployment
Deploy to production environments