正在关注 https://developer.atlassian.com/bamboodev/bamboo-tasks-api/executing-external-processes-using-processservice我想使用 ProcessService bean 调用一些命令。链接中描述的注入(inject)不起作用。 我检查了 Bitbucket 上其他几个插件的来源,但每个插件都使用链接中描述的概念。
我的类(class):
import com.atlassian.bamboo.process.ProcessService;
public class CheckTask implements TaskType {
private final ProcessService processService;
public CheckTask(@NotNull final ProcessService processService) {
this.processService = processService;
}
但是 Bamboo 没有找到 ProcessService bean 并失败并显示以下内容:
(org.springframework.beans.factory.UnsatisfiedDependencyException : Error creating bean with name 'bamboo.tasks.CheckTask': Unsatisfied dependency expressed through constructor argument with index 0 of type [com.atlassian.bamboo.process.ProcessService]: : No qualifying bean of type [com.atlassian.bamboo.process.ProcessService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.bamboo.process.ProcessService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {})
我错过了什么吗? Bamboo 版:5.13.0 AMPS版本:6.2.6
最佳答案
最后的解决方案很简单,虽然没有官方文档讨论解决方案。希望这对您有所帮助。
终于感谢这篇文章,我让它工作了:https://answers.atlassian.com/questions/33141765/testcollationservice-not-injected-into-tasktype-constructor-on-sdk-bamboo
import com.atlassian.bamboo.process.ProcessService;
import com.atlassian.plugin.spring.scanner.annotation.component.Scanned;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
@Scanned
public class CheckTask implements TaskType {
@ComponentImport
private final ProcessService processService;
public CheckTask(@NotNull final ProcessService processService) {
this.processService = processService;
}
项目的其余部分基本上是默认的,由 atlas-create-bamboo-plugin 生成。
关于java - Bamboo ProcessService bean 不存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38969235/