如何在 gradle 启动测试中关闭关机钩子的输出?
您可以从 start.spring.io 到此问题生成项目,https://start.spring.io/starter.zip?type=gradle-project&language=java&bootVersion=2.2.5.RELEASE&baseDir=demo&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&packaging=jar&javaVersion=1.8&dependencies=h2,data-jpa,web
我有一个用gradle构建的多模块springBoot应用程序,有一堆SpringBoot集成测试。当我进行构建时,我最终会从SpringBoot关闭到控制台的一些输出,如下所示。如何关闭此输出?
± |master ↑1 {1} S:3 U:10 ✗| → ./gradlew build
> Task :core:test
2020-02-01 11:20:33.529 INFO 24114 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-02-01 11:20:33.531 INFO 24114 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-02-01 11:20:33.538 INFO 24114 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
> Task :email:test
2020-02-01 11:20:43.820 INFO 24150 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-02-01 11:20:43.820 INFO 24150 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-02-01 11:20:43.822 INFO 24150 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Shutdown initiated...
2020-02-01 11:20:43.822 INFO 24150 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-02-01 11:20:43.830 INFO 24150 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2020-02-01 11:20:43.830 INFO 24150 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Shutdown completed.
> Task :security:test
2020-02-01 11:20:54.941 INFO 24188 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-02-01 11:20:54.944 INFO 24188 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-02-01 11:20:54.952 INFO 24188 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 46s
57 actionable tasks: 54 executed, 3 up-to-date
作为参考,从具有 gradle 的 start.spring.io 创建的应用程序不会在屏幕上生成任何输出
./gradlew build
BUILD SUCCESSFUL in 779ms
5 actionable tasks: 5 up-to-date
相反,输出被放置在build/reports/
在我的情况下,我没有对启动附带的日志记录配置进行任何更改。没有对应用程序进行日志备份.xml或更改。yml 用于日志记录级别。我期望gradle正在捕获系统输出和系统错误并将它们发送到,但有些输出似乎正在逃逸到系统输出。build/reports/