2 sinat 24091517 sinat_24091517 于 2017.01.17 13:20 提问

person is not mapped--.整合Hibernate出现错误 2C

图片说明
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

/**

  • Created by on 2017/1/16.
    */
    @Entity
    @Table(name="person")
    public class Person {

    private String id;
    private String name;
    private String idCard;
    private String phone;
    private String address;

    @Id
    @Column(name = "id",nullable = false,length = 32,unique = true)
    @GenericGenerator(name = "generator",strategy = "uuid.hex")
    @GeneratedValue(generator = "generator")
    public String getId() {
    return id;
    }

    public void setId(String id) {
    this.id = id;
    }

    @Column(name="name",nullable = false,length = 32)
    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }
    @Column(name="idCard",nullable = false,length = 32)
    public String getIdCard() {
    return idCard;
    }

    public void setIdCard(String idCard) {
    this.idCard = idCard;
    }
    @Column(name="phone",nullable = false,length = 32)
    public String getPhone() {
    return phone;
    }

    public void setPhone(String phone) {
    this.phone = phone;
    }
    @Column(name="address",nullable = false,length = 32)
    public String getAddress() {
    return address;
    }

    public void setAddress(String address) {
    this.address = address;
    }
    }


3个回答

lihongbiao0610
lihongbiao0610   Rxr 2017.01.17 14:03

查看包名,是不是在自动扫描的包符合

sinat_24091517
sinat_24091517 配置文件没看到有错误
11 个月之前 回复
aslgm_1
aslgm_1   2017.01.17 14:16

检查Hibernate配置文件 看一下写错没

sinat_24091517
sinat_24091517 配置文件已经上传 没看到有错误
11 个月之前 回复
zzhao114
zzhao114   2017.02.10 15:43

实体类是反映射生成的?如果先配置spring的话,并且没有hiernate的配置文件,再用hibernate反映射,就会自动更新spring的配置

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!