I';我在表单中输入字符串,但得到java.lang.NumberFormatException:SpringBoot hibernate java app

I';我在表单中输入字符串,但得到java.lang.NumberFormatException:SpringBoot hibernate java app,java,spring,hibernate,jpa,Java,Spring,Hibernate,Jpa,我需要帮助。我花了两个小时,什么也找不到 问题是:我正在以html格式在技能和熟练程度字段中输入文本。模型采用字符串。但我得到的错误是:无法转换为数字 这就是我得到的错误: Failed to bind request element: org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'com.byAJ.pe

我需要帮助。我花了两个小时,什么也找不到

问题是:我正在以html格式在技能和熟练程度字段中输入文本。模型采用字符串。但我得到的错误是:无法转换为数字

这就是我得到的错误:

Failed to bind request element: 
org.springframework.beans.TypeMismatchException: Failed to convert value of 
type 'java.lang.String' to required type 'com.byAJ.persistence.models.Skills'; 
nested exception is 
org.springframework.core.convert.ConversionFailedException: Failed to convert 
from type [java.lang.String] to type [java.lang.Long] for value 'Designing 
engines'; nested exception is java.lang.NumberFormatException: For input 
string: "Designingengines"
2017-07-09 15:48:57.233  WARN 16312 --- [nio-8080-exec-9] 
.w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by 
Handler execution: org.springframework.beans.TypeMismatchException: Failed to 
convert value of type 'java.lang.String' to required type 
'com.byAJ.persistence.models.Skills'; nested exception is 
org.springframework.core.convert.ConversionFailedException: Failed to convert 
from type [java.lang.String] to type [java.lang.Long] for value 'Designing 
engines'; nested exception is java.lang.NumberFormatException: For input 
string: "Designingengines"
HTML页面:

 <form autocomplete="off" action="#" th:action="@{/skill}"
       th:object="${skill}" method="post">
    <div class="form-group">
       <!--   <label for="degree">Degree <mark><strong><span th:if="${#fields.hasErrors('firstName')}" th:errors="*{firstName}">First Name Error</span></strong></mark></label>-->
        <label for="skill">Skill<mark><strong><span th:if="${#fields.hasErrors('skill')}" th:errors="*{skill}">can't be empty</span></strong></mark></label>
        <input type="text" class="form-control" id="skill" placeholder="Engineer" th:field="*{skill}" />
    </div>
    <div class="form-group">
        <label for="proficiency">Proficiency( Beginner, Proficient, Expert) <mark><strong><span th:if="${#fields.hasErrors('proficiency')}" th:errors="*{proficiency}"> can't be empty</span></strong></mark></label>
        <input type="text" class="form-control" id="proficiency" placeholder="Expert" th:field="*{proficiency}" />
    </div>


    <div class="form-group">
        <p>Enter More Skills?</p>

    <input type="radio" name="yesOrNo" value="yes"> Yes
    <input type="radio" name="yesOrNo" value="no" checked> No

    </div>
    <button type="submit" class="btn btn-default">Submit</button>
</form>
技能模式:

@Entity
public class Skills {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;



@NotEmpty
private String skill, proficiency;
private String username;


public String getSkill() {
    return skill;
}

public void setSkill(String skill) {
    this.skill = skill;
}

public String getProficiency() {
    return proficiency;
}

public void setProficiency(String proficiency) {
    this.proficiency = proficiency;
}

public String getUsername() {
    return username;
}

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

public long getId() {
    return id;
}



}   
最后,技能库积垢:

import com.byAJ.persistence.models.Skills;

import org.springframework.data.repository.CrudRepository;

public interface SkillRepository extends CrudRepository<Skills, Long>{

}
import com.byAJ.persistence.models.Skills;
导入org.springframework.data.repository.crudepository;
公共接口SkillRepository扩展了crudepository{
}
任何提示都非常感谢。谢谢


更新:当我尝试在技能字段中输入一个数字时,我没有得到任何错误和存储在数据库中的值gerts。这真的很让人困惑,因为我没有一个字段需要这些值为整数。

我注意到我的对象、字段和映射都有相同的名称。所以我把它们改成了不同的名字,现在程序开始工作了

看起来您正在将
string:“Designingengines”
传递到一个需要
Long
的字段中,该字段在HTML中定义为文本,在模型中定义为字符串,因此我不知道它为什么需要Long。
import com.byAJ.persistence.models.Skills;

import org.springframework.data.repository.CrudRepository;

public interface SkillRepository extends CrudRepository<Skills, Long>{

}