2017-03-10 1 views
0

웹 프로젝트, spring spring-mvc 및 hibernate, tomcat이 시작될 때 mysql db에서 만들어진 테이블이 없습니다. 왜? 및 오류 정보Hibernate는 엔티티 주석이있을 때 테이블을 생성 할 수 없습니까?

SessionFactory에

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> 
    <property name="dataSource" ref="dataSource" /> 
    <property name="hibernateProperties"> 
     <props> 
      <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> 
      <prop key="hibernate.dialect">${hibernate.dialect}</prop> 
      <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> 
      <prop key="hibernate.format_sql">${hibernate.format_sql}</prop> 
     </props> 
    </property> 
    <property name="packagesToScan"> 
     <list> 
      <value>com.woodcoder.bean</value> 
     </list> 
    </property> 
</bean> 

속성

hibernate.hbm2ddl.auto=update 
hibernate.show_sql=true 
hibernate.format_sql=false 

내가 hibernate.hbm2ddl.auto=create 시도는, 동일한 없습니다. 왜 하이버 네이트가 테이블을 생성하지 않는가?

엔터티

@Entity 
    @Table(name="user_bean") 

public class UserBean extends BaseBean { 

    private String username; 
    private String password; 

    public String getUsername() { 
     return username; 
    } 
    public void setUsername(String username) { 
     this.username = username; 
    } 
    public String getPassword() { 
     return password; 
    } 
    public void setPassword(String password) { 
     this.password = password; 
    } 


} 

baseEntity

@MappedSuperclass 
public class BaseBean implements Serializable{ 
    /** 
    * ID 
    */ 
    @Id 
    @Column(name="id",length = 32, nullable = true) 
    @GeneratedValue(generator = "uuid") 
    @GenericGenerator(name = "uuid", strategy = "uuid") 
    private String id; 

    @Column(updatable = false) 
    private Date createDate; 

    private Date modifyDate; 


    public String getId() { 
     return id; 
    } 

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

    public Date getCreateDate() { 
     return createDate; 
    } 

    public void setCreateDate(Date createDate) { 
     this.createDate = createDate; 
    } 

    public Date getModifyDate() { 
     return modifyDate; 
    } 

    public void setModifyDate(Date modifyDate) { 
     this.modifyDate = modifyDate; 
    } 
+0

디버그 로깅을 켭니다 (사용하지 않은 경우). 아마도 스키마 도구가 오류를 찾고 있지만 로그 수준이 낮기 때문에 오류가 표시되지 않습니다. 두 번째로 XML 파일이 배포 전쟁의 값으로 올바르게 대체되고 있는지 확인하십시오. 종종 그런 일이 일어나지 않는 이유가 될 수 있습니다. – Naros

+0

당신의 제안대로, 나는 로그 레벨을 DEBUG로 낮춘 다음, 더 많은 정보를 얻지 만 테이블을 만들지 않습니다. 나는 tomcat에서 deploy 디렉토리를 검사했다. 모든 속성과 xml 파일이 제대로 배포되었다. –

답변

0

예,이 문제가있어. 최대 절전 모드 구성에서 각 줄의 끝에 약간의 공간이 있지만, 내가 볼 수는 없지만 them.i이 공간을 삭제하면 테이블이 만들어졌습니다.

hibernate.hbm2ddl.auto=update 
hibernate.show_sql=true 
hibernate.format_sql=false 
관련 문제