mybatis session.selectOne(key,value)问题

各位大神们,mybatis session.selectOne(key,value)调用xml的sql语句无返回值,怎么回事?
情况是这样的,今天领导给我一个完成的项目代码,是用spring,struts,mybatis编写的java项目,让我把里面连接的sqlserver数据库改为连接mysql,改完连接的驱动,用户名,密码之后,运行发现连接不上,数据库没问题,看完各种逻辑代码之后,发现是使用到了session.selectOne()方法时无法从数据库查询到的数据返回,不知什么原因,这问题困扰了我一整天,实在没办法,请各位有相关经验的高手指点指点,本人之前没接触过mybatis,请各位帮我解答,小弟万分感谢!!!!

4个回答

selectOne()我大约记得这个函数好像是mybatis的查询中用到的

qq_30408111
二三三 回复anjing1001: 你可以用mybatis的你想工程试试
接近 4 年之前 回复
lcz3607
anjing1001 就是用这个来查询的,最有可能的是配置文件出现问题,但是配置文件我有不懂,不敢乱改,也不知道怎么还!所以很迷茫,网上看了好久,也没个有用的!
接近 4 年之前 回复

既然数据库连接不上,那么session.selectOne()这段代码就不可能正确执行的。运行过程中有什么异常信息么?
贴出来看看。建议找过简单的mybatis的demo,对照各个步骤检查下你的代码。主要就是数据库相关配置,sql映射配置,实体类,DAO实现类。仔细找找问题所在。

lcz3607
anjing1001 数据库没问题,sql语句我也跑过,没问题,数据库连接,我测试过,也没问题
接近 4 年之前 回复

2016-03-29 13:55:25,699 DEBUG (Slf4jImpl.java:47) - Creating a new SqlSession
2016-03-29 13:55:25,699 DEBUG (Slf4jImpl.java:47) - Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1248d56]
2016-03-29 13:55:25,714 DEBUG (Slf4jImpl.java:47) - JDBC Connection [jdbc:mysql://127.0.0.1:3306/TDSZ_DIMS, UserName=root@localhost, MySQL-AB JDBC Driver] will be managed by Spring
2016-03-29 13:55:25,714 DEBUG (Slf4jImpl.java:47) - ooo Using Connection [jdbc:mysql://127.0.0.1:3306/TDSZ_DIMS, UserName=root@localhost, MySQL-AB JDBC Driver]
2016-03-29 13:55:25,714 DEBUG (PaginationInterceptor.java:77) - 列表查询。
2016-03-29 13:55:25,714 DEBUG (CommonsLogger.java:68) - Entering nullPropertyValue [target=[{CON_PAGE_RESULT_VALUE_KEY=login, com.opensymphony.xwork2.util.OgnlValueStack.MAP_IDENTIFIER_KEY=}, com.tydic.immanage.login.action.LoginAction@1c1576e, com.opensymphony.xwork2.DefaultTextProvider@b84fd7], property=CON_REQUEST_RUNTIME_SQL_KEY]
2016-03-29 13:55:25,714 DEBUG (Slf4jImpl.java:47) - ==> Preparing: select * from MHC_SYS_STAFF_INFO t where LOGIN_CODE = ? and PASSWORD = ? and STATE = '10A'
2016-03-29 13:55:25,714 DEBUG (Slf4jImpl.java:47) - ==> Parameters: lvcaijiang(String), e3c2e2fedd76daef3caec412a1685e1a(String)
2016-03-29 13:55:25,714 DEBUG (Slf4jImpl.java:47) - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1248d56]

selectOne调用了selectList方法,当selectList方法返回值的size小于1 的时候,selectOne方法会返回null值,这边就会出现空指针的问题

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Mybatis Plus 的 selectOne一直报错,说sql语法有问题,然而我没有进行mapper拓展啊,咋就有问题了?
![图片说明](https://img-ask.csdn.net/upload/202002/09/1581177656_966381.png) **第一张表(ItemType)一直报错,后面两张表没错误,我的数据库表设计没问题啊。** 上错误信息: ``` org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order FROM item_type WHERE (id = 2)' at line 1 ### The error may exist in com/kuanggong/demo/mapper/ItemTypeMapper.java (best guess) ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: SELECT id,pid,type_name,order FROM item_type WHERE (id = ?) ### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order FROM item_type WHERE (id = 2)' at line 1 ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order FROM item_type WHERE (id = 2)' at line 1 at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:235) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:88) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440) at com.sun.proxy.$Proxy109.selectOne(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:159) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:108) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:96) at com.sun.proxy.$Proxy136.selectOne(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy137.selectOne(Unknown Source) at com.kuanggong.demo.DemoApplicationTests.ceshi(DemoApplicationTests.java:55) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) 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: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order FROM item_type WHERE (id = 2)' at line 1 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:974) at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:391) at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:494) at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64) at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63) at com.sun.proxy.$Proxy189.query(Unknown Source) at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doQuery(MybatisSimpleExecutor.java:67) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:155) at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:90) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:76) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426) ... 47 more ```
Mybatis提示Cannot find class [org.mybatis.spring.mapper.MapperScannerConfigurer]
如题:mybatis提示如下异常,是什么原因? by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.mybatis.spring.mapper.MapperScannerConfigurer] for bean with name 'org.mybatis.spring.mapper.MapperScannerConfigurer#0' defined in class path resource [applicationContext-mybatis.xml]; nested exception is java.lang.ClassNotFoundException: org.mybatis.spring.mapper.MapperScannerConfigurer mybatis相关配置: <!-- scan for mappers and let them be autowired --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.hft.dal.mapper" /> <property name="markerInterface" value="com.hft.dal.SqlMapper" /> </bean>
异常org.mybatis.spring.MyBatisSystemException:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for InvestorMapper.listInvestor ### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for InvestorMapper.listInvestor at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:364) at $Proxy5.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:194) at models.Dao.findForList(Dao.java:148) at controllers.BusiTzNetvalController.listInvestor(BusiTzNetvalController.java:33) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:546) at play.mvc.ActionInvoker.invoke(ActionInvoker.java:500) at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:476) at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:471) at play.mvc.ActionInvoker.invoke(ActionInvoker.java:159) at play.server.PlayHandler$NettyInvocation.execute(PlayHandler.java:220) at play.Invoker$Invocation.run(Invoker.java:265) at play.server.PlayHandler$NettyInvocation.run(PlayHandler.java:200) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for InvestorMapper.listInvestor ### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for InvestorMapper.listInvestor at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:107) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:354) ... 24 more Caused by: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for InvestorMapper.listInvestor at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:768) at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:603) at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:596) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:103) ... 30 more
myBatis3.x 如何调用 存储过程?
myBatis 映射 xml 文件里 好像 好像 没有 类似于 ibatis 2.x 中 <procedure>的标签 来支持 存储过程 请问 使用 myBatis 3.x 应该怎么 实现 对存储过程的 调用??
Mybatis 3.4.4批量插入时当使用IGNORE重复忽略时,返回的id错乱
Mybatis 3.4.4批量插入时当使用IGNORE重复忽略时,返回的id错乱 比如 数据库原有3条数据 pid时唯一键,id为主键 id--pid--name 1--01--test 2--02--test 3--03--test 然后插入3条数据 02--test 04--test 05--test 理解上的正确返回到对象里的id应该是 null--02--test 4--04--test 5--05--test 但是返回的对象里的id确是 4--02--test 5--04--test null--05--test 求大神指点
myBatis3.0.6+Spring3.0.6框架整合
今天从网上自学搭建springMVC+myBatis框架,根据文档一步一步的整合报如下错误 [code="java"] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in ServletContext resource [/WEB-INF/classes/ApplicationContext.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/main/java/com/myBatis/MyBatis_contextConfig.xml] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:578) 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.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/main/java/com/myBatis/MyBatis_contextConfig.xml] at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:117) at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:286) at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:268) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 36 more 2012-2-7 15:11:59 org.apache.catalina.core.StandardContext listenerStart 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in ServletContext resource [/WEB-INF/classes/ApplicationContext.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/main/java/com/myBatis/MyBatis_contextConfig.xml] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:578) 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.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/main/java/com/myBatis/MyBatis_contextConfig.xml] at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:117) at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:286) at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:268) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 36 more 2012-2-7 15:11:59 org.apache.catalina.core.StandardContext start [/code] 找不到MyBatis_contextConfig.xml文件。编译过后的MyBatis_contextConfig.xml在WEB-INF/classes/目录下。路径我也些了但是还报错。 以下是spring配置文件 [code="java"] <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <!-- spring配置文件 --> <!--读取connectJDBC.properties文件所在的位置 --> <bean class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"> <property name="locations" value="WEB-INF/classes/connectJDBC.properties"> </property> </bean> <!-- 读取connectJDBC.properties文件,配置数据源 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc_driver}"></property> <property name="url" value="${jdbc_url}"></property> <property name="username" value="${jdbc_userName}"></property> <property name="password" value="${jdbc_passWord}"></property> <!-- 数据库连接池配置 --> </bean> <!-- 这个地方开始放置所有bean的配置信息 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="configLocation" value="main/java/com/myBatis/MyBatis_contextConfig.xml"></property> <property name="dataSource" ref="dataSource"></property> </bean> </beans> [/code] 以下是MyBatis 和mapper配置文件 [code="java"] <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD SQL Map Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <!-- 为类起个别名 --> <typeAliases> <typeAlias alias="TestTableEntity" type="main.java.com.entity.TestTable" /> </typeAliases> <!-- 加载myBatis中实体类的sql映射语句文件 --> <mappers> <mapper resource="main/java/com/mapper/TestTableMapper.xml" /> </mappers> </configuration> [/code] [code="java"] <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd"> <!--namespace的作用是为这张表取一个名字--> <mapper namespace="main.java.com.dao.ITestTableMapper"> <!-- 数据库映射 --> <resultMap type="TestTableEntity" id="testtable"> <id column="id" property="id"/> <result column="name" property="name" /> </resultMap> <!-- sql 操作语句 --> <!-- 添加一条心记录 --> <insert id="doInsert" parameterType="TestTable"> insert into testtable(name) value(#{name}) </insert> </mapper> [/code] 三个配置文件都在上面。请各位帮忙看看那里出错了。早上弄了一早上都没弄好。头疼的。
Mybatis Mapper.selectByPrimaryKey 不响应
目前在做宜立方项目,先上代码吧 ![图片说明](https://img-ask.csdn.net/upload/202001/14/1578986455_358050.png) 我自己测试了一下容器和xml文件是否正确,这个测试到是成功的 然后解除下面2行注释: ![图片说明](https://img-ask.csdn.net/upload/202001/14/1578986638_830179.png) 再进行测试的时候就一直卡在哪里不动,也不知道什么原因! 之后又去创建了一个web动态工程来进行测试,结果能响应输出结果! 我就在猜想是否是因为跟这个Maven是否没有创建好,因为它这个还涉及到一些子模块所以牵涉的东西就比较难了!!! 各路高手指点一下,,,,哎,卡了几天了!!第一次做搞项目哎!!
springboot gradle mybatis MapperScan.factoryBean()异常
异常 ``` Caused by: java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.mybatis.spring.annotation.MapperScan.factoryBean() at java.lang.reflect.Method.getDefaultValue(Method.java:612) ~[na:1.8.0_131] at org.springframework.core.annotation.AnnotationUtils.registerDefaultValues(AnnotationUtils.java:1258) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] ``` 配置: ``` @Configuration @MapperScan(basePackages = EntMasterDataSourceConfig.BASE_PACKAGE, sqlSessionFactoryRef = "entMasterSqlSessionFactory") public class EntMasterDataSourceConfig { static final String BASE_PACKAGE = "com.sunlands.entmaster"; static final String MAPPER_LOCATION = "classpath:/*.xml"; @Value("${spring.datasource.ent_master.url}") private String dbUrl; @Value("${spring.datasource.ent_master.username}") private String dbUser; @Value("${spring.datasource.ent_master.password}") private String dbPassword; @Value("${spring.datasource.driver-class-name}") private String dbDriver; /** * 配置数据数据源 master * * @return */ @Bean(name = "entMasterDatasource") @Primary public DataSource masterDatasource() { DruidDataSource dataSource = new DruidDataSource(); dataSource.setDriverClassName(dbDriver); dataSource.setUrl(dbUrl); dataSource.setUsername(dbUser); dataSource.setPassword(dbPassword); //连接池启动时创建的初始化连接数量 dataSource.setInitialSize(1); //连接池中可同时连接的最大的连接数 dataSource.setMaxActive(100); //连接池中最小的空闲的连接数,低于这个数量会被创建新的连接 dataSource.setMinIdle(5); //最大等待时间,当没有可用连接时,连接池等待连接释放的最大时间,超过该时间限制会抛出异常,如果设置-1表示无限等待 dataSource.setMaxWait(60000); //超过removeAbandonedTimeout时间后,是否进 行没用连接(废弃)的回收(默认为false,调整为true) dataSource.setRemoveAbandoned(true); //超过时间限制,回收没有用(废弃)的连接(默认为 300秒,调整为180) dataSource.setRemoveAbandonedTimeout(180); //默认提交 dataSource.setDefaultAutoCommit(true); //打开检查,用异步线程evict进行检查 dataSource.setTestWhileIdle(true); //就是在进行borrowObject进行处理时,对拿到的connection进行validateObject校验 dataSource.setTestOnBorrow(false); //就是在进行returnObject对返回的connection进行validateObject校验,个人觉得对数据库连接池的管理意义不大 dataSource.setTestOnReturn(false); // 代表检查的sql dataSource.setValidationQuery("select 1 from dual"); //代表在执行检查时,通过statement设置,statement.setQueryTimeout(validationQueryTimeout) dataSource.setValidationQueryTimeout(1); dataSource.setTimeBetweenEvictionRunsMillis(30000); return dataSource; } /** * 配置session工厂 * * @param entMasterDatasource * @return * @throws Exception */ @Bean(name = "entMasterSqlSessionFactory") @Primary public SqlSessionFactory masterSqlSessionFactory(@Qualifier("entMasterDatasource") DataSource entMasterDatasource) throws Exception { final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); sessionFactory.setDataSource(entMasterDatasource); sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver() .getResources(EntMasterDataSourceConfig.MAPPER_LOCATION)); return sessionFactory.getObject(); } /** * 配置事务管理器 * * @param dataSource * @return */ @Bean(name = "entMasterTransactionManger") @Primary public DataSourceTransactionManager masterTransactionManger(@Qualifier("entMasterDatasource") DataSource dataSource) { return new DataSourceTransactionManager(dataSource); } } ``` gradle springboot是2.1.0 ``` dependencies { implementation('org.springframework.boot:spring-boot-starter-web') providedRuntime('org.springframework.boot:spring-boot-starter-tomcat') testImplementation('org.springframework.boot:spring-boot-starter-test') compile group: 'org.springframework.boot', name: 'spring-boot-starter', version: '2.1.0.RELEASE' compile group: 'com.alibaba', name: 'fastjson', version: '1.2.51' compile group: 'com.alibaba', name: 'druid', version: '1.1.12' compile group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc', version: '2.1.0.RELEASE' compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1' compile group: 'mysql', name: 'mysql-connector-java', version:'5.1.34' compile group: 'org.mybatis.spring.boot', name: 'mybatis-spring-boot-starter', version: '1.3.2' compile group: 'org.mybatis', name: 'mybatis-spring', version: '1.3.2' compile group: 'org.springframework', name: 'spring-jdbc', version: '5.1.2.RELEASE' compile group: 'org.springframework', name: 'spring-orm', version: '5.1.2.RELEASE' compile group: 'org.mybatis', name: 'mybatis', version: '3.4.6' } ```
mybatis session 手动提交
1、拿到Mybatis的session,设置手动提交 2、批量插入数据 3、设置session.commit 4、异常的话就session.rollback 5、关闭session 现在的问题是我有一批数据,比如100条,前50条是正确的,从第51条开始有异常数据导致入库失败,正常情况应该是这100条数据都不应该入库,但是目前的结果是前50条正常的数据已经入库成功了,麻烦各位大神解释下为什么会出现这种情况,已经如何解决,谢谢!
spring整合mybatis时,student.java只构建有参构造函数为什么会报如下错误,加了无参构造错误就会消失
log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment). 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.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.entity.Student with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.entity.Student.<init>() at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) at com.sun.proxy.$Proxy1.selectOne(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43) at com.sun.proxy.$Proxy2.QueryStudentByPid(Unknown Source) at com.mapper.impl.StudentMapperImpl.QueryStudentByPid(StudentMapperImpl.java:15) at com.service.impl.QueryServiceImpl.QuerServiceStudent(QueryServiceImpl.java:18) at com.test.main(test.java:13) Caused by: org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.entity.Student with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.entity.Student.<init>() at org.apache.ibatis.reflection.factory.DefaultObjectFactory.instantiateClass(DefaultObjectFactory.java:83) at org.apache.ibatis.reflection.factory.DefaultObjectFactory.create(DefaultObjectFactory.java:45) at org.apache.ibatis.reflection.factory.DefaultObjectFactory.create(DefaultObjectFactory.java:38) at org.apache.ibatis.executor.resultset.FastResultSetHandler.createResultObject(FastResultSetHandler.java:386) at org.apache.ibatis.executor.resultset.FastResultSetHandler.createResultObject(FastResultSetHandler.java:365) at org.apache.ibatis.executor.resultset.FastResultSetHandler.getRowValue(FastResultSetHandler.java:261) at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleRowValues(FastResultSetHandler.java:216) at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSet(FastResultSetHandler.java:188) at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSets(FastResultSetHandler.java:154) at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:57) at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:70) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:57) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:62) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) ... 8 more Caused by: java.lang.NoSuchMethodException: com.entity.Student.<init>() at java.lang.Class.getConstructor0(Class.java:3082) at java.lang.Class.getDeclaredConstructor(Class.java:2178) at org.apache.ibatis.reflection.factory.DefaultObjectFactory.instantiateClass(DefaultObjectFactory.java:57) ... 31 more
spring2.5可以整合mybatis3.0.4吗
之前做过spring3整合mybatis的demo,但是现在项目要求spring2.5,在网上查了好多信息,基本没有这部分内容,不知道spring2.5可以整合mybatis么?是否也需要mybatis-spring.jar?给点相应的文章或者小demo参考下,谢谢~
一个事务里面执行两个insert 语句 只有后面一个insert 被commit,请问大神怎么回事?
org.mybatis.spring.SqlSessionUtils 97 getSqlSession - Creating a new SqlSession org.mybatis.spring.SqlSessionUtils 128 registerSessionHolder - Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] org.mybatis.spring.transaction.SpringManagedTransaction 87 openConnection - JDBC Connection [1784195322, URL=jdbc:sqlserver://192.168.11.2:11433;authentication=NotSpecified;authenticationScheme=nativeAuthentication;xopenStates=false;sendTimeAsDatetime=true;trustServerCertificate=false;TransparentNetworkIPResolution=true;serverNameAsACE=false;sendStringParametersAsUnicode=true;selectMethod=direct;responseBuffering=adaptive;packetSize=8000;multiSubnetFailover=false;loginTimeout=15;lockTimeout=-1;lastUpdateCount=true;encrypt=false;disableStatementPooling=true;databaseName=zyscm;columnEncryptionSetting=Disabled;applicationName=Microsoft JDBC Driver for SQL Server;applicationIntent=readwrite;, UserName=sa, Microsoft JDBC Driver 6.0 for SQL Server] will be managed by Spring org.apache.ibatis.logging.jdbc.BaseJdbcLogger 159 debug - ==> Preparing: {call P_SYS_GET_FNO (?,?)} org.apache.ibatis.logging.jdbc.BaseJdbcLogger 159 debug - ==> Parameters: PI(String) org.mybatis.spring.SqlSessionUtils 186 closeSqlSession - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] org.mybatis.spring.SqlSessionUtils 163 sessionHolder - Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] from current transaction org.mybatis.spring.SqlSessionUtils 186 closeSqlSession - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] org.mybatis.spring.SqlSessionUtils 163 sessionHolder - Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] from current transaction org.apache.ibatis.logging.jdbc.BaseJdbcLogger 159 debug - ==> Preparing: {call P_SYS_GET_FID (?)} org.apache.ibatis.logging.jdbc.BaseJdbcLogger 159 debug - ==> Parameters: org.mybatis.spring.SqlSessionUtils 186 closeSqlSession - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] org.mybatis.spring.SqlSessionUtils 163 sessionHolder - Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] from current transaction org.apache.ibatis.logging.jdbc.BaseJdbcLogger 159 debug - ==> Preparing: INSERT INTO T_IM_PURINMT(FID,FNUMBER,FDATE,FSALEMANID,FSTATUS,FREMARK,FCREATEUSERID,FLASTUPDATEUSERID) (SELECT ?,?,?,?,?,?,?,?) org.apache.ibatis.logging.jdbc.BaseJdbcLogger 159 debug - ==> Parameters: 90000000000096(String), PI0000000095(String), 2019-07-10(String), U2NQUFIMMSK(String), 1(String), 4444(String), U2NQUFIMMSK(String), U2NQUFIMMSK(String) org.apache.ibatis.logging.jdbc.BaseJdbcLogger 159 debug - <== Updates: 1 org.mybatis.spring.SqlSessionUtils 186 closeSqlSession - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] org.mybatis.spring.SqlSessionUtils 163 sessionHolder - Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] from current transaction org.mybatis.spring.SqlSessionUtils 186 closeSqlSession - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] org.mybatis.spring.SqlSessionUtils 163 sessionHolder - Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] from current transaction org.apache.ibatis.logging.jdbc.BaseJdbcLogger 159 debug - ==> Preparing: {call P_SYS_GET_FID (?)} org.apache.ibatis.logging.jdbc.BaseJdbcLogger 159 debug - ==> Parameters: org.mybatis.spring.SqlSessionUtils 186 closeSqlSession - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] org.mybatis.spring.SqlSessionUtils 163 sessionHolder - Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] from current transaction org.apache.ibatis.logging.jdbc.BaseJdbcLogger 159 debug - ==> Preparing: INSERT INTO T_IM_PURINDT(FID,FPARENTID,FPRODUCTID,FQTY,FPRICE,FREMARK) ( SELECT ?,?,?,?,?,? ) org.apache.ibatis.logging.jdbc.BaseJdbcLogger 159 debug - ==> Parameters: 90000000000097(String), 90000000000096(String), 90000000000045(String), 4444.00(BigDecimal), 4444.00(String), 4444(String) org.apache.ibatis.logging.jdbc.BaseJdbcLogger 159 debug - <== Updates: 1 org.mybatis.spring.SqlSessionUtils 186 closeSqlSession - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] org.mybatis.spring.SqlSessionUtils$SqlSessionSynchronization 284 beforeCommit - Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] org.mybatis.spring.SqlSessionUtils$SqlSessionSynchronization 310 beforeCompletion - Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7387309a] org.mybatis.spring.SqlSessionUtils$SqlSessionSynchronization 315 beforeCompletion - Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@73873
“产品名”相同的数据记录有多条,java用getByProName()查询报错
BUG: 数据库中产品名相同的记录有多条,当调用getByProName() 时会得到不止一条该“产品名”的数据记录,会报错 单元测试方法: @Test public void testQueryByProName() { String proName = "小王子饼干"; Products products = productsDao.queryByProName(proName); System.out.println("产品名: " + products.getProName()); System.out.println("信息: " + products); // log.info("products ={} ", products); } 报错: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 6 at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371) at com.sun.proxy.$Proxy13.selectOne(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:163) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) at com.sun.proxy.$Proxy14.queryByProName(Unknown Source) at cn.syy.test.dao.ProductsDaoTest.testQueryByProName(ProductsDaoTest.java:43) Caused by: org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 6 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:70) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358) ... 35 more ------- 然后我的解决思路:把返回的多条proname相同的数据记录放到List里,遍历输出,单元测试依然报错(相同的错) 修改单元测试方法: @Test public void testQueryByProName() { String proName = "小王子饼干"; List<Products> list = (List<Products>) productsDao.queryByProName(proName); for(Products p : list){ System.out.println("产品名: " + p.getProName()); System.out.println("信息: " + p); } } org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 6 at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371) at com.sun.proxy.$Proxy13.selectOne(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:163) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) at com.sun.proxy.$Proxy14.queryByProName(Unknown Source) at cn.syy.test.dao.ProductsDaoTest.testQueryByProName(ProductsDaoTest.java:52) Caused by: org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 6 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:70) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358) ... 35 more 请问有啥办法能把proname相同的数据记录查询出来么?
mybatis3.3.0 查询出现的问题
首先给大家看一下代码 这个是员工实体类 ``` public class Employee { private int employee_id; //编号 private int number; //工号 private String password; //密码 private String ename; //姓名 private Position position; //职位 private Deparment department; //部门 private String status; //状态 ``` 报销单实体类 ``` public class Expense { private int expense_id; //编号 private Employee handler; //报销单处理人 private Employee creator; //报销单创建人 private Date time; //报销单创建时间 private String reason; //报销单事由 private int total; //总金额 private Stauts estauts; //报销单状态 ``` sql语句 ``` <select id="getExpenseByEmp" parameterType="Employee" resultMap="EmployeeMap"> SELECT ex.expense_id,em.ename,em2.ename FROM expense ex left join employee em on ex.creator = em.employee_id left join employee em2 on ex.handler = em2.employee_id WHERE em.employee_id = #{employee_id} </select> <resultMap type="Expense" id="EmployeeMap"> <id property="expense_id" column="expense_id" /> <association property="creator" column="creator" javaType="Employee" /> <association property="handler" column="handler" javaType="Employee"/> </resultMap> ``` 因为要用 报销单表连员工表 查询出 创建者和处理者 但是最后结果 创建者和处理者 都变成了同一个人 要不然都是创建者的名字 或者是处理者的名字 ![图片说明](https://img-ask.csdn.net/upload/201610/26/1477464778_383188.png) ![图片说明](https://img-ask.csdn.net/upload/201610/26/1477464794_597276.png) ![在数据库中运行sql语句的结果是这样的](https://img-ask.csdn.net/upload/201610/26/1477464872_931149.png) 实在找不出原因了,有没有大神来指点下! 新人求教!
MyBatis逆向工程提示javax.net.ssl.SSLException是什么问题?
请问MyBatis逆向工程提示javax.net.ssl.SSLException是什么问题?怎么解决? 错误提示: ``` Wed Jan 22 15:08:37 CST 2020 WARN: Caught while disconnecting... EXCEPTION STACK TRACE: ** BEGIN NESTED EXCEPTION ** javax.net.ssl.SSLException MESSAGE: closing inbound before receiving peer's close_notify STACKTRACE: javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:133) at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117) at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308) at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264) at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:255) at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:645) at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:624) at com.mysql.cj.protocol.a.NativeProtocol.quit(NativeProtocol.java:1284) at com.mysql.cj.NativeSession.quit(NativeSession.java:182) at com.mysql.cj.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:1911) at com.mysql.cj.jdbc.ConnectionImpl.close(ConnectionImpl.java:730) at org.mybatis.generator.config.Context.closeConnection(Context.java:535) at org.mybatis.generator.config.Context.introspectTables(Context.java:468) at org.mybatis.generator.api.MyBatisGenerator.generate(MyBatisGenerator.java:222) at org.mybatis.generator.api.MyBatisGenerator.generate(MyBatisGenerator.java:133) at GeneratorSqlmap.generator(GeneratorSqlmap.java:27) at GeneratorSqlmap.main(GeneratorSqlmap.java:33) ** END NESTED EXCEPTION ** WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.mybatis.generator.internal.DomWriter (file:/F:/SSM%e9%a1%b9%e7%9b%ae%e5%ae%9e%e6%88%98/%e7%ac%ac%e4%b8%80%e4%bb%b6%20maven%e7%ae%a1%e7%90%86%e7%9a%84ssm%e6%a1%86%e6%9e%b6(%e8%af%a6%e8%a7%a3)/e3%e5%95%86%e5%9f%8e_day01/%e9%bb%91%e9%a9%ac32%e6%9c%9f/01.%e6%95%99%e6%a1%88-3.0/01.%e5%8f%82%e8%80%83%e8%b5%84%e6%96%99/mybatis/%e9%80%86%e5%90%91%e5%b7%a5%e7%a8%8b/generatorSqlmapCustom/lib/mybatis-generator-core-1.3.2.jar) to method com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.getXmlVersion() WARNING: Please consider reporting this to the maintainers of org.mybatis.generator.internal.DomWriter 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 ``` 工程结构: ![图片说明](https://img-ask.csdn.net/upload/202001/22/1579677296_992794.png) GeneratorSqlmap类 ``` public class GeneratorSqlmap { public void generator() throws Exception{ List<String> warnings = new ArrayList<String>(); boolean overwrite = true; File configFile = new File("generatorConfig.xml"); ConfigurationParser cp = new ConfigurationParser(warnings); Configuration config = cp.parseConfiguration(configFile); DefaultShellCallback callback = new DefaultShellCallback(overwrite); MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings); myBatisGenerator.generate(null); } public static void main(String[] args) throws Exception { try { GeneratorSqlmap generatorSqlmap = new GeneratorSqlmap(); generatorSqlmap.generator(); } catch (Exception e) { e.printStackTrace(); } } } ``` generatorConfig.xml ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> <generatorConfiguration> <context id="testTables" targetRuntime="MyBatis3"> <commentGenerator> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="true" /> </commentGenerator> <!--数据库连接的信息:驱动类、连接地址、用户名、密码 --> <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/e3mall?serverTimezone=UTC" userId="root" password="root"> </jdbcConnection> <!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL 和 NUMERIC 类型解析为java.math.BigDecimal --> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- targetProject:生成PO类的位置 --> <javaModelGenerator targetPackage="cn.e3mall.pojo" targetProject=".\src"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="false" /> <!-- 从数据库返回的值被清理前后的空格 --> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- targetProject:mapper映射文件生成的位置 --> <sqlMapGenerator targetPackage="cn.e3mall.mapper" targetProject=".\src"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="false" /> </sqlMapGenerator> <!-- targetPackage:mapper接口生成的位置 --> <javaClientGenerator type="XMLMAPPER" targetPackage="cn.e3mall.mapper" targetProject=".\src"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="false" /> </javaClientGenerator> <!-- 指定数据库表 --> <table schema="" tableName="tb_content"></table> <table schema="" tableName="tb_content_category"></table> <table schema="" tableName="tb_item"></table> <table schema="" tableName="tb_item_cat"></table> <table schema="" tableName="tb_item_desc"></table> <table schema="" tableName="tb_item_param"></table> <table schema="" tableName="tb_item_param_item"></table> <table schema="" tableName="tb_order"></table> <table schema="" tableName="tb_order_item"></table> <table schema="" tableName="tb_order_shipping"></table> <table schema="" tableName="tb_user"></table> </context> </generatorConfiguration> ```
spring4.0+mybatis3.3+tomcat8.0整合出的NoClassDefFoundError一个问题
具体工程见如下地址: https://yunpan.cn/cr5AZCTwuI7pp 访问密码 e565 代码是我学习的demo,第一次做spring+mybatis的开发。 本来所有代码放在一个工程(参见附件的springMVC03_single.rar)运行都是ok的。 但是我把dao和pojo两块代码单独出一个工程后(参见附件的springMVC03_mutiproj.rar),加载就出现问题了。 加载的错误是: ![图片说明](https://img-ask.csdn.net/upload/201601/29/1454075373_508953.png) 错误调用栈信息如下: ![图片说明](https://img-ask.csdn.net/upload/201601/29/1454075359_525757.png) 初步怀疑和tomcat的webapp类加载器有关,具体tomcat的加载器原理到底是怎么样,为何会引起这个问题以及如何规避这个问题请各位大侠赐教
boot客户管理系统登录报错HTTP Status 500 – Internal Server Error
HTTP Status 500 – Internal Server Error Type 异常报告 消息 Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 描述 服务器遇到一个意外的情况,阻止它完成请求。 Exception org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES)) ### The error may exist in com/ssm/core/dao/UserDao.xml ### The error may involve com.ssm.core.dao.UserDao.findUser ### The error occurred while executing a query ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES)) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) javax.servlet.http.HttpServlet.service(HttpServlet.java:660) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) Root Cause org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES)) ### The error may exist in com/ssm/core/dao/UserDao.xml ### The error may involve com.ssm.core.dao.UserDao.findUser ### The error occurred while executing a query ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES)) org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77) org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) com.sun.proxy.$Proxy16.selectOne(Unknown Source) org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166) org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82) org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) com.sun.proxy.$Proxy22.findUser(Unknown Source) com.ssm.core.service.impl.UserServiceImpl.findUser(UserServiceImpl.java:21) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.base/java.lang.reflect.Method.invoke(Method.java:566) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) com.sun.proxy.$Proxy23.findUser(Unknown Source) com.ssm.core.web.controller.UserController.login(UserController.java:28) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.base/java.lang.reflect.Method.invoke(Method.java:566) org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) javax.servlet.http.HttpServlet.service(HttpServlet.java:660) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) Root Cause org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES)) ### The error may exist in com/ssm/core/dao/UserDao.xml ### The error may involve com.ssm.core.dao.UserDao.findUser ### The error occurred while executing a query ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES)) org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150) org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.base/java.lang.reflect.Method.invoke(Method.java:566) org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) com.sun.proxy.$Proxy16.selectOne(Unknown Source) org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166) org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82) org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) com.sun.proxy.$Proxy22.findUser(Unknown Source) com.ssm.core.service.impl.UserServiceImpl.findUser(UserServiceImpl.java:21) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.base/java.lang.reflect.Method.invoke(Method.java:566) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) com.sun.proxy.$Proxy23.findUser(Unknown Source) com.ssm.core.web.controller.UserController.login(UserController.java:28) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.base/java.lang.reflect.Method.invoke(Method.java:566) org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) javax.servlet.http.HttpServlet.service(HttpServlet.java:660) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) Root Cause org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES)) org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80) org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:82) org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:68) org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:336) org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:84) org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62) org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324) org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.base/java.lang.reflect.Method.invoke(Method.java:566) org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) com.sun.proxy.$Proxy16.selectOne(Unknown Source) org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166) org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82) org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) com.sun.proxy.$Proxy22.findUser(Unknown Source) com.ssm.core.service.impl.UserServiceImpl.findUser(UserServiceImpl.java:21) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.base/java.lang.reflect.Method.invoke(Method.java:566) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) com.sun.proxy.$Proxy23.findUser(Unknown Source) com.ssm.core.web.controller.UserController.login(UserController.java:28) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.base/java.lang.reflect.Method.invoke(Method.java:566) org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) javax.servlet.http.HttpServlet.service(HttpServlet.java:660) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) Root Cause java.sql.SQLException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES)) org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2294) org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2039) org.apache.commons.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1533) org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:82) org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:68) org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:336) org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:84) org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62) org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324) org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.base/java.lang.reflect.Method.invoke(Method.java:566) org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) com.sun.proxy.$Proxy16.selectOne(Unknown Source) org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166) org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82) org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) com.sun.proxy.$Proxy22.findUser(Unknown Source) com.ssm.core.service.impl.UserServiceImpl.findUser(UserServiceImpl.java:21) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.base/java.lang.reflect.Method.invoke(Method.java:566) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) com.sun.proxy.$Proxy23.findUser(Unknown Source) com.ssm.core.web.controller.UserController.login(UserController.java:28) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.base/java.lang.reflect.Method.invoke(Method.java:566) org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) javax.servlet.http.HttpServlet.service(HttpServlet.java:660) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) Root Cause java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835) com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455) com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240) com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199) org.apache.commons.dbcp2.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:39) org.apache.commons.dbcp2.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:256) org.apache.commons.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:2304) org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2290) org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2039) org.apache.commons.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1533) org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:82) org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:68) org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:336) org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:84) org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62) org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324) org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.base/java.lang.reflect.Method.invoke(Method.java:566) org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) com.sun.proxy.$Proxy16.selectOne(Unknown Source) org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166) org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82) org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) com.sun.proxy.$Proxy22.findUser(Unknown Source) com.ssm.core.service.impl.UserServiceImpl.findUser(UserServiceImpl.java:21) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.base/java.lang.reflect.Method.invoke(Method.java:566) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) com.sun.proxy.$Proxy23.findUser(Unknown Source) com.ssm.core.web.controller.UserController.login(UserController.java:28) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.base/java.lang.reflect.Method.invoke(Method.java:566) org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) javax.servlet.http.HttpServlet.service(HttpServlet.java:660) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ):注意 主要问题的全部 stack 信息可以在 server logs 里查看 Apache Tomcat/8.5.49
Spring5 + mybatis3.2.7 + springmvc 运行项目是报错
**Annotation @WebServlet at 'org.springframework.http.server.reactive.JettyHttpHandlerAdapter' must specify either value or urlPatterns** ![图片说明](https://img-ask.csdn.net/upload/201803/07/1520405905_721842.png)
用springboot+mybatis取出数据contant字段总是显示null(查了一下午debug没找出来)
实现类 ``` public Page<Person> getNewPersonList( Integer currentPage, Integer pageSize) { // 实例化查询条件 final PersonExample personExample = new PersonExample(); PersonExample.Criteria criteria = personExample.createCriteria(); criteria.andIsDeleteEqualTo((byte)0); // 获取查询结果集 Page<Person> result = PageHelper.startPage(currentPage, pageSize).doSelectPage(new ISelect() { @Override public void doSelect() { // personRepository.selectByExample(personExample); personRepository.selectByExample(personExample); } }); return result; } ``` 其中返回值得实体类的代码: ``` package com.ebiz.code.repository.api.entity; import java.util.Date; public class Person { /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.id * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private Integer id; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.name * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private String name; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.duty * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private String duty; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.Email * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private String email; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.phone * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private String phone; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.place * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private String place; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.is_delete * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private Byte isDelete; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.create_time * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private Date createTime; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.update_time * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private Date updateTime; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.photo * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private String photo; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.type * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private Byte type; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column ebiz_person.contant * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ private String contant; /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.id * * @return the value of ebiz_person.id * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public Integer getId() { return id; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.id * * @param id the value for ebiz_person.id * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setId(Integer id) { this.id = id; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.name * * @return the value of ebiz_person.name * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public String getName() { return name; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.name * * @param name the value for ebiz_person.name * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setName(String name) { this.name = name; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.duty * * @return the value of ebiz_person.duty * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public String getDuty() { return duty; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.duty * * @param duty the value for ebiz_person.duty * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setDuty(String duty) { this.duty = duty; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.Email * * @return the value of ebiz_person.Email * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public String getEmail() { return email; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.Email * * @param email the value for ebiz_person.Email * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setEmail(String email) { this.email = email; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.phone * * @return the value of ebiz_person.phone * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public String getPhone() { return phone; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.phone * * @param phone the value for ebiz_person.phone * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setPhone(String phone) { this.phone = phone; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.place * * @return the value of ebiz_person.place * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public String getPlace() { return place; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.place * * @param place the value for ebiz_person.place * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setPlace(String place) { this.place = place; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.is_delete * * @return the value of ebiz_person.is_delete * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public Byte getIsDelete() { return isDelete; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.is_delete * * @param isDelete the value for ebiz_person.is_delete * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setIsDelete(Byte isDelete) { this.isDelete = isDelete; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.create_time * * @return the value of ebiz_person.create_time * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public Date getCreateTime() { return createTime; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.create_time * * @param createTime the value for ebiz_person.create_time * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setCreateTime(Date createTime) { this.createTime = createTime; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.update_time * * @return the value of ebiz_person.update_time * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public Date getUpdateTime() { return updateTime; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.update_time * * @param updateTime the value for ebiz_person.update_time * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.photo * * @return the value of ebiz_person.photo * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public String getPhoto() { return photo; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.photo * * @param photo the value for ebiz_person.photo * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setPhoto(String photo) { this.photo = photo; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.type * * @return the value of ebiz_person.type * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public Byte getType() { return type; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.type * * @param type the value for ebiz_person.type * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setType(Byte type) { this.type = type; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column ebiz_person.contant * * @return the value of ebiz_person.contant * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public String getContant() { return contant; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column ebiz_person.contant * * @param contant the value for ebiz_person.contant * * @mbg.generated Sat May 11 13:04:24 CST 2019 */ public void setContant(String contant) { this.contant = contant; } } ``` 数据库图字段没写错 ![图片说明](https://img-ask.csdn.net/upload/201905/11/1557568172_353594.png)
130 个相见恨晚的超实用网站,一次性分享出来
相见恨晚的超实用网站 持续更新中。。。
终于明白阿里百度这样的大公司,为什么面试经常拿ThreadLocal考验求职者了
点击上面↑「爱开发」关注我们每晚10点,捕获技术思考和创业资源洞察什么是ThreadLocalThreadLocal是一个本地线程副本变量工具类,各个线程都拥有一份线程私...
win10系统安装教程(U盘PE+UEFI安装)
一、准备工作 u盘,电脑一台,win10原版镜像(msdn官网) 二、下载wepe工具箱 极力推荐微pe(微pe官方下载) 下载64位的win10 pe,使用工具箱制作启动U盘打开软件, 选择安装到U盘(按照操作无需更改) 三、重启进入pe系统 1、关机后,将U盘插入电脑 2、按下电源后,按住F12进入启动项选择(技嘉主板是F12) 选择需要启...
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
C语言魔塔游戏
很早就很想写这个,今天终于写完了。 游戏截图: 编译环境: VS2017 游戏需要一些图片,如果有想要的或者对游戏有什么看法的可以加我的QQ 2985486630 讨论,如果暂时没有回应,可以在博客下方留言,到时候我会看到。 下面我来介绍一下游戏的主要功能和实现方式 首先是玩家的定义,使用结构体,这个名字是可以自己改变的 struct gamerole { char n...
java源码分析 Arrays.asList()与Collections.unmodifiableList()
ArrayList支持所有的可选操作(因为一个UnsupportedOperationException异常都没有捕获到),所以要想拥有完备的功能,还是得使用ArrayList啊。 Arrays$ArrayList除了set()操作外,都不支持。 Collections$UnmodifiableRandomAccessList都不支持,名副其实的Unmodifiable不可修改。
究竟你适不适合买Mac?
我清晰的记得,刚买的macbook pro回到家,开机后第一件事情,就是上了淘宝网,花了500元钱,找了一个上门维修电脑的师傅,上门给我装了一个windows系统。。。。。。 表砍我。。。 当时买mac的初衷,只是想要个固态硬盘的笔记本,用来运行一些复杂的扑克软件。而看了当时所有的SSD笔记本后,最终决定,还是买个好(xiong)看(da)的。 已经有好几个朋友问我mba怎么样了,所以今天尽量客观...
Python爬虫爬取淘宝,京东商品信息
小编是一个理科生,不善长说一些废话。简单介绍下原理然后直接上代码。 使用的工具(Python+pycharm2019.3+selenium+xpath+chromedriver)其中要使用pycharm也可以私聊我selenium是一个框架可以通过pip下载 pip installselenium -ihttps://pypi.tuna.tsinghua.edu.cn/simple/ ...
Java学习笔记(七十二)—— Cookie
概述 会话技术: 会话:一次会话中包含多次请求和响应 一次会话:浏览器第一次给服务器发送资源请求,会话建立,直到有一方断开为止 功能:在一次会话的范围内的多次请求间,共享数据 方式: 客户端会话技术:Cookie,把数据存储到客户端 服务器端会话技术:Session,把数据存储到服务器端 Cookie 概念:客户端会话技术,将数据存储到客户端 快速入门: 使用步骤: 创建C...
程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
Java工作4年来应聘要16K最后没要,细节如下。。。
前奏: 今天2B哥和大家分享一位前几天面试的一位应聘者,工作4年26岁,统招本科。 以下就是他的简历和面试情况。 基本情况: 专业技能: 1、&nbsp;熟悉Sping了解SpringMVC、SpringBoot、Mybatis等框架、了解SpringCloud微服务 2、&nbsp;熟悉常用项目管理工具:SVN、GIT、MAVEN、Jenkins 3、&nbsp;熟悉Nginx、tomca...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
程序员该看的几部电影
1、骇客帝国(1999) 概念:在线/离线,递归,循环,矩阵等 剧情简介: 不久的将来,网络黑客尼奥对这个看似正常的现实世界产生了怀疑。 他结识了黑客崔妮蒂,并见到了黑客组织的首领墨菲斯。 墨菲斯告诉他,现实世界其实是由一个名叫“母体”的计算机人工智能系统控制,人们就像他们饲养的动物,没有自由和思想,而尼奥就是能够拯救人类的救世主。 可是,救赎之路从来都不会一帆风顺,到底哪里才是真实的世界?如何...
蓝桥杯知识点汇总:基础知识和常用算法
此系列包含蓝桥杯所考察的绝大部分知识点,一共有==基础语法==,==常用API==,==基础算法和数据结构==,和==往年真题==四部分,虽然语言以JAVA为主,但算法部分是相通的,C++组的小伙伴也可以看哦。
作为一个程序员,CPU的这些硬核知识你必须会!
CPU对每个程序员来说,是个既熟悉又陌生的东西? 如果你只知道CPU是中央处理器的话,那可能对你并没有什么用,那么作为程序员的我们,必须要搞懂的就是CPU这家伙是如何运行的,尤其要搞懂它里面的寄存器是怎么一回事,因为这将让你从底层明白程序的运行机制。 随我一起,来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说,我们首先就要搞明白它是怎么回事,也就是它的内部构造,当然,CPU那么牛的一个东...
破14亿,Python分析我国存在哪些人口危机!
一、背景 二、爬取数据 三、数据分析 1、总人口 2、男女人口比例 3、人口城镇化 4、人口增长率 5、人口老化(抚养比) 6、各省人口 7、世界人口 四、遇到的问题 遇到的问题 1、数据分页,需要获取从1949-2018年数据,观察到有近20年参数:LAST20,由此推测获取近70年的参数可设置为:LAST70 2、2019年数据没有放上去,可以手动添加上去 3、将数据进行 行列转换 4、列名...
实现简单的轮播图(单张图片、多张图片)
前言 刚学js没多久,这篇博客就当做记录了,以后还会完善的,希望大佬们多多指点。ps:下面出现的都是直接闪动,没有滑动效果的轮播图。 单张图片的替换 · ...
强烈推荐10本程序员在家读的书
很遗憾,这个春节注定是刻骨铭心的,新型冠状病毒让每个人的神经都是紧绷的。那些处在武汉的白衣天使们,尤其值得我们的尊敬。而我们这些窝在家里的程序员,能不外出就不外出,就是对社会做出的最大的贡献。 有些读者私下问我,窝了几天,有点颓丧,能否推荐几本书在家里看看。我花了一天的时间,挑选了 10 本我最喜欢的书,你可以挑选感兴趣的来读一读。读书不仅可以平复恐惧的压力,还可以对未来充满希望,毕竟苦难终将会...
Linux自学篇——linux命令英文全称及解释
man: Manual 意思是手册,可以用这个命令查询其他命令的用法。 pwd:Print working directory 意思是密码。 su:Swith user 切换用户,切换到root用户 cd:Change directory 切换目录 ls:List files 列出目录下的文件 ps:Process Status 进程状态 mkdir:Make directory ...
Python实战:抓肺炎疫情实时数据,画2019-nCoV疫情地图
今天,群里白垩老师问如何用python画武汉肺炎疫情地图。白垩老师是研究海洋生态与地球生物的学者,国家重点实验室成员,于不惑之年学习python,实为我等学习楷模。先前我并没有关注武汉肺炎的具体数据,也没有画过类似的数据分布图。于是就拿了两个小时,专门研究了一下,遂成此文。
智力题(程序员面试经典)
NO.1  有20瓶药丸,其中19瓶装有1克/粒的药丸,余下一瓶装有1.1克/粒的药丸。给你一台称重精准的天平,怎么找出比较重的那瓶药丸?天平只能用一次。 解法 有时候,严格的限制条件有可能反倒是解题的线索。在这个问题中,限制条件是天平只能用一次。 因为天平只能用一次,我们也得以知道一个有趣的事实:一次必须同时称很多药丸,其实更准确地说,是必须从19瓶拿出药丸进行称重。否则,如果跳过两瓶或更多瓶药...
Java与Python学习通法(1)和(2)序言和编程语言发展史怎么学
dd
在家远程办公效率低?那你一定要收好这个「在家办公」神器!
相信大家都已经收到国务院延长春节假期的消息,接下来,在家远程办公可能将会持续一段时间。 但是问题来了。远程办公不是人在电脑前就当坐班了,相反,对于沟通效率,文件协作,以及信息安全都有着极高的要求。有着非常多的挑战,比如: 1在异地互相不见面的会议上,如何提高沟通效率? 2文件之间的来往反馈如何做到及时性?如何保证信息安全? 3如何规划安排每天工作,以及如何进行成果验收? ...... ...
作为一个程序员,内存和磁盘的这些事情,你不得不知道啊!!!
截止目前,我已经分享了如下几篇文章: 一个程序在计算机中是如何运行的?超级干货!!! 作为一个程序员,CPU的这些硬核知识你必须会! 作为一个程序员,内存的这些硬核知识你必须懂! 这些知识可以说是我们之前都不太重视的基础知识,可能大家在上大学的时候都学习过了,但是嘞,当时由于老师讲解的没那么有趣,又加上这些知识本身就比较枯燥,所以嘞,大家当初几乎等于没学。 再说啦,学习这些,也看不出来有什么用啊!...
阿里架构师花近十年时间整理出来的Java核心知识pdf(Java岗)
由于细节内容实在太多啦,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容! 整理了一份Java核心知识点。覆盖了JVM、锁、并发、Java反射、Spring原理、微服务、Zookeeper、数据库、数据结构等大量知识点。 欢迎大家加入java学习交流社区 点击加入 可获取文中文档 小编推荐: ...
Python基础知识点梳理
python常见知识点梳理 摘要: 本文主要介绍一些平时经常会用到的python基础知识点,用于加深印象。python的详细语法介绍可以查看官方编程手册,也有一些在线网站对python语法进行了比较全面的介绍,比如菜鸟教程: python3 教程|菜鸟教程 本文主要是介绍基础语法,操作实例在另一篇博客中单独介绍: python语言介绍 python是一门解释型语言,python的设计目标: 一门...
2020年2月全国程序员工资统计,平均工资13716元
趋势 2020年2月,中国大陆程序员平均工资13716员,比上个月增加。具体趋势如图: 各主要程序员城市工资变化 城市 北京,上海,深圳,杭州,广州四地的工资最高。 city 平均工资 最低工资 中位数 最高工资 招聘人数 百分比 北京 18098 3750 15000 45000 20529 9.53% 深圳 16903 5750 15000 37500 30941 1...
Java坑人面试题系列: 包装类(中级难度)
Java Magazine上面有一个专门坑人的面试题系列: https://blogs.oracle.com/javamagazine/quiz-2。 这些问题的设计宗旨,主要是测试面试者对Java语言的了解程度,而不是为了用弯弯绕绕的手段把面试者搞蒙。 如果你看过往期的问题,就会发现每一个都不简单。 这些试题模拟了认证考试中的一些难题。 而 “中级(intermediate)” 和 “高级(ad...
为什么说程序员做外包没前途?
之前做过不到3个月的外包,2020的第一天就被释放了,2019年还剩1天,我从外包公司离职了。我就谈谈我个人的看法吧。首先我们定义一下什么是有前途 稳定的工作环境 不错的收入 能够在项目中不断提升自己的技能(ps:非技术上的认知也算) 找下家的时候能找到一份工资更高的工作 如果你目前还年轻,但高不成低不就,只有外包offer,那请往下看。 外包公司你应该...
相关热词 c#导入fbx c#中屏蔽键盘某个键 c#正态概率密度 c#和数据库登陆界面设计 c# 高斯消去法 c# codedom c#读取cad文件文本 c# 控制全局鼠标移动 c# temp 目录 bytes初始化 c#
立即提问