0
我嘗試使用iBatis的桌面應用程序。但我有以下錯誤。無法找到一個適當的解決方案在net.Please任何人幫我。線程「main」中的異常java.lang.NoSuchMethodError:com.ibatis.common.beans.ClassInfo.setCacheEnabled(Z)V
日誌::
Exception in thread "main" java.lang.NoSuchMethodError: com.ibatis.common.beans.ClassInfo.setCacheEnabled(Z)V
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$3.process(SqlMapConfigParser.java:179)
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:112)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:75)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:93)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:63)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:86)
at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
at IbatisInsert.main(IbatisInsert.java:12)
代碼:: IbatisInsert.java
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import java.io.*;
import java.sql.SQLException;
import java.util.*;
public class IbatisInsert{
public static void main(String[] args)
throws IOException,SQLException{
Reader rd = Resources.getResourceAsReader("SqlMapConfig.xml");
SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(rd);
/* This would insert one record in Employee table. */
System.out.println("Going to insert record.....");
Employee em = new Employee("Zara", "Ali", 5000);
smc.insert("Employee.insert", em);
System.out.println("Record Inserted Successfully ");
}
}
Employee.java
public class Employee {
private int id;
private String first_name;
private String last_name;
private int salary;
/* Define constructors for the Employee class. */
public Employee() {}
public Employee(String fname, String lname, int salary) {
this.setFirst_name(fname);
this.setLast_name(lname);
this.setSalary(salary);
}
public String getFirst_name() {
return first_name;
}
public void setFirst_name(String first_name) {
this.first_name = first_name;
}
public String getLast_name() {
return last_name;
}
public void setLast_name(String last_name) {
this.last_name = last_name;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
} /* End of Employee */
我已經把默認包類都src下。
看起來像一個jar衝突問題。該代碼與其他版本的iBatis一起編譯並在其他版本上運行。 – Manish
我是新來ibatis,我需要什麼所有的罐子。我有以下的jar :: 1> ibatis-commons-2.jar 2> ibatis-2.3.0.677.jar 3> spring.jar 4> mysql-connector-java-5.1.5.JAR –
@AbhijeetSinha問題不是由於罐子不夠,但罐子的版本不正確。我在下面給出的代碼嘗試運行它。 –