Spring boot Spring启动-外部化数据库设置

Spring boot Spring启动-外部化数据库设置,spring-boot,configuration,Spring Boot,Configuration,我有一个用SpringBoot开发的JAVA项目 数据库设置位于默认的resources/application.properties文件中 spring.datasource.driver-class-name=oracle.jdbc.OracleDriver spring.datasource.driver-class-oracle.jdbc.driver.OracleDriver spring.datasource.url=jdbc:oracle:thin:@//172.********:

我有一个用SpringBoot开发的JAVA项目

数据库设置位于默认的resources/application.properties文件中

spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.datasource.driver-class-oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@//172.********:1521/BDHML
spring.datasource.username=********
spring.datasource.password=********
应用程序将通过以下命令运行:

java -jar **CONFIGURAÇÃO** app-cosolidar.jar
我需要将数据库设置放在项目外部的.properties文件中

我该怎么做

.properties文件应该是什么样子

我应该更改任何.java文件吗

我应该在java-jar中设置什么


另外,Diego可以在运行jar时提供命令行参数

You would be able to launch your spring boot application with the external properties file path as follows:

java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties

https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config
java-jarapp.jar--spring.config.location=file:///application.properties

您还可以传递应用程序将在其中搜索文件的文件夹位置

java-jarapp.jar--spring.config.name=application,jdbc--spring.config.location=file://

请参阅此链接以了解更多信息