spring boot 環境でアプリ実行時にエラーが発生してしまいます。
Q&A
spring boot 環境でアプリ実行時にエラーが発生してしまいます。
有識者の方ご教授をお願いいたします。
タイトルの通りですがspring boot 環境でアプリ実行時に以下のエラーが出てしまいます。
発生している問題・エラー
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
[2m2025-11-25T00:56:42.241+09:00[0;39m [31mERROR[0;39m [35m18948[0;39m [2m--- [todoapp] [ main] [0;39m[36mo.s.b.d.LoggingFailureAnalysisReporter [0;39m [2m:[0;39m
***************************
APPLICATION FAILED TO START
***************************
Description:
Field todoMapper in com.todo.app.controller.TodoController required a bean of type 'com.todo.app.mapper.TodoMapper' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'com.todo.app.mapper.TodoMapper' in your configuration.
自分なりに調べ[pom.xml]に以下を追記しましたが状況は変わらず。。。。
追記したコード
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.4</version>
</dependency>
以下追記
Mapper.java
package com.todo.app.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import com.todo.app.entity.Todo;
@Mapper
public interface TodoMapper {
public List<Todo> selectAll();
}
MapperInterfaceがDIされてないてきなエラーということでしたがコードを確認してみたところ@Mapperアノテーションはしっかりついています、、
いろいろ調べていましたが猶更訳が分からなくなってしまいました。。
使用しているSpringのバージョンが「4.0.0」に対してMybatisのバージョンが低いのでしょうか、、
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>4.0.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
判断に追加で必要な情報ありましたら追記していきます。
0 likes