1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Spring Cloud Configでファイルシステム上のプロパティファイルを使用

Posted at

クラスパスとかファイル指定とかでプロパティファイルを読み込むやり方。リファレンスの Spring Cloud Config - File System Backendに書いてある。ちょっとしたテストをやるには手軽で良い。

ソースコード

Server

まず、server側のプロパティファイルにspring.profiles.active=nativeと指定する。

次に、プロパティファイルはデフォルトでは以下に配置する。なので\src\main\resourcesに配置すれば読み込んでくれる。

classpath:/
classpath:/config
file:./
file:./config

プロパティファイル配置場所を任意のディレクトリに変更したい場合spring.cloud.config.server.native.searchLocationsを使用する。以下はwindowsでC:\configtestを指定した例。

spring.cloud.config.server.native.searchLocations=file:///C:/configtest/
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?