2016-11-18 77 views
2
@RunWith(SpringRunner.class) 
@SpringBootTest(classes=Application.class) 
public class MyTest { 

    @Autowired AppsRepo appRepo; 
    @Autowired OrdersRepo ordersRepo; 

    @Test 
    public void doTest() { 
     System.out.println("hello world"); 
    } 
} 


@SpringBootApplication 
@ComponentScan 
public class Application { 

    private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Application.class); 


    public static void main(String[] args) { 
     SpringApplication.run(Application.class, args); 
    } 

} 

我有非常简单的集成测试,hibernate和postgresql数据库。只有2个存储库和1个控制器。运行此集成测试需要大约62秒。发生了什么事情?春季开机休眠慢启动

我只有2个域对象,只有2个存储库。有什么方法可以加速测试吗?貌似大部分时间采取休眠从62

40秒是在那里度过的 -

2016-11-18 15:58:52.264 INFO 8424 --- [restartedMain] org.hibernate.dialect.Dialect   : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL92Dialect 
2016-11-18 15:59:31.528 DEBUG 8424 --- [restartedMain] o.h.e.j.env.spi.IdentifierHelperBuilder : JDBC driver metadata reported database stores quoted identifiers in neither upper, lower nor mixed case 
+0

你尝试'DevTools'?这里是链接https://spring.io/blog/2015/06/17/devtools-in-spring-boot-1-3 –

+0

启用调试,你会看到你自己。在整个spring/hibernate加载/引导过程中会执行大量的操作。长时间加载也可能是一些连接问题 - 只需再次调试即可。 –

+0

@SergeyBenner更新了问题,即使在调试日志记录时也没有什么有趣的 – user12384512

回答

1

这个属性添加到您的Hibernate配置:

hibernate.temp.use_jdbc_metadata_defaults=false