首先将所有实体类都继承BaseEntity:
BaseEntity:
package org.ty.cloudCourse.entity; import java.util.HashMap; import java.util.Map; /** * @author kangtaiyang * @date 2018/7/3 */ public abstract class BaseEntity { protected Integer id = null; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Map<String,BaseEntity> getParentEntity(){ return new HashMap<>(); } }
spring bean 配置:
<!-- DatabaseSyncUtil配置 --> <bean id="databaseSyncUtil" class="org.ty.cloudCourse.util.DatabaseSyncUtil"> <property name="HOST" value="${redis.host}"/> <property name="PORT" value="${redis.port}"/> </bean>
同步工具类:
DatabaseSyncUtil:
package org.ty.cloudCourse.util; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.beanutils.converters.ArrayConverter; import org.apache.commons.beanutils.converters.SqlDateConverter; import org.springframework.beans.fact