我的配置文件:
<bean id="newscontentDAO" 
class="com.caicai.lead21.service.dao.hibernate.NewsContentHibernateDAO">
<property name="sessionFactory"><ref local="mySessionFactory"/></property>
</bean>

<bean id="newscontentTarget" 
class="com.caicai.lead21.service.spring.NewsContentServiceSpringImpl">
<property name="newscontentDAO"><ref local="newscontentDAO"/></property>
</bean>

<bean id="newscontentService" 
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref local="myTransactionManager"/>
</property>
<property name="target"><ref local="newscontentTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="find*">
PROPAGATION_REQUIRED,readOnly
</prop>
<prop key="save*">
PROPAGATION_REQUIRED
</prop>
</props>
</property>
</bean>请给予回答,谢谢

解决方案 »

  1.   

    看看 你的类'newscontentDAO' is not writable or has an invalid setter method有问题
      

  2.   

    我的NewsContentHibernateDAO里没有SETTER METHOD啊public class NewsContentHibernateDAO 
    extends HibernateDaoSupport 
    implements INewsContentDAO{ public TnewsContent savedt(final TnewsContent newscontent) { getHibernateTemplate().save(newscontent); return newscontent;
    }
    }
      

  3.   

    NewsContentServiceSpringImpl这个类
      

  4.   

    我没发现有什么问题啊
    public class NewsContentServiceSpringImpl implements INewsContentService{ private INewsContentDAO newscontentDAO; /**
     * 缺省的构造方法
     */
    public NewsContentServiceSpringImpl() {
    super();
    } /**
     * 保存新闻
     */
    public TnewsContent savedt(TnewsContent newscontent) throws Exception{ // do some business logic
    TnewsContent tc = null;
    try {
    tc = this.getNewsContentDAO().savedt(newscontent);
    }catch (Exception e) {
    throw new Exception("Could not save newscontent " + e.toString());
    }
    return tc;
    }

    /**
     * @return
     */
    public INewsContentDAO getNewsContentDAO() {
    return newscontentDAO;
    } /**
     * 设置INewsContentDAO接口的实例
     * 
     * @param newscontentDAO
     */
    public void setNewsContentDAO(INewsContentDAO newscontentDAO) {
    this.newscontentDAO = newscontentDAO;
    }}
      

  5.   

    请问我的applicationContext.xml中放多个bean 有什么规则吗,我放一个就没错,多了就报错
      

  6.   

    public INewsContentDAO getNewscontentDAO() {
    return newscontentDAO;
    }
    public void setNewscontentDAO(INewsContentDAO newscontentDAO) {
    this.newscontentDAO = newscontentDAO;
    }
    换成这样写 注意大小写