server:
port: 9090
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/nhy?serverTimezone=GMT%2b8
username: root
password: 123456
mybatis:
mapper-locations: classpath:mapper/*.xml #扫描所有mybatis的xml文件
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.demo.dao.UserDao">
<resultMap id="userSearch" type="com.example.demo.pojo.userBean">
<id column="id" property="id"></id>
<result column="username" property="name"></result>
<result column="password" property="pwd"></result>
<result column="nickname" property="nickname"></result>
<result column="email" property="email"></result>
<result column="phone" property="phone"></result>
<result column="address" property="address"></result>
</resultMap>
<select id="search" resultMap="userSearch">
select * from sys_user limit #{newPageNum},#{newPageSize};
</select>
</mapper>
//@Mapper
public interface UserDao {
//@Select(" select * from sys_user where username like concat('%',#{username},'%') limit #{newPageNum},#{newPageSize};")
List<UserBean> search(@Param("newPageNum") Integer pageNum,@Param("newPageSize") Integer pageSize,String username,String address);
// @Select("select count(*) from sys_user")
Integer finaAll();
}
一启动就报错,mapper-locations: classpath:mapper/*.xml 删了就好了,只用注解的话就没问题,应该是配置文件问题
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Inject
boot用的2.7,mybatis-boot2.2