马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 孤世星辰 于 2024-5-25 21:41 编辑 Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-05-25T21:30:27.515+08:00 ERROR 32720 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userMapper': Error creating bean with name 'userMapper' defined in file [C:\Users\a2032\Desktop\JAVA cod\springbootMybatis\target\classes\com\zwl\mapper\UserMapper.class]: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
package com.zwl.controller;
import com.zwl.mapper.UserMapper;
import com.zwl.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class UserController {
@Autowired
private UserMapper userMapper;
@GetMapping("/selectAll")
public List<User> selectAll(){
List<User> users = userMapper.selectAll();
for (User user : users) {
System.out.println(user);
}
return users;
}
}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package com.zwl.mapper;
import com.zwl.pojo.User;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
@Repository
@Mapper
public interface UserMapper {
List<User> selectAll();
User queryById(int id);
int insert(User user);
int update(User user);
int deleteById(int id);
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zwl.mapper.UserMapper">
<select id="selectAll" resultType="User">
select * from user
</select>
<select id="queryById" resultType="User">
select * from user where id=#{id}
</select>
<insert id="insert" parameterType="User">
insert into uer (id,name,pwd) values (#{id},#{name},#{pwd})
</insert>
<update id="update" parameterType="User">
update user set name=#{name},pwd=#{pwd} where id=#{id}
</update>
<delete id="deleteById" parameterType="int">
delete from user where id=#{id}
</delete>
</mapper>
|