✅ 1. What is pom.xml
in Maven?
-
pom.xml
(Project Object Model) is the configuration file for Maven. -
It defines:
-
Your project details
-
Dependencies (like libraries you use)
-
Build settings
-
Plugins (extra build tools, like making fat JAR)
-
✅ 2. Maven pom.xml
Structure with Explanation
✅ 3. What Each Section Means
Section | Purpose |
---|---|
<dependencies> | Libraries you need (like Gson, Spring, etc.) |
<build> | Defines plugins and how to build |
<plugins> | Extra build tools (e.g., for fat JAR) |
<mainClass> | Entry point (the main() method class) |
✅ 4. Maven Commands
Task | Command |
---|---|
Clean old builds | mvn clean |
Compile Java code | mvn compile |
Create normal JAR | mvn package |
Create fat JAR (with plugin) | mvn clean compile assembly:single |
🔹 This command will generate:
✅ 5. Run the Fat JAR
This works anywhere — no need to install the 3 dependencies on target machine.
🧪 Sample Java Class
File: src/main/java/com/mitesh/MainApp.java
No comments:
Post a Comment