William,
On 27.03.2025 14:39, William Crowell wrote:
Is there a way to add an additional properties file to the startup of Apache
Tomcat, so that server.xml and context.xml can reference the values like we do
with catalina.properties?
For instance:
application.properties:
my.user=foo
my.password=bar
context.xml:
…
<Resource … " type="javax.sql.DataSource" … username="${my.user}"
password="${my.password}” …
/>
…
[...]
You can use environment variables (and setenv.sh/.bat). Example:
Set your environment variable:
> export USER_NAME=user1
Modify / create setenv.sh:
JAVA_OPTS=-Dcustom_user_name=${USER_NAME}
Modify your context.xml:
[...] <Resource … " type="javax.sql.DataSource" …
username="${custom_user_name}" [...]
I didn't test it, but it should work like this.
Reference:
https://stackoverflow.com/questions/44761831/tomcat-8-context-xml-use-environment-variable-in-datasource
Sebastian
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org