Я пытаюсь показать все данные в базе данных mysql с помощью mybatis в Spring Boot. Однако файл mapper.xml не известен MapperRegistry.
Я попытался изменить путь к классу application.yaml.
application.yaml
mybatis:
mapper-locations: classpath:com/example/demo/repository/mybatis/*.xml
Магазин Класса
public class Shop {
private String shopId;
private String shopName;
public Shop() {
}
public Shop(String shopId, String shopName) {
this.shopId = shopId;
this.shopName = shopName;
}
}
ShopMapper.xml
<!-- Mapping Shop Class to Shop tables -->
<resultMap id="Shop"
type="com.example.demo.domain.Shop">
<id property="shopId" column="SHOP_ID"/>
<result property="shopName" column="SHOP_NAME"/>
</resultMap>
<!-- Show all shops with the designated shopid -->
<select id="get" resultMap="Shop">
SELECT SHOP_ID, SHOP_NAME FROM SHOP
WHERE SHOP_ID = #{shopId}
</select>
</mapper>
ShopRepository
public Shop findOne(String shopId) {
Shop shop = this.sqlSessionTemplate.getMapper(ShopMapper.class).get(shopId);
return shop;
}
Контроллер
@RestController
public class PageController {
@GetMapping(path = "/{shopId}", produces = "application/json")
public Shop get(@PathVariable String shopId) {
return this.service.get(shopId);
}
}
Ошибка:
org.apache.ibatis.binding.BindingException: интерфейс типа com.example.demo.repository.mybatis.ShopMapper не известен MapperRegistry