亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 spring boot + .yaml 創建配置文件?

如何使用 spring boot + .yaml 創建配置文件?

呼喚遠方 2021-10-27 09:56:13
我有帶有 2 個屬性文件的 Spring Boot 服務器:application-local.properties和application-test.properties在每個文件中,我都有用于開發機器和測試的配置。像這樣開始:-Dspring.profiles.active=local但是在新的 Spring Boot 項目中,我使用了.yaml配置文件。而且我不明白如何使用profileswith .yaml. 我嘗試閱讀文檔,但什么也不懂。你能一步一步解釋該怎么做嗎?我需要兩個文件?application-local.yaml 和 application-test.yaml或者我需要在一個application.yaml文件中寫入所有內容?如果在一個文件中,我如何分離配置?這是我的配置:server:  path: ***  port: ***cxf:  path: ***spring.datasource:  type: com.zaxxer.hikari.HikariDataSource  driver-class-name: oracle.jdbc.OracleDriver  url: ***  username: ***  password: ***  hikari:    minimumIdle: 5    maximumPoolSize: 20    idleTimeout: 30000    poolName: SpringBootJPAHikariCP    maxLifetime: 2000000    connectionTimeout: 30000    connection-test-query: SELECT 1 FROM DUALspring.jpa:  show-sql: false  database-platform: org.hibernate.dialect.Oracle10gDialect  properties.hibernate.jdbc.batch_size: 30  properties.hibernate.cache.use_second_level_cache: false  hibernate:    ddl-auto: validatespring.cache:  ehcache:    config: classpath:ehcache.xml#app configsmy:  messages-max-count: 5  messages-delay: 100  schedulers-charge-delay: 100  client:    first-server-address: ***    second-server-address: ***    last-server-address: ***  enabled-client: FirstClient我想創建測試配置文件并更改數據庫 url(或更改為 postgreSql),更改maximumPoolSize屬性
查看完整描述

2 回答

?
HUH函數

TA貢獻1836條經驗 獲得超4個贊

是的,即使使用單個文件,您也可以創建多個配置文件配置文件用 3 個 DASH ( --- )分隔


logging:

  level:

    .: error

    org.springframework: ERROR


spring:

  profiles:

    active: "dev"

  main:

    banner-mode: "off"


server:

  port: 8085


---


spring:

  profiles: dev


---


spring:

  profiles: prod


查看完整回答
反對 回復 2021-10-27
  • 2 回答
  • 0 關注
  • 220 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號