gpt4 book ai didi

Java Maven Jasperreport 从 Eclipse 运行 好的,从 java - jar JRRuntimeException : Chart theme "eye.candy.sixties" not found

转载 作者:行者123 更新时间:2023-11-30 06:21:36 25 4
gpt4 key购买 nike

我创建了一个 Java 程序,它使用 JasperReports 创建报告。在我的 JasperReports 之一中,我使用 theme="eye.candy.sixties"。

当我在 gui 中从 Eclipse 运行项目时,一切都很好,请参阅 enter image description here

但是,当我使用 Maven 构建相同的项目并从命令行运行它时,我收到错误:

Maven: clean compile assembly:single
Command line: java -jar chartTheme-0.0.1-SNAPSHOT-jar-with-dependencies.jar

Exception in thread "main" net.sf.jasperreports.engine.JRRuntimeException: Chart theme "eye.candy.sixties" not found.

我错过了什么,我应该改变什么?欢迎任何帮助!

源代码可以在Github上找到:ChartTheme

我确实在 Maven 中包含了图表主题依赖项,请参阅“Eclipse 中的 Maven 依赖项列表:

enter image description here 并在下面的代码中(pom.xml)

    <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>com.lightroomstatistics.samples</groupId>
<artifactId>chartTheme</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>chartTheme</name>
<description>chartTheme</description>

<url>www.lightroomstatistics.com</url>
<organization>
<name>LightroomStatistics</name>
<url>www.lightroomstatistics.com</url>
</organization>

<parent>
<groupId>com.lightroomstatistics.maven</groupId>
<artifactId>lightroomstatistics-parent-pom</artifactId>
<version>1.0.0</version>
</parent>

<properties>
<java.version>1.8</java.version>
<jasperreports.version>6.4.0</jasperreports.version>
<jasperreportsfonts.version>4.0.0</jasperreportsfonts.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>

<repositories>
<!-- Needed for Jasperreports chart-themes -->
<repository>
<id>jr-ce-releases</id>
<name>JasperReports CE Releases</name>
<url>http://jaspersoft.jfrog.io/jaspersoft/jr-ce-releases</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>${jasperreports.version}</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-fonts</artifactId>
<version>${jasperreportsfonts.version}</version>
</dependency>
<!-- jasperreports-chart-themes -->
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-chart-themes</artifactId>
<version>${jasperreports.version}</version>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>reports</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
<resource>
<directory>data</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>

<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-report-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/reports</outputDirectory>
<resources>
<resource>
<directory>reports</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-data-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/data</outputDirectory>
<resources>
<resource>
<directory>data</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>chartTheme.ChartThemesApp</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>

最佳答案

如果您打开构建的联合库 chartTheme-0.0.1-SNAPSHOT-jar-with-dependency.jar,您会发现文件 jasperreports-char- 的内容theme-6.4.0.jar/jasperreports_extension.properties缺失,因为它们被您的其他jasperreports_extension.properties文件的内容覆盖。依赖关系。

事实上,如果您在运行 mvn assembly 后在输出控制台中进行搜索,您会发现以下痕迹:

[INFO] jasperreports_extension.properties already added, skipping

...顺便说一句,这并不是汇编时跳过的唯一一个文件。

因此,由于存在重叠,将所有这些依赖项组装在一起绝对不是一个好主意。至少,不是这样。

我认为您应该尝试的第一件事是参数化 assembly descriptor file排除不需要的文件,优先考虑所需的文件,我认为这些文件将是 jasperreports-chart-themes.jar 中的文件(通过您发布的日志中的跟踪)。

关于Java Maven Jasperreport 从 Eclipse 运行 好的,从 java - jar JRRuntimeException : Chart theme "eye.candy.sixties" not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48033887/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com