eclipse - 尝试从 eclipse spring xml 文件连接到配置单元时出现套接字连接错误

标签 eclipse spring hadoop hive

org.springframework.beans.factory.BeanCreationException:创建名为“hiveServer”的 bean 时出错:调用 init 方法失败;嵌套异常是 org.apache.thrift.transport.TTransportException:无法在地址 0.0.0.0/0.0.0.0:10000 上创建 ServerSocket。

最佳答案

可能是配置文件中的 bean 声明不正确。

您可以按照以下提到的步骤操作:

  1. 创建 hive-config.xml

    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:c="http://www.springframework.org/schema/c"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    
    <context:property-placeholder location="hive.properties"/> 
    <bean id="hive-driver" class="org.apache.hadoop.hive.jdbc.HiveDriver"/>
    <bean id="hive-ds" class="org.springframework.jdbc.datasource.SimpleDriverDataSource"
     c:driver-ref="hive-driver" c:url="${hive.url}"/>
    </beans>
    
  2. 创建 hive.properties

    hive.url=jdbc:hive://localhost:10000/default
    
  3. 添加spring-jdbc jar

  4. 在 java 代码中获取连接。

    ApplicationContext ac = new FileSystemXmlApplicationContext("hive-config.xml");
    DataSource dataSource =  (DataSource) ac.getBean("hive-ds");
    Connection con =dataSource.getConnection();
    

并开始向 hiveServer 发送查询

关于eclipse - 尝试从 eclipse spring xml 文件连接到配置单元时出现套接字连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15425498/

相关文章:

css - 我无法在 Eclipse 中更改包资源管理器的字体大小

java - 是否可以在外部文件中为 Spring Framework 指定类名?

java - 将 yamr 作业提交到远程集群时出现 ClassNotFoundException

hadoop - 连续摄取的 HDFS 文件压缩

hadoop - 在Hadoop上配置Hive,Map Reduce无法正常工作-错误:找不到或加载主类1600

eclipse - 如何从eclipse中删除断点?

java - 如何将 ImageJ 添加到 Eclipse 中的构建路径,以及在哪里可以找到 ImageJ .jar 文件?

java.io.FileNotFoundException :/target/test. 日志

java - 带有分页的 Spring Data JPA 方法查询给我一个错误

Eclipse,远程(SFTP)编辑和备份文件