applicationContext.xml文件出错

cqcjcc123 2006-09-01 10:22:53
具体出错信息:
2006-09-01 09:01:45,453 WARN ehcache.config.Configurator:126 2006-09-01 09:01:49,265 ERROR web.context.ContextLoader:205 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'newscontentTarget' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'newscontentDAO' of bean class [com.caicai.lead21.service.spring.NewsContentServiceSpringImpl]: Bean property 'newscontentDAO' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
org.springframework.beans.NotWritablePropertyException: Invalid property 'newscontentDAO' of bean class [com.caicai.lead21.service.spring.NewsContentServiceSpringImpl]: Bean property 'newscontentDAO' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
2006-09-01 09:01:49,265 ERROR [Catalina].[localhost].[/oil]:662 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'newscontentTarget' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'newscontentDAO' of bean class [com.caicai.lead21.service.spring.NewsContentServiceSpringImpl]: Bean property 'newscontentDAO' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
org.springframework.beans.NotWritablePropertyException: Invalid property 'newscontentDAO' of bean class [com.caicai.lead21.service.spring.NewsContentServiceSpringImpl]: Bean property 'newscontentDAO' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
...全文
928 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
cqcjcc123 2006-09-01
  • 打赏
  • 举报
回复
谢谢,解决了!
interpb 2006-09-01
  • 打赏
  • 举报
回复
public INewsContentDAO getNewscontentDAO() {
return newscontentDAO;
}
public void setNewscontentDAO(INewsContentDAO newscontentDAO) {
this.newscontentDAO = newscontentDAO;
}
换成这样写 注意大小写
cqcjcc123 2006-09-01
  • 打赏
  • 举报
回复
请问我的applicationContext.xml中放多个bean 有什么规则吗,我放一个就没错,多了就报错
cqcjcc123 2006-09-01
  • 打赏
  • 举报
回复
我没发现有什么问题啊
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;
}

}
interpb 2006-09-01
  • 打赏
  • 举报
回复
NewsContentServiceSpringImpl

这个类
cqcjcc123 2006-09-01
  • 打赏
  • 举报
回复
我的NewsContentHibernateDAO里没有SETTER METHOD啊

public class NewsContentHibernateDAO
extends HibernateDaoSupport
implements INewsContentDAO{

public TnewsContent savedt(final TnewsContent newscontent) {

getHibernateTemplate().save(newscontent);

return newscontent;
}
}

interpb 2006-09-01
  • 打赏
  • 举报
回复
看看 你的类

'newscontentDAO' is not writable or has an invalid setter method

有问题
cqcjcc123 2006-09-01
  • 打赏
  • 举报
回复
我的配置文件:
<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>

请给予回答,谢谢

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧