2017-09-05 74 views

回答

1

您可以使用jasypt來處理加密,然後使用Jasypt's Spring integrationJasypt Spring Boot Starter將它連接到Spring。

這將允許你在application.properties例如定義一個加密的數據庫密碼屬性,例如

db.password=ENC(.....) 

你的問題的另一部分是:

如何更改數據庫密碼如果應用程序密碼的應用程序屬性中

您可以通過overring定義的屬性做到這一點在具有系統屬性的屬性文件中。例如:-Ddb.password='....'。您還可以定義JAR外部的其他屬性源,並且可以在運行時對其進行編輯。例如:

@PropertySources({ 
     @PropertySource(value = "classpath:/**.properties"), 
     @PropertySource(value = "file:/some/external/directory/override.properties", ignoreResourceNotFound = true) 
}) 
public class Application { 
    // ... 
} 

創建文件/some/external/directory/override.propertiesdb.password=...填充它會導致你的應用程序 - 在下次重新啓動 - 使用屬性值。