在 Wildfly 上设置每个应用程序的属性 [英] Setting per application properties on Wildfly
问题描述
我通常是 Tomcat 人,但我们在我们的一个客户项目中使用 Widlfly.
I am normally the Tomcat guy but we use Widlfly on one of our client project.
使用 Tomcat,我可以通过为每个应用程序创建单独的上下文来设置每个应用程序"属性,就像 Tomcat 文档说得很好.
With Tomcat, I can set "per application" properties by creating a separate context for each application, just as Tomcat documentation very nicely says.
这样,我的 WebApp1.war
可以用 my.property.value=Cat
运行,WebApp2.war
可以用 运行>my.property.value=Dog
同时.
This way, my WebApp1.war
can run with my.property.value=Cat
and WebApp2.war
can run with my.property.value=Dog
at the same time.
我没有发现任何与 Wildfly 类似的文档/功能.能否请您建议我如何单独为应用程序设置属性,或者向我指出文档?
I haven't found any similar documentation / feature with Wildfly. Could you please advice me how to set properties to applications individually, or point me to the documentation?
谢谢.:-)
推荐答案
对我来说,以下方法有效.首先,我更改了应用程序属性的名称.其次,我使用 Wildfly 配置路径更改了配置文件的路径.
For me the following approach worked. First i changed name of application properties. Second i changed the path to configuration file using Wildfly configuration path.
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
String configPath = System.getProperties().getProperty("jboss.server.config.dir") + "/";
return builder
.properties("spring.config.name:my-app")
.properties("spring.config.location:" + configPath)
.sources(Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
这篇关于在 Wildfly 上设置每个应用程序的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!