Exception org. apache. ibatis. binding. BindingException: Invalid bound statement (not found): caused by incomplete Spring scan path configuration, boundstatement

Source: Internet
Author: User

Exception org. apache. ibatis. binding. BindingException: Invalid bound statement (not found): caused by incomplete Spring scan path configuration, boundstatement

Run the Junit test class

Package cn. bgodata. x. zero. service; import org. junit. test; import org. junit. runner. runWith; import org. springframework. beans. factory. annotation. autowired; import org. springframework. test. context. contextConfiguration; import org. springframework. test. context. junit4.SpringJUnit4ClassRunner; import cn. bgodata. x. zero. core. model. cube; import cn. bgodata. x. zero. core. model. z0Dimension; import cn. bgodata. x. zero. dao. cubeDAO; import cn. bgodata. x. zero. dao. dimensionDAO; @ RunWith (SpringJUnit4ClassRunner. class) @ ContextConfiguration ({"classpath: spring/spring-dao.xml", "classpath: spring/spring-service.xml"}) public class ServiceTestClass {@ Autowired private DimService dimService; @ Autowired private CubeService cubeService; @ Autowired private CubeDAO cubeDao; @ Autowired private DimensionDAO dimDao; @ Test public void TXtestTX () throws Exception {Cube c1 = new Cube (); c1.setWormholeId (80001 ); c1.setWormholeCode ("great cube"); c1.setName ("slice and Cube"); Z0Dimension dim = new Z0Dimension (); dim. setWormholeId (80999); dim. setWormholeCode ("multi-dimen1_domain: dimension"); dim. setName ("Administrative Division"); dim. setCube (c1); dimService. saveDim (dim); cubeService. saveCube (c1, false );}}

 

Throw an exception

Org. apache. ibatis. binding. BindingException: Invalid bound statement (not found): cn. bgodata. x. zero. service. DimService. save
At org. apache. ibatis. binding. MapperMethod $ SqlCommand. <init> (MapperMethod. java: 196)
At org. apache. ibatis. binding. MapperMethod. <init> (MapperMethod. java: 44)
At org. apache. ibatis. binding. MapperProxy. cachedMapperMethod (MapperProxy. java: 59)
At org. apache. ibatis. binding. MapperProxy. invoke (MapperProxy. java: 52)
At com. sun. proxy. $ Proxy19.save (Unknown Source)
At cn. bgodata. x. zero. service. ServiceTestClass. TXtestTX (ServiceTestClass. java: 36)
At sun. reflect. NativeMethodAccessorImpl. invoke0 (Native Method)
At sun. reflect. NativeMethodAccessorImpl. invoke (NativeMethodAccessorImpl. java: 62)
At sun. reflect. DelegatingMethodAccessorImpl. invoke (DelegatingMethodAccessorImpl. java: 43)
At java. lang. reflect. Method. invoke (Method. java: 498)

 

 

Check the service interface and implementation, dao interface and implementation, dimension-mapper.xml, cube-mapper.xml, and source code and configuration file path, all are correct

 

package cn.bgodata.x.zero.dao;import cn.bgodata.x.zero.core.model.Cube;public interface CubeDAO {        public int save(Cube cube);    }
package cn.bgodata.x.zero.dao;import java.util.List;import cn.bgodata.x.zero.core.model.Z0Dimension;public interface DimensionDAO {        public List<Z0Dimension> loadAllDimensions();        public int saveDim(Z0Dimension dim);}
package cn.bgodata.x.zero.service;import cn.bgodata.x.zero.core.model.Cube;public interface CubeService {    public void saveCube(Cube c, boolean throwExFlag);}
package cn.bgodata.x.zero.service;import cn.bgodata.x.zero.core.model.Z0Dimension;import cn.bgodata.x.zero.dao.DimensionDAO;public interface DimService {    public void saveDim(Z0Dimension dimension);        public DimensionDAO getDimensionDAO();}
package cn.bgodata.x.zero.service.impl;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import org.springframework.transaction.annotation.Transactional;import cn.bgodata.x.zero.core.model.Cube;import cn.bgodata.x.zero.dao.CubeDAO;import cn.bgodata.x.zero.service.CubeService;@Servicepublic class CubeServiceImpl implements CubeService {    @Autowired    private CubeDAO cubeDao;    //    @Override    public void saveCube(Cube c, boolean throwExFlag) {                System.out.println("save cube count is [" + cubeDao.save(c) + "]");                if (throwExFlag) {            throw new RuntimeException("test tx ...");        }            }}
package cn.bgodata.x.zero.service.impl;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import org.springframework.transaction.annotation.Transactional;import cn.bgodata.x.zero.core.model.Z0Dimension;import cn.bgodata.x.zero.dao.DimensionDAO;import cn.bgodata.x.zero.service.DimService;@Servicepublic class DimServiceImpl implements DimService {    @Autowired    private DimensionDAO dimDao;    //    @Override    public void saveDim(Z0Dimension dimension) {        System.out.println("save dimension count is [" + dimDao.saveDim(dimension) + "]");    }    @Override    public DimensionDAO getDimensionDAO() {        // TODO Auto-generated method stub        return dimDao;    }}
<?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="cn.bgodata.x.zero.dao.CubeDAO">    <insert id="save" parameterType="Cube">        insert ignore into WORMHOLE_CUBE (wormhole_id, wormhole_code, name)        values (#{wormholeId}, #{wormholeCode}, #{name})    </insert></mapper>
<?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="cn.bgodata.x.zero.dao.DimensionDAO">    <select id="loadAllDimensions" resultType="Z0Dimension">        select            wc.name 'cube.name',            wc.wormhole_code 'cube.wormhole_code',            wc.wormhole_id 'cube.wormhole_id',            wd.name,            wd.wormhole_code,            wd.wormhole_id        from WORMHOLE_CUBE wc inner join WORMHOLE_DIMENSION wd          on wc.wormhole_id = wd.cube_id    </select>    <insert id="saveDim" parameterType="Z0Dimension">        insert ignore into WORMHOLE_DIMENSION (wormhole_id, wormhole_code, name, cube_id)        values (#{wormholeId}, #{wormholeCode}, #{name}, #{cube.wormholeId})    </insert></mapper>

 

 

Cause of problem in spring-dao.xml

 

 

 

 

The DAO interface scan path configured in the spring-dao.xml is not a full package name (cause of exception)

 

 

Modify spring-dao.xml

Configure the scan path to the full path of the package where the DAO interface is located. The problem is solved.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.