The difference in the use of mybatis when integrating with different frameworks, the framework automatically encapsulates several situations (redis, active, solr)

 

http://www.xuebuyuan.com/910877.html How to encapsulate multiple data sources? ? ?

 

The difference in the use of mybatis when integrating with different frameworks, the framework automatically encapsulates several situations (redis, active, solr)

How to automatically encapsulate:

http://www.xuebuyuan.com/910877.html

 

 

1. Inject into the class to be encapsulated through the factory or public template id (this can be suitable for configurations similar to multiple data sources)

http://www.cnblogs.com/digdeep/p/4512368.html

  <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">

      <property name="basePackage" value="net.aazj.mapper" />

      <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>

    </bean>

 

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">

      <property name="basePackage" value="net.aazj.mapper2" />

      <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory_2"/>

    </bean>

 

 

2. The relevant framework automatically obtains the encapsulation directly according to the template class or factory inside the container

spring integration mybatis

  <bean id="sqlSessionFactory11" class="org.mybatis.spring.SqlSessionFactoryBean">

        <property name="dataSource" ref="dataSource" />

        <property name="typeAliasesPackage" value="com.esteel.*.bean"/> 

        <!-- typeAliasesPackage generates aliases for all classes under this package, which can be referenced directly by the class name in the configuration file instead of writing the full path -->

        <!-- <property name="typeAliasesPackage" value="com.esteel.system.bean,com.esteel.search" />

        <property name="mapperLocations" value="classpath:config_mybatis/*.xml" /> -->

        <property name="configLocation" value="classpath:config_spring/mybatis-config.xml" />

        <!-- Automatically scan entity directory, save manual configuration in Configuration.xml -->

<property name="mapperLocations"  >

<array>

                <value> classpath:config_mybatis/**/*.xml</value>

            </array>

</property>

      

        <property name="plugins">

            <array>

              <bean class="com.github.pagehelper.PageHelper">

                    <property name="properties">

                        <value>

                            dialect=oracle

                            reasonable=true

                        </value>

                    </property> 

                </bean> 

               <!--  <bean class="com.github.abel533.mapperhelper.MapperInterceptor">

                    <property name="properties">

                        <value>

                            mappers=com.github.abel533.mapper.Mapper

                            ORDER=BEFORE

                           

                        </value>

                    </property>

                </bean> -->

            </array>

        </property> 

    </bean>

3. The relevant framework is encapsulated according to the specific id of the bean

for example:

cache:

<!-- redis cache manager -->

<bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager"

c:template-ref="jedisTemplate" /> 

 

Correct the previous: the encapsulation directly encapsulates the factory class. Generally, the encapsulation of the framework will not find a template. Only the custom encapsulation will be encapsulated through the template (because we all operate through the template)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326409659&siteId=291194637