Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:求帮助

log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.LogFactory).

log4j:WARN Please initialize the log4j system properly.

log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:

The last packet successfully received from the server was 11,979 milliseconds ago. The last packet sent successfully to the server was 11,969 milliseconds ago.

The error may exist in pojo/CustomerMapper.xml

The error may involve pojo.Customer.findCustomerById

The error occurred while executing a query

The last packet successfully received from the server was 11,979 milliseconds ago. The last packet sent successfully to the server was 11,969 milliseconds ago.

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 org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:76)

at test.MybatisTest.main(MybatisTest.java:29)

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 11,979 milliseconds ago. The last packet sent successfully to the server was 11,969 milliseconds ago.

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl

The error may exist in pojo/CustomerMapper.xml
The error may involve pojo.Customer.findCustomerById
The error occurred while executing a query
Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
看下提示的地方findCustomerById
你先测试一下数据库驱动,是否能和数据库建立连接

Communications link failure,数据库连接失败,请检查mysql是否正常启动。