What's Actually Happening
You run your Spring Boot application, expecting it to start up and serve requests, but instead it crashes during the Application Context initialization phase. The startup process fails with various errors: beans can't be created due to missing dependencies, circular dependencies prevent initialization, configuration properties can't be bound, or component scanning fails to find your classes.
The Application Context is the core of a Spring application - it's the IoC (Inversion of Control) container that manages all beans, handles dependency injection, and wires together your entire application. When it fails to start, the application is completely broken and can't serve any requests.
The Error You'll See
Spring Boot Application Context failures manifest in various ways depending on what went wrong:
```bash # Bean creation failure 2026-04-08 10:15:23.456 ERROR 12345 --- [main] o.s.b.d.LoggingFailureAnalysisReporter:
******* APPLICATION FAILED TO START *******
Description: Failed to instantiate 'com.example.service.UserService': constructor threw exception; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.repository.UserRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Action: Consider defining a bean of type 'com.example.repository.UserRepository' in your configuration.
# Circular dependency 2026-04-08 10:15:24.123 ERROR 12345 --- [main] o.s.b.d.LoggingFailureAnalysisReporter:
******* APPLICATION FAILED TO START *******
Action: Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle.
# Configuration binding failure 2026-04-08 10:15:25.789 ERROR 12345 --- [main] o.s.b.d.LoggingFailureAnalysisReporter:
******* APPLICATION FAILED TO START *******
Description: Failed to bind properties under 'app.datasource' to com.example.config.DataSourceProperties: Property: app.datasource.url Value: null Reason: The specified property 'app.datasource.url' is required but was not found.
Action: Update your application's configuration to provide a valid value for 'app.datasource.url'.
# Component scan not finding classes 2026-04-08 10:15:26.012 WARN 12345 --- [main] o.s.c.a.AnnotationConfigApplicationContext: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'userService' for bean class [com.example.service.UserService] conflicts with existing, non-compatible bean definition of same name and class [com.example.v2.service.UserService]
# Missing configuration class org.springframework.context.ApplicationContextException: Unable to start ServletWebServerFactory due to missing ServletWebServerFactory bean. org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration required a bean of type 'org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactory' that could not be found.
# DataSource connection failure com.zaxxer.hikari.pool.HikariPool: HikariPool-1 - Exception during pool initialization. java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=localhost)(port=5432)(type=master): Connection refused
# Multiple bean definitions Field userRepository in com.example.service.UserService required a single bean, but 2 were found: - userRepository: defined in file [/app/classes/com/example/repository/UserRepository.class] - userJpaRepository: defined in file [/app/classes/com/example/repository/UserJpaRepository.class]
Action: Consider marking one of the beans as @Primary or using @Qualifier to specify the bean.
# JPA/Hibernate error org.hibernate.AnnotationException: No identifier specified for entity: com.example.entity.User org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is org.hibernate.AnnotationException: No identifier specified for entity: com.example.entity.User ```
Additional symptoms: - Application exits immediately after startup attempt - Stack traces with BeanCreationException at the top - Errors mentioning autowiring, injection, or dependency resolution - Database connection errors during startup - Port binding errors (address already in use) - ClassNotFoundException for your components - Errors about missing @Configuration or @Component annotations
Why This Happens
- 1.Missing Bean Definition: A class depends on a bean that doesn't exist. The repository interface isn't annotated with @Repository, the interface isn't being scanned, or JPA repositories aren't enabled with @EnableJpaRepositories. The dependency injection fails because Spring can't find anything to inject.
- 2.Circular Dependency: Service A depends on Service B, which depends on Service C, which depends back on Service A. Spring can't initialize any of them because each needs the others to exist first. This was allowed in older Spring versions but is now prohibited by default.
- 3.Missing Required Configuration: Properties marked with @Value or bound to @ConfigurationProperties are required but not provided. The application.yml/application.properties is missing, environment variables aren't set, or the property name is wrong.
- 4.Incorrect Package Structure: The main application class is in a different package than your components, and @SpringBootApplication's default component scanning doesn't reach your classes. @Component, @Service, @Repository annotations exist but Spring never finds them.
- 5.Duplicate Bean Names: Two classes have the same simple name and Spring's default bean naming creates a conflict, or you explicitly gave two beans the same name via @Service("sameName"). Spring can't decide which to use.
- 6.Database Connection Issues: The datasource is configured but the database isn't reachable, credentials are wrong, or the database doesn't exist. Spring tries to validate the datasource during startup and fails.
- 7.Missing Dependencies in pom.xml/build.gradle: You're using annotations like @Entity, @Repository (JPA), or @RestController but the corresponding dependencies (spring-boot-starter-data-jpa, spring-boot-starter-web) aren't included in your build file.
- 8.Entity Mapping Errors: JPA entities have incorrect annotations - missing @Id, wrong @Column mappings, invalid relationships, or entities without proper configuration. Hibernate validation fails during startup.
Step 1: Identify the Root Cause from Stack Trace
First, examine the full stack trace to understand exactly which bean or configuration failed.
```bash # Run the application and capture full output java -jar your-app.jar 2>&1 | tee startup-error.log
# Or if running via Maven: mvn spring-boot:run 2>&1 | tee startup-error.log
# Or via Gradle: gradle bootRun 2>&1 | tee startup-error.log
# Enable debug logging for more details: java -jar your-app.jar --debug 2>&1 | tee startup-debug.log
# Or add to application.properties: logging.level.org.springframework=DEBUG logging.level.org.springframework.context=TRACE logging.level.org.springframework.beans=TRACE
# Look at the stack trace cat startup-error.log | grep -A100 "APPLICATION FAILED TO START"
# Identify the specific failing bean cat startup-error.log | grep -i "BeanCreationException|NoSuchBeanDefinitionException|CircularDependencyException|ConflictingBeanDefinitionException"
# Find the root cause at the end of stack trace: cat startup-error.log | grep "Caused by:" | tail -5
# Example analysis: # 1. BeanCreationException: Which bean failed? grep "Error creating bean with name" startup-error.log
# 2. NoSuchBeanDefinitionException: What type is missing? grep "No qualifying bean of type" startup-error.log
# 3. CircularDependencyException: Which beans form the cycle? grep -A20 "form a cycle" startup-error.log
# Check for configuration issues: grep -i "property|config|bind" startup-error.log
# Check for database issues: grep -i "datasource|connection|hikari|jdbc" startup-error.log ```
Document the exact bean name, missing dependency type, or circular dependency chain.
Step 2: Check Component Scanning and Package Structure
Ensure Spring is scanning the packages where your components exist.
```bash # Find your main application class grep -r "@SpringBootApplication" src/main/java/
# Check what package it's in: cat src/main/java/com/example/Application.java | grep "package"
# Example: package com.example;
# Spring Boot scans com.example and all sub-packages by default
# List all your components: find src/main/java -name "*.java" -exec grep -l "@Component|@Service|@Repository|@Controller|@RestController|@Configuration|@Entity" {} \;
# Check which package each component is in: find src/main/java -name "*.java" | while read f; do pkg=$(grep "^package" $f | sed 's/package //;s/;//') echo "$pkg: $f" done
# If components are in packages NOT under the main class package: # Example: Main in com.example, but Service in org.other.service # That's a scanning problem!
# Fix by adding @ComponentScan: cat src/main/java/com/example/Application.java ```
```java package com.example;
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication @ComponentScan(basePackages = {"com.example", "org.other"}) public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ```
```bash # Or check @SpringBootApplication configuration: cat src/main/java/com/example/Application.java
# Should be in the root package that covers all components # Move Application.java if needed to root package
# For JPA repositories, check @EnableJpaRepositories: grep -r "@EnableJpaRepositories" src/main/java/
# If missing, add it: cat src/main/java/com/example/Application.java ```
@SpringBootApplication
@EnableJpaRepositories(basePackages = "com.example.repository")
public class Application { ... }```bash # For JPA entities, check @EntityScan: grep -r "@EntityScan" src/main/java/
# Add if entities aren't being found: @SpringBootApplication @EntityScan(basePackages = "com.example.entity") public class Application { ... } ```
Step 3: Fix Missing Bean Definitions
Add missing annotations or create missing bean definitions.
```bash # Check if the missing bean type exists as a class: find src/main/java -name "*Repository.java" -o -name "*Service.java"
# Check annotations on the class: cat src/main/java/com/example/repository/UserRepository.java
# For JPA repositories, should have: cat src/main/java/com/example/repository/UserRepository.java ```
```java package com.example.repository;
import com.example.entity.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository;
@Repository public interface UserRepository extends JpaRepository<User, Long> { // methods } ```
```bash # If @Repository is missing, add it!
# For regular classes, check for @Component/@Service/@Configuration: cat src/main/java/com/example/service/UserService.java ```
```java package com.example.service;
import com.example.repository.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;
@Service public class UserService { @Autowired private UserRepository userRepository; // ... } ```
```bash # If class exists but annotation missing, add @Service or @Component
# Check if the bean type is an interface that needs implementation: cat src/main/java/com/example/repository/UserRepository.java
# If it's a plain interface (not JpaRepository), create implementation: cat > src/main/java/com/example/repository/UserRepositoryImpl.java << 'EOF' package com.example.repository;
import org.springframework.stereotype.Component;
@Component public class UserRepositoryImpl implements UserRepository { // implementation } EOF
# For @Configuration beans, check they return @Bean methods: cat src/main/java/com/example/config/AppConfig.java ```
```java package com.example.config;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;
@Configuration public class AppConfig { @Bean public SomeService someService() { return new SomeServiceImpl(); } } ```
```bash # Check pom.xml/gradle for required dependencies: cat pom.xml | grep "spring-boot-starter" cat build.gradle | grep "spring-boot-starter"
# Missing starters cause beans to not be auto-configured: # - spring-boot-starter-data-jpa: Enables JPA repositories # - spring-boot-starter-web: Enables controllers # - spring-boot-starter-data-mongodb: Enables Mongo repositories
# Add missing starter to pom.xml: ```
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>Step 4: Resolve Circular Dependencies
Break the circular dependency chain by restructuring your code.
```bash # Identify the exact cycle from the error message: grep -A20 "form a cycle" startup-error.log
# Example cycle: # userService -> orderService -> productService -> userService
# Examine each bean in the cycle: cat src/main/java/com/example/service/UserService.java cat src/main/java/com/example/service/OrderService.java cat src/main/java/com/example/service/ProductService.java
# Find where each injects the other: grep "@Autowired|@Inject" src/main/java/com/example/service/*.java ```
Solution 1: Use @Lazy to defer injection:
``java
@Service
public class UserService {
@Autowired
@Lazy
private OrderService orderService;
// ...
}
# Edit UserService:
sed -i 's/@Autowired/@Autowired\n @Lazy/' src/main/java/com/example/service/UserService.javaSolution 2: Use setter injection instead of constructor injection: ```java @Service public class UserService { private OrderService orderService;
@Autowired public void setOrderService(OrderService orderService) { this.orderService = orderService; } } ```
Solution 3: Refactor to eliminate the cycle: ```bash # Create a shared service that both can depend on: cat > src/main/java/com/example/service/CommonService.java << 'EOF' package com.example.service;
import org.springframework.stereotype.Service;
@Service public class CommonService { // Shared functionality that was causing the cycle } EOF
# Update UserService to use CommonService instead of OrderService: ```
@Service
public class UserService {
@Autowired
private CommonService commonService; // Instead of OrderService
// Methods that need OrderService functionality call CommonService
}Solution 4: Allow circular references (not recommended): ```bash # Add to application.properties: echo "spring.main.allow-circular-references=true" >> src/main/resources/application.properties
# Or in application.yml: cat src/main/resources/application.yml ```
spring:
main:
allow-circular-references: trueStep 5: Fix Configuration Property Binding
Ensure required properties are provided correctly.
```bash # Check what properties are required: cat startup-error.log | grep "Property:|required|Value: null"
# Examine configuration class: cat src/main/java/com/example/config/DataSourceProperties.java ```
```java package com.example.config;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; import jakarta.validation.constraints.NotNull;
@Component @ConfigurationProperties(prefix = "app.datasource") public class DataSourceProperties { @NotNull private String url; private String username; private String password; // getters, setters } ```
```bash # Check application.properties: cat src/main/resources/application.properties
# Should have matching properties: # app.datasource.url=jdbc:mysql://localhost:3306/mydb # app.datasource.username=root # app.datasource.password=secret
# Check application.yml: cat src/main/resources/application.yml ```
app:
datasource:
url: jdbc:mysql://localhost:3306/mydb
username: root
password: secret```bash # If properties missing, add them: echo "app.datasource.url=jdbc:mysql://localhost:3306/mydb" >> src/main/resources/application.properties echo "app.datasource.username=root" >> src/main/resources/application.properties echo "app.datasource.password=secret" >> src/main/resources/application.properties
# Check environment variables if using env config: env | grep APP_DATASOURCE
# Spring converts: app.datasource.url -> APP_DATASOURCE_URL
# Set environment variables: export APP_DATASOURCE_URL="jdbc:mysql://localhost:3306/mydb" export APP_DATASOURCE_USERNAME="root" export APP_DATASOURCE_PASSWORD="secret"
# Run with environment variables: java -jar app.jar
# Or pass as command arguments: java -jar app.jar --app.datasource.url=jdbc:mysql://localhost:3306/mydb
# Check for profile-specific config: ls src/main/resources/application-*.properties ls src/main/resources/application-*.yml
# Active profile: cat src/main/resources/application.properties | grep "spring.profiles.active" # Or: spring.config.activate.on-profile
# If profile is set, that profile's config must have the properties
# Make properties optional if truly optional: cat src/main/java/com/example/config/DataSourceProperties.java ```
@ConfigurationProperties(prefix = "app.datasource")
public class DataSourceProperties {
@NotNull // Remove if truly optional
private String url;
// or use default value:
private String url = "jdbc:mysql://localhost:3306/default";
}Step 6: Fix Duplicate Bean Names
Resolve conflicts between beans with the same name.
```bash # Find all beans with the conflicting name: grep -r "class.*UserService" src/main/java/
# Check for @Service annotations with explicit names: grep -r "@Service(\"userService\")" src/main/java/ grep -r "@Component(\"userService\")" src/main/java/
# List all beans and their names: grep -r "@Service|@Component|@Repository|@Controller" src/main/java/ | grep -v "//"
# For classes with same simple name: ls src/main/java/com/example/service/UserService.java ls src/main/java/com/example/v2/service/UserService.java
# Both create bean named "userService" by default!
# Solution 1: Rename one class: mv src/main/java/com/example/v2/service/UserService.java src/main/java/com/example/v2/service/UserServiceV2.java
# Update the class name inside: sed -i 's/class UserService/class UserServiceV2/' src/main/java/com/example/v2/service/UserServiceV2.java
# Solution 2: Use @Qualifier: cat src/main/java/com/example/v2/service/UserService.java ```
```java package com.example.v2.service;
import org.springframework.stereotype.Service;
@Service("userServiceV2") // Explicit different name public class UserService { ... } ```
# Solution 3: Mark one as @Primary:
cat src/main/java/com/example/service/UserService.java```java package com.example.service;
import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Service;
@Service @Primary // This one will be used by default public class UserService { ... } ```
# Solution 4: Use @Qualifier when injecting:
cat src/main/java/com/example/controller/UserController.java@RestController
public class UserController {
@Autowired
@Qualifier("userServiceV2") // Specify which bean
private UserService userService;
}Step 7: Fix Database Connection Issues
Ensure the database is reachable and credentials are correct.
```bash # Check datasource configuration: cat src/main/resources/application.properties | grep datasource cat src/main/resources/application.yml | grep -A10 datasource
# Test database connectivity manually: # For MySQL: mysql -h localhost -P 3306 -u root -p
# For PostgreSQL: psql -h localhost -p 5432 -U postgres
# For H2 (embedded): java -jar h2.jar
# Check database is running: systemctl status mysql systemctl status postgresql docker ps | grep mysql docker ps | grep postgres
# Start database if not running: sudo systemctl start mysql docker run -d --name mysql -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 mysql:8
# Check firewall allows connections: sudo iptables -L | grep 3306 sudo firewall-cmd --list-ports
# Verify connection URL is correct: # MySQL: jdbc:mysql://localhost:3306/dbname # PostgreSQL: jdbc:postgresql://localhost:5432/dbname # H2: jdbc:h2:mem:testdb
# Check database exists: mysql -u root -p -e "SHOW DATABASES LIKE 'mydb'" psql -U postgres -l | grep mydb
# Create database if missing: mysql -u root -p -e "CREATE DATABASE mydb" psql -U postgres -c "CREATE DATABASE mydb"
# Disable datasource validation temporarily: echo "spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver" >> src/main/resources/application.properties echo "spring.sql.init.mode=never" >> src/main/resources/application.properties
# Or use embedded database for testing: cat src/main/resources/application-test.properties ```
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driver-class-name=org.h2.Driver
spring.jpa.database-platform=org.hibernate.dialect.H2DialectStep 8: Fix JPA Entity Mapping Errors
Ensure entities have proper annotations for Hibernate.
```bash # Find all entity classes: find src/main/java -name "*.java" -exec grep -l "@Entity" {} \;
# Check each entity for required annotations: cat src/main/java/com/example/entity/User.java ```
```java package com.example.entity;
import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Table;
@Entity @Table(name = "users") public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id;
private String name; private String email;
// getters, setters } ```
```bash # Check for missing @Id: grep "@Id" src/main/java/com/example/entity/User.java
# Add @Id if missing: sed -i 's/private Long id;/@Id\n @GeneratedValue(strategy = GenerationType.IDENTITY)\n private Long id;/' src/main/java/com/example/entity/User.java
# Check imports: grep "import jakarta.persistence" src/main/java/com/example/entity/User.java
# Add imports if missing: ```
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;```bash # For older Spring Boot (< 3.0), use javax.persistence: import javax.persistence.Entity; import javax.persistence.Id;
# Check for invalid @Column annotations: grep "@Column" src/main/java/com/example/entity/User.java
# Fix column names that don't match database: @Column(name = "user_name") // Maps to database column "user_name"
# Check for relationship annotations: grep "@OneToMany|@ManyToOne|@ManyToMany|@OneToOne" src/main/java/com/example/entity/*.java
# Ensure relationships are properly configured: ```
```java @Entity public class Order { @Id private Long id;
@ManyToOne @JoinColumn(name = "user_id") private User user;
@OneToMany(mappedBy = "order", cascade = CascadeType.ALL) private List<OrderItem> items; } ```
Step 9: Add Missing Dependencies to Build File
Ensure all required Spring Boot starters are included.
```bash # Check pom.xml for starters: cat pom.xml | grep "<artifactId>spring-boot-starter"
# Common starters needed: # - spring-boot-starter-web: For @Controller, @RestController # - spring-boot-starter-data-jpa: For @Entity, @Repository (JPA) # - spring-boot-starter-data-mongodb: For MongoDB # - spring-boot-starter-validation: For @Valid, validation annotations # - spring-boot-starter-security: For @PreAuthorize, security
# Add missing starter to pom.xml: ```
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>```bash # For Gradle, check build.gradle: cat build.gradle | grep "spring-boot-starter"
# Add missing implementations: ```
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
runtimeOnly 'com.mysql:mysql-connector-j'
}```bash # Rebuild after adding dependencies: mvn clean install gradle clean build
# Verify dependencies are downloaded: mvn dependency:tree | grep spring-boot-starter gradle dependencies | grep spring-boot-starter ```
Step 10: Enable Debug Logging and Create Startup Health Check
Configure Spring to provide detailed startup information for future debugging.
```bash # Enable condition evaluation report: echo "debug=true" >> src/main/resources/application.properties
# This shows which auto-configurations were applied/skipped
# Enable bean creation logging: echo "logging.level.org.springframework.beans.factory.support=DEBUG" >> src/main/resources/application.properties
# Create startup health check script: cat > scripts/check-spring-startup.sh << 'EOF' #!/bin/bash
APP_JAR="target/your-app.jar" TIMEOUT=60
echo "Checking Spring Boot application startup..."
# Start app in background java -jar $APP_JAR --spring.main.log-startup-info=true > /tmp/spring-startup.log 2>&1 & APP_PID=$!
# Wait for startup or timeout for i in $(seq 1 $TIMEOUT); do if grep -q "Started Application in" /tmp/spring-startup.log; then echo "✓ Application started successfully" kill $APP_PID 2>/dev/null exit 0 fi if grep -q "APPLICATION FAILED TO START" /tmp/spring-startup.log; then echo "✗ Application failed to start" cat /tmp/spring-startup.log | grep -A20 "APPLICATION FAILED" kill $APP_PID 2>/dev/null exit 1 fi sleep 1 done
echo "✗ Startup timeout after $TIMEOUT seconds" cat /tmp/spring-startup.log kill $APP_PID 2>/dev/null exit 1 EOF
chmod +x scripts/check-spring-startup.sh
# Run the check: scripts/check-spring-startup.sh
# Create Actuator health endpoint check (if actuator enabled): curl -s http://localhost:8080/actuator/health | jq .
# Enable actuator in application.properties: echo "management.endpoints.web.exposure.include=health,info,beans" >> src/main/resources/application.properties ```
Checklist for Fixing Spring Boot Application Context Failures
| Step | Action | Command | Status |
|---|---|---|---|
| 1 | Identify root cause from stack trace | grep "APPLICATION FAILED TO START" startup.log | ☐ |
| 2 | Check component scanning and packages | grep "@SpringBootApplication" src/main/java/ | ☐ |
| 3 | Fix missing bean definitions | Add @Service/@Repository annotations | ☐ |
| 4 | Resolve circular dependencies | Use @Lazy or refactor code | ☐ |
| 5 | Fix configuration property binding | Add properties to application.properties | ☐ |
| 6 | Fix duplicate bean names | Rename classes or use @Primary/@Qualifier | ☐ |
| 7 | Fix database connection issues | Test DB connectivity, check config | ☐ |
| 8 | Fix JPA entity mapping errors | Add @Id, check @Entity annotations | ☐ |
| 9 | Add missing dependencies | Add spring-boot-starter-* to pom.xml | ☐ |
| 10 | Enable debug logging and health check | Add debug=true, create check script | ☐ |
Verify the Fix
After fixing Application Context issues, verify startup succeeds:
```bash # 1. Application starts without errors java -jar target/your-app.jar # Should see: "Started Application in X seconds"
# 2. No errors in startup log java -jar target/your-app.jar --spring.main.log-startup-info=true 2>&1 | grep -i error # Should return nothing
# 3. Actuator health endpoint returns UP curl http://localhost:8080/actuator/health # {"status":"UP"}
# 4. Beans endpoint shows all expected beans curl http://localhost:8080/actuator/beans | jq '.contexts[].beans | keys' # Should list all your beans
# 5. Application responds to requests curl http://localhost:8080/api/users # Should return valid response
# 6. Debug condition report shows expected configs java -jar target/your-app.jar --debug # Check CONDITIONS EVALUATION REPORT
# 7. Database connectivity verified curl http://localhost:8080/actuator/health | jq '.components.db' # {"status":"UP"}
# 8. JPA entities are mapped curl http://localhost:8080/actuator/beans | jq '.contexts[].beans | with_entries(select(.key | contains("jpa")))'
# 9. All controllers registered curl http://localhost:8080/actuator/mappings | jq '.contexts[].mappings.dispatcherServlets.dispatcherServlet[].details.requestMappingConditions.patterns' # Should show your endpoint paths
# 10. Application restarts successfully java -jar target/your-app.jar & sleep 10 curl http://localhost:8080/actuator/health kill %1 ```
Related Issues
- [Fix Spring Boot Bean Creation Exception](/articles/fix-spring-boot-bean-creation-exception) - Specific bean creation issues
- [Fix Spring Security Authentication Failed](/articles/fix-springboot-security-authentication) - Security configuration issues
- [Fix Hibernate Entity Mapping Error](/articles/fix-hibernate-entity-mapping) - JPA entity problems
- [Fix PostgreSQL Connection Refused](/articles/fix-postgresql-connection-refused) - Database connectivity
- [Fix MySQL Connection Timeout](/articles/fix-mysql-connection-timeout) - MySQL connection issues
- [Fix Java NullPointerException](/articles/fix-java-nullpointerexception) - Common Java errors
- [Fix Tomcat Port Already in Use](/articles/fix-tomcat-port-already-in-use) - Port binding issues