我不知道为什么我的UserEntity.java
在调试模式下测试时无法对密码进行编码。密码显示没有MD5编码。另外,当我点击org.springframework.security.authentication
时,它会说:
此元素没有附加Javadoc,并且在附加源中找不到Javadoc
我在Maven依赖项中有springframework-core
,其中包含Md5PasswordEncoder.java
和PasswordEncoder.java
这两个类。
如果这两个需要bean定义,我该如何创建它?
package com.example.j2eeapp.domain;
import java.io.Serializable;
import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
import org.springframework.security.authentication.encoding.PasswordEncoder;
/**
* Entity to hold application user data - first name, last name, etc.
*/
public class UserEntity implements Serializable {
private static final long serialVersionUID = 9014169812363387062L;
private String firstName;
private String lastName;
private String userName;
private String password;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
PasswordEncoder crypto = new Md5PasswordEncoder();
this.password = crypto.encodePassword(password, null);
}
}