如何修复“AOP配置似乎无效”错误?

时间:2017-03-01 04:35:43

标签: spring aop bitbucket-server atlassian-plugin-sdk

我正在使用atlassian-sdk为Bitbucket开发一个插件。当我尝试使用GitCommandFactory时,我遇到了以下错误:

"AOP configuration seems to be invalid: tried calling method [public 
abstract com.atlassian.bitbucket.scm.git.command.GitCommandFactory 
com.atlassian.bitbucket.scm.git.GitScm.getCommandFactory()] on target 
[com.atlassian.stash.internal.scm.git.DefaultGitScm@321c944]; nested 
exception is java.lang.IllegalArgumentException: object is not an 
instance of declaring class"

这是抛出错误的代码行:

 GitCommandFactory gitCommandFactory = gitScm.getCommandFactory();

我的班级和构造函数的一瞥:

 @ComponentImport
private final PullRequestService pullRequestService;
@ComponentImport
private final GitScm gitScm;
@ComponentImport
private final GitScmConfig gitScmConfig;
@ComponentImport
private final EventPublisher eventPublisher;

@Autowired
private ApplicationContext applicationContext;


private Logger loggerLocal;

@Autowired
public SquashServlet(PullRequestService pullRequestService, GitScm gitScm, GitScmConfig gitScmConfig, EventPublisher eventPublisher) throws Exception{
    super();
    this.pullRequestService = pullRequestService;
    this.gitScm = gitScm;
    this.gitScmConfig = gitScmConfig;
    this.eventPublisher = eventPublisher;

    FileHandler handler = new FileHandler("BitBuckSquash.log",true);
    this.loggerLocal = java.util.logging.Logger.getLogger("com.atlassian.kaushik.plugin.servlet");
    loggerLocal.addHandler(handler);
}

如何解决此问题?我究竟做错了什么?

1 个答案:

答案 0 :(得分:1)

修正了问题。这是由于不兼容的依赖关系。

我必须在pom.xml中添加与我的bitbucket版本相同的版本号,并且它有效。

    <dependency>
        <groupId>com.atlassian.bitbucket.server</groupId>
        <artifactId>bitbucket-git-api</artifactId>
        <scope>provided</scope>
        <version>${bitbucket.version}</version>
    </dependency>