Spring-boot + Mybatis3.0.6配置 鏈接db2as400方案

充阳秋
2023-12-01

項目需要兼容較老的db2 as400 ,3.0.6以上版本mybatis會有權限設置問題,故需要使用老版本mybatis但是在網上搜了很久沒有相關文檔,踩了很多坑,所以將自己摸索了三天的相關配置分享記錄一下

<!-- 降低mybatis版本,兼容as400數據庫驅動jt400  start -->
         
         
	      <dependency>
			    <groupId>org.springframework</groupId>
			    <artifactId>spring-jdbc</artifactId>
			    <version>3.0.0.RELEASE</version>
			</dependency>

          <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.0.6</version>
        </dependency>
         <dependency>
	        <groupId>org.mybatis</groupId>
	        <artifactId>mybatis-spring</artifactId>
            <!-- mybatis 3.0.6最低要配置1.0.2, 1.0.0版本會導致xml的<sql>解析不了 -->
	        <version>1.0.2</version>
	      </dependency>
        
         <dependency>
			<groupId>cglib</groupId>
			<artifactId>cglib</artifactId>
			<version>3.2.5</version>
         </dependency>
         <!-- 降低mybatis版本,兼容as400數據庫驅動jt400  end -->

    <!-- 因springboot套件最低的mybatis也是3.4.6,所以需要去掉重複依賴 -->
         <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.4</version>
            <exclusions>
		      <exclusion>
			      <groupId>org.mybatis.spring.boot</groupId>
			      <artifactId>mybatis-spring-boot-autoconfigure</artifactId>
		      </exclusion>
		      <exclusion>
		         <groupId>org.mybatis</groupId>
     			 <artifactId>mybatis</artifactId>
		      </exclusion>
		      <exclusion>
		      <groupId>org.mybatis</groupId>
		      <artifactId>mybatis-spring</artifactId>
		      </exclusion>
		   </exclusions>
        </dependency>

	<dependency>
	   <groupId>org.springframework.boot</groupId>
	   <artifactId>spring-boot-starter-web</artifactId>
	</dependency>
        
	<dependency>
	   <groupId>org.springframework.boot</groupId>
	   <artifactId>spring-boot-starter-jdbc</artifactId>
	   <exclusions>
   			<exclusion>
		        <groupId>org.springframework</groupId>
		        <artifactId>spring-jdbc</artifactId>
		    </exclusion>
	   </exclusions>
	</dependency>

 类似资料: