无法导入配置文件

问题描述 投票:0回答:1

有一种方法可以在 Spring Boot 中导入启动配置文件,我们可以在开发过程中传递我们的敏感数据。

enter image description here

我尝试以这种方式创建 .LAUNCH 文件,当我尝试添加它时,导入是不可见的。

enter image description here

一般来说,所有的LAUNCH文件都会出现在右侧。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type = "org.springframework.ide.eclipse.boot.launch"> 
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/student-directory/src/main/java/com/bma/directory/StudentDirectoryApplication.java"/>
</listAttributes>
<listAttribute key= "org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.environmentVariables">
<mapEntry key="DB_URL" value="https://mysql:3036"/>
<mapEntry key="DB_USER" value="John"/>
<mapEntry key="DB_PORT" value="9090"/>
</mapAttribute>
</launchConfiguration>
java backend
1个回答
0
投票

我们传递数据库信用等的方式(我更改本地开发网络服务器端口、日志输出级别等)是在我们的机器上在一个地方有一个本地属性文件,第一次运行 spring 应用程序停止并抱怨数据库 URL 等,然后我们编辑它生成的配置并添加引用以使用运行配置的覆盖属性区域中的

spring.config.additional-location
选项来告诉它拉取并使用此文件。

请注意,执行此操作时,此文件的内容优先于应用程序资源文件夹中的 application.properties/application.yaml 文件。我们还在服务器上的 systemd 启动脚本中指定了这一点,指向 eureka、rabbit、DB、邮件服务器等的共享属性文件,供我们所有应用程序使用

还值得注意的是,即使您在 Windows 计算机上,只要您的文件和 spring 应用程序位于同一驱动器号上,使用 *nix 样式路径就可以工作...

© www.soinside.com 2019 - 2024. All rights reserved.