Help us understand the problem. What is going on with this article?

SpringBoot + Mybatis 起動時にエラー

More than 1 year has passed since last update.

環境

  • 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

matyahiko2831
インプットしたこと・考えたことを言語化する練習をしています!お気軽にコメントください♪
https://www.adglobe.co.jp
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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした