【发布时间】:2016-11-21 18:20:17
【问题描述】:
我在 Spring Boot 应用程序中使用 MySQL 作为数据库。我删除了数据库并再次创建它并运行了 Junit 测试,它现在没有创建 hibernate_sequence 表,而是在它确实拥有该表之前。
我的实体类是这样的
@Entity
public class Greeting {
@Id
@GeneratedValue
private Long id;
private String text;
//getters & setters
}
我的休眠属性
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.jpa.properties.hibernate.hbm2ddl.auto=update
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.connection.sid=xe
spring.jpa.properties.hibernate.connection.characterEncoding=utf8
spring.jpa.properties.hibernate.connection.CharSet=utf8
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.LocalSessionFactoryBean
spring.jpa.properties.hibernate.id.new_generator_mappings=true
我的 Junit 测试
@RunWith(SpringRunner.class)
@ContextConfiguration(locations = { "classpath:applicationContext.xml" })
@SpringBootTest
public class GreetingRepositoryDAOTest {
@Resource
private BaseRepository greetingRepositoryImpl;
@Test
public void test() {
Greeting gr = new Greeting();
gr.setText("Third Text");
greetingRepositoryImpl.save(gr);
}
}
【问题讨论】:
标签: java hibernate spring-boot