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