1

我正在使用 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);
}

我该如何解决这个问题?我究竟做错了什么?

4

1 回答 1

1

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

我必须在 pom.xml 中添加与我的 bitbucket 版本相同的版本号,并且它起作用了。

    <dependency>
        <groupId>com.atlassian.bitbucket.server</groupId>
        <artifactId>bitbucket-git-api</artifactId>
        <scope>provided</scope>
        <version>${bitbucket.version}</version>
    </dependency>
于 2017-03-02T21:21:09.377 回答