我是spring mvc的新手,我正在尝试使用注释制作数据库表。但是当我使用 hbm.xml 时它没有创建它可以正常工作。请帮我。任何帮助都将是可观的。
我的表单编码是:-
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotEmpty;
@Entity
@Table(name = "LOGIN_MASTER")
public class LoginForm {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long Id;
@NotEmpty
@Size(min = 1, max = 50)
@Column(name = "userName")
private String userName;
@NotEmpty
@Size(min = 1, max = 20)
@Column(name = "password")
private String password;
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserName() {
return userName;
}
public void setPassword(String password) {
this.password = password;
}
public String getPassword() {
return password;
}
public long getId() {
return Id;
}
public void setId(long id) {
Id = id;
}
}
休眠.cfg.xml
<session-factory>
<property name="hibernate.connection.driver_class"> com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/spring3login</property>
<property name="hibernate.connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.pool_size">1</property>
<property name="hibernate.dialect"> org.hibernate.dialect.HSQLDialect </property>
<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">create</property>
春天.xml
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix"> <value>/WEB-INF/views/</value> </property>
<property name="suffix"> <value>.jsp</value> </property>
</bean>