我的问题与此非常相似:Suppressing logs from AppClassLoader
不同之处在于,我将 AspectJ 与 Spring Boot 一起使用(通过 @EnableAspectJAutoProxy
和 @EnableLoadTimeWeaving(aspectjWeaving = ENABLED)
注释),所以我既没有 META-INF/aop.xml
,也不是META-INF/aop-ajc.xml
文件,在答案中提到。
如何使用基于注释的配置禁用这些烦人的 AppClassLoader 警告?
更新 为了澄清一下,我正在谈论这种日志:
...
[AppClassLoader@18b4aac2] error can't determine implemented interfaces of missing type org.springframework.cache.ehcache.EhCacheCacheManager
when weaving type org.springframework.boot.autoconfigure.cache.EhCacheCacheConfiguration
when weaving classes
when weaving
[Xlint:cantFindType]
[AppClassLoader@18b4aac2] error can't determine implemented interfaces of missing type org.springframework.cache.ehcache.EhCacheCacheManager
when weaving type org.springframework.boot.autoconfigure.cache.EhCacheCacheConfiguration
when weaving classes
when weaving
[Xlint:cantFindType]
[AppClassLoader@18b4aac2] error can't determine implemented interfaces of missing type org.springframework.cache.ehcache.EhCacheCacheManager
when weaving type org.springframework.boot.autoconfigure.cache.EhCacheCacheConfiguration
when weaving classes
when weaving
...
它们是红色的,而且数量很多。所以我想以某种方式抑制这些日志。
最佳答案
为了在使用 AspectJ 加载时编织时抑制某些 AspectJ 编译器消息,您可以执行以下操作。
创建文件 aspectjweaver.jar!/org/aspectj/weaver/XlintDefault.properties
的副本给您resources/META-INF
名为 Xlint.properties
的文件夹.
换行
cantFindType = error
至
cantFindType = ignore
然后,创建您的 aop.xml
在你的resources/META-INF
文件夹如下,或者在 <weaver>
中添加相应选项条目如图:
<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN"
"http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
<weaver options="-Xlintfile:META-INF/Xlint.properties" />
</aspectj>
现在您应该拥有 cantFindType
错误被抑制,但其他 AspectJ 消息保持不变。您可以类似地更改其他 linter 消息的报告。
关于java - 使用 Spring Boot 禁用 AppClassLoader AspectJ 日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56131932/