请稍等 ...
×

采纳答案成功!

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

请问这个问题咋解决啊,百度之后一直还是有问题

D:\jdk\bin\java.exe -ea -Didea.test.cyclic.buffer.size=1048576 “-javaagent:E:\IntelliJ IDEA 2018.2.4\配置\lib\idea_rt.jar=52386:E:\IntelliJ IDEA 2018.2.4\配置\bin” -Dfile.encoding=UTF-8 -classpath “E:\IntelliJ IDEA 2018.2.4\配置\lib\idea_rt.jar;E:\IntelliJ IDEA 2018.2.4\配置\plugins\junit\lib\junit-rt.jar;E:\IntelliJ IDEA 2018.2.4\配置\plugins\junit\lib\junit5-rt.jar;D:\mywork\shops\target\test-classes;D:\mywork\shops\target\classes;C:\Users\lenovo.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\lenovo.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\lenovo.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\lenovo.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\lenovo.m2\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;C:\Users\lenovo.m2\repository\org\springframework\spring-core\5.1.8.RELEASE\spring-core-5.1.8.RELEASE.jar;C:\Users\lenovo.m2\repository\org\springframework\spring-jcl\5.1.8.RELEASE\spring-jcl-5.1.8.RELEASE.jar;C:\Users\lenovo.m2\repository\org\springframework\spring-beans\5.1.8.RELEASE\spring-beans-5.1.8.RELEASE.jar;C:\Users\lenovo.m2\repository\org\springframework\spring-context\5.1.8.RELEASE\spring-context-5.1.8.RELEASE.jar;C:\Users\lenovo.m2\repository\org\springframework\spring-aop\5.1.8.RELEASE\spring-aop-5.1.8.RELEASE.jar;C:\Users\lenovo.m2\repository\org\springframework\spring-expression\5.1.8.RELEASE\spring-expression-5.1.8.RELEASE.jar;C:\Users\lenovo.m2\repository\org\springframework\spring-jdbc\5.1.8.RELEASE\spring-jdbc-5.1.8.RELEASE.jar;C:\Users\lenovo.m2\repository\org\springframework\spring-tx\5.1.8.RELEASE\spring-tx-5.1.8.RELEASE.jar;C:\Users\lenovo.m2\repository\org\springframework\spring-web\5.1.8.RELEASE\spring-web-5.1.8.RELEASE.jar;C:\Users\lenovo.m2\repository\org\springframework\spring-webmvc\5.1.8.RELEASE\spring-webmvc-5.1.8.RELEASE.jar;C:\Users\lenovo.m2\repository\org\springframework\spring-test\5.1.8.RELEASE\spring-test-5.1.8.RELEASE.jar;C:\Users\lenovo.m2\repository\javax\servlet\javax.servlet-api\3.1.0\javax.servlet-api-3.1.0.jar;C:\Users\lenovo.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.9.9\jackson-databind-2.9.9.jar;C:\Users\lenovo.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;C:\Users\lenovo.m2\repository\com\fasterxml\jackson\core\jackson-core\2.9.9\jackson-core-2.9.9.jar;C:\Users\lenovo.m2\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;C:\Users\lenovo.m2\repository\org\mybatis\mybatis\3.5.2\mybatis-3.5.2.jar;C:\Users\lenovo.m2\repository\org\mybatis\mybatis-spring\2.0.2\mybatis-spring-2.0.2.jar;C:\Users\lenovo.m2\repository\mysql\mysql-connector-java\8.0.15\mysql-connector-java-8.0.15.jar;C:\Users\lenovo.m2\repository\com\google\protobuf\protobuf-java\3.6.1\protobuf-java-3.6.1.jar;C:\Users\lenovo.m2\repository\c3p0\c3p0\0.9.1.2\c3p0-0.9.1.2.jar” com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 shops.dao.AreDaoTest
16:37:23.684 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class shops.dao.AreDaoTest]
16:37:23.702 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
16:37:23.718 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
16:37:23.731 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [shops.dao.AreDaoTest] from class [org.springframework.test.context.support.DefaultTestContextBootstrapper]
16:37:23.787 [main] DEBUG org.springframework.test.context.support.AbstractDelegatingSmartContextLoader - Delegating to GenericXmlContextLoader to process context configuration [ContextConfigurationAttributes@31c88ec8 declaringClass = ‘shops.BaseTest’, classes = ‘{}’, locations = ‘{classpath:spring/spring-dao.xml}’, inheritLocations = true, initializers = ‘{}’, inheritInitializers = true, name = [null], contextLoaderClass = ‘org.springframework.test.context.ContextLoader’].
16:37:23.834 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an ‘annotation declaring class’ for annotation type [org.springframework.test.context.ActiveProfiles] and class [shops.dao.AreDaoTest]
16:37:23.835 [main] DEBUG org.springframework.test.context.support.DefaultTestContextBootstrapper - @TestExecutionListeners is not present for class [shops.dao.AreDaoTest]: using defaults.
16:37:23.835 [main] INFO org.springframework.test.context.support.DefaultTestContextBootstrapper - 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]
16:37:23.856 [main] INFO org.springframework.test.context.support.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@145f66e3, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@3023df74, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@313ac989, org.springframework.test.context.support.DirtiesContextTestExecutionListener@4562e04d, org.springframework.test.context.transaction.TransactionalTestExecutionListener@2a65fe7c, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@4135c3b]
16:37:23.859 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [shops.dao.AreDaoTest]
16:37:23.860 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [shops.dao.AreDaoTest]16:37:23.880 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [shops.dao.AreDaoTest]
16:37:23.880 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [shops.dao.AreDaoTest]16:37:23.882 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [shops.dao.AreDaoTest]
16:37:23.882 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [shops.dao.AreDaoTest]
16:37:23.882 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [shops.dao.AreDaoTest]
16:37:23.883 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [shops.dao.AreDaoTest]
16:37:23.885 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@7e6f74c testClass = AreDaoTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@dd05255 testClass = AreDaoTest, 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].
16:37:23.886 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [shops.dao.AreDaoTest]
16:37:23.886 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [shops.dao.AreDaoTest]
16:37:23.907 [main] DEBUG org.springframework.test.context.support.DependencyInjectionTestExecutionListener - Performing dependency injection for test context [[DefaultTestContext@7e6f74c testClass = AreDaoTest, testInstance = shops.dao.AreDaoTest@3eb25e1a, testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@dd05255 testClass = AreDaoTest, 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]]]].
16:37:23.910 [main] DEBUG org.springframework.test.context.support.AbstractDelegatingSmartContextLoader - Delegating to GenericXmlContextLoader to load context from [MergedContextConfiguration@dd05255 testClass = AreDaoTest, locations = ‘{classpath:spring/spring-dao.xml}’, classes = ‘{}’, contextInitializerClasses = ‘[]’, activeProfiles = ‘{}’, propertySourceLocations = ‘{}’, propertySourceProperties = ‘{}’, contextCustomizers = set[[empty]], contextLoader = ‘org.springframework.test.context.support.DelegatingSmartContextLoader’, parent = [null]].
16:37:23.910 [main] DEBUG org.springframework.test.context.support.AbstractGenericContextLoader - Loading ApplicationContext for merged context configuration [[MergedContextConfiguration@dd05255 testClass = AreDaoTest, locations = ‘{classpath:spring/spring-dao.xml}’, classes = ‘{}’, contextInitializerClasses = ‘[]’, activeProfiles = ‘{}’, propertySourceLocations = ‘{}’, propertySourceProperties = ‘{}’, contextCustomizers = set[[empty]], contextLoader = ‘org.springframework.test.context.support.DelegatingSmartContextLoader’, parent = [null]]].
16:37:24.000 [main] DEBUG org.springframework.core.env.StandardEnvironment - Activating profiles []
16:37:24.329 [main] DEBUG org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loaded 4 bean definitions from class path resource [spring/spring-dao.xml]
16:37:24.338 [main] DEBUG org.springframework.context.support.GenericApplicationContext - Refreshing org.springframework.context.support.GenericApplicationContext@41a2befb
16:37:24.362 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor’
16:37:24.423 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.mybatis.spring.mapper.MapperScannerConfigurer#0’
16:37:24.487 [main] DEBUG org.apache.ibatis.logging.LogFactory - Logging initialized using ‘class org.apache.ibatis.logging.slf4j.Slf4jImpl’ adapter.
16:37:24.509 [main] DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner - Identified candidate component class: file [D:\mywork\shops\target\test-classes\dao\AreaDao.class]
16:37:24.510 [main] DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner - Identified candidate component class: file [D:\mywork\shops\target\classes\dao\AreaDao.class]
16:37:24.512 [main] DEBUG org.mybatis.spring.mapper.ClassPathMapperScanner - Creating MapperFactoryBean with name ‘areaDao’ and ‘dao.AreaDao’ mapperInterface
16:37:24.518 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0’
16:37:24.532 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Found key ‘jdbc.driver’ in PropertySource ‘localProperties’ with value of type String
16:37:24.532 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Found key ‘jdbc.url’ in PropertySource ‘localProperties’ with value of type String
16:37:24.532 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Found key ‘jdbc.username’ in PropertySource ‘localProperties’ with value of type String
16:37:24.532 [main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Found key ‘jdbc.password’ in PropertySource ‘localProperties’ with value of type String
16:37:24.533 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerProcessor’
16:37:24.534 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerFactory’
16:37:24.537 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor’
16:37:24.543 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'dataSource’
7月 26, 2019 4:37:24 下午 com.mchange.v2.log.MLog
信息: MLog clients using java 1.4+ standard logging.
7月 26, 2019 4:37:25 下午 com.mchange.v2.c3p0.C3P0Registry banner
信息: Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
16:37:25.845 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'sqlSessionFactory’
16:37:26.171 [main] DEBUG org.mybatis.spring.SqlSessionFactoryBean - Parsed configuration file: 'class path resource [mybatis-config.xml]'
16:37:26.352 [main] DEBUG org.mybatis.spring.SqlSessionFactoryBean - Parsed mapper file: 'file [D:\mywork\shops\target\classes\mapper\AreaDao.xml]'
16:37:26.366 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'areaDao’
16:37:26.539 [main] DEBUG org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate - Storing ApplicationContext in cache under key [[MergedContextConfiguration@dd05255 testClass = AreDaoTest, locations = ‘{classpath:spring/spring-dao.xml}’, classes = ‘{}’, contextInitializerClasses = ‘[]’, activeProfiles = ‘{}’, propertySourceLocations = ‘{}’, propertySourceProperties = ‘{}’, contextCustomizers = set[[empty]], contextLoader = ‘org.springframework.test.context.support.DelegatingSmartContextLoader’, parent = [null]]]
16:37:26.540 [main] DEBUG org.springframework.test.context.cache - Spring test ApplicationContext cache statistics: [DefaultContextCache@6105f8a3 size = 1, maxSize = 32, parentContextCount = 0, hitCount = 0, missCount = 1]
16:37:26.554 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test method: context [DefaultTestContext@7e6f74c testClass = AreDaoTest, testInstance = shops.dao.AreDaoTest@3eb25e1a, testMethod = testQueryArea@AreDaoTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@dd05255 testClass = AreDaoTest, 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].
16:37:26.568 [main] DEBUG org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession
16:37:26.573 [main] DEBUG org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@181d7f28] was not registered for synchronization because synchronization is not active
16:37:26.582 [main] DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource
7月 26, 2019 4:37:26 下午 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 -> 1hgeby9a4clrhx51wbramc|77d2e85, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.cj.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hgeby9a4clrhx51wbramc|77d2e85, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://lcoalhost:3306/shop?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false, 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 ]
16:37:36.632 [main] DEBUG org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@181d7f28]
16:37:36.633 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - After test method: context [DefaultTestContext@7e6f74c testClass = AreDaoTest, testInstance = shops.dao.AreDaoTest@3eb25e1a, testMethod = testQueryArea@AreDaoTest, testException = org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.

The error may exist in file [D:\mywork\shops\target\classes\mapper\AreaDao.xml]

The error may involve dao.AreaDao.queryArea

The error occurred while executing a query

Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out., mergedContextConfiguration = [MergedContextConfiguration@dd05255 testClass = AreDaoTest, 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].

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.

The error may exist in file [D:\mywork\shops\target\classes\mapper\AreaDao.xml]

The error may involve dao.AreaDao.queryArea

The error occurred while executing a query

Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.

at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:78)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)
at com.sun.proxy.$Proxy18.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:223)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:57)
at com.sun.proxy.$Proxy19.queryArea(Unknown Source)
at shops.dao.AreDaoTest.testQueryArea(AreDaoTest.java:18)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Caused by: org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.

The error may exist in file [D:\mywork\shops\target\classes\mapper\AreaDao.xml]

The error may involve dao.AreaDao.queryArea

The error occurred while executing a query

Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
... 37 more

Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:81)
at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:80)
at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:67)
at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:336)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:85)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
… 43 more
Caused by: java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:65)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:527)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:157)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78)
… 53 more
Caused by: com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@e36bb2a – timeout at awaitAvailable()
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1317)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)
… 57 more

16:37:36.645 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - After test class: context [DefaultTestContext@7e6f74c testClass = AreDaoTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@dd05255 testClass = AreDaoTest, 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].
16:37:36.651 [Thread-0] DEBUG org.springframework.context.support.GenericApplicationContext - Closing org.springframework.context.support.GenericApplicationContext@41a2befb, started on Fri Jul 26 16:37:24 CST 2019

Process finished with exit code -1

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

2回答

翔仔 2019-07-27 00:26:07

同学好,请先确保你的本地的mysql客户端能通过你的项目一模一样的配置,也就是和jdbc.properties里面的host 端口 帐号 密码一致的情况下,能手工连上数据库。

其次,如果你的mysql客户端能够按照上面说的你的项目的配置连上数据库,再看看是不是你用的mysql8,如果是的话 pom.xml里面的 mysql-connector-java也得升级到最新版,才能兼容最新版本的mysql驱动 

<dependency>

<groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>

<version>8.0.16</version>

</dependency>


0 回复 有任何疑惑可以回复我~
  • 提问者 慕容3299777 #1
    配置改了之后还是一样唉,还是连接不上
    回复 有任何疑惑可以回复我~ 2019-07-27 13:31:56
  • 翔仔 回复 提问者 慕容3299777 #2
    同学用的是不是mysql8?感觉还是数据库版本和c3p0版本以及数据库驱动版本不兼容的问题,可以参照我们后面的章节,也就是升级以支持mysql8的驱动配置试试
    回复 有任何疑惑可以回复我~ 2019-07-27 23:31:16
qq_大寒_2 2019-07-26 19:50:27

感觉是AreaDao.xml文件映射出错,导致查询异常,最终导致数据库链接超时


0 回复 有任何疑惑可以回复我~
  • 提问者 慕容3299777 #1
    <?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="dao.AreaDao">
        <select id="queryArea" resultType="entity.Area">
            select area_id,area_name,priority,create_time,last_edit_time
            from tb_area order by priority desc;
        </select>
    </mapper>
    我是这么配的
    回复 有任何疑惑可以回复我~ 2019-07-26 21:09:20
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信