java - 使用 Spring Boot 禁用 AppClassLoader AspectJ 日志记录

标签 java spring spring-boot aspectj

我的问题与此非常相似: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/

相关文章:

java - 如何比较两个不同页面中的两种产品

java - 从单个服务多次调用多个微服务的最佳方法或设计模式是什么?

java - 将PlatformTransactionManager注入(inject)Ehcache

java - th :disabled objects in Thymeleaf

java - 如何使用具有预定义 "src"描述符的 Maven 程序集插件制作单个 zip 存档?

java - 如何在 RAD/Websphere 8.5 中进行热代码替换

java - 向服务发送带有两个参数的请求时出现 NULL 指针

java - 使用 ORDER BY 查询对端点中的值进行排序

java - 为什么我的java LinkedList添加了相同的值

java - 使用 Calendar 和 SimpleDateFormat 将时间转换为 "HH:mm:ss"会增加 1 小时