Jira 没有“com.atlassian.velocity.VelocityManager”类型的合格bean可用

Jira 没有“com.atlassian.velocity.VelocityManager”类型的合格bean可用,jira,jira-plugin,spring-bean,Jira,Jira Plugin,Spring Bean,我有我的邮件处理程序插件,它在Jira 7.13.18中运行良好,但当我尝试用它启动Jira 8.13.2时,插件无法启动。原因是: “扩展邮件处理程序”加载失败。 创建名为“sendMessageService”的bean时出错:通过构造函数参数2表示的未满足的依赖关系;嵌套异常为org.springframework.beans.factory.NoSuchBeanDefinitionException:没有“com.atlassian.velocity.VelocityManager”类型

我有我的邮件处理程序插件,它在Jira 7.13.18中运行良好,但当我尝试用它启动Jira 8.13.2时,插件无法启动。原因是:

“扩展邮件处理程序”加载失败。 创建名为“sendMessageService”的bean时出错:通过构造函数参数2表示的未满足的依赖关系;嵌套异常为org.springframework.beans.factory.NoSuchBeanDefinitionException:没有“com.atlassian.velocity.VelocityManager”类型的合格bean可用:至少需要1个符合autowire候选条件的bean。依赖项批注:{@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImportvalue=} 没有“com.atlassian.velocity.VelocityManager”类型的合格bean可用:至少需要1个符合autowire候选条件的bean。依赖项批注:{@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImportvalue=}

以下是sendMessageService的代码:


@Named
public class SendMessageService {
    private final MailServerManager mailServerManager;
    private final MailQueue mailQueue;
    private final VelocityManager velocityManager;

    @Inject
    public SendMessageService(@ComponentImport MailServerManager mailServerManager,
                              @ComponentImport MailQueue mailQueue,
                              @ComponentImport VelocityManager velocityManager) {
        this.mailServerManager = mailServerManager;
        this.mailQueue = mailQueue;
        this.velocityManager = velocityManager;
    }
VelocityManager有什么问题?据我所知,VelocityManager不是在Spring上下文中定义的,但它是在以前的版本中定义的,如何添加它

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>xx.xxx.jira.plugins</groupId>
    <artifactId>mail-handler</artifactId>
    <version>1.0-SNAPSHOT</version>

    <organization>
        <name>Nane</name>
        <url>http://</url>
    </organization>

    <name>Extended Mail Handler</name>
    <description>
        Provides basic "Create Issue or Comment Handler" functionality with additional features supported.
    </description>
    <packaging>atlassian-plugin</packaging>

    <dependencies>
        <!--JIRA Plugin dependencies-->
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-api</artifactId>
            <version>${jira.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <version>${atlassian.spring.scanner.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <scope>provided</scope>
        </dependency>

        <!--Mail handler plugin dependencies-->
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-mail-plugin</artifactId>
            <version>${jira.mail.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.mail</groupId>
            <artifactId>atlassian-mail</artifactId>
            <version>4.0.6</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.7</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jta</groupId>
            <artifactId>jta</artifactId>
            <version>1.0.1b</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-jira-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <productVersion>${jira.version}</productVersion>
                    <productDataVersion>${jira.version}</productDataVersion>

                    <enableQuickReload>true</enableQuickReload>
                    <enableFastdev>false</enableFastdev>

                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>

                        <!-- Add package to export here -->
                        <Export-Package>
                        </Export-Package>

                        <!-- Add package import here -->
                        <Import-Package>
                            *
                        </Import-Package>

                        <!-- Ensure plugin is spring powered -->
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
                <version>${atlassian.spring.scanner.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>atlassian-spring-scanner</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
                <configuration>
                    <verbose>true</verbose>                    
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <jira.version>7.12.1</jira.version>
        <amps.version>6.3.21</amps.version>
        <jira.mail.version>10.0.13</jira.mail.version>
        <plugin.testrunner.version>1.2.3</plugin.testrunner.version>
        <atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>
        <!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>

如果我们看一下Jira的来源,在ContainerRegistrar中:

        register.implementation(PROVIDED, VelocityManager.class, JiraVelocityManager.class);
提供的范围意味着组件是通过OSGi发布的

事实上,我可以创建一个简单的Jira插件来导入VelocityManager:

    @Inject
    public MyPluginComponentImpl(final ApplicationProperties applicationProperties, @ComponentImport VelocityManager velocityManager) {
        this.applicationProperties = applicationProperties;
        this.velocityManager = requireNonNull(velocityManager);
    }
并在构造函数中设置断点,查看正在注入JiraVelocityManager的实例

这在Jira 8.13.2中

所以你所看到的不应该发生

您能否将pom.xml添加到问题中,特别是jira maven插件配置


还有,检查一下http://localhost:2990/jira/plugins/servlet/upm/osgi 在Jira运行的任何地方替换,并检查“系统捆绑包、注册服务”部分是否包含类似服务501 com.atlassian.velocity.VelocityManager的内容。编号可能不同

我添加了pom。使用该指令[link]italic,我发现在插件配置中添加+com.atlassian.jira.plugins.issue.create.*后,注入了VelocityManager,一切正常,但我不明白为什么