本人第一次接触springboot框架本来想用mybatis连接数据库,引入mybatisplus配置就启动报错
package com.hu.springboot_mybatis.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hu.springboot_mybatis.pojo.UserPojo;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UserDao extends BaseMapper<UserPojo> {
}
package com.hu.springboot_mybatis.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "user")
public class UserPojo {
public String username;
public String password;
}
package com.hu.springboot_mybatis.service;
import com.hu.springboot_mybatis.dao.UserDao;
import com.hu.springboot_mybatis.pojo.UserPojo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class UserServiceImpl {
@Autowired
UserDao userDao;
public void addUser(String username,String password){
userDao.insert(new UserPojo(username,password));
}
}
然后在网上各种找原因最终是因为
mybatis-spring版本原因
我一开始是2.0的版本改成3.0就ok了
标签:lang,springboot,value,hu,报错,mybatis,import,com,public From: https://blog.csdn.net/qq_52388401/article/details/139374631