JerseyJiraRestClientFactory не может быть решена? - PullRequest
0 голосов
/ 05 июля 2019

Я пытаюсь создать плагин для Confluence, похожий на плагин Jira.Сейчас я просто играю с SDK, пытаясь заставить все работать.Я использую Atlassian SDK для этого.Я пытаюсь использовать Jersey для доступа к остальному API Jira, но не могу заставить компилятор распознавать JerseyJiraRestClientFactory.Я искал везде, и все делают это совершенно по-разному, ни один из которых не работал для меня.

Я считаю, что у меня есть все необходимые импорты в моем файле Java и необходимые зависимости в моем pom.xml(см. код), но по какой-то причине мой код не скомпилируется.

(У меня может быть слишком много зависимостей, чем требуется, потому что я пробовал сотни разных вещей, чтобы заставить это работать, я никогда не использовал javaили Maven раньше, так что это все немного над моей головой)

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.atlassian.tutorial</groupId>
<artifactId>myConfluenceMacro</artifactId>
<version>1.0.0-SNAPSHOT</version>

<organization>
    <name>Test</name>
    <url>http://www.example.com/</url>
</organization>

<name>myConfluenceMacro</name>
<description>This is the com.atlassian.tutorial:myConfluenceMacro plugin for Atlassian Confluence.</description>
<packaging>atlassian-plugin</packaging>

<dependencies>
    <dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-rest-java-client-core</artifactId>
        <version>2.0.0-m25</version>
    </dependency>

    <dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-rest-java-client-parent</artifactId>
        <version>4.0.0</version>
        <type>pom</type>
    </dependency>

     <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>1.9</version>
    </dependency>

     <dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-rest-java-client-api</artifactId>
        <version>2.0.0-m25</version>
    </dependency>

    <dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-api</artifactId>
        <version>8.2.1</version>
        <scope>provided</scope>
        <exclusions>
            <!-- JRJC depends on a newer version of atlassian-util-concurrent than the one provided by JIRA -->
            <exclusion>
                <groupId>com.atlassian.util.concurrent</groupId>
                <artifactId>atlassian-util-concurrent</artifactId>
            </exclusion>
            <!-- JRJC uses 4.0 of the apache httpclient. JIRA bundled version 3.x -->
            <exclusion>
                <groupId>commons-httpclient</groupId>
                <artifactId>commons-httpclient</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-rest-java-client</artifactId>
        <version>2.0.0-m2</version>
        <!--
         JIRA will already provide a number of dependencies that JRJC needs. We need to exclude them from the
         JRJC dependency as we don't want to package them up inside the plugin.
        -->
        <exclusions>
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
            <exclusion>
                <groupId>joda-time</groupId>
                <artifactId>joda-time</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jersey</groupId>
                <artifactId>jersey-json</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.atlassian.sal</groupId>
                <artifactId>sal-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.atlassian.event</groupId>
                <artifactId>atlassian-event</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
            </exclusion>
            <exclusion>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jersey</groupId>
                <artifactId>jersey-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-->/////////////////////////<-->


    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.confluence</groupId>
        <artifactId>confluence</artifactId>
        <version>${confluence.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>compile</scope>
    </dependency>

    <dependency>
        <groupId>com.atlassian.plugin</groupId>
        <artifactId>atlassian-spring-scanner-runtime</artifactId>
        <version>${atlassian.spring.scanner.version}</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
        <scope>provided</scope>
    </dependency>

    <!-- WIRED TEST RUNNER DEPENDENCIES -->
    <dependency>
        <groupId>com.atlassian.plugins</groupId>
        <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
        <version>${plugin.testrunner.version}</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.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.2.2-atlassian-1</version>
    </dependency>
</dependencies>

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

                <!-- See here for an explanation of default instructions: -->
                <!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
                <instructions>
                    <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>

                    <!-- Add package to export here -->
                    <Export-Package>
                        com.atlassian.tutorial.api,
                    </Export-Package>

                    <!-- Add package import here -->
                    <Import-Package>
                        org.springframework.osgi.*;resolution:="optional",
                        org.eclipse.gemini.blueprint.*;resolution:="optional",
                        *
                    </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>
                <scannedDependencies>
                    <dependency>
                        <groupId>com.atlassian.plugin</groupId>
                        <artifactId>atlassian-spring-scanner-external-jar</artifactId>
                    </dependency>
                </scannedDependencies>
                <verbose>false</verbose>
            </configuration>
        </plugin>
    </plugins>
</build>

<properties>
    <confluence.version>6.14.0</confluence.version>
    <confluence.data.version>6.14.0</confluence.data.version>
    <amps.version>8.0.2</amps.version>
    <plugin.testrunner.version>2.0.1</plugin.testrunner.version>
    <atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>
    <!-- This property ensures consistency between the key in atlassian-plugin.xml and the OSGi bundle's key. -->
    <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>

helloworld.java:

    package com.atlassian.tutorial.macro;

    import com.atlassian.confluence.content.render.xhtml.ConversionContext;
    import com.atlassian.confluence.macro.Macro;
    import com.atlassian.confluence.macro.MacroExecutionException;
    import com.atlassian.jira.rest.client.JiraRestClient;

    import java.util.Map;

    public class helloworld implements Macro {

        public String execute(Map<String, String> map, String s, ConversionContext conversionContext) throws MacroExecutionException {
            int noOfCols = Integer.parseInt(map.get("noOfColumns"));
            int noOfRows = Integer.parseInt(map.get("noOfRows"));
            String someHTML = "<table>";
            String columnHeadingsPreformatted = map.get("columnHeadingsCSV");
            String [] columnHeadings = columnHeadingsPreformatted.split("\\s*,\\s*");
            String rowHeadingsPreformatted = map.get("rowHeadingsCSV");
            String [] rowHeadings = rowHeadingsPreformatted.split("\\s*,\\s*");


            //Where the problems are
            JerseyJiraRestClientFactory factory = new JerseyJiraRestClientFactory();
            URI jiraServerUri = new URI("http://localhost:2990/jira");
            JiraRestClient restClient = factory.create(jiraServerUri, myAuthenticationHandler);

            }


        public BodyType getBodyType() { return BodyType.NONE; }

        public OutputType getOutputType() { return OutputType.BLOCK; }
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...