1
org.springframework.beans.factory.BeanCreationException:創建名爲'hiveServer'的bean時出錯:init方法的調用失敗;嵌套異常是org.apache.thrift.transport.TTransportException:無法在地址0.0.0.0/0.0.0.0:10000上創建ServerSocket。在嘗試從eclipse連接到配置單元時出現套接字連接錯誤spring xml文件
A
回答
1
可能是配置文件中不正確的bean聲明。
您可以按照以下提到的步驟:
創建蜂巢-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