Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
3
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

SpringBoot + Mybatis 起動時にエラー

環境

  • Windows10
  • Eclipse 4.8
  • SpringBoot 1.5.3
  • Maven 3.5.4
  • Mybatis3

Eclipseにて 実行→SpringBootアプリケーション を実施したところ、
下記エラーが発生しました。

エラー抜粋

***************************
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.

原因

Mapperが見つけられなかったようです。
@MapperScanでMapperを読み込ませるのを忘れていました。

対応

@MapperScanを定義しました。


@SpringBootApplication
@MapperScan(basePackages = "hoge.fuga") // ←Mapperクラスがあるpackageを設定
public class DemoApplication {

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

}

下記サイトの Mapperの自動検出 の項目にかかれているいずれかの対応が必要かと思います。
http://www.mybatis.org/spring/ja/mappers.html

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
3
Help us understand the problem. What are the problem?