jfinal代码生成器

package generator;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.logging.Logger;

import javax.sql.DataSource;

import com.jfinal.kit.PathKit;
import com.jfinal.kit.Prop;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.generator.Generator;
import com.jfinal.plugin.c3p0.C3p0Plugin;

public class GeneratorType{
    public static DataSource getDataSource() {
        //加载配置文件
        Prop p = PropKit.use("generator/a.txt");
        //创建c3p0连接
        C3p0Plugin c3p0Plugin = new C3p0Plugin(p.get("jdbcUrl"), p.get("user"), p.get("password"));
        c3p0Plugin.start();
        return c3p0Plugin.getDataSource();
    }
	public static void main(String[] args) {
		// base model 所使用的包名
		String baseModelPkg = "model.base";
		// base model 文件保存路径
		//因为我是用maven建立的项目,路径可能有些出入
		String baseModelDir = PathKit.getWebRootPath() + "/src/main/java/model/base";
		 
		// model 所使用的包名
		String modelPkg = "model";
		// model 文件保存路径
		String modelDir = baseModelDir + "/..";
		 
		Generator gernerator = new Generator(getDataSource(), baseModelPkg, baseModelDir, modelPkg, modelDir);
		gernerator.generate();
	}

}

接下来就以JAVA Application运行就可以le

你可能感兴趣的:(jfinal)