- 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商務辦公從新手到高手(白金全彩版)
- 高效隨身查:PPT2021必學的美化設計應用技巧(視頻教學版)
- Oracle CX Cloud Suite
- 一圖抵萬言:從Excel數據到分析結果可視化
- 非常Easy:Office高效辦公
- Excel商務圖表應用與技巧108例
- Excel公式、函數、圖表與數據處理應用大全(全新版)
- PPT演義:100%幻燈片設計密碼
- Excel 2013實戰應用超級手冊
- 和秋葉一起學Excel(第2版)
- 中文版Office2016大全
- IT審計:用SQL+Python提升工作效率
- Word Excel PPT 2013:辦公應用從入門到精通
- 人事管理政務網上公開的發展與對策
- 一看即會:電腦組裝·系統安裝·日常維護與故障排除(超值視頻教學版)