- Mastering Spring Boot 2.0
- Dinesh Rajput
- 131字
- 2021-06-25 21:29:15
Renaming application.properties in the Spring application
Spring Boot doesn't force us to use only one properties file with the name application.properties or application.yml. It allows you to override the name of this file. For example, you could use myapp.properties as follows:
package com.dineshonjava.masteringspringboot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class MasteringSpringBootApplication { public static void main(String[] args) { System.setProperty("spring.config.name", "myapp"); SpringApplication.run(MasteringSpringBootApplication.class, args); } }
The property filename must be defined as myapp, not myapp.properties; if we use myapp.properties, the file would get named as myapp.properties.properties.
As you can see in the code snippet, here, I am using the myapp.properties file instead of using the application.properties file.
Let's see how to create external application properties by using beans and how to register with the Spring application as a property file.
推薦閱讀
- Word/Excel/PPT 2007辦公技巧
- Word/Excel/PPT 2013辦公應用從入門到精通
- Excel 2010辦公應用實戰從入門到精通(超值版)
- 遠程辦公效率手冊
- Office 2013輕松辦公:Word/Excel/PowerPoint三合一超級應用大全(實戰案例版)
- Excel 2016辦公應用從入門到精通
- Excel+PPT+Word+PS+短視頻剪輯+PDF+思維導圖+居家辦公+辦公設備9合1
- Learning AWS IoT
- Excel 2013財務管理應用全流程實戰指南
- 微軟辦公軟件國際認證(MOS)Office 2010大師級通關教程(第2版)
- 電腦辦公直通車
- LoadRunner性能測試巧匠訓練營
- WebGL開發與應用
- Hands-On Kubernetes on Azure
- Excel 2007使用大全