Introduction:
Today, I encountered a frustrating but educational error while working on a Spring Boot project in Eclipse. The error message read:
"One or more constraints have not been satisfied. Utility Module and Dynamic Web Module 6.0 cannot both be selected."
If you're new to Spring Boot or Maven, this might confuse you — here’s what it means and how I resolved it.
🔥 The Root of the Problem:
Spring Boot is designed to run as a standalone JAR with an embedded server (like Tomcat). It doesn't need or support legacy Java EE modules like the Dynamic Web Module.
Eclipse, however, sometimes misinterprets your project structure and adds these facets automatically, causing conflicts like:
- Dynamic Web Module cannot be removed
- Utility Module conflicts with Web Module
- Spring Boot controllers not working
✅ Step-by-Step Solution:
- Delete Eclipse’s Facet Metadata:
-
.settings/
,.project
, and.classpath
from the project folder
- Re-import Project:
File → Import → Maven → Existing Maven Project
- Ensure Correct Maven Configuration:
<packaging>jar</packaging>
- Run the Project with:
mvn spring-boot:run
- OR
Run As → Java Application
on your main class
- Fix the Controller:
java
@Controller
public class HomeController {
@RequestMapping("/")
@ResponseBody
public String home() {
System.out.println("Hit HomeController");
return "Welcome to Spring Boot!";
}
}
### 🔎 Lesson Learned:
* Don’t use `Dynamic Web Module` with Spring Boot
* Use embedded server – not external WAR deployment unless required
* Always check controller method return types and annotations
* Spring Boot thrives on simplicity — don’t force Java EE structures into it
### 💬 Final Words:
I faced this issue for hours and now fully understand why Spring Boot doesn't need the overhead of servlet container configuration. If you're facing the same — **delete Eclipse metadata, use pure Maven, and let Spring Boot do its magic.**
Top comments (0)