[JAVA] SpringBoot + Mybatis error when booting

environment

When I executed Run → Spring Boot Application in Eclipse, The following error has occurred.

Error excerpt

***************************
APPLICATION FAILED TO START
***************************

Description:
Parameter 0 of constructor in hoge.fuga.PiyoRepositoryImpl required a bean of type 'hoge.fuga.PiyoMapper' that could not be found.


Action:
Consider defining a bean of type 'hoge.fuga.PiyoMapper' in your configuration.

Cause

It looks like Mapper couldn't be found. I forgot to load Mapper with @MapperScan.

Correspondence

Defined @MapperScan.


@SpringBootApplication
@MapperScan(basePackages = "hoge.fuga") //← Set a package with Mapper class
public class DemoApplication {

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

}

I think that one of the measures described in the item of Mapper automatic detection on the following site is necessary. http://www.mybatis.org/spring/ja/mappers.html

Recommended Posts

SpringBoot + Mybatis error when booting
Error when using SnapKit
Error when bundle install
Error when deploying EC2
Suffering from MyBatis foreach error
Error when playing with java
Error when using rails capybara
Error when introducing SNS authentication
Error when npm install on Windows 7
The basics of SpringBoot + MyBatis + MySQL
Error when deploying EC2 on CircleCI
[Practice! ] Minimum settings when using MyBatis
About error when implementing spring validation