gpt4 book ai didi

java - 在类里面找不到密码的 getter

转载 作者:行者123 更新时间:2023-12-01 12:56:28 35 4
gpt4 key购买 nike

我正在使用 Java RESTLET 编写 REST 服务。

我在这里有我的用户类:

@Entity
@Table(name = "user")
public class User implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "idUser", nullable = false, unique = true, length = 255)
private Long idUser;

@Column(name = "name", nullable = true, length = 255)
private String name;

@Column(name = "username", nullable = false, length = 255)
private String username;

@Column(name = "password", nullable = false, length = 255)
private String password;
public Object setValue(Object input) {

Object fieldValue = ((input == null) ? JSONObject.NULL.toString()
: input);
return fieldValue;
}

public String getUserPassword() {
return password;
}

public void setUserPassword(String password) {
this.password = password;
}
public String getUserName() {
return username ;
}

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





public Long getidUser() {
return idUser;
}

public void setIdUser(Long idUser) {
this.idUser = idUser;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getContactFirstName() {
return contactFirstName;
}

public void setContactFirstName(String contactFirstName) {
this.contactFirstName = contactFirstName;
}

public String getContactLastName() {
return contactLastName;
}

public void setContactLastName(String contactLastName) {
this.contactLastName = contactLastName;
}

public String getContactEmail() {
return contactEmail;
}

public void setContactEmail(String contactEmail) {
this.contactEmail = contactEmail;
}

public String getContactMobile() {
return contactMobile;
}

public void setContactMobile(String contactMobile) {
this.contactMobile = contactMobile;
}

public String getContactPhone() {
return contactPhone;
}

public void setContactPhone(String contactPhone) {
this.contactPhone = contactPhone;
}

public String getContactAddress() {
return contactAddress;
}

public void setContactAddress(String contactAddress) {
this.contactAddress = contactAddress;
}

public Integer getStatus() {
return status;
}

public void setStatus(Integer status) {
this.status = status;
}

public Integer getType() {
return type;
}

public void setType(Integer type) {
this.type = type;
}

public Timestamp getCreatedDate() {
return createdDate;
}

public void setCreatedDate(Timestamp createdDate) {
this.createdDate = createdDate;
}

public Timestamp getUpdatedDate() {
return updatedDate;
}

public void setUpdatedDate(Timestamp updatedDate) {
this.updatedDate = updatedDate;
}

}

我的 User.hbm.xml 文件看起来像。

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="persistence.entity.User" table="user">
<id name="idUser" type="long" unsaved-value="null">
<column name="idUser" not-null="true"/>
<generator class="identity"/>
</id>
<property name="userName">
<column name="username" not-null="true" />
</property>

<property name="password">
<column name="password" not-null="true" />
</property>

<property name="status">
<column name="status" not-null="true" />
</property>
<property name="type">
<column name="type" not-null="true" />
</property>
<property name="createdDate">
<column name="createdDT" not-null="true" />
</property>
<property name="updatedDate">
<column name="updatedDT" not-null="false" />
</property>
<property name="name">
<column name="name" length="255" not-null="false" />
</property>
<property name="contactFirstName">
<column name="contactFirstName" length="255" not-null="false" />
</property>
<property name="contactLastName">
<column name="contactLastName" length="255" not-null="false" />
</property>
<property name="contactEmail">
<column name="contactEmail" length="255" not-null="false" />
</property>
<property name="contactMobile">
<column name="contactMobile" length="32" not-null="false" />
</property>
<property name="contactPhone">
<column name="contactPhone" length="32" not-null="false" />
</property>
<property name="contactAddress">
<column name="contactAddress" not-null="false" />
</property>

</class>
</hibernate-mapping>

我在 User.java 文件中明确定义了 getter 和 setter。

但是当我运行此代码时,我收到错误

 Could not find a getter for password in class tecd.persistenc.entity.User

我不知道我错过了什么,请帮助我

最佳答案

您已经为 password 声明了 getter 和 setter,如下所示:

public String getUserPassword() {
return password;
}

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

我认为应该是这样的(其中没有“用户”):

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

这些是密码字段的标准“bean”样式名称。

关于java - 在类里面找不到密码的 getter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23842335/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com