设置 jasper 报告的类路径以查找本地化文件?

发布于 2024-11-18 22:09:26 字数 743 浏览 6 评论 0原文

我有一个 grails 应用程序,我试图将所有 .jrxml 报告存储在 src/reports 中。由于我可以使用 jasper 编译器指向文件,因此效果很好。但是,现在我的报告需要本地化,并且每个报告都需要自己的本地化。

我在 src/reports 中有这样的包:
com.stefankendall.blah.blah
com.stefankendall.ab
com.stefankendall.c

在 iReport 4.0.2 中,我可以在类路径上指定每个包的确切文件夹,但是我可以在正在运行的 grails 应用程序中执行此操作吗?

整理文档,我有这个:

src/reports/com/stefankendall/a/report1.jrxml
src/reports/com/stefankendall/a/report1_Bundle/report1.properties, report1_en_US.properties...

在我正在运行的应用程序中,report_Bundle 似乎没有出现在类路径,所以 jasper 报告炸弹。当我通过 groovy 调用 jasper 时,有没有办法指定此路径?或者,我可以以某种方式将 src/reports 添加到类路径并以某种方式从报告中向下钻取吗?

I have a grails application, and I'm trying to store all my .jrxml reports in src/reports. Since I can point at files with the jasper compiler, this works fine. However, now my reports need to be localized, and each report needs its own localization.

I have packages like this in src/reports:
com.stefankendall.blah.blah
com.stefankendall.a.b
com.stefankendall.c

In iReport 4.0.2, I can specify the exact folder of each bundle on the classpath, but can I do this within my running grails application?

Scraping together documentation, I have this:

src/reports/com/stefankendall/a/report1.jrxml
src/reports/com/stefankendall/a/report1_Bundle/report1.properties, report1_en_US.properties...

In my running application, report_Bundle doesn't appear to be on the classpath, so the jasper reports bomb. Is there a way to specify this path when I'm invoking jasper through groovy? Alternatively, can I somehow add src/reports to the classpath and drilldown somehow from the report?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

給妳壹絲溫柔 2024-11-25 22:09:26

可能有更好的方法,但是......

_Events.groovy:

eventClasspathStart = {
    addResourceBundlesToClasspath()
}


private def addResourceBundlesToClasspath(){
    classpathSet = false
    File reportsDir = new File("src/reports")
    reportsDir.eachDirRecurse { File directory ->
        if( directory.name.endsWith("_Bundle") ){
            println "Adding ${directory.getAbsolutePath()} to classpath"
            rootLoader.addURL( directory.toURL() )
        }
    }
}

There may be a better way, but...

_Events.groovy:

eventClasspathStart = {
    addResourceBundlesToClasspath()
}


private def addResourceBundlesToClasspath(){
    classpathSet = false
    File reportsDir = new File("src/reports")
    reportsDir.eachDirRecurse { File directory ->
        if( directory.name.endsWith("_Bundle") ){
            println "Adding ${directory.getAbsolutePath()} to classpath"
            rootLoader.addURL( directory.toURL() )
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文