java.lang.IllegalStateException:找不到匹配的编辑器或转换策略

时间:2017-03-22 09:51:00

标签: java spring hibernate

所以我正在构建一个弹簧3.2.3.RELEASE / hibernate 4.0.1.FINAL应用程序,我得到了以下异常

  

[2017-03-22 09:29:47,860] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory [localhost-startStop-1]忽略FactoryBean类型上的bean创建异常check:org.springframework.beans.factory .BeanCreationException:创建名称为' loginService'的bean时出错在URL [jar:file:/ D:/Programmes/apache-tomcat-7.0.33/webapps/perWeb/WEB-INF/lib/perService-2.0.jar!/applicationContext-transactional-service.xml]中定义:无法解析引用bean' loginServiceImpl'设置bean属性' target&#39 ;;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名称为' loginServiceImpl'的bean时出错在URL [jar:file:/ D:/Programmes/apache-tomcat-7.0.33/webapps/perWeb/WEB-INF/lib/perService-2.0.jar!/applicationContext-simple-service.xml]中定义:初始化豆子失败了;嵌套异常是org.springframework.beans.ConversionNotSupportedException:无法转换类型' ma.dao.impl.GenericDAO'的属性值。要求的类型' ma.dao.IGenericDAO'对于财产' dao&#39 ;;嵌套异常是java.lang.IllegalStateException:无法将[ma.dao.impl.GenericDAO]类型的值转换为属性' dao所需的类型[ma.dao.IGenericDAO]:没有匹配的编辑器或转换策略结果

这是我的bean:loginservice

<bean id="loginService"
        class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
        <property name="transactionManager">
            <ref bean="transactionManagerPER" />
        </property>
        <property name="target">
            <ref bean="loginServiceImpl" />
        </property>
        <property name="transactionAttributes">
            <props>
                <prop key="loadUserByUsername">
                    PROPAGATION_REQUIRED,-Exception
                </prop>
            </props>
        </property>
    </bean>

loginServiceImpl

<bean id="loginServiceImpl"
          class="ma.service.login.LoginService">
        <property name="dao">
            <ref bean="userDAO" />
        </property>
    </bean>

UserDAO的

<bean id="userDAO"
        class="ma.dao.impl.GenericDAO">
        <constructor-arg>
            <value>
                ma.dao.mappings.Utilisateur
            </value>
        </constructor-arg>
        <property name="sessionFactory">
            <ref bean="sessionFactoryPER" />
        </property>
    </bean>

Utilisateur.Java

@Entity
@NamedQueries(
        {
            @NamedQuery(name="findUtilisateurByName", 
                    query = "select user from Utilisateur user where user.login=:userName"
                    ) 
        }
)
public class Utilisateur implements java.io.Serializable {

    private static final long serialVersionUID = 7214071893495381842L;
    private Integer id;
    private Profil  profil;
    private String  nom;
    private String  prenom;
    private String  login;
    private String  passwd;

    public Utilisateur() {
    }

    public Utilisateur(Integer id) {
        this.id = id;
    }

    @Id @GeneratedValue
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne
    public Profil getProfil() {
        return profil;
    }

    public void setProfil(Profil profil) {
        this.profil = profil;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPasswd() {
        return passwd;
    }

    public void setPasswd(String passwd) {
        this.passwd = passwd;
    }
}

我错过了什么吗? 如果您需要更多信息,请告诉我

1 个答案:

答案 0 :(得分:0)

看起来你的GenericDao无法转换为IGenericDao,为此,可能有几个原因,例如你的GenericDao实现了IGenericDao等。

如果要实现GenericDao模式,以下链接可能也很有用:

https://www.codeproject.com/Articles/251166/The-Generic-DAO-pattern-in-Java-with-Spring-and