java - atlassian 插件 sdk : maven dependency not resolved for apache commons

标签 java maven jira jira-plugin

我们一直致力于 JIRA 插件开发,并使用 apache-commons 库进行文件上传,如下所示:

<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.2</version>
<scope>provided</scope>
</dependency>

生成的插件在 atlas 开发环境中运行良好,但在 JIRA 上上传生成的 Jar 时,日志中显示以下错误。

 2017-12-11 09:49:53,841 UpmAsynchronousTaskManager:thread-3 
 ERROR jira.admin 357x1243x1 1ycla6b 14.102.4.74,13.58.31.162 /rest/plugins/1.0/ 
 [c.a.p.osgi.factory.OsgiPlugin] Detected an error (BundleException) enabling the plugin 'com.atlassian.tutorial.myPlugin' :
 Unresolved constraint in bundle com.atlassian.tutorial.myPlugin [237]: Unable to resolve 237.0: missing requirement [237.0] 
 osgi.wiring.package; (osgi.wiring.package=org.apache.commons.fileupload).  
 This error usually occurs when your plugin imports a package from another bundle with a specific version constraint and either the bundle providing that package doesn't meet those version constraints,
 or there is no bundle available that provides the specified package. For more details on how to fix this, see https://developer.atlassian.com/x/mQAN

在通过各种线程解决此问题后,我们尝试了以下方法。


  • 尝试使用不同版本的 Apache-Common 1.3.2 或 1.3 或 1.2.x 等...
  • 我们没有使用 Maven,而是直接上传了 lib 文件夹中的 .jar 文件,并更新了依赖项部分。 到目前为止,以上均无效。

这是 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>myPlugin</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <organization>
        <name>Atlassian SDK Tutorial</name>
        <url>http://developer.atlassian.com/</url>
    </organization>
    <name>myPlugin</name>
    <description>This is the com.atlassian.tutorial:myPlugin plugin for Atlassian JIRA.</description>
    <packaging>atlassian-plugin</packaging>
    <dependencies>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-api</artifactId>
            <version>${jira.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
        <!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->
        <!--
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-core</artifactId>
            <version>${jira.version}</version>
            <scope>provided</scope>
        </dependency>
        -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</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.activeobjects</groupId>
            <artifactId>activeobjects-plugin</artifactId>
            <version>1.2.3</version>
            <scope>provided</scope>
        </dependency>
       <!-- <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity-tools</artifactId>
            <version>1.3</version>
        </dependency>-->
        <!--<dependency>
            <groupId>info.bliki.wiki</groupId>
            <artifactId>bliki-core</artifactId>
            <version>3.0.19</version>
        </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>
        <!-- Uncomment to use TestKit in your project. Details at https://bitbucket.org/atlassian/jira-testkit -->
        <!-- You can read more about TestKit at https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+Smarter+integration+testing+with+TestKit -->
        <!--
        <dependency>
            <groupId>com.atlassian.jira.tests</groupId>
            <artifactId>jira-testkit-client</artifactId>
            <version>${testkit.version}</version>
            <scope>test</scope>
        </dependency>
        -->
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.8.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.6</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.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
        <!--<dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3.2</version>
            <scope>provided</scope>
        </dependency>-->
        <dependency>
            <artifactId>commons-fileupload</artifactId>
            <groupId>commons-fileupload</groupId>
            <version>1.3.2</version>
            <scope>system</scope>
            <systemPath>${basedir}/lib/commons-fileupload-1.3.2.jar</systemPath>
            <extractDependencies>false</extractDependencies>
        </dependency>
        <dependency>
            <groupId>com.atlassian.templaterenderer</groupId>
            <artifactId>atlassian-template-renderer-api</artifactId>
            <version>1.3.1</version>
            <scope>provided</scope>
        </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>
                    <!-- Uncomment to install TestKit backdoor in JIRA. -->
                    <!--
                    <pluginArtifacts>
                        <pluginArtifact>
                            <groupId>com.atlassian.jira.tests</groupId>
                            <artifactId>jira-testkit-plugin</artifactId>
                            <version>${testkit.version}</version>
                        </pluginArtifact>
                    </pluginArtifacts>
                    -->
                    <enableQuickReload>true</enableQuickReload>
                    <enableFastdev>false</enableFastdev>
                    <!-- 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 class="atlassian tut"></com>orial.myPlugin.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>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <fork>true</fork>
                    <executable>C:\Program Files\Java\jdk1.8.0_151\bin\javac</executable>
                </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>
        <jira.version>7.5.0</jira.version>
        <amps.version>6.3.6</amps.version>
        <jdkLevel>1.8</jdkLevel>
        <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>
        <!-- TestKit version 6.x for JIRA 6.x -->
        <testkit.version>6.3.11</testkit.version>
        <template.renderer.version>1.3.1</template.renderer.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

我们需要有关故障排除/解决上述问题的指导。

最佳答案

这看起来像第 3 方库。所以你需要改变你的范围 providedcompile -

<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.2</version>
<scope>compile</scope>
</dependency>

通过指定 <scope>compile</scope> ,您告诉 SDK 在编译时和运行时需要 commons-fileupload 库。 SDK 会将 commons-fileupload 库捆绑到您的插件中,插件系统会在插件启动时在插件类加载器中提供它。

更多详情 - https://developer.atlassian.com/docs/getting-started/working-with-the-pom/managing-dependencies

关于java - atlassian 插件 sdk : maven dependency not resolved for apache commons,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47750782/

相关文章:

java - 使用 JNI 代替 JNA 调用原生代码?

java - 自动滚动代码不起作用 : cannot find symbol

java - 在 Spring 的 Controller 中存储状态

java - 无法启动嵌入式tomcat

maven - maven-javadoc-plugin 中的 sourceFileExcludes 标记

regex - Powershell查找特定模式

java - 匿名类的构造函数调用可以有参数吗

java - 在 eclipse 中创建 org.jenkins-ci.plugins 时出现 maven-enforcer-plugin 问题

java - JIRA自定义插件开发-创建自定义字段返回null

customization - 如何在 Jira 中设置自定义字段配置模式?