简体   繁体   English

如何将属性放在项目之外并同时加载属性项目属性和外部项目属性?

[英]How can I put properties outside the project and load both properties project properties and outside project properties?

I'm setting up different projects on the same server and want to put the same properties on some path outside the tomcat folder and load project properties as well how can I achieve it so that load both project properties and properties on path.我在同一台服务器上设置不同的项目,并希望将相同的属性放在 tomcat 文件夹之外的某个路径上,并加载项目属性以及如何实现它以便在路径上加载项目属性和属性。

You have asked 2 questions:你问了2个问题:

  • To put properties outside the project you have to create a custom class file that is extending the Resource bundle.要将属性放在项目之外,您必须创建一个扩展资源包的自定义 class 文件。 For further details see this: Loading resources outside project有关更多详细信息,请参见: 在项目外加载资源
  • To load both properties you can load both with different var like:要加载这两个属性,您可以使用不同的 var 加载这两个属性,例如:

    <.-- loading properties outside the project --> <resource-bundle> <base-name>com.yourpackage.CustomResourceBundle</base-name> <var>msgCustom</var> </resource-bundle> <.-- loading properties inside the project --> <resource-bundle> <base-name>com.yourpackage.resources.view</base-name> <var>msg</var> </resource-bundle>

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

相关问题 如何访问位于项目文件夹外部和项目类路径外部的.properties文件? - How can I access to a .properties file situated outside the project folder and outside the project classpath? Git或外部项目中的属性文件? - Properties file in Git or outside project? 将休眠属性配置文件移到项目之外? - Moving hibernate properties configuration file outside of project? 如何使用Java中的记事本在项目外部调用database.properties? - How to call database.properties outside the project using notepad in java? 当项目导出为 JAR 时,有没有办法从项目目录之外的属性文件中加载信息? - Is there a way to load information from a properties file that is outside a project's directory when the project gets exported as a JAR? 如何从外部项目文件夹访问hibernate.cfg.xml,config.properties和log4j.properties - How to Access hibernate.cfg.xml, config.properties, and log4j.properties from outside project folder 如何为每个项目指定本地 gradle.properties? - How can I specify local gradle.properties per project? 将属性文件放在Eclipse项目中的位置 - where to put the properties file in an eclipse project android项目中的project.properties - project.properties in android project 将.properties文件放在Eclipse项目中的位置? - where to put .properties files in an Eclipse project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM