MyBatisのキャメルケース命名の設定方法はどうですか?

MyBatisのキャメルケース命名を設定する方法は、設定ファイルに以下の設定を追加することで実現できます。

  1. mybatis-config.xmlかapplication.propertiesに設定する:
<settings>
    <setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>
  1. SpringBootでapplication.propertiesファイルを設定する。
mybatis.configuration.map-underscore-to-camel-case=true

この設定を行うと、MyBatisは自動的にデータベース内のアンダースコア命名をキャメルケースに変換します。たとえば、データベースのフィールド名がuser_nameである場合、Javaクラスのプロパティ名はuserNameにマッピングされます。

コメントを残す 0

Your email address will not be published. Required fields are marked *


广告
広告は10秒後に閉じます。
bannerAds