Failed to load ApplicationContext
来源:7-3 商品类别批量添加后端开发

进击的盐酱
2021-04-21
老师 做对照了一下我的mapper里面的配置,没有找到getProductCategoryList,我的xml文件是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.graduate.o2o.dao.ProductCategoryDao">
<!-- 目的:为dao接口方法提供sql语句配置 -->
<select id="queryProductCategoryList" resultType="com.graduate.o2o.entity.ProductCategory"
parameterType="Long">
<!-- 具体的sql -->
SELECT
product_category_id,
product_category_name,
priority,
create_time,
shop_id
FROM
tb_product_category
WHERE
shop_id = #{shopId}
ORDER BY
priority DESC
</select>
<insert id="batchInsertProductCategory" parameterType="java.util.List">
INSERT INTO
tb_product_category(product_category_name, priority,
create_time, shop_id)
VALUES
<foreach collection="list" item="productCategory" index="index"
separator=",">
(
#{productCategory.productCategoryName},
#{productCategory.priority},
#{productCategory.createTime},
#{productCategory.shopId}
)
</foreach>
</insert>
<delete id="deleteProductCategory">
DELETE FROM
tb_product_category
WHERE
product_category_id = #{productCategoryId}
AND shop_id = #{shopId}
</delete>
</mapper>
报错:
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘productCategoryServiceImpl’: Unsatisfied dependency expressed through method ‘getProductCategoryList’ parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘long’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
我又测试了以前写好的单元测试,发现以前写好的现在也运行不了了,也是显示这样的错误。不知道怎么改TAT
写回答
1回答
-
进击的盐酱
提问者
2021-04-21
解决啦 多写了一个@Autowired
10
相似问题