Reading a dynamic property map into Spring managed bean

后端 未结 4 2160
悲哀的现实
悲哀的现实 2021-02-05 23:53

I have a properties file like this:

my.properties file:
app.One.id=1
app.One.val=60

app.Two.id=5
app.Two.val=75

And I read these values into a

4条回答
  •  Happy的楠姐
    2021-02-06 00:45

    It's a classic environment problem.

    There are two ways to do this:

    1. Add an environment string at the end of the appropriate .properties file; pass that value to the app when it starts and let Spring choose the correct one.
    2. Put those dynamic properties in a database and query for them on startup. The JNDI for the database will pick the right values.

提交回复
热议问题