问题
Out of a blue I'm getting "Pointcut is malformed: Class must not be null
" error in Eclipse with a couple of Aspects classes. The code works fine but, without a change in those classes, Eclipse suddenly started reporting the error.
I'm trying to track down if the source of the problem is a eclipse platform/plugin update or a project's dependency update.
I'm using Spring Tool Suite Version: 3.7.1.RELEASE Build Id: 201510041213 Platform: Eclipse Mars.1 (4.5.1) and Spring IO Platform 2.0.0.
Does anyone have the same problem?
I'm posting one of the aspects code (although the problem probably is not here)
@Aspect
@Order(200)
@Component
public class FooAspect {
@Around("execution(public org.springframework.http.ResponseEntity com.acme.endpoints.controller..*.*(..)) && " +
"@target(org.springframework.web.bind.annotation.RestController) && " +
"@annotation(com.acme.endpoints.annotations.FooAnnotation)")
public Object doCurrencyConversion(ProceedingJoinPoint pjp) throws Throwable {
String bar = extractBar(pjp);
ResponseEntity<?> retVal;
retVal = (ResponseEntity<?>) pjp.proceed();
processFooBar(retVal, bar);
return retVal;
}
private String extractBar(ProceedingJoinPoint pjp) {
return "...";
}
private void processFooBar(ResponseEntity<?> retVal, String targetBar) {
// ...
}
}
回答1:
Now the errors have gone away. What I have done is change the way I managed the Spring dependencies.
Before I imported the platform BOM in my parent POM so that all my modules inherit it as described in the Spring website with:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement><repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
With this configuration, some version overrides where not working and since the BOM version I'm using is a SNAPSHOT, the actual versions of the dependencies where changing everyday.
What I did was to set the BOM as my parent's parent, this way the version overrides worked as expected an everything compiled without a hint:
<parent>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath />
</parent>
<repositories>
<repository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
来源:https://stackoverflow.com/questions/33254795/pointcut-is-malformed-class-must-not-be-null