spring boot 2.x版本:java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedDataBinder

標題 ##搭建spring boot 2.0.3版本

使用alibaba的druid數據庫鏈接池,com.github.pagehelper的分頁插件,啓動項目報錯。 
錯誤提示:java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedDataBinder
boot.bind下找不到RelaxedDataBinder這個方法
查看API發現,這個org.springframework.boot.bind 包已經刪掉了,致使RelaxedPropertyResolver這個方法已經不可用了java

解決方案一:使用jdbc鏈接

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

附application.yml配置,建議使用yml格式配置,properties格式的配置文件有時無效果mysql

server:
  port: 8080

spring:
    datasource:
        name: test
        url: jdbc:mysql://127.0.0.1:3306/mytest
        username: root
        password: 123456
        driver-class-name: com.mysql.jdbc.Driver
mybatis:
  mapper-locations: classpath:mapper/*Mapper.xml
  type-aliases-package: com.example.spring_boot.bean

解決方案二:boot版本改成1.5.x版本

附alibaba的druid數據庫鏈接池git

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.1.0</version>
        </dependency>
    

com.github.pagehelper分頁插件github

        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.1.2</version>
        </dependency>

附application.yml配置spring

server:
  port: 8080

spring:
    datasource:
        name: test
        type: com.alibaba.druid.pool.DruidDataSource
        druid:
          driver-class-name: com.mysql.jdbc.Driver
          url: jdbc:mysql://127.0.0.1:3306/mytest
          username: root
          password: 123456
mybatis:
  mapper-locations: classpath:mapper/*Mapper.xml
  type-aliases-package: com.example.spring_boot.bean

#pagehelper
pagehelper:
    helperDialect: mysql
    reasonable: true
    supportMethodsArguments: true
    params: count=countSql
    returnPageInfo: check
相關文章
相關標籤/搜索