|
|
|
@ -4,14 +4,16 @@ import com.lq.code.dto.QueueDto; |
|
|
|
|
import com.lq.code.util.BeanUtil; |
|
|
|
|
import com.lq.code.util.jdbc.JdbcUtils; |
|
|
|
|
import com.lq.code.util.sql.AbstractDbBuiler; |
|
|
|
|
import com.lq.code.util.sql.MysqlBuilder; |
|
|
|
|
import com.lq.code.util.sql.SqlConstant; |
|
|
|
|
import com.lq.code.util.sql.factory.DbBuilerFactory; |
|
|
|
|
import com.lq.code.util.sql.factory.impl.DefaultDbBuilerFactory; |
|
|
|
|
import org.springframework.context.ApplicationListener; |
|
|
|
|
import org.springframework.context.event.ContextRefreshedEvent; |
|
|
|
|
|
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Created by qi_liang on 2018/6/1. |
|
|
|
|
* @author qi |
|
|
|
|
*/ |
|
|
|
|
public class InstantiationTracingBeanPostProcessor implements ApplicationListener<ContextRefreshedEvent> { |
|
|
|
|
|
|
|
|
@ -42,15 +44,12 @@ public class InstantiationTracingBeanPostProcessor implements ApplicationListene |
|
|
|
|
//需要执行的逻辑代码,当spring容器初始化完成后就会执行该方法。
|
|
|
|
|
//扫描实体类
|
|
|
|
|
if (isUpdateDB) { |
|
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
|
Set<Class> set = BeanUtil.getClassSet(packagePath); |
|
|
|
|
QueueDto<Class> queueDto = BeanUtil.getQueueDto(packagePath); |
|
|
|
|
AbstractDbBuiler dbBuiler = new MysqlBuilder(); |
|
|
|
|
// String sql = dbBuiler.automaticUpdateDbNew(queueDto);
|
|
|
|
|
DbBuilerFactory dbBuilerFactory = new DefaultDbBuilerFactory(); |
|
|
|
|
AbstractDbBuiler dbBuiler = dbBuilerFactory.getSqlBuilder(SqlConstant.DB_TYPE_MYSQL); |
|
|
|
|
String sql = dbBuiler.automaticUpdateDb(set); |
|
|
|
|
JdbcUtils.createTable(sql); |
|
|
|
|
System.out.println("=========实体同步数据结构==========="); |
|
|
|
|
System.out.println(System.currentTimeMillis()-startTime+"毫秒"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|