首页 新闻 会员 周边 捐助

关于spring数据源配置

0
悬赏园豆:5 [已关闭问题] 关闭于 2014-09-20 22:02

配完spring数据源后,跑不起来.报[Error creating bean with name 'dataSource' defined in class path resource [beans-properties.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector]这个错.

配置文件是(beans-properties.xml):

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="user" value="sa"></property>
        <property name="password" value="111111"></property>
        <property name="driverClass" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"></property>
        <property name="jdbcUrl" value="jdbc:sqlserver://localhost:1433;databaseName=test"></property>
    </bean>

</beans>

代码:

public class Main {
    @SuppressWarnings("resource")
    public static void main(String[] args) throws SQLException {
        ApplicationContext cxt = new ClassPathXmlApplicationContext(
                "beans-properties.xml");
        DataSource dataSource = (DataSource) cxt.getBean("dataSource");
        System.out.println(dataSource.getConnection());
    }
}

代码中直接调配置的数据源,debug时第一行代码就过不去.
求助大神啊.

用心守护迩的主页 用心守护迩 | 初学一级 | 园豆:136
提问于:2014-09-20 21:38
< >
分享
所有回答(1)
0

解决,少了一个jar包mchange-commons-java-0.2.3.4.jar

用心守护迩 | 园豆:136 (初学一级) | 2014-09-20 22:01
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册