SpringFramework

Spring Boot 2 アップグレード後に JPA ( Hibernate )が勝手に SEQUENCE を使おうとする問題

問題 Spring Boot 1.5 -> 2.0 に上げたとき MySQL を JPA (Hibernate)経由で利用している場合、 GeneratedValue に AUTO を指定していると INSERT 処理時などに下記のような例外が発生する可能性がある。 Exception: com.mysql.jdbc.exceptions.jdbc4.MySQ…

Spring Boot で Gzip を使ってレスポンスを返す

概要 nginx などの web server では静的ファイルなどを gzip で返すとパフォーマンスがよくなるよーという記事は良くみる。 これを Spring Boot で行うにはどうすればいいか。(アプリケーションから gzip で返す必要性が発生するのかというのは別の話) 設…

ConditionalOnClass を使うライブラリを書いたときにハマったことメモ

概要 Spring Boot の機能として auto configuration を作る Spring Boot ライブラリを作成する場合に、特定のライブラリが読まれているときのみ動く設定などを使いたい場合がある。そういう場合に ConditionalOnClass アノテーションを使うだろうと思う。(…

spring.properties 相当のファイルを増やす

概要 共通モジュールとそれを利用するモジュールを、同一 gradle プロジェクト内で開発したいときなど 共通モジュール用と利用側モジュールでそれぞれ設定ファイルを書きたい場合がある。 Spring Boot の設定について Spring Bootでは 設定(プロパティ)を …

spring で logback を使う際に application.yml の値を使う

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html#_environment_properties The <springProperty> tag allows you to surface properties from the Spring Environment for use within Logback. This can be useful if you want </springproperty>…