Nick Grealy Nick Grealy - 4 months ago 68
Java Question

Spring-Boot > Setting using JNDI

According to this github issue, I can specify the location of an file. e.g.

JNDI Environment Resource:

java:comp/env/spring.config.location = /some/path/

What I'd like to know is:

Can I use a JNDI binding to directly configure an individual property value in my Spring Boot application?

I've tried the following JNDI vars (to no avail):

JNDI Environment Resource:

java:comp/env/my.env.myCustomStringField = foobar
java:comp/env/ = foobar

Spring Reference:

If you are running in a container then JNDI properties (in
) or servlet context initialization parameters can be used instead of, or as well as, environment variables or system properties.

I'm currently using the following workaround.


Not sure what I was thinking, you can use JNDI to set the location of the file, and/orr override any application variables.


spring.config.location = file:/some/location/properties/
my.env.myCustomStringField = foobar

Don't bother with the java:comp/env/, Spring shields you from it.