尝试为Dropwizard应用程序编写Dao测试用例。 我已经将自己的版本实现到AbstractDaoTest类,它与Dropwizard的配置没什么关系。想知道我是否可以使用Dropwizard的hibernate配置并从Dropwizard的HibernateBundle获取会话工厂。
public AbstractDaoTest() {
Configuration config=new Configuration();
config.setProperty("hibernate.connection.url","jdbc:mysql://127.0.0.1/testme");
config.setProperty("hibernate.connection.username","haha");
config.setProperty("hibernate.connection.password","haha");
config.setProperty("hibernate.connection.driver_class","com.mysql.jdbc.Driver");
config.setProperty("hibernate.current_session_context_class","thread");
config.setProperty("hibernate.show_sql", "true");
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build();
sessionFactory = config.buildSessionFactory(serviceRegistry);
}
我有没有办法在AbstarctDaoTest课程中掌握Dropwizard的HibernateBundle
?