どのように私は春ブーツ+ .yamlでプロファイルを作成することができますか?

ip696:

私は2つのプロパティファイルで春のブートサーバーを持っていますapplication-local.propertiesし、application-test.properties

各ファイルには、私はdevのマシン用とテスト用のconfigsを持っています。このようにそれを起動します。

-Dspring.profiles.active=local

しかし、新しい春のブートプロジェクトに私が使用して.yaml設定ファイルを。そして私は、私がどのように使用できるかを理解していないprofiles.yaml私は読むのドキュメントを試みたが、何も理解していません。あなたは、何をすべきかをステップバイステップで説明できますか?

私は2つのファイルを持っている必要がありますか?

application-local.yaml そして application-test.yaml

それとも私は1つので全てを書く必要は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 DUAL

spring.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: validate


spring.cache:
  ehcache:
    config: classpath:ehcache.xml

#app configs
my:
  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プロパティを

アンドリューTobilko:
  1. 作成しapplication.yaml、そこにすべてのデフォルトプロパティを定義します。
  2. 作成application-local.yamlに必要なプロパティおよび上書きlocalプロファイルを。
  3. 作成application-test.yamlに必要なプロパティおよび上書きtestプロファイルを。
  4. セットspring.profiles.activeのいずれか(システムプロパティとして渡すことによって-Dためjava)、または以内に規定application.yaml

あなたが使用してアプリケーションを実行しているときに{PROFILE}、春が解析されますapplication-{PROFILE}.yamlapplication.yaml

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=186228&siteId=1