9

将 jasper 报告版本4.5.0 升级到 5.1.0。当我安装我的插件时,它会引发错误,例如缺少某些依赖项。我想用 Maven 配置 JasperReports 5.1.0。

Execution default of goal org.codehaus.mojo:jasperreports-maven-plugin:1.0-beta-2:compile-reports failed: Plugin org.codehaus.mojo:jasperreports-maven-plugin:1.0-beta-2 or one of its dependencies could not be resolved: Failure to find com.lowagie:itext:jar:2.1.7.js2

我有两个查询。

1)我想知道我必须在 pom 中添加哪些依赖项才能使用 jasper 报告 5.1.0。

2)我正在使用下面的插件将我的 jrxml 文件编译为 jasper 文件。我在这个插件中看到了这个问题。这个插件可能是什么问题。我应该添加任何镜子吗?

<groupId>org.codehaus.mojo</groupId>
<artifactId>jasperreports-maven-plugin</artifactId>
<version>1.0-beta-2</version>

我完整的 pom 是,除了 jasper 报告之外,可能还有额外的依赖项,我将它用于我的内部目的。

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://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">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.test.plugins</groupId>
  <artifactId>report-test-plugin</artifactId>
  <version>2.2.1.1001-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>report-test-plugin</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
            <version>2.0.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-project</artifactId>
            <version>2.0.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-artifact</artifactId>
            <version>${maven-artifact.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-artifact-manager</artifactId>
            <version>${maven-artifact-manager.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-model</artifactId>
            <version>${maven-model.version}</version>
        </dependency>

        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-utils</artifactId>
            <version>${plexus-utils.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-provider-api</artifactId>
            <version>${wagon-provider-api.version}</version>
        </dependency>

        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>${dom4j.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.maven.shared</groupId>
            <artifactId>maven-plugin-testing-harness</artifactId>
            <version>1.0-beta-1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>jmock</groupId>
            <artifactId>jmock</artifactId>
            <version>${jmock.version}</version>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
            <version>${commons-configuration.version}</version>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.1</version>
        </dependency>

        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>${json.version}</version>
        </dependency>

        <!--  itext -->
        <dependency>
            <groupId>com.itextpdf</groupId>
            <artifactId>itextpdf</artifactId>
            <version>5.1.2</version>
        </dependency>

        <dependency>
            <groupId>com.itextpdf</groupId>
            <artifactId>itext-xtra</artifactId>
            <version>5.1.2</version>
        </dependency>

        <dependency>
            <groupId>com.itextpdf.tool</groupId>
            <artifactId>xmlworker</artifactId>
            <version>1.1.0</version>
        </dependency>

        <dependency>
            <groupId>org.xhtmlrenderer</groupId>
            <artifactId>core-renderer</artifactId>
            <version>R8</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml</groupId>
            <artifactId>classmate</artifactId>
            <version>0.5.4</version>
        </dependency>

        <dependency>
            <groupId>net.sourceforge.htmlcleaner</groupId>
            <artifactId>htmlcleaner</artifactId>
            <version>2.2</version>
        </dependency>

        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>5.1.0</version>
        </dependency>

        <dependency>
            <groupId>com.lowagie</groupId>
            <artifactId>itext</artifactId>
            <version>2.1.7</version>
        </dependency>


        <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jasperreports-maven-plugin</artifactId>
            <version>1.0-beta-2</version>
            <exclusions>
                 <exclusion>
                    <artifactId>plexus-container-default</artifactId>
                    <groupId>org.codehaus.plexus</groupId>
                </exclusion>
                <exclusion>
                    <groupId>jasperreports</groupId>
                    <artifactId>jasperreports</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.9</version>
        </dependency>

  </dependencies>

     <build>
        <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>3.1</version>
              <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <source>1.6</source>
                            <target>1.6</target>
                        </configuration>
                    </execution>
                   </executions>
        </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jasperreports-maven-plugin</artifactId>
                <version>1.0-beta-2</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <inherited>false</inherited>
                        <goals>
                            <goal>compile-reports</goal>
                        </goals>
                        <configuration>
<!--                             define where is your jrxml file -->
                            <sourceDirectory>src\\main\\resources</sourceDirectory>
                            <sourceFileExt>.jrxml</sourceFileExt>
                            <compiler>net.sf.jasperreports.engine.design.JRJavacCompiler</compiler>
<!--                             define where is the jasper file will be generated -->
                            <outputDirectory>src\\main\\resources</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
<!--                     Note this must be repeated here to pick up correct xml validation -->

                    <dependency>
                        <groupId>net.sf.jasperreports</groupId>
                        <artifactId>jasperreports</artifactId>
                        <version>5.1.0</version>
                    </dependency>

                    <dependency>
                        <groupId>log4j</groupId>
                        <artifactId>log4j</artifactId>
                        <version>1.2.16</version>
                    </dependency>

                </dependencies>
            </plugin>

        </plugins>
    </build>

</project>
4

2 回答 2

13

对于在使用 JasperReports 5.x maven 依赖项时遇到类似问题的任何人:

jasper 家伙运行一个公共 maven 存储库,他们在其中发布错误修复到他们的第三方依赖项。这些固定版本并不总是出现在公共 Maven 存储库中。因此,当您遇到依赖项问题时,请尝试添加存储库http://jasperreports.sourceforge.net/maven2

于 2013-07-15T14:03:45.723 回答
8

对我来说,解决方案是添加

      <dependency>
      <groupId>com.lowagie</groupId>
      <artifactId>itext</artifactId>
      <version>2.1.7</version>
      </dependency>

这样它就不会寻找 .js2 版本并且可以解决依赖关系。

于 2014-04-23T12:51:13.760 回答