When I print in XML the data ( nombrep
and especialidad
) of the class Profesor
I get the error that it has two properties with the same name " especialidad
" and two others with " nombrep
".
Does anyone know why?
This is my code:
@XmlRootElement()
public class Profesor {
@XmlElement(required = true)
private String nombrep;
@XmlElement(required = true)
protected String apellidos;
@XmlElement(required = true)
protected String dni;
@XmlElement(required = true)
protected String especialidad;
//CONSTRUCTOR
public Profesor(String nombrep, String apellidos, String dni, String especialidad) {
this.nombrep = nombrep;
this.apellidos = apellidos;
this.dni = dni;
this.especialidad = especialidad;
}
public Profesor() {}
public String getNombrep() { return nombrep; }
public String getApellidos() { return apellidos; }
public String getDni() {return dni; }
public String getEspecialidad() { return especialidad;}
@XmlElement(name = "Nombre_profesor")
public void setNombrep(String nombrep) { this.nombrep = nombrep; }
public void setAutor(String apellidos) { this.apellidos = apellidos; }
public void setEditorial(String dni) { this.dni = dni; }
public void setEspecialidad(String especialidad) { this.especialidad = especialidad; }
}
Details of the exception:
Exception in thread "main" com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions The class has two properties with the same name "specialty" this problem is related to the following location: at public java.lang.String generated.Professor.getSpeciality () at generated.Professor this problem is related to the following location: at protected java.lang.String generated.Profesor.especialidad at generated.Professor