2017-11-20 31 views
0

새 스프링 부트 프로젝트에서 사용되는이 비추천 클래스를 교체해야합니다. 후더 이상 사용되지 않는 SqlMapClientFactoryBean 대체에 도움이 필요합니다.

하는 SqlMapClientFactoryBean

일부 검색 내가 이것을 대체 할 수있는 쉬운 방법을 찾을 수 없습니다,하지만 내가 비슷한 대안이 있어야 느낌?

Bean 정의 :

<bean id="clientMap" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> 
    <property name="dataSource" ref="datasource" /> 
    <property name="configLocation" value="classpath:/my/path/to/SqlMapConfig.xml" /> 
</bean> 

SQLMapConfig.xml :

<sqlMapConfig> 
    <settings cacheModelsEnabled="true" 
      enhancementEnabled="true" 
      lazyLoadingEnabled="false" 
      maxRequests="32" 
      maxSessions="10" 
      maxTransactions="5" 
      useStatementNamespaces="true"/> 
    <sqlMap resource="path/to/config/ibatis/ibatis.xml"/> 
</sqlMapConfig> 

ibatis.xml :

<sqlMap namespace="abd.xyz.flow"> 
    <!-- Object-Index --> 
    <resultMap id="objectIndexResult" class="abd.xyz.model.ObjectIndex"> 
     <result property="objectIndex" columnIndex="1" /> 
     <result property="idx1" columnIndex="2" /> 
     <result property="idx2" columnIndex="3" /> 
     <result property="idx3" columnIndex="4" /> 
     <result property="idx4" columnIndex="5" />  
    </resultMap> 

    <select id="wflow.getObjectIndexById" resultMap="objectIndexResult"> 
     select * from om.object_index oi where oi.object_index = #objectIndex# 
    </select> 

    <!-- GPQ --> 
    <resultMap id="detail" class="abc.xyz.model.SomeDetail"> 
     <result property="processId" column="PROCESS_ID" /> 
     <result property="processTypeDescr" column="PROCESS_TYPE_DESCR" /> 
     <result property="nextActionCd" column="NEXT_ACTION_CD" /> 
     <result property="idx9" column="IDX9" /> 
     <result property="idx17" column="IDX17" /> 
    </resultMap> 

    <select id="flow.getDetails" resultMap="Detail"> 
     SELECT * FROM flow.detail 
    </select> 
</sqlMap> 

콩에게 & XMLS를 참조하십시오 미리 감사드립니다 :)

답변

1

문서가 너무 명확하게 설명하지 않을 수도 있습니다. 공식 Spring Boot MyBatis Examples을보십시오. SqlMapClientFactoryBean을 다른 클래스로 바꾸려면 클래스가 필요하지 않습니다.

: configLocation SqlMapClientFactoryBean에 교체로

spring.datasource.url=jdbc:mysql://localhost/test 
spring.datasource.username=dbuser 
spring.datasource.password=dbpass 
spring.datasource.driver-class-name=com.mysql.jdbc.Driver 

등가 : 당신은 그냥 application.propertieslike so 당신의 봄 부팅에 데이터 소스를 선언해야한다

: datasourceSqlMapClientFactoryBean에 교체 상당

그리고 또한 application.properties 파일의 mybatis-config.xml location 지정

mybatis.config-location=classpath:mybatis-config.xml 

가 위의 질문에 결론을; 즉 SqlMapClientFactoryBean에 해당합니다. 사용자 설정 마이그레이션의 나머지 부분

mapper XML 항목이 이제 이전하여 XML에 sqlMapsettingsin your 선언 config file이 거의 동일하게 유지해야를 대체 docs indicate.

+0

감사! 나는 그것을 시도 할 것이다! – superloop