简体   繁体   English

无法在 com.itextpdf:itext7-core:pom:RELEASE 收集依赖项

[英]Failed to collect dependencies at com.itextpdf:itext7-core:pom:RELEASE

I am trying to create a pdf report using itextpdf library.我正在尝试使用 itextpdf 库创建 pdf 报告。 As it is instructed in the official documentation , I did add the following dependency in my pom.xml :正如官方文档中所指示,我确实在 pom.xml 中添加了以下依赖项:

<properties>
   <itext.version>RELEASE</itext.version>
</properties>
<dependencies>
    <!-- add all iText 7 modules -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>itext7-core</artifactId>
        <version>${itext.version}</version>
        <type>pom</type>
    </dependency>
</dependencies>

To make sure everything is neat and clean, I deleted my .m2/repository directory $rm -R .m2/repository and did run afterwwards $mvn clean compile in my project home directory.为了确保一切都整洁干净,我删除了我的 .m2/repository 目录$rm -R .m2/repository并在我的项目主目录中运行了$mvn clean compile I got then the following error :我得到了以下错误:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project business-project: Could not resolve dependencies for project myproject:business-project:jar:1.1-SNAPSHOT: Failed to collect dependencies at com.itextpdf:itext7-core:pom:RELEASE
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies (LifecycleDependencyResolver.java:269)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies (LifecycleDependencyResolver.java:147)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved (MojoExecutor.java:248)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:202)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project myproject:business-project:jar:1.1-SNAPSHOT: Failed to collect dependencies at com.itextpdf:itext7-core:pom:RELEASE

This the output of $mvn dependency:tree :这是$mvn dependency:tree的输出:

[INFO] -------------------< myproject:business-project >--------------------
[INFO] Building Business Layer 1.1-SNAPSHOT                        [3/4]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for myproject 1.1-SNAPSHOT:
[INFO] 
[INFO] my project ......................................... SUCCESS [  0.921 s]
[INFO] DB .......................................... SUCCESS [  0.108 s]
[INFO] Business Layer .............................. FAILURE [  0.234 s]
[INFO] Web Application ............................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.662 s
[INFO] Finished at: 2020-02-21T20:07:06+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project business-project: Could not resolve dependencies for project myproject:business-project:jar:1.1-SNAPSHOT: Failed to collect dependencies at com.itextpdf:itext7-core:pom:RELEASE: Failed to read artifact descriptor for com.itextpdf:itext7-core:pom:RELEASE: Failed to resolve version for com.itextpdf:itext7-core:pom:RELEASE: Could not find metadata com.itextpdf:itext7-core/maven-metadata.xml in local (/Users/MyComputer/.m2/repository) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :business-project

Running $mvn -v I get :运行$mvn -v我得到:

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven/3.6.3/libexec
Java version: 1.8.0_101, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/jre
Default locale: de_DE, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.3", arch: "x86_64", family: "mac"

My nexus server configured in my settings.xml :我在 settings.xml 中配置的连接服务器:

<mirrors>

        <mirror>
                                               <id>public</id>
                                               <mirrorOf>*</mirrorOf>
                                               <name>Central Repositories of internal repository manager Nexus</name>
                                                <url>http://nexus-server:8081/nexus/content/repositories/public</url>
                               </mirror>
    </mirrors>

How can I fix this problem please?请问我该如何解决这个问题? Thank you.谢谢你。

I don't understand exactly what you are trying to do but based on the given information I suppose you are trying to import the pom file as a so called BOM (Bill Of Material) .我不完全明白您要做什么,但根据给定的信息,我想您正在尝试将 pom 文件作为所谓的BOM (Bill Of Material)导入。 The issue you have is that you are trying to define a pom type as a dependency which will not work cause it is nothing what you can put on the classpath.您遇到的问题是您正在尝试将pom类型定义为依赖项,该依赖项不起作用,因为您无法将其放在类路径上。 Furthermore the given version, which you have defined via the property does simply not exist in Central repository .此外,您通过属性定义的给定版本在 Central repository 中根本不存在

The trick is to go via dependencyManagement like this:诀窍是通过这样的dependencyManagement

<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>itext7-core</artifactId>
        <version>7.1.10</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
   </dependencies>
</dependencyManagement>

Afterwards you can use now the dependencies which have been defined in that BOM file as this:之后,您现在可以使用在该 BOM 文件中定义的依赖项,如下所示:

<dependencies>
  <dependency>
      <groupId>com.itextpdf</groupId>
      <artifactId>barcodes</artifactId>
  </dependency>
</dependencies>

All of the dependencies in that bom can now simply being used by defining them without the version which is controlled by the bom file in the dependencyManagement .该 bom 中的所有依赖项现在可以简单地通过定义它们来使用,而不需要由dependencyManagement的 bom 文件控制的版本。 This is an elegant way to manage dependencies at a single location via the bom file.这是一种通过 bom 文件在单个位置管理依赖项的优雅方式。 You only need to change the version of the bom file and that's it.您只需要更改 bom 文件的版本即可。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 动态jasper或jasper报告不适用于maven依赖项:无法读取com.itextpdf:itext-pdfa:jar:5.5.0的工件描述符 - dynamic jasper or jasper reporting does not work with maven dependency: Failed to read artifact descriptor for com.itextpdf:itext-pdfa:jar:5.5.0 将ImportPackage com.itextpdf导入XPages中的Java类 - ImportPackage com.itextpdf into a Java Class in XPages iTextPDF库JAVA-导入com.itextpdf无法解析 - iTextPDF library JAVA - The import com.itextpdf cannot be resolved 无法在 com.fasterxml 收集依赖项。 jackson.core:jackson-core:jar:2.11.0: - Failed to collect dependencies at com.fasterxml. jackson.core:jackson-core:jar:2.11.0: Maven构建失败,无法在org.springframework:spring-core:jar:4.0.2.4.2上收集依赖项 - Maven Build Failure, Failed to collect dependencies at org.springframework:spring-core:jar:4.0.2.RELEASE com.itextpdf:book:war:5.3.1-SNAPSHOT:无法解决以下工件: - com.itextpdf:book:war:5.3.1-SNAPSHOT: The following artifacts could not be resolved: iText-com.itextpdf.tool.xml.exceptions.NotImplementedException - iText - com.itextpdf.tool.xml.exceptions.NotImplementedException iText 7-com.itextpdf.io.IOException:找不到PDF startxref - iText 7 - com.itextpdf.io.IOException: PDF startxref not found iText-如何将条形码添加到文档(com.itextpdf.text.Document)? - iText - how to add barcode to a Document (com.itextpdf.text.Document)? com.itextpdf.text.pdf.PdfPKCS7库不存在于Java IText中 - com.itextpdf.text.pdf.PdfPKCS7 library not present in java IText
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM