工作空間存在三個項目:`CommonUtils` (工具類)、`CoreService` (業務邏輯)、`WebApp` (Web 端)。需在 `WebApp` 中調用 `CoreService`,`CoreService` 依賴 `CommonUtils`。
MyEclipse 內置 Maven 支持,**拋棄 Build Path 手動依賴,拥抱 Maven 聚合工程**。
<project>
<modules>
<module>CommonUtils</module>
<module>CoreService</module>
<module>WebApp</module>
</modules>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>CommonUtils</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<!-- 統一版本號 -->
</dependencies>
</dependencyManagement>
</project>
<!-- CoreService/pom.xml -->
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>CommonUtils</artifactId>
</dependency>
</dependencies>
<!-- WebApp/pom.xml -->
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>CoreService</artifactId>
</dependency>
<!-- 传递依赖自动引入 CommonUtils -->
</dependencies>
| 維度 | Build Path 手動依賴 | Maven 聚合工程 |
|---|---|---|
| 依賴傳遞 | 需手動勾選 Order and Export | ✅ 自動傳遞 (compile scope) |
| 版本管理 | 靠人工/文檔 | ✅ 統一 dependencyManagement |
| 構建產物 | 手動 Deployment Assembly | ✅ `mvn package` 自動打 WAR/JAR |
| CI/CD 集成 | 困難 | ✅ 原生支持 Jenkins/GitLab/GitHub Actions |
| IDE 遷移 | 綁定 MyEclipse | ✅ IDEA/Eclipse/VS Code 通用 |
MyEclipse 多項目整合:**短期用 Build Path + Deployment Assembly 快速跑通,長期必遷移 Maven 聚合工程**。Maven 解決了傳遞依賴、版本統一、構建標準化、IDE 解耦四大痛點,是企業級 Java 開發的**事實標準**。