企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
实体类是由工具类DbToEntity生成,无需手写 ~~~ package com.asiainfo.walk.webdemo.tools; import org.walkframework.base.system.common.Common; import org.walkframework.batis.tools.dbtobean.CreateBeanConfig; import org.walkframework.batis.tools.dbtobean.CreateBeans; import org.walkframework.data.util.IData; /** * 根据数据库表生成实体类 * */ public abstract class DbToEntity { public static void main(String[] args) throws Exception { //根包和输出路径设置 String basePackage = "com.asiainfo.walk.webdemo"; String outBasePath = "E:/codegen"; //开始生成 String packageName = basePackage + ".mvc.entity"; String packagePath = outBasePath + "/src/main/java/" + basePackage.replaceAll("\\.", "/") + "/mvc/entity"; String[][] tables = new String[][]{ new String[]{"TD_M_STAFF", packageName, packagePath}, new String[]{"TD_M_USER", packageName, packagePath}, }; CreateBeans.createJavaBean(tables, createBeanConfig()); } /** * 数据源设置 * * @return */ @SuppressWarnings("rawtypes") private static CreateBeanConfig createBeanConfig() { String dbName = "ds_1";//设置数据库 Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties"); String dbAddr = props.getProperty(String.format("ds.%s.addr", dbName)); String dbUrl = props.getProperty(String.format("ds.%s.url", dbName)); CreateBeanConfig appConfig = new CreateBeanConfig(); appConfig.setDriverClassName(props.getProperty(String.format("ds.%s.driverClassName", dbName))); appConfig.setDburl(dbUrl.replaceAll(String.format("\\$\\{ds.%s.addr\\}", dbName), dbAddr)); appConfig.setDbusername(props.getProperty(String.format("ds.%s.username", dbName))); appConfig.setDbpassword(props.getProperty(String.format("ds.%s.password", dbName))); return appConfig; } } ~~~