Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
148 views
in Technique[技术] by (71.8m points)

java - how can I use System.getProperty in persistence.xml file

I'm workin in on java project ( with maven) I have a file (env-dev-windows.vars) for config like this :

APPLICATION_LOG_DIR=C:DIRLOG
APPLICATION_BDD_URL=jdbc::PostgreSQL://localhost:5432/postgres
APPLICATION_USER=user_name
APPLICATION_PASSWD=passwd
...

in persistence.xml file instead of using the username and password like this :

    <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
        <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/test" />
        <property name="javax.persistence.jdbc.user" value="postgres" />
        <property name="javax.persistence.jdbc.password" value="James123" />

I want to replace them with

System.getProperty("APPLICATION_USER") 
and System.getProperty("APPLICATION_PASSWD") 

I just want to use the Application properties and not for exemple ( the windows env variables defined in a local machine (in the parameters of a machine)

Is this possible ? for the moment I have no idea how to do it? is there another alternative

question from:https://stackoverflow.com/questions/66065806/how-can-i-use-system-getproperty-in-persistence-xml-file

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...