I develop an application which will be used on Windows and Mac OS. I use H2 db there. I want to store my db files in AppData dir. Like this:
application.properties:
spring.datasource.url=jdbc:h2:${APP_DATA}/data/keywords
APP_DATA
should be ${user.home}/AppData/Roaming/
for Windows and ${user.home}/Library/Application Support
for Mac .
I thought about having two Maven profiles for both Windows and Mac (I will ship them separately anyway) and using maven resources plugin filtering, in this way:
spring.datasource.url=jdbc:h2:${user.home}${suffix}
The problem is, I can't filter only suffix
and leave user.home
untouched. Now as a result I get C:\\\\Users\\\\Denis/AppData/Roaming/Keywords
after the Maven build which is incorrect as I need to user.home
proceed on user's machine.
For now I see only solution to move suffix
to separate file, then exclude application.properties
from resources plugin and then somehow intregate first into second. Any other ideas?
All I need is to escape ${user.home}
with backslash \\
:
application.properties
APP_DATA=\${user.home}${app.data.dir}
pom.xml
<properties>
<app.data.dir>/AppData/Roaming/</app.data.dir>
</properties>
For me that's all, but it may be also needed to add this ( docs ):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<escapeString>\</escapeString>
</configuration>
</plugin>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.