切入点格式错误:类不能为空 [英] Pointcut is malformed: Class must not be null

查看:19
本文介绍了切入点格式错误:类不能为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出乎意料的是,我在 Eclipse 中遇到了Pointcut is malformed: Class must not be null"错误,其中包含几个 Aspects 类.代码运行良好,但是,如果没有更改这些类,Eclipse 突然开始报告错误.我正在尝试追踪问题的根源是 Eclipse 平台/插件更新还是项目的依赖更新.

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.

我使用的是 Spring Tool Suite 版本:3.7.1.RELEASE Build Id:201510041213 平台:Eclipse Mars.1 (4.5.1) 和 Spring IO Platform 2.0.0.

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) {
        // ...
    }
}

推荐答案

现在错误消失了.我所做的是改变我管理 Spring 依赖项的方式.

Now the errors have gone away. What I have done is change the way I managed the Spring dependencies.

在我在父 POM 中导入平台 BOM 之前,我的所有模块都按照 Spring 网站中的描述继承它:

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>

使用此配置,某些版本会覆盖不起作用的地方,并且由于我使用的 BOM 版本是快照,依赖项的实际版本每天都在变化.

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.

我所做的是将 BOM 设置为我父级的父级,这样版本覆盖就按预期工作,并且在没有提示的情况下编译了所有内容:

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>

这篇关于切入点格式错误:类不能为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆