日韩精品欧美激情国产一区_中文无码精品一区二区三区在线_岛国毛片AV在线无码不卡_亞洲歐美日韓精品在線_使劲操好爽好粗视频在线播放_日韩一区欧美二区_八戒八戒网影院在线观看神马_亚洲怡红院在线色网_av无码不卡亚洲电影_国产麻豆媒体MDX

springboot 啟動報錯Consider defining a bean of type

時間:2020-03-30 23:32:23 類型:JAVA
字號:    

  springboot使用mybatis的注解時,可以使用@Mapper注解簡單明了,也可以使用@MapperScan

使用@Mapper示例

  直接在Mapper類上面添加注解@Mapper,這種方式需要每一個mapper類都添加此注解,有些麻煩

@Mapper
@Repository("studentDao")
public interface StudentDao {
	public int addStudent(Student stu);
	public int editStudent(Student stu);
	public List<Student> selectStudent(Student stu);
	public int deleteStudent(Integer id);
	public int deleteStudents(String ids);
	public int delsStudents(String[] id);
	public Student selectStudentById(Integer id);
}

使用@MapperScan示例

   直接將mapper所在的目錄掃描進去就行,一勞永逸

package com.yt;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan({"com.yt.dao"}) 
public class SpringytApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringytApplication.class, args);
	}

}


<