请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

Service测试出现错误

图片描述
图片描述
图片描述
图片描述
我用视频的方法就一直null,我数据库里面也有数据,classpath路径也是对的。之前Dao测试都没问题。我直接打印就没有错误

正在回答 回答被采纳积分+3

4回答

提问者 司音子衿 2021-01-29 15:02:02

老师已解决,我在spring-dao文件里面不小心把mybatis给注释掉了

1 回复 有任何疑惑可以回复我~
提问者 司音子衿 2021-01-29 14:51:33

老师,我找到问题了是因为<setting name="mapUnderscoreToCamelCase" value="true" />没生效,我把areaDao.xml查询语句中的area_name改成areaname,数据库也改成areaname。就能查到数据。这个问题该怎么处理?

0 回复 有任何疑惑可以回复我~
提问者 司音子衿 2021-01-29 13:38:22

1月 29, 2021 1:38:30 下午 org.springframework.test.context.support.DefaultTestContextBootstrapper getDefaultTestExecutionListenerClassNames

信息: Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]

1月 29, 2021 1:38:30 下午 org.springframework.test.context.support.DefaultTestContextBootstrapper getTestExecutionListeners

信息: Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@6b1274d2, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@7bc1a03d, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@70b0b186, org.springframework.test.context.support.DirtiesContextTestExecutionListener@ba8d91c, org.springframework.test.context.transaction.TransactionalTestExecutionListener@7364985f, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@5d20e46]

1月 29, 2021 1:38:30 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions

信息: Loading XML bean definitions from class path resource [spring/spring-dao.xml]

1月 29, 2021 1:38:30 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions

信息: Loading XML bean definitions from class path resource [spring/spring-service.xml]

1月 29, 2021 1:38:30 下午 org.springframework.context.support.GenericApplicationContext prepareRefresh

信息: Refreshing org.springframework.context.support.GenericApplicationContext@1a0dcaa: startup date [Fri Jan 29 13:38:30 CST 2021]; root of context hierarchy

1月 29, 2021 1:38:30 下午 com.mchange.v2.log.MLog <clinit>

信息: MLog clients using java 1.4+ standard logging.

1月 29, 2021 1:38:31 下午 com.mchange.v2.c3p0.C3P0Registry banner

信息: Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]

13:38:31.369 [main] DEBUG org.apache.ibatis.logging.LogFactory - Logging initialized using 'class org.apache.ibatis.logging.slf4j.Slf4jImpl' adapter.

13:38:31.382 [main] DEBUG org.mybatis.spring.SqlSessionFactoryBean - Property 'configuration' or 'configLocation' not specified, using default MyBatis Configuration

13:38:31.433 [main] DEBUG org.apache.ibatis.io.VFS - Class not found: org.jboss.vfs.VFS

13:38:31.434 [main] DEBUG org.apache.ibatis.io.JBoss6VFS - JBoss 6 VFS API is not available in this environment.

13:38:31.435 [main] DEBUG org.apache.ibatis.io.VFS - Class not found: org.jboss.vfs.VirtualFile

13:38:31.436 [main] DEBUG org.apache.ibatis.io.VFS - VFS implementation org.apache.ibatis.io.JBoss6VFS is not valid in this environment.

13:38:31.437 [main] DEBUG org.apache.ibatis.io.VFS - Using VFS adapter org.apache.ibatis.io.DefaultVFS

13:38:31.442 [main] DEBUG org.mybatis.spring.SqlSessionFactoryBean - Scanned package: 'com.imooc.entity' for aliases

13:38:31.527 [main] DEBUG org.mybatis.spring.SqlSessionFactoryBean - Parsed mapper file: 'file [D:\Eclipse\o2o\target\classes\mapper\AreaDao.xml]'

13:38:31.676 [main] DEBUG org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession

13:38:31.702 [main] DEBUG org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@e041f0c] was not registered for synchronization because synchronization is not active

1月 29, 2021 1:38:31 下午 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager

信息: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 2, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 10000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hgeby9afl9mwo112kvupu|3adcc812, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.cj.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hgeby9afl9mwo112kvupu|3adcc812, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://localhost:3306/o2o?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 30, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {password=******, user=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]

13:38:32.165 [main] DEBUG org.mybatis.spring.transaction.SpringManagedTransaction - JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@130a0f66] will not be managed by Spring

13:38:32.220 [main] DEBUG com.imooc.o2o.dao.AreaDao.queryArea - ==>  Preparing: SELECT area_id, area_name, priority, create_time, last_edit_time FROM tb_area ORDER BY priority DESC 

13:38:32.305 [main] DEBUG com.imooc.o2o.dao.AreaDao.queryArea - ==> Parameters: 

WARNING: An illegal reflective access operation has occurred

WARNING: Illegal reflective access by org.apache.ibatis.reflection.Reflector (file:/C:/Users/lenovo/.m2/repository/org/mybatis/mybatis/3.4.2/mybatis-3.4.2.jar) to method java.lang.Object.finalize()

WARNING: Please consider reporting this to the maintainers of org.apache.ibatis.reflection.Reflector

WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations

WARNING: All illegal access operations will be denied in a future release

13:38:32.345 [main] DEBUG com.imooc.o2o.dao.AreaDao.queryArea - <==      Total: 2

13:38:32.352 [main] DEBUG org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@e041f0c]


0 回复 有任何疑惑可以回复我~
提问者 司音子衿 2021-01-29 13:35:58

我把Area.xml那段查询语句,放到mysql里面能查到数据。然后我故意写get(-1),就会告诉我指针错误。它能查到数据库有2条数据,但是显示不出来西苑

0 回复 有任何疑惑可以回复我~

相似问题

登录后可查看更多问答,登录/注册

问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号