“azure-storage-blob” 依赖项未被引入到使用的 Grails 应用程序中。

huangapple go评论45阅读模式
英文:

azure-storage-blob dependency defined in custom java library is not pulled into consuming grails application

问题

我已经构建了一个自定义的Java库,它包装了一些常见的Azure存储功能,称为"lib-azure-blob-storage"。库的build.gradle文件具有以下依赖项:

dependencies {
    //@see https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/boms/azure-sdk-bom/README.md
    implementation(platform('com.azure:azure-sdk-bom:1.2.13'))
    implementation 'com.azure:azure-storage-blob'
    implementation 'commons-io:commons-io:2.12.0'
}

而发布的库具有以下POM内容:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <!-- This module was also published with a richer model, Gradle metadata,  -->
  <!-- which should be used instead. Do not delete the following line which  -->
  <!-- is to indicate to Gradle or any Gradle module metadata file consumer  -->
  <!-- that they should prefer consuming it instead. -->
  <!-- do_not_remove: published-with-gradle-metadata -->
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.basesStudio</groupId>
  <artifactId>lib-azure-blob-storage</artifactId>
  <version>1.0.0-jre8</version>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.azure</groupId>
        <artifactId>azure-sdk-bom</artifactId>
        <version>1.2.13</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.azure</groupId>
      <artifactId>azure-storage-blob</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.12.0</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
</project>

然而,当我将这个库导入我的Grails Web应用程序时,如下所示:

implementation "com.basesStudio:lib-azure-blob-storage:1.0.0-jre8"

它无法解析一个类,出现以下错误:

startup failed:
app/services/com/basesStudio/jet/RunRService.groovy: 12: unable to resolve class com.azure.storage.blob.specialized.BlockBlobClient
 @ line 12, column 1.
   import com.azure.storage.blob.specialized.BlockBlobClient
   ^

1 error

我必须再次在消费应用程序中添加"azure-storage-blob"以避免此错误:

implementation "com.azure:azure-storage-blob:12.22.2"
implementation "com.basesStudio:lib-azure-blob-storage:1.0.0-jre8"

我本来认为只要实现"com.basesStudio:lib-azure-blob-storage:1.0.0-jre8"应该就足够了,因为它应该已经包含了"com.azure:azure-storage-blob:12.22.2"的依赖关系。

当我在Gradle中运行依赖关系报告时,我看到以下内容:

+--- com.basesStudio:lib-azure-blob-storage:1.0.0-jre8
|    +--- com.azure:azure-sdk-bom:1.2.13 (*)
|    +--- com.azure:azure-storage-blob -> 12.22.2
|    |    +--- com.azure:azure-core:1.39.0 (*)
|    |    +--- com.azure:azure-core-http-netty:1.13.3 (*)
|    |    +--- com.azure:azure-storage-common:12.21.1
|    |    |    +--- com.azure:azure-core:1.39.0 (*)
|    |    |    +--- com.azure:azure-core-http-netty:1.13.3 (*)
|    |    |    \--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.5 -> 2.13.4 (*)
|    |    +--- com.azure:azure-storage-internal-avro:12.7.1
|    |    |    +--- com.azure:azure-core:1.39.0 (*)
|    |    |    +--- com.azure:azure-core-http-netty:1.13.3 (*)
|    |    |    +--- com.azure:azure-storage-common:12.21.1 (*)
|    |    |    \--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.5 -> 2.13.4 (*)
|    |    \--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.5 -> 2.13.4 (*)
|    \--- commons-io:commons-io:2.12.0

在构建我的库时,我可以做什么,以使消费的Grails应用程序不必重新导入已在库中定义的依赖项?

英文:

I have built a custom java library that wraps around some common functionality of azure storage called "lib-azure-blob-storage". The build.gradle file of the library has following dependencies:


dependencies {
    //@see https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/boms/azure-sdk-bom/README.md
    implementation(platform(&#39;com.azure:azure-sdk-bom:1.2.13&#39;))
    implementation &#39;com.azure:azure-storage-blob&#39;
    implementation &#39;commons-io:commons-io:2.12.0&#39;
}

And the published library has following pom content:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot; xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
    xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
  &lt;!-- This module was also published with a richer model, Gradle metadata,  --&gt;
  &lt;!-- which should be used instead. Do not delete the following line which  --&gt;
  &lt;!-- is to indicate to Gradle or any Gradle module metadata file consumer  --&gt;
  &lt;!-- that they should prefer consuming it instead. --&gt;
  &lt;!-- do_not_remove: published-with-gradle-metadata --&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.basesStudio&lt;/groupId&gt;
  &lt;artifactId&gt;lib-azure-blob-storage&lt;/artifactId&gt;
  &lt;version&gt;1.0.0-jre8&lt;/version&gt;
  &lt;dependencyManagement&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.azure&lt;/groupId&gt;
        &lt;artifactId&gt;azure-sdk-bom&lt;/artifactId&gt;
        &lt;version&gt;1.2.13&lt;/version&gt;
        &lt;type&gt;pom&lt;/type&gt;
        &lt;scope&gt;import&lt;/scope&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/dependencyManagement&gt;
  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;com.azure&lt;/groupId&gt;
      &lt;artifactId&gt;azure-storage-blob&lt;/artifactId&gt;
      &lt;scope&gt;runtime&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;commons-io&lt;/groupId&gt;
      &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
      &lt;version&gt;2.12.0&lt;/version&gt;
      &lt;scope&gt;runtime&lt;/scope&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;
&lt;/project&gt;

However when I import this library to my consuming grails web application like:

implementation &quot;com.basesStudio:lib-azure-blob-storage:1.0.0-jre8&quot;

Its unable to resolve one of the class with following error:

startup failed:
app/services/com/basesStudio/jet/RunRService.groovy: 12: unable to resolve class com.azure.storage.blob.specialized.BlockBlobClient
 @ line 12, column 1.
   import com.azure.storage.blob.specialized.BlockBlobClient
   ^

1 error

I have to again add "azure-storage-blob" in the consuming app to avoid this error:

implementation &quot;com.azure:azure-storage-blob:12.22.2&quot;
implementation &quot;com.basesStudio:lib-azure-blob-storage:1.0.0-jre8&quot;

I would have though implementing com.basesStudio:lib-azure-blob-storage:1.0.0-jre8 should be enough since it should have pulled in the com.azure:azure-storage-blob:12.22.2 dependency along with it.

When I run dependency report in gradle I see following:

+--- com.basesStudio:lib-azure-blob-storage:1.0.0-jre8
|    +--- com.azure:azure-sdk-bom:1.2.13 (*)
|    +--- com.azure:azure-storage-blob -&gt; 12.22.2
|    |    +--- com.azure:azure-core:1.39.0 (*)
|    |    +--- com.azure:azure-core-http-netty:1.13.3 (*)
|    |    +--- com.azure:azure-storage-common:12.21.1
|    |    |    +--- com.azure:azure-core:1.39.0 (*)
|    |    |    +--- com.azure:azure-core-http-netty:1.13.3 (*)
|    |    |    \--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.5 -&gt; 2.13.4 (*)
|    |    +--- com.azure:azure-storage-internal-avro:12.7.1
|    |    |    +--- com.azure:azure-core:1.39.0 (*)
|    |    |    +--- com.azure:azure-core-http-netty:1.13.3 (*)
|    |    |    +--- com.azure:azure-storage-common:12.21.1 (*)
|    |    |    \--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.5 -&gt; 2.13.4 (*)
|    |    \--- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.5 -&gt; 2.13.4 (*)
|    \--- commons-io:commons-io:2.12.0

What can I do when building my library so that the consuming grails application doesn't have to re-import the dependency that is already defined in the library?

答案1

得分: 0

>app/services/com/basesStudio/jet/RunRService.groovy: 12: unable to resolve class com.azure.storage.blob.specialized.BlockBlobClient.

azure-storage-blob依赖项添加到您的Grails应用程序的build.gradle文件中,如下所示:

dependencies{

implementation &#39;com.azure:azure-storage-blob:12.22.2&#39;
implementation group: &#39;com.azure&#39;, name: &#39;azure-storage-blob&#39;, version: &#39;12.22.2&#39;

}

这是为了确保Grails应用程序中可用BlockBlobClient类。

  1. 确保azure-storage-blob包或其依赖项没有冲突的版本。
  2. 运行命令gradle clean build来刷新/清理依赖项并构建应用程序。

在pom.xml中,将azure-storage-blobversion添加到dependencies部分。

&lt;dependency&gt;
      &lt;groupId&gt;com.azure&lt;/groupId&gt;
      &lt;artifactId&gt;azure-storage-blob&lt;/artifactId&gt;
      &lt;version&gt;12.22.2&lt;/version&gt;
      &lt;scope&gt;runtime&lt;/scope&gt;
&lt;/dependency&gt;

我在我的应用程序中使用以下依赖项。

dependencies {

implementation &#39;org.springframework.boot:spring-boot-starter-web&#39;
implementation &#39;com.azure:azure-storage-blob:12.22.2&#39;
implementation group: &#39;com.azure&#39;, name: &#39;azure-storage-blob&#39;, version: &#39;12.22.2&#39;
implementation group: &#39;com.microsoft.azure&#39;, name: &#39;azure-storage-spring-boot-starter&#39;, version: &#39;2.2.5&#39;
implementation group: &#39;commons-fileupload&#39;, name: &#39;commons-fileupload&#39;, version: &#39;1.4&#39;

}

我可以导入com.azure.storage.blob.specialized.BlockBlobClient类。

“azure-storage-blob” 依赖项未被引入到使用的 Grails 应用程序中。

英文:

>app/services/com/basesStudio/jet/RunRService.groovy: 12: unable to resolve class com.azure.storage.blob.specialized.BlockBlobClient.

Add the azure-storage-blob dependency to your Grails application's build.gradle file as shown below:

dependencies{

implementation &#39;com.azure:azure-storage-blob:12.22.2&#39;
implementation group: &#39;com.azure&#39;, name: &#39;azure-storage-blob&#39;, version: &#39;12.22.2&#39;

}

This is to make sure BlockBlobClient class is available in the Grails application.

  1. Make sure there are no conflicting versions of the azure-storage-blob package or its dependencies.
  2. Run the command gradle clean build to refresh/clean the dependencies and build the application.

And in pom.xml, add version of azure-storage-blob in dependencies section.

&lt;dependency&gt;
      &lt;groupId&gt;com.azure&lt;/groupId&gt;
      &lt;artifactId&gt;azure-storage-blob&lt;/artifactId&gt;
      &lt;version&gt;12.22.2&lt;/version&gt;
      &lt;scope&gt;runtime&lt;/scope&gt;
&lt;/dependency&gt;

I have the tried with below dependencies in my application.

dependencies {

implementation &#39;org.springframework.boot:spring-boot-starter-web&#39;
implementation &#39;com.azure:azure-storage-blob:12.22.2&#39;
implementation group: &#39;com.azure&#39;, name: &#39;azure-storage-blob&#39;, version: &#39;12.22.2&#39;
implementation group: &#39;com.microsoft.azure&#39;, name: &#39;azure-storage-spring-boot-starter&#39;, version: &#39;2.2.5&#39;
implementation group: &#39;commons-fileupload&#39;, name: &#39;commons-fileupload&#39;, version: &#39;1.4&#39;

}

I could import the class com.azure.storage.blob.specialized.BlockBlobClient

“azure-storage-blob” 依赖项未被引入到使用的 Grails 应用程序中。

huangapple
  • 本文由 发表于 2023年6月19日 03:46:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76502284.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定