| name | fix-mvn-compile |
| description | Fix common Maven compilation errors in emp-script project (missing imports, throws declarations) |
| source | auto-skill |
| extracted_at | 2026-06-26T08:25:21.571Z |
Fix Maven Compilation Errors
Quick Diagnosis
Run mvn clean compile 2>&1 | tail -80 to identify error types:
- Unreported exception - Method calls throw checked Exception but doesn't declare
throws
- Cannot find symbol - Missing import statements
Common Fixes
1. Missing throws Exception
Error pattern:
error: unreported exception Exception; must be caught or declared to be thrown
Cause: DTRow.getCell(String colName) throws Exception, calling methods must declare throws Exception.
Fix: Add throws Exception to method signature:
private static JSONObject createEndpointDescription(...) {
private static JSONObject createEndpointDescription(...) throws Exception {
2. Missing Imports
Common missing classes and their packages:
| Class | Package |
|---|
UserConfig | com.gdxsoft.easyweb.script.userConfig.UserConfig |
UserXItems | com.gdxsoft.easyweb.script.userConfig.UserXItems |
UserXItem | com.gdxsoft.easyweb.script.userConfig.UserXItem |
UserXItemValue | com.gdxsoft.easyweb.script.userConfig.UserXItemValue |
UserXItemValues | com.gdxsoft.easyweb.script.userConfig.UserXItemValues |
JSONArray | org.json.JSONArray |
JSONObject | org.json.JSONObject |
DTTable | com.gdxsoft.easyweb.data.DTTable |
DTRow | com.gdxsoft.easyweb.data.DTRow |
Fix: Add import after existing imports:
import com.gdxsoft.easyweb.script.userConfig.UserConfig;
import com.gdxsoft.easyweb.script.userConfig.UserXItem;
import com.gdxsoft.easyweb.script.userConfig.UserXItems;
import org.json.JSONArray;
3. Test Compilation: EwaConfig vs IConfig
Error pattern (pre-existing, in bussinessXmlCreator tests):
不兼容的类型: com.gdxsoft.easyweb.script.template.EwaConfig无法转换为com.gdxsoft.easyweb.script.userConfig.IConfig
Cause: Test files use EwaConfig (template package) but BusinessXmlCreator.create() expects IConfig (userConfig package). These are different class hierarchies.
IConfig implementations: FileConfig, JdbcConfig, ResourceConfig (all in script.userConfig package).
Quick fix — skip test compilation:
mvn clean package -Dmaven.test.skip=true
Important: -DskipTests only skips test execution, test compilation still runs. Use -Dmaven.test.skip=true to skip both.
Workflow
- Run
mvn clean compile
- Identify error type from output
- Apply targeted fix (add throws or imports)
- Verify with
mvn clean compile
- For packaging:
mvn clean package -Dmaven.test.skip=true (avoids pre-existing test issues)