org.springframework.beans.factory.BeanCreationException:创建名为“hiveServer”的bean时出错:调用init方法失败;嵌套异常是 org.apache.thrift.transport.TTransportException:无法在地址 0.0.0.0/0.0.0.0:10000 上创建 ServerSocket。
问问题
647 次
1 回答
1
可能是配置文件中的 bean 声明不正确。
您可以按照以下提到的步骤操作:
创建 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>
创建 hive.properties
hive.url=jdbc:hive://localhost:10000/default
添加spring-jdbc jar
在java代码中获取连接。
ApplicationContext ac = new FileSystemXmlApplicationContext("hive-config.xml"); DataSource dataSource = (DataSource) ac.getBean("hive-ds"); Connection con =dataSource.getConnection();
并开始向 hiveServer 发起查询
于 2013-04-18T09:07:25.797 回答