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

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

问题描述

出乎意料的是,在Eclipse中,我遇到了几个Aspects类,出现"Pointcut is malformed: Class must not be null"错误.该代码可以正常工作,但是在这些类中没有进行任何更改的情况下,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构建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.

有人有同样的问题吗?

我正在发布方面代码之一(尽管问题可能不在这里)

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.

在将平台BOM导入父POM之前,我的所有模块都按照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表版本是SNAPSHOT,因此依赖项的实际版本每天都在更改.

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>

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

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