如何防止 Spring 工具套件在每次编译时在控制台中添加额外的 data/details

How to prevent Spring Tool Suite from adding extra data/details in the console on every compilation

我是 Java/Spring 的新手,每当我在 Spring Tool Suite 中编译和 运行 一个包或 class 时,我都会看到输出,但是 STS还将包括一堆我真的不关心的其他信息。我怎样才能让 STS 只显示输出和相关错误,而不显示所有无关信息,如下所示:

  .   ____          _            __ _ _
 /\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.5.RELEASE)

2018-10-01 20:43:06.780  INFO 74504 --- [           main] JDBCTest.CodeWarsAppApplication          : Starting CodeWarsAppApplication on Johns-MacBook-Pro-3.local with PID 74504 (/Users/johnwolfe/Documents/workspace-sts-3.9.5.RELEASE/demo/CodeWarsApp/bin/main started by johnwolfe in /Users/johnwolfe/Documents/workspace-sts-3.9.5.RELEASE/demo/CodeWarsApp)
2018-10-01 20:43:06.785  INFO 74504 --- [           main] JDBCTest.CodeWarsAppApplication          : No active profile set, falling back to default profiles: default
2018-10-01 20:43:06.840  INFO 74504 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@413d1baf: startup date [Mon Oct 01 20:43:06 CDT 2018]; root of context hierarchy
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils (file:/Users/johnwolfe/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.0.9.RELEASE/9f9a828936d81afd49a603bda9cc1aed863a0d85/spring-core-5.0.9.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2018-10-01 20:43:07.409  INFO 74504 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-10-01 20:43:07.425  INFO 74504 --- [           main] JDBCTest.CodeWarsAppApplication          : Started CodeWarsAppApplication in 0.99 seconds (JVM running for 1.436)
2018-10-01 20:43:07.429  INFO 74504 --- [       Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@413d1baf: startup date [Mon Oct 01 20:43:06 CDT 2018]; root of context hierarchy
2018-10-01 20:43:07.431  INFO 74504 --- [       Thread-1] o.s.j.e.a.AnnotationMBeanExporter

显然您需要更改默认记录器阈值。这可以在您的 application.properties 中完成,如果您使用任何第三方日志库,也可以直接在您的记录器配置文件中完成。

允许的级别为:ERRORWARNINFODEBUGTRACE

对于 Spring 引导,默认值是:

根目录:
logging.level.root=ERROR

Spring 网页:
logging.level.org.springframework.web: ERROR

如果您使用的是 Hibernate:
logging.level.org.hibernate: ERROR

更多信息请访问 Spring's Boot Logging Page