2017-11-17 03:09:44


applicationContext-dao.xml文件
<bean id="userDAO" class="cn.itcast.bos.dao.impl.GenericDAOImp1">
<!-- 构造器注入 ,传入 实体类 完整类名 -->
<constructor-arg index="0" value="cn.itcast.bos.domain.user.FUsers"></constructor-arg>
<!-- 注入SessionFactory -->
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>


cn.itcast.bos.dao.impl.GenericDAOImp1文件
public class GenericDAOImp1<T> extends HibernateDaoSupport implements GenericDAO<T>{
private String className;


public void setClassName(String className) {
this.className = className;
}
public List<T> findByNamedQuery(String queryName, Object... values) {
return this.getHibernateTemplate().findByNamedQuery(queryName,values);
}
}

cn.itcast.bos.domain.user.FUsers文件
public class FUsers implements java.io.Serializable {

// Fields

private String id;
private String username;
private String password;
private int salary;
private Date birthday;
private String gender;
private String station;
private String telephone;
private String remark;

// Constructors

/** default constructor */
public FUsers() {
}

/** minimal constructor */
public FUsers(String id) {
this.id = id;
}

/** full constructor */
public FUsers(String id, String username, String password,
int salary, Date birthday, String gender, String station,
String telephone, String remark) {
this.id = id;
this.username = username;
this.password = password;
this.salary = salary;
this.birthday = birthday;
this.gender = gender;
this.station = station;
this.telephone = telephone;
this.remark = remark;
}

// Property accessors

public String getId() {
return this.id;
}

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

public String getUsername() {
return this.username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return this.password;
}

public void setPassword(String password) {
this.password = password;
}

public int getSalary() {
return this.salary;
}

public void setSalary(int salary) {
this.salary = salary;
}

public Date getBirthday() {
return this.birthday;
}

public void setBirthday(Date birthday) {
this.birthday = birthday;
}

public String getGender() {
return this.gender;
}

public void setGender(String gender) {
this.gender = gender;
}

public String getStation() {
return this.station;
}

public void setStation(String station) {
this.station = station;
}

public String getTelephone() {
return this.telephone;
}

public void setTelephone(String telephone) {
this.telephone = telephone;
}

public String getRemark() {
return this.remark;
}

public void setRemark(String remark) {
this.remark = remark;
}

}
报错内容:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDAO' defined in class path resource [applicationContext-dao.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
...全文
191 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yql1986 2017-11-17
  • 打赏
  • 举报
回复
发错了,没看仔细 type ambiguities 是说无法确定具体的类型,你用了泛型 能知道具体的类型
yql1986 2017-11-17
  • 打赏
  • 举报
回复
type ambiguities 晕了 GenericDAOImp1<T> GenericDAOImp1<FUsers>
李德胜1995 2017-11-17
  • 打赏
  • 举报
回复
Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)。。。。翻译一下

50,527

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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