Struts2 專案啟動 Tomcat 時提示缺少 JAR 包(如 struts2-core、xwork-core 等),或 IDE 提示 This element has no attached source and the Javadoc could not be found,通常是專案建置路徑缺少依賴、或 Maven 依賴未正確解析。
pom.xml 是否包含 Struts2 核心依賴:<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.5.30</version> <!-- 使用對應版本 -->
</dependency>mvn clean compile dependency:resolve。Maven Dependencies 已加入,輸出至 WEB-INF/lib。-sources.jar/-javadoc.jar 附加至 Library。AbstractInterceptor),會導致編譯/運行錯誤。重新命名自訂類別,避免與框架核心包衝突。struts2-corexwork-coreognlfreemarker (若使用標籤)commons-fileupload, commons-io (檔案上傳)javassist (動態代理)專案右鍵 → Build Path → Configure Build Path → Libraries → Maven Dependencies 展開,確認上述 JAR 存在且無紅叉。若缺少,執行 mvn dependency:tree 分析傳遞依賴是否被排除。
規範 Maven 依賴管理、避免類別命名衝突,是 Struts2 專案穩定運行的基礎。