import com.github.alenfive.rocketapi.datasource.DataSourceDialect;
import com.github.alenfive.rocketapi.datasource.MySQLDataSource;
import com.github.alenfive.rocketapi.entity.DBConfig;
import org.springframework.stereotype.Component;
@Component //需要注册为spring bean
public class MySQLDriver extends JdbcDriver {
public String getName() { //驱动名称,全局唯一
public String getIcon() { //定义驱动的图标
return "rocketapi/images/mysql.png";
public String getFormat() { //驱动URL的格式
return "jdbc:mysql://localhost:3306/test";
* DBConfig对象中的入参为界面数据源中的配置项,
* 根据配置项自定义数据源的配置,要求返回`DataSourceDialect`
public DataSourceDialect factory(DBConfig config) throws Exception {
return new MySQLDataSource(super.getJdbcTemplate(config));