Hbase Rest Client 설정


<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:context="http://www.springframework.org/schema/context"

xsi:schemaLocation="

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">


    <bean id="hbaseRestClient" class="com.google.HttpComponentsClientFactory">

        <property name="maxTotalConnections" value="1000" />

        <property name="maxConnectionsPerRoute" value="1000" />

        <property name="connectTimeout" value="5000" />

        <property name="socketTimeout" value="5000" />

    </bean>


    <bean id="hbaseRestClientFactory" class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory">

        <constructor-arg index="0" ref="hbaseRestClient" />

    </bean>


    <bean id="hbaseRestTemplate" class="org.springframework.web.client.RestTemplate">

        <constructor-arg ref="hbaseRestClientFactory" />

        <property name="messageConverters">

            <list>

                <bean class="org.springframework.http.converter.StringHttpMessageConverter">

                    <constructor-arg value="UTF-8"/>

                </bean>

            </list>

        </property>

    </bean>


</beans>


위의 코드 중 아래 코드를 잘 살펴야 한다. 아래 코드는 java 7, java8 에도 동작하는 코드이다. 


  <bean class="org.springframework.http.converter.StringHttpMessageConverter">

                    <constructor-arg value="UTF-8"/>

 </bean>



  <bean class="org.springframework.http.converter.StringHttpMessageConverter">

     <constructor-arg>

<bean class="java.nio.charset.Charset" factory-method="forName">

   <constructor-arg value="UTF-8" />

</bean>

   </constructor-arg> 

</bean>


StringHttpMessageConverter는 인코딩쪽 설정인데, 한글이 깨지면 이 부분 이슈이다.




그러나, StringHttpMessageConverter의 생성자가 Charset 이기 때문에 생성자 아규먼트를 아래와 같이 Charset Type을 넘기면, java 7에서는 작동하나, java 8에서는 Spring boot가 실패한다. 


  <bean class="org.springframework.http.converter.StringHttpMessageConverter">

                   <constructor-arg value="#{T(java.nio.charset.Charset).forName('UTF-8')}"/>

</bean>


특별히 에러 메시지 없이 StringHttpMessageConverter 생성하려다가 container를 destory 한다... ;;;;;




Posted by '김용환'
,