刚不小心发错论坛了!我的问题如下:
不知道怎么了,老是报错。定义其他的bean都没有问题。报错如下
log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.ustcori.familyfinancing.dao.database.UserDAOImpl]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.ustcori.familyfinancing.dao.database.UserDAOImpl.<init>()
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:881)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:837)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at com.ustcori.familyfinancing.Test.main(Test.java:29)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.ustcori.familyfinancing.dao.database.UserDAOImpl]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.ustcori.familyfinancing.dao.database.UserDAOImpl.<init>()
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:58)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:875)
    ... 16 more
Caused by: java.lang.NoSuchMethodException: com.ustcori.familyfinancing.dao.database.UserDAOImpl.<init>()
    at java.lang.Class.getConstructor0(Unknown Source)
    at java.lang.Class.getDeclaredConstructor(Unknown Source)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:54)
    ... 17 more
applicationContext.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-2.5.xsd">
    <bean id="placeholderConfig"
        class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
        <property name="location">
            <value>classpath:init.properties</value>
        </property>
    </bean>
    <bean id="dataSource"
        class="com.mchange.v2.c3p0.ComboPooledDataSource"
        destroy-method="close" dependency-check="none">
        <property name="driverClass">
            <value>${datasource.driverClassName}</value>
        </property>
        <property name="jdbcUrl">
            <value>${datasource.url}</value>
        </property>
        <property name="user">
            <value>${datasource.username}</value>
        </property>
        <property name="password">
            <value>${datasource.password}</value>
        </property>
        <property name="acquireIncrement">
            <value>${c3p0.acquireIncrement}</value>
        </property>
        <!-- 初始化时获取连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
        <property name="initialPoolSize">
            <value>${c3p0.initialPoolSize}</value>
        </property>
        <!-- 连接池中保留的最小连接数 -->
        <property name="minPoolSize">
            <value>${c3p0.minPoolSize}</value>
        </property>
        <!-- -连接池中保留的最大连接数。Default: 15 -->
        <property name="maxPoolSize">
            <value>${c3p0.maxPoolSize}</value>
        </property>
        <!-- 连接最大空闲时间,单位为秒。若为0则永不丢弃。Default: 0 -->
        <property name="maxIdleTime">
            <value>${c3p0.maxIdleTime}</value>
        </property>
        <!-- 检查所有连接池中的空闲连接的时间间隔,单位是秒。Default: 0 -->
        <property name="idleConnectionTestPeriod">
            <value>${c3p0.idleConnectionTestPeriod}</value>
        </property>
        <!-- JDBC的标准参数,用以控制数据源内加载的PreparedStatements数量。 -->
        <property name="maxStatements">
            <value>${c3p0.maxStatements}</value>
        </property>
        <!-- -c3p0支持的线程数,c3p0是异步操作的,通过多线程实现多个操作同时被执行。Default: 3- -->
        <property name="numHelperThreads">
            <value>${c3p0.numHelperThreads}</value>
        </property>
    </bean>
    <bean id="sqlMapClient"
        class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
        <property name="configLocation">
            <value>SqlMapConfig_MySQL.xml</value>
        </property>
        <property name="dataSource" ref="dataSource" />
    </bean>
    <bean id="userDao"
        class="com.ustcori.familyfinancing.dao.database.UserDAOImpl">
        <property name="sqlMapClient" ref="sqlMapClient" />
    </bean>
    <bean id="user"
        class="com.ustcori.familyfinancing.model.database.User">
    </bean> 
</beans>测试类:
public static void main(String[] args) {
        ApplicationContext factory = new ClassPathXmlApplicationContext(
        "applicationContext.xml");        UserDAO userDao = (UserDAOImpl) factory.getBean("userDao");    }
其中UserDAO和UserDAOImpl都是用abator自动生成的.