亚洲色蝴蝶中文娱乐网,在线亚洲欧美一区二区中文字幕,无人视频在线观看视频高清视频,99午夜国产精品一区二区,人人妻人人爽人人狠狠

springboot 啟動(dòng)報(bào)錯(cuò)Consider defining a bean of type

時(shí)間:2020-03-30 23:32:23 類型:JAVA
字號(hào):    

  springboot使用mybatis的注解時(shí),可以使用@Mapper注解簡(jiǎn)單明了,也可以使用@MapperScan

使用@Mapper示例

  直接在Mapper類上面添加注解@Mapper,這種方式需要每一個(gè)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所在的目錄掃描進(jìn)去就行,一勞永逸

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);
	}

}


<