MyBatis-plus 数据库中对应表未找到

问题:

org.springframework.jdbc.BadSqlGrammarException:

Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table ‘mp.employee’ doesn’t exist

The error may involve com.ezerbel.mp.mapper.EmployeeMapper.insert-Inline

The error occurred while setting parameters

SQL: INSERT INTO employee ( last_name, email, gender, age ) VALUES ( ?, ?, ?, ? )

Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table ‘mp.employee’ doesn’t exist

; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table ‘mp.employee’ doesn’t exist
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate S q l S e s s i o n I n t e r c e p t o r . i n v o k e ( S q l S e s s i o n T e m p l a t e . j a v a : 446 ) a t c o m . s u n . p r o x y . SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) at com.sun.proxy. SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)atcom.sun.proxy.Proxy10.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:278)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
at com.sun.proxy.$Proxy13.insert(Unknown Source)
at com.ezerbel.mp.test.TestMP.testCommonInsert(TestMP.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner 2. e v a l u a t e ( P a r e n t R u n n e r . j a v a : 222 ) a t o r g . j u n i t . r u n n e r s . P a r e n t R u n n e r . r u n ( P a r e n t R u n n e r . j a v a : 292 ) a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t 4. r u n n e r . J U n i t 4 T e s t R e f e r e n c e . r u n ( J U n i t 4 T e s t R e f e r e n c e . j a v a : 86 ) a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t . r u n n e r . T e s t E x e c u t i o n . r u n ( T e s t E x e c u t i o n . j a v a : 38 ) a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t . r u n n e r . R e m o t e T e s t R u n n e r . r u n T e s t s ( R e m o t e T e s t R u n n e r . j a v a : 538 ) a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t . r u n n e r . R e m o t e T e s t R u n n e r . r u n T e s t s ( R e m o t e T e s t R u n n e r . j a v a : 760 ) a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t . r u n n e r . R e m o t e T e s t R u n n e r . r u n ( R e m o t e T e s t R u n n e r . j a v a : 460 ) a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t . r u n n e r . R e m o t e T e s t R u n n e r . m a i n ( R e m o t e T e s t R u n n e r . j a v a : 206 ) C a u s e d b y : c o m . m y s q l . j d b c . e x c e p t i o n s . j d b c 4. M y S Q L S y n t a x E r r o r E x c e p t i o n : T a b l e ′ m p . e m p l o y e e ′ d o e s n ′ t e x i s t a t s u n . r e f l e c t . N a t i v e C o n s t r u c t o r A c c e s s o r I m p l . n e w I n s t a n c e 0 ( N a t i v e M e t h o d ) a t s u n . r e f l e c t . N a t i v e C o n s t r u c t o r A c c e s s o r I m p l . n e w I n s t a n c e ( U n k n o w n S o u r c e ) a t s u n . r e f l e c t . D e l e g a t i n g C o n s t r u c t o r A c c e s s o r I m p l . n e w I n s t a n c e ( U n k n o w n S o u r c e ) a t j a v a . l a n g . r e f l e c t . C o n s t r u c t o r . n e w I n s t a n c e ( U n k n o w n S o u r c e ) a t c o m . m y s q l . j d b c . U t i l . h a n d l e N e w I n s t a n c e ( U t i l . j a v a : 404 ) a t c o m . m y s q l . j d b c . U t i l . g e t I n s t a n c e ( U t i l . j a v a : 387 ) a t c o m . m y s q l . j d b c . S Q L E r r o r . c r e a t e S Q L E x c e p t i o n ( S Q L E r r o r . j a v a : 941 ) a t c o m . m y s q l . j d b c . M y s q l I O . c h e c k E r r o r P a c k e t ( M y s q l I O . j a v a : 3870 ) a t c o m . m y s q l . j d b c . M y s q l I O . c h e c k E r r o r P a c k e t ( M y s q l I O . j a v a : 3806 ) a t c o m . m y s q l . j d b c . M y s q l I O . s e n d C o m m a n d ( M y s q l I O . j a v a : 2470 ) a t c o m . m y s q l . j d b c . M y s q l I O . s q l Q u e r y D i r e c t ( M y s q l I O . j a v a : 2617 ) a t c o m . m y s q l . j d b c . C o n n e c t i o n I m p l . e x e c S Q L ( C o n n e c t i o n I m p l . j a v a : 2550 ) a t c o m . m y s q l . j d b c . P r e p a r e d S t a t e m e n t . e x e c u t e I n t e r n a l ( P r e p a r e d S t a t e m e n t . j a v a : 1861 ) a t c o m . m y s q l . j d b c . P r e p a r e d S t a t e m e n t . e x e c u t e ( P r e p a r e d S t a t e m e n t . j a v a : 1192 ) a t c o m . m c h a n g e . v 2. c 3 p 0. i m p l . N e w P r o x y P r e p a r e d S t a t e m e n t . e x e c u t e ( N e w P r o x y P r e p a r e d S t a t e m e n t . j a v a : 67 ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e 0 ( N a t i v e M e t h o d ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e ( U n k n o w n S o u r c e ) a t s u n . r e f l e c t . D e l e g a t i n g M e t h o d A c c e s s o r I m p l . i n v o k e ( U n k n o w n S o u r c e ) a t j a v a . l a n g . r e f l e c t . M e t h o d . i n v o k e ( U n k n o w n S o u r c e ) a t o r g . a p a c h e . i b a t i s . l o g g i n g . j d b c . P r e p a r e d S t a t e m e n t L o g g e r . i n v o k e ( P r e p a r e d S t a t e m e n t L o g g e r . j a v a : 59 ) a t c o m . s u n . p r o x y . 2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:292) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206) Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'mp.employee' doesn't exist at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:404) at com.mysql.jdbc.Util.getInstance(Util.java:387) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:941) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3870) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3806) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2470) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2617) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2550) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861) at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1192) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59) at com.sun.proxy. 2.evaluate(ParentRunner.java:222)atorg.junit.runners.ParentRunner.run(ParentRunner.java:292)atorg.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)atorg.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)Causedby:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:Tablemp.employeedoesntexistatsun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeMethod)atsun.reflect.NativeConstructorAccessorImpl.newInstance(UnknownSource)atsun.reflect.DelegatingConstructorAccessorImpl.newInstance(UnknownSource)atjava.lang.reflect.Constructor.newInstance(UnknownSource)atcom.mysql.jdbc.Util.handleNewInstance(Util.java:404)atcom.mysql.jdbc.Util.getInstance(Util.java:387)atcom.mysql.jdbc.SQLError.createSQLException(SQLError.java:941)atcom.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3870)atcom.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3806)atcom.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2470)atcom.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2617)atcom.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2550)atcom.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)atcom.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1192)atcom.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:67)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59)atcom.sun.proxy.Proxy16.execute(Unknown Source)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
… 29 more

解决

使用@TableName注解

在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值