标题 ##搭建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这个方法已经不可用了
解决方案一:使用jdbc连接
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency>
附application.yml配置,建议使用yml格式配置,properties格式的配置文件有时无效果
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数据库连接池
<dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.1.0</version> </dependency>
com.github.pagehelper分页插件
<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.1.2</version> </dependency>
附application.yml配置
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