【问题标题】:Where to put property file in config folder of tomcat将属性文件放在tomcat的config文件夹中的位置
【发布时间】:2018-03-07 04:26:55
【问题描述】:

我正在使用一个 Spring Boot 项目,其中有两个模块 Search 和 Web。我从 web 模块和搜索模块构建战争作为 jar 注入。我在搜索模块中有一个属性文件 index.properties,所以每次我制作一个 jar 时它都会进入搜索 jar,但是我想从搜索模块中删除这个 jar,并想将它外部化到 tomcat 的配置文件夹中。我正在使用 sprinboot 项目,我不知道该怎么做。

System.setProperty("spring.config.name", "search_index");

这样做会奏效吗?

【问题讨论】:

  • 你能把它重新框起来清楚吗?我想从搜索模块中删除这个jar,并想将它外部化到tomcat的config文件夹中。

标签: java spring tomcat spring-boot


【解决方案1】:

如果我正确理解你的问题

1) 你想外部化 .properties 文件

2) 你不想在 jar 文件中包含 .properties

要回答第一个问题,有多种方法可以外部化 props 文件 试试 - spring.config.location
从您的主要方法设置此值或 - 在 Tomcat 内部将以下值放入 setenv.sh

Dspring.config.location=/filelocation/application.properties 

参考 - https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html

要解决第二个问题,请尝试在 Maven 配置中使用排除标记。 喜欢 -

<excludes>
<exclude>*.properties</exclude>
</excludes>

我的回答是基于您提供的简要理解,请发布所有有助于为问题提供正确解决方案的细节。

【讨论】:

    猜你喜欢
    • 2015-08-13
    • 1970-01-01
    • 1970-01-01
    • 2012-07-24
    • 1970-01-01
    • 2016-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多