今天配ibatis碰到一个问题
Exception in thread "main" java.lang.NoSuchMethodError: com.ibatis.common.resources.Resources.instantiate(Ljava/lang/String;)Ljava/lang/Object;
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$9.process(SqlMapConfigParser.java:299)
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:112)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:96)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:93)
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:78)
at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:62)
at test.amin.getSqlMapClient(amin.java:18)
at test.amin.insertOne(amin.java:27)
at test.amin.main(amin.java:43)
代码
public SqlMapClient getSqlMapClient(){
String resource = "db/SqlMapConfig.xml";
SqlMapClient sqlMapClient = null;
try {
Reader reader = Resources.getResourceAsReader(resource);
sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return sqlMapClient;
}
最后查出来原因
ibatis-common-2.jar
debug-ibatis-db.jar
包含了同一个类,干掉其中一个jar包就ok了
Exception in thread "main" java.lang.NoSuchMethodError: com.ibatis.common.resources.Resources.instantiate(Ljava/lang/String;)Ljava/lang/Object;
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$9.process(SqlMapConfigParser.java:299)
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:112)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:96)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:93)
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:78)
at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:62)
at test.amin.getSqlMapClient(amin.java:18)
at test.amin.insertOne(amin.java:27)
at test.amin.main(amin.java:43)
代码
public SqlMapClient getSqlMapClient(){
String resource = "db/SqlMapConfig.xml";
SqlMapClient sqlMapClient = null;
try {
Reader reader = Resources.getResourceAsReader(resource);
sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return sqlMapClient;
}
最后查出来原因
ibatis-common-2.jar
debug-ibatis-db.jar
包含了同一个类,干掉其中一个jar包就ok了