IntelliJ IDEA 2020.1.1 で .properties ファイルの空行が削除される現象を解消する
記事一覧はこちらです。
Spring Boot + npm + Geb で入力フォームを作ってテストする ( その89 )( Spring Boot を 2.1.4 → 2.2.7 へバージョンアップする ) を書いている時に気づいたのですが、IntelliJ IDEA で .properties ファイルを開いて保存するとなぜか空行が削除されます。
これが、
server.tomcat.basedir=C:/webapps/boot-npm-geb-sample logging.file.name=${server.tomcat.basedir}/logs/boot-npm-geb-sample.log spring.autoconfigure.exclude=com.integralblue.log4jdbc.spring.Log4jdbcAutoConfiguration spring.mail.host=localhost spring.mail.port=25 valueshelper.classpath.prefix=BOOT-INF.classes.
自動で保存されてこうなります。
server.tomcat.basedir=C:/webapps/boot-npm-geb-sample logging.file.name=${server.tomcat.basedir}/logs/boot-npm-geb-sample.log spring.autoconfigure.exclude=com.integralblue.log4jdbc.spring.Log4jdbcAutoConfiguration spring.mail.host=localhost spring.mail.port=25 valueshelper.classpath.prefix=BOOT-INF.classes.
IntelliJ IDEA の設定を確認したところ、Editor -> Code Style -> Properties の「Keep blank lines」がチェックされていないことが原因でした。この設定をチェックすると空行が維持されるようになります。