简体   繁体   English

在grails的启动带中,在应用程序启动时加载资源包

[英]Load the resource bundle on start of application in boot strap in grails

I created a new package under src/java in a Grails application for a specific resource bundle which I want to use like src/java/resourcebundle/abc.properties . 我在Grails应用程序中的src/java下为要使用的特定资源包创建了一个新包,例如src/java/resourcebundle/abc.properties This is working fine when I use it from other classes within src/java . 当我在src/java其他类中使用它时,这工作正常。 I want to load this file when application loads. 我想在应用程序加载时加载此文件。 So I was trying to add it to bootstrap.groovy in: 所以我试图将其添加到bootstrap.groovy中:

def init = { -> def myProperties =  ResourceBundle.getBundle("src/java/resourcebundle.abc")}.

I am getting an exception 我有一个例外

Error executing bootstraps: Can't find bundle for base name src/java/resourcebundle.abc, locale en_US

Any suggestions on how to load the resource bundle in bootstrap? 关于如何在引导程序中加载资源包的任何建议?

remove src/java? 删除src / java? or use ClasspathResource? 或使用ClasspathResource?

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM