我使用gridgain的网络控制台为我的ignite节点(ignite-config.xml)创建了一个配置文件。我想看看是否可以在apache的docker ignite镜像(apacheignite / ignite)中运行它。我已经在撰写文件中创建了一个卷,该卷映射到一个存放ignite-config.xml的配置文件夹。
我还需要包括secret.properties(具有我的jdbc url /用户名/密码)文件,因此我也将其放在config文件夹中。
当我做一个 docker 组成我得到java.io.FileNotFoundException: class path resource [config/secret.properties] cannot be opened because it does not exist]
这是xml配置中处理secret.properties位置的部分:
<!-- Load external properties file. -->
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:secret.properties"/>
</bean>
我需要更改什么以便加载config文件夹中的secret.properties文件?有一个更好的方法吗?
最佳答案
我不知道如何在不进行完整构建和部署的情况下轻松地部署secret.properties文件,但是为了进行测试,为了超越该范围,您可以摆脱secret.properties并使用环境变量。
对于到Postgres的JDBC连接,可能看起来像这样:
<!-- Data source beans will be initialized from external properties file. -->
<bean id="dsPostgreSQL_Daifcqkp30zkdj" class="org.postgresql.ds.PGPoolingDataSource">
<property name="url" value="#{systemEnvironment['dsPostgreSQL_Daifcqkp30zkdj_jdbc_url']}"/>
<property name="user" value="#{systemEnvironment['dsPostgreSQL_Daifcqkp30zkdj_jdbc_username']}"/>
<property name="password" value="#{systemEnvironment['dsPostgreSQL_Daifcqkp30zkdj_jdbc_password']}"/>
</bean>
然后,只需设置您的环境变量:
IGNITE_VERSION=2.7.5
CONFIG_URI=https://raw.github.com/some/path/to/your/config.xml
OPTION_LIBS=ignite-zookeeper,ignite-rest-http
EXTERNAL_LIBS=https://github.com/some/path/to/your/jdbc-drivers/postgresql-42.2.6.jar?raw=true
dsPostgreSQL_Daifcqkp30zkdj_jdbc_username=0a9suf09asdfkjwel
dsPostgreSQL_Daifcqkp30zkdj_jdbc_password=8faskdfn94noiasnf09_s09fklajfealk
dsPostgreSQL_Daifcqkp30zkdj_jdbc_url=jdbc:postgresql://<host>:<port>/Daifcqkp30zkdj?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
关于spring - 如何在apacheignite/docker库存图像中加载secret.properties文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56000389/