java
VScode
Gradle
SpringBoot
Thymeleafを使用
SpringBootを使用して、Postgreのデータベースとの接続を行おうとしているのですが、
@Mapperなどのアノテーションのインポートをすることができず、
import org.apache.ibatis.annotations.Mapper;の、
「org.apache.ibatis」に赤線が引かれている状態です。
インポートする方法などがあればご教授お願いします。
※プログラミング初心者で質問の文がおかしいかもしれませんが、よろしくお願いいたします。
実現したいこと
サーバー側とPostgreのデータベースとの接続。
連携後はデータベースから持ってきた値をHTML(Thymeleaf)で出力する
src\main\java\com\example\springmvc1\model\mapper.java ### 発生している問題・エラーメッセージ package com.example.springmvc1.model; import java.util.List; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import com.example.springmvc1.model.User; @Mapper public interface UserMapper { @Select("SELECT * FROM data01.person ORDER BY id") public List<Person> findAll(); @Select("SELECT * FROM data01.person WHERE id = #{id}") public Person findById(@Param("id") Integer id); } //「org.apache.ibatis」に赤線がありインポートが行えない
build.gradle plugins { id 'org.springframework.boot' version '2.7.2' id 'io.spring.dependency-management' version '1.0.12.RELEASE' id 'java' } group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = '11' configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' annotationProcessor 'org.projectlombok:lombok' implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.0.1' runtimeOnly 'org.postgresql:postgresql' testImplementation 'org.springframework.boot:spring-boot-starter-test' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' } tasks.named('test') { useJUnitPlatform() }
エラーメッセージ
The import org.apache.ibatis cannot be resolvedJava(268435846)
さいごに
至らぬ点がございますが、ご教授いただけると幸いです。
あなたの回答
tips
プレビュー