简体   繁体   English

有没有办法在Apache Wicket中加载多个应用程序属性文件?

[英]Is there a way to load multiple application properties files in Apache Wicket?

My WicketApplication.properties file has grown very large, and now to keep it more readable I want to categorize properties in different files. 我的WicketApplication.properties文件已经变得非常大,现在为了保持它的可读性,我想在不同的文件中对属性进行分类。 Is there a way to accomplish that and still access the properties like if they were all in the WicketApplication.properties? 有没有办法实现这一点,仍然可以访问属性,如果它们都在WicketApplication.properties中?

See org.apache.wicket.settings.IResourceSettings.addStringResourceLoader(IStringResourceLoader). 请参阅org.apache.wicket.settings.IResourceSettings.addStringResourceLoader(IStringResourceLoader)。 You can implement your own IStringResourceLoader which may load from wherever your want. 您可以实现自己的IStringResourceLoader,它可以从您想要的任何地方加载。

You can use property files dedicated per page or even component: 您可以使用每页专用的属性文件甚至组件:

  • AddressPicker.properties - properties specific to an AddressPicker.java componen AddressPicker.properties - 特定于AddressPicker.java组件的属性
  • ProfilePage.properties - properties used only on a given page ( ProfilePage.java ) ProfilePage.properties - 仅在给定页面上使用的属性( ProfilePage.java
  • WicketApplication.properties - for aplication-wide properties ( WicketApplication.java ) WicketApplication.properties - 用于应用程序范围的属性( WicketApplication.java

Wicket, when looking for properties for a given component, will look for the property files in the same order as above. Wicket在查找给定组件的属性时,将按照与上面相同的顺序查找属性文件。 AFAIR Struts2 uses exactly the same technic. AFAIR Struts2使用完全相同的技术。

Please look at Wicket documentation: https://cwiki.apache.org/WICKET/i18n-and-resource-bundles.html . 请查看Wicket文档: https//cwiki.apache.org/WICKET/i18n-and-resource-bundles.html

As a last resort, you could write multiple files, but merge them into a single WicketApplication.properties as part of your build process. 作为最后的手段,您可以编写多个文件,但在构建过程中将它们合并到一个WicketApplication.properties中。 Unix has a tool precisely for doing this . Unix有一个精确的工具来做这件事

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

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