浏览 1668 次
已锁定 主题:iBatis问题
该帖已经被评为隐藏帖
|
|
---|---|
作者 | 正文 |
发表时间:2007-07-13
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 请问这是什么原因 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |