SpringBoot连接Presto,亲测有效

SpringBoot连接Presto,亲测有效

  1. 配置依赖
    
    
      com.facebook.presto
      presto-jdbc
      0.203
    
  1. 配置连接参数
#presto
spring.datasource.presto.name=presto
spring.datasource.presto.type=org.apache.tomcat.jdbc.pool.DataSource
spring.datasource.presto.driver-class-name=com.facebook.presto.jdbc.PrestoDriver
spring.datasource.presto.jdbc-url=jdbc:presto://127.0.0.1:8889/hive/test
spring.datasource.presto.username=root
  1. 配置prestojdbc模板
@Slf4j
@Configuration
public class PrestoConfig {

    @Bean(name = "prestoDataSource")
    @ConfigurationProperties(prefix = "spring.datasource.presto")
    public DataSource prestoDataSource() {
        log.info("-------------------- presto init ---------------------");
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "prestoTemplate")
    public JdbcTemplate prestoJdbcTemplate(@Qualifier("prestoDataSource") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }
}
  1. 使用模板
	@Autowired
	@Qualifier("prestoTemplate")
	private JdbcTemplate prestoTemplate;

你可能感兴趣的:(大数据,spring,spring,boot,presto,java)