【发布时间】:2017-03-15 13:02:43
【问题描述】:
我正在尝试编写一个切入点来获得周围的建议:com.fasterxml.jackson.databind.DeserializationContext.reportMappingException() 方法。
这是我到目前为止所拥有的,但它不起作用,即 maven 抱怨:
[WARNING] advice defined in com.charter.aesd.videocatalog.client.interceptor.ContactManagerLogger has not been applied [Xlint:adviceDidNotMatch]
/Users/rhasija/dev/projects/video/videocatalog-middle/client/src/main/java/com/charter/aesd/videocatalog/client/interceptor/ContactManagerLogger.java:36
试验一:
@Pointcut("execution(* com.fasterxml.jackson.databind.DeserializationContext+.*(..))")
public void servicePointcut() {}
试验 2:
@Pointcut("execution( * com.fasterxml.jackson.databind.*.*(..) )")
public void servicePointcut() {}
下面是我的 pom.xml。是不是不能通过 AspectJ 有一个指向外部库的切入点?
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
....
</dependencies>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.10</version>
<configuration>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
<includes>
<include>**/*.java</include>
<include>**/*.groovy</include>
</includes>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<!--suppress MavenModelInspection -->
<goal>compile</goal>
<!--suppress MavenModelInspection -->
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>info.ponge.julien.hacks.guiceaspectj.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<!--suppress MavenModelInspection -->
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
【问题讨论】:
-
Minimal, Complete, and Verifiable example 怎么样?例如,我没有看到您的
ContactManagerLogger,也没有看到调用杰克逊的代码。 POM 也不完整。你使用正确的杰克逊版本吗?要拦截的方法只有2.8以后才有。这么多变数,我不喜欢胡思乱想。
标签: jackson aspectj aspectj-maven-plugin