Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
147 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...