注解加载实体类文件代码如下:
package com.bird.user.entity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Id;
@Entity
@Table(name = "user")
public class User {
private int id ;
@Id
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
如果不用注解 ,需要在spring.xml中增加如下代码。
com/bird/user/entity/User.hbm.xml
看的我头痛眼花,不过我可以指点你下,你用的注解是吧?那么请问你的配置文件里面有没有引进注解需要的各种头文件:
xmlns:context="http://www.springframework.org/schema/context"
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
还有你的命名,你的springconfg里面配置的bean名称要和你的action里面的名称一样,假如你配置的dao或者是service、那么就要实现借口。在action里面应是写借口,因为spring是面试借口编程的。
sessionFactoty这个bean配置有错误? 数据源的配置能不能贴出来看看
去掉
配置文件修改如下: