微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Jira 插件开发 |小服务程序问题

如何解决Jira 插件开发 |小服务程序问题

我是一名正在为 JIRA 开发插件的学生,并且在让我的 servlet 读取我的 html 文件时遇到了问题。所以现在我想知道哪些注释适合使用?,以及哪些依赖项?。我没有收到任何错误消息,只是无法打开 index.vm 页面

如果有人可以看看我在下面附上的代码,或者只是帮助我找到在这方面知识渊博的合适人选,我将不胜感激。

感谢您的帮助 // Rickard

我的 Servlet

package com.i3tex.plugin.servlet;

import com.atlassian.jira.issue.IssueManager;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.templaterenderer.TemplateRenderer;
import com.atlassian.veLocity.VeLocityManager;
import com.atlassian.webresource.api.assembler.PageBuilderService;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import javax.servlet.servletexception;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@Component
public class SumalizerServlet extends HttpServlet {

    @ComponentImport
    private final VeLocityManager veLocityManager;
    @ComponentImport
    private PageBuilderService pageBuilderService;
    private IssueManager im;
    private TemplateRenderer tr;


    private static final Logger log = LoggerFactory.getLogger(
            SumalizerServlet.class
    );

    @Inject
    public SumalizerServlet(VeLocityManager veLocityManager,PageBuilderService pageBuilderService,IssueManager im,TemplateRenderer tr) {
        this.veLocityManager = veLocityManager;
        this.pageBuilderService = pageBuilderService;
        this.im = im;
        this.tr = tr;
    }

    @Override
    protected void doGet(HttpServletRequest request,HttpServletResponse response) throws servletexception,IOException {
        this.pageBuilderService
                .assembler()
                .resources()
                .requireWebResource("com.i3tex.plugin.Sumalizer:test-resource");

        Map<String,Object> context = Maps.newHashMap();
        context.put("ic",this.im.getIssueCount());
        
        String content = this.veLocityManager.getEncodedBody("/templates/","index.vm","UTF-8",context);
        
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().write(content);
        response.getWriter().close();
    }
}

Atlassian-plugin.xml

<?xml version="1.0" encoding="UTF-8"?>

<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2"> 
  <plugin-info> 
    <description>${project.description}</description>  
    <version>${project.version}</version>  
    <vendor name="${project.organization.name}" url="${project.organization.url}"/>  
    <param name="plugin-icon">images/pluginIcon.png</param>  
    <param name="plugin-logo">images/pluginlogo.png</param> 
  </plugin-info>  
  
  <resource type="i18n" name="i18n" location="Sumalizer"/>  
  <web-resource key="Sumalizer-resources" name="Sumalizer Web Resources"> 
    <resource type="download" name="Sumalizer.css" location="/css/Sumalizer.css"/>  
    <resource type="download" name="Sumalizer.js" location="/js/Sumalizer.js"/>  
    <resource type="download" name="images/" location="/images"/>  
    <context>Sumalizer</context>
  </web-resource>  

  <!--  Menu link to my servlet  -->
  <web-item name="Sumalizer" i18n-name-key="sumalizer.name" key="sumalizer" section="find_link/issues_new" weight="1000"> 
    <description key="sumalizer.description">The Sumalizer Plugin</description>  
    <label key="sumalizer.label"/>  
    <link linkId="sumalizer-link">/plugins/servlet/sumalizer</link> 
  </web-item>

  <!--  This is my servlet  -->
  <servlet name="Sumalizer Servlet" i18n-name-key="sumalizer-servlet.name" key="sumalizer-servlet" class="com.i3tex.plugin.servlet.SumalizerServlet">
    <description key="sumalizer-servlet.description">The Sumalizer Servlet Plugin</description>  
    <url-pattern>/sumalizer</url-pattern> 
  </servlet>

  <!--  My test resource  -->
  <web-resource key="test-resource" name="test-resource">
    <resource type="download" name="test.css" location="/css/test.css"/>
    <resource type="download" name="test.js" location="/js/test.js"/>
  </web-resource>
  
</atlassian-plugin>

这是我的 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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.i3tex.plugin</groupId>
    <artifactId>Sumalizer</artifactId>
    <version>0.0.1</version>
    <organization>
        <name>i3tex</name>
        <url>http://www.i3tex.com/</url>
    </organization>
    <name>Sumalizer</name>
    <description>This is the Sumalizer plugin.</description>
    <packaging>atlassian-plugin</packaging>
<dependencies>
    <dependency>
        <groupId>com.atlassian.templaterenderer</groupId>
        <artifactId>atlassian-template-renderer-api</artifactId>
        <version>4.1.1</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-api</artifactId>
        <version>${jira.version}</version>
        <scope>provided</scope>
        <exclusions>
            <exclusion>
                <groupId>jta</groupId>
                <artifactId>jta</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    
    <dependency>
        <groupId>com.atlassian.sal</groupId>
        <artifactId>sal-api</artifactId>
        <version>2.0.17</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.4</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.6</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>

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.1.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>jsr311-api</artifactId>
        <version>1.1.1</version>
        <scope>provided</scope>
    </dependency>


    <dependency>
        <groupId>com.atlassian.plugins</groupId>
        <artifactId>atlassian-plugins-core</artifactId>
        <version>5.3.5</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>5.3.4</version>
        <scope>provided</scope>
    </dependency>

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

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

                        <Export-Package>
                            com.i3tex.api,</Export-Package>
                        
                        <Import-Package>
                            org.springframework.osgi.*;resolution:="optional",org.eclipse.gemini.blueprint.*;resolution:="optional",*
                        </Import-Package>

                        <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>
                    <includeExclude>+com.atlassian.jira.plugins.issue.create.*</includeExclude>
                    <scannedDependencies>
                        <dependency>
                            <groupId>com.atlassian.plugin</groupId>
                            <artifactId>atlassian-spring-scanner-external-jar</artifactId>
                        </dependency>
                    </scannedDependencies>
                    <verbose>false</verbose>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <jira.version>7.13.18</jira.version>
        <amps.version>8.1.0</amps.version>
        <osgi.javaconfig.version>0.2.0</osgi.javaconfig.version>
        <spring.version>4.2.5.RELEASE</spring.version>
        <plugin.testrunner.version>2.0.1</plugin.testrunner.version>
        <atlassian.spring.scanner.version>2.2.0</atlassian.spring.scanner.version>
        <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>
    
    <repositories>
        <repository>
            <releases>
                <enabled>true</enabled>
                <checksumPolicy>warn</checksumPolicy>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
            </snapshots>
            <id>atlassian-public</id>
            <url>https://maven.atlassian.com/repository/public</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <releases>
                <enabled>true</enabled>
                <checksumPolicy>warn</checksumPolicy>
            </releases>
            <snapshots>
                <updatePolicy>never</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
            </snapshots>
            <id>atlassian-public</id>
            <url>https://maven.atlassian.com/repository/public</url>
        </pluginRepository>
    </pluginRepositories>

</project>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?