简体   繁体   English

Spring和Hibernate运行时错误

[英]Spring and Hibernate Runtime error

Below error is seen on my eclipse. 在我的日食中看到以下错误。 I am just trying to save a terminalgroup object and was getting an error about TerminalGroupImpl not found. 我只是想保存一个terminalgroup对象,却收到关于TerminalGroupImpl的错误消息。 So I created a TerminalGroupImpl.java to be a hibernate file that has the @Entity for the terminal_group table. 因此,我将TerminalGroupImpl.java创建为一个休眠文件,该文件具有terminal_group表的@Entity。 I have a TerminalGroupDaoHibernate.java file that using the TerminalGroupImpl.class to execute queries on the terminal_group table. 我有一个TerminalGroupDaoHibernate.java文件,该文件使用TerminalGroupImpl.class在terminal_group表上执行查询。

Please if someone can tell me what is wrong with my code and/or what I can do to figure out what is wrong? 如果有人可以告诉我我的代码有什么问题和/或我可以做些什么来找出什么问题,请告诉我?

Error 错误

Invalid property 'terminalGroupDaoHibernate' of bean class
[com.ccadllc.dac.model.consumer.terminalgroups.TerminalGroupServiceImpl]: 
Bean property 'terminalGroupDaoHibernate' is not writable or has an invalid setter method. 
Does the parameter type of the setter match the return type of the getter?

Here is my applicationContext.xml file: 这是我的applicationContext.xml文件:

<!-- Terminal Group Service -->
<bean id="com.ccadllc.dac.model.consumer.terminalgroups.TerminalGroupService"
    class="com.ccadllc.dac.model.consumer.terminalgroups.TerminalGroupServiceImpl">
 <property name="terminalGroupDao"   
ref="com.ccadllc.dac.model.consumer.terminalgroups.dao.TerminalGroupDao"/>
 <property name="terminalGroupComponentDao" 
ref="com.ccadllc.dac.model.consumer.terminalgroups.dao.TerminalGroupComponentDao"/>
</bean>

<bean id="com.ccadllc.dac.model.consumer.terminalgroups.TerminalGroupImpl"
    class="com.ccadllc.dac.model.consumer.terminalgroups.TerminalGroupImpl" abstract="true">
    <property name="terminalGroupDaoHibernate" 
ref="com.ccadllc.dac.model.consumer.terminalgroups.dao.TerminalGroupDaoHibernate"/>
</bean>

<bean id="com.ccadllc.dac.model.consumer.terminalgroups.dao.TerminalGroupDao"
    class="com.ccadllc.dac.model.consumer.terminalgroups.dao.TerminalGroupDaoHibernate">
        <property name="messageService" ref="com.ccadllc.dac.messaging.MessagingService" /> 
</bean>

under hibernate.annotated.classes:                  
<value>com.ccadllc.dac.model.consumer.terminalgroups.TerminalGroupImpl</value>

TerminalGroupServiceImpl.java TerminalGroupServiceImpl.java

Getter/Setter in TerminalGroupServiceImpl.java:
private TerminalGroupDao terminalGroupHibernateDao;
 /**
 * @param TerminalGroupHibernateDao The TerminalGroupHibernateDao to set.
 */
@Required
@Transactional
public void setTerminalGroupHibernateDao(final TerminalGroupDao terminalGroupHibernateDao)
{
    this.terminalGroupHibernateDao = terminalGroupHibernateDao;
}

@Required
@Transactional
public TerminalGroupDao getTerminalGroupHibernateDao()
{
    return terminalGroupHibernateDao;
}

您正在尝试设置terminalGroupDaoHibernate属性而不是terminalGroupHibernateDao。

The property you have defined in the xml is "terminalGroupDaoHibernate", but the setter in your service impl's name is "setTerminalGroupHibernateDao". 您在xml中定义的属性是“ terminalGroupDaoHibernate”,但是服务隐含名称中的设置程序是“ setTerminalGroupHibernateDao”。 There is typo error. 有错字错误。 The setter name should be "setTerminalGroupDaoHibernate" 设置器名称应为“ setTerminalGroupDaoHibernate”

You should not add the @Required annotation on a getter. 您不应在吸气剂上添加@Required批注。 Also, in your bean xml, you use the property name terminalGroupDao but your setter has the name setTerminalGroupHibernateDao rather than setTerminalGroupDao . 另外,在bean xml中,使用属性名称terminalGroupDao但是设置程序的名称为setTerminalGroupHibernateDao而不是setTerminalGroupDao

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM