论坛首页 Java企业应用论坛

iBatis问题

浏览 1668 次
该帖已经被评为隐藏帖
作者 正文
   发表时间:2007-07-13  
import java.io.Reader;
import java.util.Properties;

import com.ibatis.common.resources.Resources;
import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.DaoManagerBuilder;

/**
* @author
*
*/
public class DAOConfig {

private static final String resource = "com/cornerstone/eaglepro/dao/maps/dao.xml";

private static DaoManager daoManager;

static {
try {
daoManager = newDaoManager(null);
// Properties props = Resources.getResourceAsProperties("config/db.properties");
//     String url = props.getProperty("url");
// String driver = props.getProperty("driver");
// String username = props.getProperty("username");
// String password = props.getProperty("password");
// Class.forName(driver).newInstance();
//         Connection conn = DriverManager.getConnection(url, username, password);
}
catch(Exception e) {
e.printStackTrace();
}
}

public static DaoManager getDaoManager() {
return daoManager;
}

public static DaoManager newDaoManager(Properties props) {
try {
Reader reader = Resources.getResourceAsReader(resource);
return DaoManagerBuilder.buildDaoManager(reader, props);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Could not initialize DaoConfig.");
return null;
}
}

public static void main(String[] args) {
DAOConfig.getDaoManager();
}
}
走到这步Reader reader = Resources.getResourceAsReader(resource);
总是报错,我ibatis-common2.jar添加到classpath下呢
java.lang.NoClassDefFoundError: com/ibatis/common/resources/Resources
请问这是什么原因
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics