用AI赚第一桶💰低成本搭建一套AI赚钱工具,源码可二开。 广告
# The &lt;javaTypeResolver&gt; Element The &lt;javaTypeResolver&gt; element is used to define properties of the Java Type Resolver. The Java Type Resolver is used to calculate Java types from database column information. The default Java Type Resolver attempts to make JDBC DECIMAL and NUMERIC types easier to use by substituting Integral types if possible (Long, Integer, Short, etc.) If this behavior is undesirable, set the property "forceBigDecimals" to "true". You can also substitute your own implementation if you want different behavior than the default. This element is an optional child element of the [&lt;context&gt;](context.html) element. ## 必选属性 无 ## 可选属性 | 属性 | 描述 | | --- | --- | | type | This can be used to specify a user provided Java Type Resolver. The class must implement the interface `org.mybatis.generator.api.JavaTypeResolver`, 必须有一个公开默认的构造函数。. The attribute also accepts the special value DEFAULT in which case the default implementation will be used (this has the same effect as not specifying the type). | ## 子元素 * [&lt;property&gt;](property.html) (0..N) ## 支持的属性 下面的表格列出了所有可用的 [&lt;property&gt;](property.html) 子元素: | 属性名 | 属性值 | | --- | --- | | forceBigDecimals | This property is used to specify whether MyBatis Generator should force the use of `java.math.BigDecimal` for DECIMAL and NUMERIC fields, rather than substituting integral types when possible. 这个属性有以下可选值: | | | false _这是默认值_ 当这个属性是false或者没有指定时, the default Java type resolver will attempt to make JDBC DECIMAL and NUMERIC types easier to work with by substituting Integral types if possible. The substitution rules are as follows: | | | If the scale is greater then zero, or the length is greater than 18, then the java.math.BigDecimal type will be used | | | If the scale is zero, and the length is 10 through 18, then the Java type resolver will substitute a java.lang.Long. | | | If the scale is zero, and the length is 5 through 9, then the Java type resolver will substitute a java.lang.Integer. | | | If the scale is zero, and the length is less than 5, then the Java type resolver will substitute a java.lang.Short. | | | true 当这个属性是true时, the Java type resolver will always use java.math.BigDecimal if the database column is of type DECIMAL or NUMERIC. | ## 示例 This element specifies that we always want to use the java.math.BigDecimal type for DECIMAL and NUMERIC columns: ``` <javaTypeResolver> <property name="forceBigDecimals" value="true" /> </javaTypeResolver> ```