聞こえないJavaエンジニアが適当に書き連ねていく

つらつらとメモしたり日頃の溜まっている想いを吐き出す場所です。

JasperReportsを使うときのライブラリについて

クラスメソッド様のブログにはいつもお世話になっております。

dev.classmethod.jp

2013年に出たブログですが、今でもたまにたどり着くこのページ。 依存ライブラリの部分がmavenだと若干古くなっているようなのでメモとして残しておく。

JasperReports LibraryはPDFを出力する場合にitextを利用しますが、この時に依存しているバージョンはLGPLである2.1系の最新バージョンである2.1.7にJasperReportsで独自のパッチを当てた、2.1.7.js2です。このバージョンはMavenのcentral repositoryに存在しないため、Jaspersoftのリポジトリを追加しなければなりません。

最新版(6.4.1)だと itext-2.1.7.js6 がMavenのcentral repositoryに存在するようで、リポジトリの追加は不要。

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>xxxx.yyy</groupId>
    <artifactId>test1</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>test1</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <javac.target>1.7</javac.target>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports -->
        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>6.4.1</version>
        </dependency>
    </dependencies>
</project>

このページを参考に依存関係を確認する。

d.hatena.ne.jp

確認結果は以下の通り。

[INFO] xxxx.xxxx:test1:jar:0.0.1-SNAPSHOT
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] \- net.sf.jasperreports:jasperreports:jar:6.4.1:compile
[INFO]    +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO]    +- commons-collections:commons-collections:jar:3.2.2:compile
[INFO]    +- commons-digester:commons-digester:jar:2.1:compile
[INFO]    +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO]    +- com.lowagie:itext:jar:2.1.7.js6:compile
[INFO]    |  \- org.bouncycastle:bcprov-jdk15on:jar:1.52:compile
[INFO]    +- org.jfree:jcommon:jar:1.0.23:compile
[INFO]    +- org.jfree:jfreechart:jar:1.0.19:compile
[INFO]    +- org.eclipse.jdt.core.compiler:ecj:jar:4.3.1:compile
[INFO]    +- org.codehaus.castor:castor-xml:jar:1.3.3:compile
[INFO]    |  +- org.codehaus.castor:castor-core:jar:1.3.3:compile
[INFO]    |  +- commons-lang:commons-lang:jar:2.6:compile
[INFO]    |  +- javax.inject:javax.inject:jar:1:compile
[INFO]    |  +- stax:stax:jar:1.2.0:compile
[INFO]    |  |  \- stax:stax-api:jar:1.0.1:compile
[INFO]    |  \- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO]    +- com.fasterxml.jackson.core:jackson-core:jar:2.1.4:compile
[INFO]    +- com.fasterxml.jackson.core:jackson-databind:jar:2.1.4:compile
[INFO]    +- com.fasterxml.jackson.core:jackson-annotations:jar:2.1.4:compile
[INFO]    +- org.apache.lucene:lucene-core:jar:4.5.1:compile
[INFO]    +- org.apache.lucene:lucene-analyzers-common:jar:4.5.1:compile
[INFO]    +- org.apache.lucene:lucene-queryparser:jar:4.5.1:compile
[INFO]    |  +- org.apache.lucene:lucene-queries:jar:4.5.1:compile
[INFO]    |  \- org.apache.lucene:lucene-sandbox:jar:4.5.1:compile
[INFO]    |     \- jakarta-regexp:jakarta-regexp:jar:1.4:compile
[INFO]    +- org.olap4j:olap4j:jar:0.9.7.309-JS-3:compile
[INFO]    +- com.google.zxing:core:jar:3.2.1:compile
[INFO]    \- com.ibm.icu:icu4j:jar:57.1:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 53.129 s
[INFO] Finished at: 2017-08-18T10:41:44+09:00
[INFO] Final Memory: 14M/64M
[INFO] ------------------------------------------------------------------------

以上。