如何防止Spring Tool Suite在每次编译时在控制台中添加额外的数据/细节

时间:2018-10-02 01:47:47

标签: java spring spring-tool-suite

我是Java / Spring的新手,每当我在Spring Tool Suite中编译并运行一个包或类时,我都会看到输出,但是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$1 (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$1
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

1 个答案:

答案 0 :(得分:1)

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

允许的级别为:ERRORWARNINFODEBUGTRACE

对于Spring Boot,默认值为:

ROOT:
logging.level.root=ERROR

Spring WEB:
logging.level.org.springframework.web: ERROR

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

更多信息,Spring's Boot Logging Page