debugjavaModeratepending
Spring Boot application fails to start — port conflict or bean conflicts
Viewed 0 times
bean definitionport already in useunsatisfied dependencycircular dependency@Primary@Qualifier
linuxmacos
Error Messages
Problem
Spring Boot application fails during startup with errors about port already in use, bean definition conflicts, or unsatisfied dependencies. The error stack trace is long and the root cause is buried.
Solution
(1) Port conflict: change server.port in application.properties or use SERVER_PORT env var. Find the process: lsof -i :8080. (2) Bean definition conflicts: two beans with same name — use @Primary, @Qualifier, or rename. Check for duplicate @ComponentScan paths. (3) Unsatisfied dependency: missing @Component/@Service annotation on the implementation, or missing dependency in pom.xml/build.gradle. (4) Read the error from the bottom up — Spring prints the root cause last. (5) Circular dependency: use @Lazy on one of the injected dependencies or restructure.
Why
Spring Boot auto-configuration creates beans automatically. Conflicts arise when multiple beans qualify for the same injection point, or when manual configuration overlaps with auto-configuration.
Revisions (0)
No revisions yet.