集成组件beanutils

dep_wangsr
RuoYi 6 years ago committed by Limy
parent 62fd45eca1
commit 9e26f3005e

@ -28,6 +28,7 @@
<oshi.version>3.9.1</oshi.version> <oshi.version>3.9.1</oshi.version>
<commons.io.version>2.5</commons.io.version> <commons.io.version>2.5</commons.io.version>
<commons.fileupload.version>1.3.3</commons.fileupload.version> <commons.fileupload.version>1.3.3</commons.fileupload.version>
<commons.beanutils.version>1.9.3</commons.beanutils.version>
<jsoup.version>1.11.3</jsoup.version> <jsoup.version>1.11.3</jsoup.version>
<poi.version>3.17</poi.version> <poi.version>3.17</poi.version>
<velocity.version>1.7</velocity.version> <velocity.version>1.7</velocity.version>
@ -137,6 +138,13 @@
<version>${commons.fileupload.version}</version> <version>${commons.fileupload.version}</version>
</dependency> </dependency>
<!-- 简化反射封工具类 -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>${commons.beanutils.version}</version>
</dependency>
<!-- HTML解析器 --> <!-- HTML解析器 -->
<dependency> <dependency>
<groupId>org.jsoup</groupId> <groupId>org.jsoup</groupId>

@ -47,18 +47,24 @@
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
</dependency> </dependency>
<!--io常用工具类 --> <!-- io常用工具类 -->
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
</dependency> </dependency>
<!--文件上传工具类 --> <!-- 文件上传工具类 -->
<dependency> <dependency>
<groupId>commons-fileupload</groupId> <groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId> <artifactId>commons-fileupload</artifactId>
</dependency> </dependency>
<!-- 简化反射封工具类 -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
<!-- HTML解析器 --> <!-- HTML解析器 -->
<dependency> <dependency>
<groupId>org.jsoup</groupId> <groupId>org.jsoup</groupId>

@ -11,7 +11,7 @@ import java.util.regex.Pattern;
* *
* @author ruoyi * @author ruoyi
*/ */
public class BeanUtils public class BeanUtils extends org.apache.commons.beanutils.BeanUtils
{ {
/** Bean方法名中属性名开始的下标 */ /** Bean方法名中属性名开始的下标 */
private static final int BEAN_METHOD_PROP_INDEX = 3; private static final int BEAN_METHOD_PROP_INDEX = 3;
@ -30,21 +30,9 @@ public class BeanUtils
*/ */
public static void copyBeanProp(Object dest, Object src) public static void copyBeanProp(Object dest, Object src)
{ {
List<Method> destSetters = getSetterMethods(dest);
List<Method> srcGetters = getGetterMethods(src);
try try
{ {
for (Method setter : destSetters) copyProperties(dest, src);
{
for (Method getter : srcGetters)
{
if (isMethodPropEquals(setter.getName(), getter.getName())
&& setter.getParameterTypes()[0].equals(getter.getReturnType()))
{
setter.invoke(dest, getter.invoke(src));
}
}
}
} }
catch (Exception e) catch (Exception e)
{ {

Loading…
Cancel
Save