Issue
I am getting the below error while running the application.Can any one please help me in understanding what I am doing wrong,
Error creating bean with name 'user' defined in file [C:\Users\Admin1\Login.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\MVC\WEB-INF\classes\Validation\user.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.String' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
package Validation;
import java.util.Date;
import org.springframework.stereotype.Repository;
import DAO.Processor;
import javax.validation.constraints.Past;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
@Repository
@Entity
@Table(name = "APP_USER", schema = "claim")
public class user {
@Id
private int uid;
@OneToOne
@JoinColumn(name = "PID")
Processor P;
@NotNull
String username = null;
@NotNull
String password;
public Processor getP() {
return P;
}
public void setP(Processor p) {
P = p;
}
@NotNull
String email;
@Past @NotNull
Date DOB;
public user(String username, String password, String email, Date dob) {
this.email = email;
this.username = username;
this.DOB = dob;
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Date getDOB() {
return DOB;
}
public void setDOB(Date dOB) {
DOB = dOB;
}
}
Solution
I was able to solve the problem by adding default constructor
public user(){}
hibernate requires default constructor for entity class.
Answered By - Yogesh Kumar Gupta
Answer Checked By - Marilyn (JavaFixing Volunteer)