1、添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!--MyBatis Plus-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.1.0</version>
</dependency>
2、在主启动类增加扫描
@SpringBootApplication
@MapperScan("com.lsqingfeng.springboot.mapper")
public class SpringBootLearningApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootLearningApplication.class, args);
}
}
3、配置文件(不是必须配置,可不管,报错才考虑加)
# mybatis-plus配置
mybatis-plus:
# xml文件位置
mapper-locations: classpath:mapper/*.xml
4、实体类
@TableName(value ="t_judgement")
public class TJudgement implements Serializable {
/**
* id
*/
@TableId(value = "judgement_id")
private Object judgementId;
/**
* 研判报告名
*/
@TableField(value = "judgement_name")
private String judgementName;
}
5、dao层
6、service层(非必选)
/**
* UserService继承IService模板提供的基础功能
*/
public interface UserService extends IService<UserEntity> {
}
/**
* ServiceImpl实现了IService,提供了IService中基础功能的实现
* 若ServiceImpl无法满足业务需求,则可以使用自定的UserService定义方法,并在实现类中实现
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> implements UserService {
}