invalid bound statement
来源:2-7 验证Dao
weixin_慕神8266847
2020-03-15
老师你好,我找了很久的解决方法也没找到,JUnit测试就是fail,控制台不报错但是我看testinstance和testMethod都为空,我检查了AreaDao.xml里的mapper和AreaDao还有AreaDaoTest的写法都没有发现问题。。。
我上一下我的控制台报的和代码吧
21:48:59.653 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'areaDao'
21:48:59.720 [main] DEBUG org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate - Storing ApplicationContext in cache under key [[MergedContextConfiguration@3a883ce7 testClass = AreaDaoTest, locations = '{classpath:/spring/spring-dao.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[[empty]], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]]
21:48:59.720 [main] DEBUG org.springframework.test.context.cache - Spring test ApplicationContext cache statistics: [DefaultContextCache@2b40ff9c size = 1, maxSize = 32, parentContextCount = 0, hitCount = 0, missCount = 1]
21:48:59.732 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test method: context [DefaultTestContext@cd2dae5 testClass = AreaDaoTest, testInstance = com.yyk.o2o.dao.AreaDaoTest@68bbe345, testMethod = testQueryArea@AreaDaoTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@3a883ce7 testClass = AreaDaoTest, locations = '{classpath:/spring/spring-dao.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[[empty]], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]], attributes = map[[empty]]], class annotated with @DirtiesContext [false] with mode [null], method annotated with @DirtiesContext [false] with mode [null].
21:48:59.741 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - After test method: context [DefaultTestContext@cd2dae5 testClass = AreaDaoTest, testInstance = com.yyk.o2o.dao.AreaDaoTest@68bbe345, testMethod = testQueryArea@AreaDaoTest, testException = org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.yyk.o2o.dao.AreaDao.queryArea, mergedContextConfiguration = [MergedContextConfiguration@3a883ce7 testClass = AreaDaoTest, locations = '{classpath:/spring/spring-dao.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[[empty]], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]], attributes = map[[empty]]], class annotated with @DirtiesContext [false] with mode [null], method annotated with @DirtiesContext [false] with mode [null].
21:48:59.746 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - After test class: context [DefaultTestContext@cd2dae5 testClass = AreaDaoTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@3a883ce7 testClass = AreaDaoTest, locations = '{classpath:/spring/spring-dao.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[[empty]], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]], attributes = map[[empty]]], class annotated with @DirtiesContext [false] with mode [null].
21:48:59.752 [Thread-1] DEBUG org.springframework.context.support.GenericApplicationContext - Closing org.springframework.context.support.GenericApplicationContext@59e5ddf, started on Sun Mar 15 21:48:58 CST 2020
AreaDao.java
package com.yyk.o2o.dao;
import java.util.List;
import com.yyk.o2o.entity.Area;
public interface AreaDao {
/* 返回列出区域列表,返回值是areaList */
List<Area> queryArea();
}
AreaDao.xml
package com.yyk.o2o.dao;
import java.util.List;
import com.yyk.o2o.entity.Area;
public interface AreaDao {
/* 返回列出区域列表,返回值是areaList */
List<Area> queryArea();
}
AreaDaoTest.java
package com.yyk.o2o.dao;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.yyk.o2o.BaseTest;
import com.yyk.o2o.entity.Area;
public class AreaDaoTest extends BaseTest{
@Autowired
private AreaDao areaDao;
@Test
public void testQueryArea() {
List<Area> areaList = areaDao.queryArea();
assertEquals(2,areaList.size());
}
}
写回答
1回答
-
翔仔
2020-03-16
同学好,需要看看你的ut failure trace,光看代码我们的环境不一样,背景也不同,不好定位问题呢
00
相似问题