spring、mybatis整合遇到的问题

单元测试报错:
Invalid bound statement (not found): com.cn.mysite
.mybatisdemo.dao.IUserDao.queryUserList
下面相关代码和配置文件:
1、先放上结构图:
图片说明
2、spring-mybatis.xml配置文件代码如下:

<context:component-scan base-package="com.cn.mysite.mybatisdemo" />

<!-- jdbc配置文件导入 -->
<context:property-placeholder location="classpath:jdbc.properties"/>

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <!-- 连接池配置 -->
    <property name="driverClassName" value="${database.driverClassName}"/>
    <property name="url" value="${database.url}"/>
    <property name="username" value="${database.username}"/>
    <property name="password" value="${database.password}"/>

    <!-- 初始化连接大小 -->
    <property name="initialSize" value="0"></property>
    <!-- 连接池最大数量 -->
    <property name="maxActive" value="20"></property>
    <!-- 连接池最大空闲 -->
    <property name="maxIdle" value="20"></property>
    <!-- 连接池最小空闲 -->
    <property name="minIdle" value="1"></property>
    <!-- 获取连接最大等待时间 -->
    <property name="maxWait" value="30000"></property>
</bean>

<!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="mapperLocations" value="classpath*:com/cn/mysite/mybatisdemo/mapping/*.xml"/>
</bean>

<!-- DAO接口所在包名,Spring会自动查找其下的类 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.cn.mysite.mybatisdemo.dao" />
    <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>

3、IUserDao接口代码:

public interface IUserDao {

List<User> queryUserList();

}


 4、mapping中xml映射文件:
 <?xml version="1.0" encoding= "UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >

<mapper namespace= "com.cn.mysite.mybatisdemo.dao.IUserDao" >
      <resultMap type ="com.cn.mysite.mybatisdemo.model.User" id="usermap">
             <result property ="id" column="id" />
             <result property ="name" column="name" />
             <result property ="age" column="age" />
             <result property ="email" column="email" />
             <result property ="address" column="address" />
      </resultMap>
      <!-- 查询所有用户记录 -->
      <select id ="queryUserList" resultMap= "usermap">
            select * from person
      </select >
</mapper>

5、测试类:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring-mybatis.xml"})
public class MybatisTest {

    @Resource
    private IUserDao dao;

    @Test
    public void test() {
        dao.queryUserList();
        System.out.println("Hello World!");
    }
}
单元测试就开始报错,请大家帮看一下是哪一步出错了,感觉好奇怪啊,实在查不出问题了



2个回答

看了半天没啥毛病 你把 @Resource 换成 @Autowired 试一下

wang3048
wang3048 回复sinat_38913556: 非常感谢!!!!
接近 3 年之前 回复
sinat_38913556
sinat_38913556 回复wang3048: 一般默认的资源文件放在resource目录下 你放在 java目录下 就需要配置一下
接近 3 年之前 回复
sinat_38913556
sinat_38913556 回复wang3048: 你把mapper放在src/main/java下面了 就要配置一下
接近 3 年之前 回复
wang3048
wang3048 回复sinat_38913556: 解决了,这是为啥呢,我看有的就不需要这样?
接近 3 年之前 回复
sinat_38913556
sinat_38913556 回复wang3048: http://blog.csdn.net/u013030276/article/details/50959349看看这个例子能解决你的问题么
接近 3 年之前 回复
wang3048
wang3048 就是没看到啥毛病,一般这情况都是接口和mapper不对应,这也没问题,换了@Autowired一样的结果
接近 3 年之前 回复

其实,你应该放多点log出来看下

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
怎样解决springmybatis整合遇到的问题

Document root element "beans", must match DOCTYPE root "null".

spring 和 mybatis整合后启动遇到的一个问题

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Invocation of init method failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'dataSource' defined in file [D:\apache-tomcat-8.0.18\wtpwebapps\Pipeline\WEB-INF\classes\config\spring-mybatis.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource

spring+mybatis整合遇到问题

spring+mybatis配置文件 ![图片说明](https://img-ask.csdn.net/upload/201611/04/1478232394_187202.png) mapper映射文件 ![图片说明](https://img-ask.csdn.net/upload/201611/04/1478232424_84854.png) 错误提示 ![图片说明](https://img-ask.csdn.net/upload/201611/04/1478232445_528701.png)

Spring和Mybatis整合后注入报错

新手入门,最近在学习框架整合的时候遇到一个问题,就是配置好必须的文件后,测试的时候发现用@Resource注入直接报错。找了很久都不知道什么原因,求大神们帮助T T 直接贴图。 spring-mybatis.xml ``` <?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:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- 自动扫描 --> <context:component-scan base-package="com.schoolmarket.ssm"/> <!-- 第一种方式:加载一个properties文件 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath:jdbc.properties"/> </bean> <!-- 第二种方式:加载多个properties文件 <bean id="configProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="locations"> <list> <value>classpath:jdbc.properties</value> <value>classpath:common.properties</value> </list> </property> <property name="fileEncoding" value="UTF-8"/> </bean> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"> <property name="properties" ref="configProperties"/> </bean> --> <!-- 配置数据源 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${driverClasss}"/> <property name="url" value="${jdbcUrl}"/> <property name="username" value="${username}"/> <property name="password" value="${password}"/> <!-- 初始化连接大小 --> <property name="initialSize" value="${initialSize}"></property> <!-- 连接池最大数量 --> <property name="maxActive" value="${maxActive}"></property> <!-- 连接池最大空闲 --> <property name="maxIdle" value="${maxIdle}"></property> <!-- 连接池最小空闲 --> <property name="minIdle" value="${minIdle}"></property> <!-- 获取连接最大等待时间 --> <property name="maxWait" value="${maxWait}"></property> </bean> <!-- mybatis和spring完美整合,不需要mybatis的配置映射文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath:mapping/*.xml"></property> </bean> <!-- DAO接口所在包名,Spring会自动查找其下的类 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> <property name="basePackage" value="com.schoolmarket.ssm.dao"/> </bean> <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx --> <tx:annotation-driven transaction-manager="transactionManager"/> </beans> ``` User.java ``` package com.schoolmarket.ssm.model; public class User { private String uid; private String username; private String pwd; private String phone; private String address; public String getUid() { return uid; } public void setUid(String uid) { this.uid = uid; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPwd() { return pwd; } public void setPwd(String pwd) { this.pwd = pwd; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } } ``` UserDao.java ``` package com.schoolmarket.ssm.dao; import com.schoolmarket.ssm.model.User; public interface UserDao { User selectById(String uid); } ``` UserMapping.xml ``` <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.schoolmarket.ssm.dao.UserDao"> <select id="selectById" resultType="com.schoolmarket.model.User" parameterType="String"> select uid,username,pwd,phone,address from users where uid = #{uid} </select> </mapper> ``` IUserService.java ``` package com.schoolmarket.ssm.service; import com.schoolmarket.ssm.model.User; public interface IUserService { public User getUserById(String uid); } ``` UserServiceImpl.java ``` package com.schoolmarket.ssm.service; import com.schoolmarket.ssm.dao.UserDao; import com.schoolmarket.ssm.model.User; import org.springframework.stereotype.Service; import javax.annotation.Resource; @Service("userService") public class UserServiceImpl implements IUserService { @Resource private UserDao userDao; public User getUserById(String uid) { return userDao.selectById(uid); } } ``` 那么重点来了。 ![图片说明](https://img-ask.csdn.net/upload/201610/28/1477619092_506993.png)

spring boot整合mybatis的坑谁踩过??

spring boot中引入了mybatis-spring-boot-starter的依赖,但这个jar包中的子依赖没有引入进来。哪位大牛遇到过这个问题??? 注:spring boot是2.0.1版的,mybatis组件是在创建工程的时候选择的 ![](https://img-ask.csdn.net/upload/201804/19/1524119964_302777.png)

spring boot 整合mybatis 取别名时遇到问题

![![图片说明](https://img-ask.csdn.net/upload/201705/23/1495530657_491711.png)图片说明](https://img-ask.csdn.net/upload/20170 5/23/1495530644_177591.png)为什么这样查到的数据都是null??? http://blog.csdn.net/jrainbow/article/details/51980036 照着这个弄的一个框架 以前用搭建好的框架也是这样取个别名 get set 就可以得到的呀

如何用属性注入的方式为spring的service注入Mybatis的Mapper对象?

万能的网友的。帮帮我吧。 spring+Mybatis+struts2整合中遇到一个问题:service层中不知道如何注入Mapper对象啊。 首先我分三层。action---> service---->Mapper(充当dao层)。 我的Mapper是扫描包生成实现类的。然而我的service里面有一个Mapper对象。 就像这样: public class ProductService { //@Autowired private ProductMapper productMapper; public void setProductMapper(ProductMapper productMapper) { this.productMapper = productMapper; } //省略其他代码。。。 } 然后我想通过setter方法将productMapper注入到ProductService中。 我的配置文件如下: <bean id="Mapper" class="org.mybatis.spring.mapper.MapperScannerConfigurer" > <property name="basePackage" value="wm.mapper" /> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> </bean> <bean id="productService" class="wm.service.ProductService" scope="prototype" > <property name="productMapper" ref=""></property> </bean> 写到这里,我忽然愣住了。这是我不知道ref该怎么写。或者还是value怎么写。如果用注解注入的话,我能解决这个问题。但是如果我用属性注入的方式怎么实现呢?大神们,没有分。不好意思啊。

hibernate和mybatis事务问题

我想在web应用中使用hibernate和mybatis配合做数据持久化,但是遇到数据源和 事务的问题。首先hibernate是使用的proxool连接池,在自己写的hibernate工具 类中加载hibernate的sessionFactory以及session的打开和事务管理等。那么问题 来了,我在mybatis中该如何配置来使用连接池,以及和hibernate使用同一个事务。 请大神支招。

求大神帮忙啊,初次整合spring mvc 和mybatis 就遇到了这么烫手的山芋

用Mybatis 逆向工程得出model 和Mapper 以及mapper.xml 在网页中测试,网页一直处于正在连接状态,后台前台都不报错,单步调试报 not available native method! ![图片说明](https://img-ask.csdn.net/upload/201605/02/1462174539_745587.png) ![图片说明](https://img-ask.csdn.net/upload/201605/02/1462174550_788500.png) ![图片说明](https://img-ask.csdn.net/upload/201605/02/1462174559_783818.png) ![图片说明](https://img-ask.csdn.net/upload/201605/02/1462174570_851615.png) ![图片说明](https://img-ask.csdn.net/upload/201605/02/1462174579_612380.png) ![图片说明](https://img-ask.csdn.net/upload/201605/02/1462174597_27266.png) ![图片说明](https://img-ask.csdn.net/upload/201605/02/1462174606_376840.png)

spring3.1.1,mybatis3.1.1 整合条件下如何配置log4j打印出sql

我的jar包版本: log4j-1.2.16.jar commons-logging-1.1.1.jar slf4j-api-1.6.2.jar slf4j-log4j12-1.6.2.jar log4j.xml或者log4j.properties文件中. 我试过很多配置方案. 只能打出获取连接的代码,类似下面的信息 2012-06-16 11:15:59,150 DEBUG [com.mchange.v2.resourcepool.BasicResourcePool] - <trace com.mchange.v2.resourcepool.BasicResourcePool@96b5c2 [managed: 10, unused: 9, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@1c21ece)> 有没有遇到同样问题的. 这个该怎么解决..

springBoot集成mybatis与shiro

最近在做一个springBoot集成mybatis与shiro的Demo 但是遇到shiro验证用户名密码一直提示不正确,实在是搞不明白,demo奉上http://pan.baidu.com/s/1jI3m9ZC,望解答,谢谢。

SSM使用Mybatis-Plus分页问题,total和pages总是为零。

![图片说明](https://img-ask.csdn.net/upload/201908/24/1566578980_538847.png) 这个问题困扰了1天了,之前没有用过mybatis-plus,但是看到他们说这个插件非常好用,可以不用写简单的CRUD,其它的倒是没有什么问题,但是在写一个多条件分页查询的时候,一直获取不到分页后的Total和Pages,出现这个问题,我也查找了很多的资料,但是仍然没有解决,希望有遇到过类似的朋友能够指点一下,看我这样写是否存在错误,如有,请帮忙指出错误的方法,谢谢! 下面贴出我的一些关键配置信息参考: ``` /** * mybatis-plus配置 * */ @Configuration public class MybatisPlusConfig { /** * 分页插件 */ @Bean public PaginationInterceptor paginationInterceptor() { PaginationInterceptor page = new PaginationInterceptor(); return page; } } ``` mybatis-config.xml: ``` <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.baomidou.mybatisplus.samples.quickstart.mapper" /> </bean> <bean id="sqlSessionFactory" class="com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath*:com/***/mapper/*.xml" /> <property name="typeAliasesPackage" value="com.***.model.po" /> </bean> ``` mybatis-plus:版本 : ``` <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus</artifactId> <version>3.0.7.1</version> </dependency> ``` 使用的数据库是MySQL5.7

easypoi导出excel遇到的问题,搭配spring+springmvc+mybatis

18:08:20.146 [http-nio-8080-exec-5] ERROR o.j.poi.cache.ExcelCache - null java.lang.NullPointerException: null at org.jeecgframework.poi.cache.ExcelCache.getWorkbook(ExcelCache.java:61) ~[easypoi-base-2.4.0.jar:na] at org.jeecgframework.poi.excel.export.template.ExcelExportOfTemplateUtil.getCloneWorkBook(ExcelExportOfTemplateUtil.java:217) [easypoi-base-2.4.0.jar:na] at org.jeecgframework.poi.excel.export.template.ExcelExportOfTemplateUtil.createExcleByTemplate(ExcelExportOfTemplateUtil.java:182) [easypoi-base-2.4.0.jar:na] at org.jeecgframework.poi.excel.ExcelExportUtil.exportExcel(ExcelExportUtil.java:165) [easypoi-base-2.4.0.jar:na] at com.TQES.sysmanager.controller.ExportController.fe_map(ExportController.java:170) [classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_31] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_31] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_31] at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_31] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) [spring-web-4.1.7.jar:4.1.7.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) [spring-web-4.1.7.jar:4.1.7.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) [spring-webmvc-4.1.7.jar:4.1.7.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776) [spring-webmvc-4.1.7.jar:4.1.7.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705) [spring-webmvc-4.1.7.jar:4.1.7.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) [spring-webmvc-4.1.7.jar:4.1.7.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) [spring-webmvc-4.1.7.jar:4.1.7.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) [spring-webmvc-4.1.7.jar:4.1.7.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967) [spring-webmvc-4.1.7.jar:4.1.7.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858) [spring-webmvc-4.1.7.jar:4.1.7.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) [servlet-api.jar:na] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843) [spring-webmvc-4.1.7.jar:4.1.7.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [servlet-api.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) [catalina.jar:8.0.27] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.27] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.0.27] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.27] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.27] at com.TQES.filter.AuthFilter.doFilter(AuthFilter.java:32) [classes/:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.27] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.27] at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123) [druid-1.0.15.jar:1.0.15] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.27] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.27] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85) [spring-web-4.1.7.jar:4.1.7.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.1.7.jar:4.1.7.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.27] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.27] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217) [catalina.jar:8.0.27] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [catalina.jar:8.0.27] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [catalina.jar:8.0.27] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) [catalina.jar:8.0.27] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [catalina.jar:8.0.27] at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) [catalina.jar:8.0.27] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [catalina.jar:8.0.27] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) [catalina.jar:8.0.27] at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091) [tomcat-coyote.jar:8.0.27] at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673) [tomcat-coyote.jar:8.0.27] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) [tomcat-coyote.jar:8.0.27] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) [tomcat-coyote.jar:8.0.27] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_31] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_31] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.0.27] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_31] 六月 26, 2018 6:08:20 下午 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet [spring] in context with path [/TQES] threw exception [Handler processing failed; nested exception is com.google.common.util.concurrent.ExecutionError: java.lang.NoSuchMethodError: org.apache.poi.util.IOUtils.closeQuietly(Ljava/io/Closeable;)V] with root cause java.lang.NoSuchMethodError: org.apache.poi.util.IOUtils.closeQuietly(Ljava/io/Closeable;)V at org.jeecgframework.poi.cache.manager.FileLoadeImpl.getFile(FileLoadeImpl.java:62) at org.jeecgframework.poi.cache.manager.POICacheManager$1.load(POICacheManager.java:57) at org.jeecgframework.poi.cache.manager.POICacheManager$1.load(POICacheManager.java:52) at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3542) at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2323) at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2286) at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201) at com.google.common.cache.LocalCache.get(LocalCache.java:3953) at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3957) at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4875) at org.jeecgframework.poi.cache.manager.POICacheManager.getFile(POICacheManager.java:67) at org.jeecgframework.poi.cache.ExcelCache.getWorkbook(ExcelCache.java:44) at org.jeecgframework.poi.excel.export.template.ExcelExportOfTemplateUtil.getCloneWorkBook(ExcelExportOfTemplateUtil.java:217) at org.jeecgframework.poi.excel.export.template.ExcelExportOfTemplateUtil.createExcleByTemplate(ExcelExportOfTemplateUtil.java:182) at org.jeecgframework.poi.excel.ExcelExportUtil.exportExcel(ExcelExportUtil.java:165) at com.TQES.sysmanager.controller.ExportController.fe_map(ExportController.java:170) 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:483) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)

springboot mybatis 使用分页插件pagehelper 分页不生效

最近在学习springboot集成mybatis的知识,在使用分页时候,遇到如下问题 添加的分页插件,但是分页效果没有 代码如下 maven引入如下 ``` <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.2.0</version> </dependency> <!-- 分页插件 --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>4.1.0</version> </dependency> ``` mybatis-config配置如下 ``` <properties> <property name="dialect" value="mysql" /> </properties> <settings> <!-- 打印查询语句 --> <setting name="logImpl" value="SLF4J" /> </settings> <!-- 分页插件的配置 --> <plugins> <plugin interceptor="com.github.pagehelper.PageHelper"> </plugin> </plugins> ``` 分页代码如下 ``` @RequestMapping("/pagelist") @ResponseBody public Object showQuestions(@RequestParam Integer page, @RequestParam Integer pageSize) { Page<Object> b = PageHelper.offsetPage(2,10); System.out.println(b); List <UserEntity> lists= userMapper.getAll(); PageInfo<UserEntity> pageinfo = new PageInfo<UserEntity>(lists); return pageinfo; } ``` 但是查询的数据,仍然是全部数据,没有按照预想的实现分页

Activiti任务监听器调用SSM DAO层

我用jeesite平台想开发一个学生提交作业给老师的工作流,工作流中通过任务监听器动态设置任务执行人(老师)框架是spring +spring mvc+ mybatis + mysql 任务监听器通过实现TaskListener接口的类并通过可视化工具中在老师TASK节点设置了create时调用该类 监听器的代码如下 ``` @Component @Service public class Teacherlisten extends CrudService<StudentToTeacherDao, StudentToT eacher> implements TaskListener{ private String userId; private StudentToTeacher st; private String assignee; private static final long serialVersionUID = 1L; @Override public void notify(DelegateTask delegateTask){ userId = delegateTask.getVariable("apply").toString(); st=dao.findteacher(userId); assignee=st.getTeacher(); delegateTask.setAssignee(assignee); } } ``` 下面为CrudService自动装配DAO的代码 ``` @Transactional(readOnly = true) public abstract class CrudService<D extends CrudDao<T>, T extends DataEntity<T>> extends BaseService { /** * 持久层对象 */ @Autowired protected D dao; ``` 我的设想是通过调用DAO方法访问数据库查询学生对应的老师,然后将执行人设置为该老师,但是遇到的问题是自动装配DAO时 值为NULL,原因可能是监听器与Spring 加载时出问题,已经尝试过很多方法,最后使用JDBC实现的,但是mybatis的框架在这里没用上,希望大神能帮小弟一下,指点一下如何在监听器中能够将Spring与mybatis整合的DAO层引进来。

ssm整合项目中出现这样的错误怎么解决?

2017-08-18 15:33:08.790 DEBUG[localhost-startStop-1]org.springframework.beans.TypeConverterDelegate.convertIfNecessary():276 -Original ConversionService attempt failed - ignored since PropertyEditor based conversion eventually succeeded org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.util.ArrayList<?> to type java.util.List<org.springframework.core.io.Resource> for value '[/WEB-INF/static/]'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.String to type org.springframework.core.io.Resource at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41) ~[spring-core-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:168) ~[spring-core-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:161) ~[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:448) [spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:494) [spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:488) [spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1463) [spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1422) [spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1158) [spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) [spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) [spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296) [spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293) [spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628) [spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) [spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) [spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651) [spring-webmvc-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:602) [spring-webmvc-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665) [spring-webmvc-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:521) [spring-webmvc-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:462) [spring-webmvc-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) [spring-webmvc-3.2.8.RELEASE.jar:3.2.8.RELEASE] at javax.servlet.GenericServlet.init(GenericServlet.java:158) [servlet-api.jar:3.0.FR] at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1269) [catalina.jar:7.0.79] at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1182) [catalina.jar:7.0.79] at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1072) [catalina.jar:7.0.79] at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5368) [catalina.jar:7.0.79] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5660) [catalina.jar:7.0.79] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) [catalina.jar:7.0.79] at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571) [catalina.jar:7.0.79] at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561) [catalina.jar:7.0.79] at java.util.concurrent.FutureTask.run(Unknown Source) [na:1.7.0_79] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.7.0_79] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.7.0_79] at java.lang.Thread.run(Unknown Source) [na:1.7.0_79] Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.String to type org.springframework.core.io.Resource at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:276) ~[spring-core-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:171) ~[spring-core-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.core.convert.support.CollectionToCollectionConverter.convert(CollectionToCollectionConverter.java:74) ~[spring-core-3.2.8.RELEASE.jar:3.2.8.RELEASE] at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:35) ~[spring-core-3.2.8.RELEASE.jar:3.2.8.RELEASE] ... 36 common frames omitted

ssm整合时遇到了这个异常 连接的是远程的数据库 细节在后面

严重: Servlet.service() for servlet [spring] in context with path [/web] threw exception [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 org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver ' ### The error may exist in file [C:\workspace\day1\web\WEB-INF\classes\demo\mapper\MyUsermapper.xml] ### The error may involve demo.dao.MyUsermapper.findall ### The error occurred while executing a query ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver '] with root cause java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1854) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1703) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:190) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:760) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540) at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:80) at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:66) at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:279) at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:69) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:141) 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:101) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:95) 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:355) at com.sun.proxy.$Proxy13.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:195) at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:124) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:90) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40) at com.sun.proxy.$Proxy14.findall(Unknown Source) at demo.service.MyUserServiceImpl.findall(MyUserServiceImpl.java:27) at demo.controller.MyUserController.execute(MyUserController.java:34) 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.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) at javax.servlet.http.HttpServlet.service(HttpServlet.java:624) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:744) **文件----**## **jdbc.properties**(数据库名是REMOTEORCL) jdbc_driver=oracle.jdbc.driver.OracleDriver jdbc_url=jdbc:Oracle:thin:@10.164.25.39:1521:REMOTEORCL jdbc_username=test2 jdbc_password=test2 initialSize=0 maxActive=20 maxIdle=20 minIdle=1 maxWait=60000 文件----## spring-mybatis.xml <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc_driver}" /> <property name="url" value="${jdbc_url}" /> <property name="username" value="${jdbc_username}" /> <property name="password" value="${jdbc_password}" /> <!-- 初始化连接大小 --> <property name="initialSize" value="${initialSize}"></property> <!-- 连接池最大数量 --> <property name="maxActive" value="${maxActive}"></property> <!-- 连接池最大空闲 --> <property name="maxIdle" value="${maxIdle}"></property> <!-- 连接池最小空闲 --> <property name="minIdle" value="${minIdle}"></property> <!-- 获取连接最大等待时间 --> <property name="maxWait" value="${maxWait}"></property> <property name="defaultAutoCommit" value="true" /> <property name="removeAbandoned" value="true" /> <property name="removeAbandonedTimeout" value="60" /> <property name="validationQuery" value="select 1 from dual "/> <property name="testOnBorrow" value="true"/> </bean> ![图片说明](https://img-ask.csdn.net/upload/201704/12/1491978669_363090.png)![图片说明](https://img-ask.csdn.net/upload/201704/12/1491978627_66374.png)sk.csdn.net/upload/201704/12/1491978599_736941.png)![图片说明](https://img-ask.csdn.net/upload/201704/12/1491978646_173283.png)

springboot 项目怎么解决前端传来json中中文乱码(变???号)问题???

## 哪位大神遇到过!我改了 @RequestMapping(value = "/getLoveAdd", produces = "text/html;charset=UTF-8", method = {RequestMethod.GET, RequestMethod.POST}) 没有用

新手ssm整合报以下错误,求大神解答?

是在整合ssm时遇到的错,mapper.xml文件是自动生成的,但就是一直报着个错误求解。 ``` org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'com/jiayuewen/mapper/UserMapper.xml'. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.jiayuewen.mapper.UserMapper.BaseResult at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:122) at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:94) at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.loadXmlResource(MapperAnnotationBuilder.java:182) at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.parse(MapperAnnotationBuilder.java:129) at org.apache.ibatis.binding.MapperRegistry.addMapper(MapperRegistry.java:72) at org.apache.ibatis.session.Configuration.addMapper(Configuration.java:759) at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:80) at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:824) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:144) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:85) at com.jiayuewen.test.UserMapperTest.setUp(UserMapperTest.java:16) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java: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.RunBefores.evaluate(RunBefores.java:24) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) 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.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209) Caused by: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.jiayuewen.mapper.UserMapper.BaseResult at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:930) at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:887) at org.apache.ibatis.session.Configuration.addResultMap(Configuration.java:644) at org.apache.ibatis.builder.MapperBuilderAssistant.addResultMap(MapperBuilderAssistant.java:208) at org.apache.ibatis.builder.ResultMapResolver.resolve(ResultMapResolver.java:47) at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:289) at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:253) at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElements(XMLMapperBuilder.java:245) at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:118) ... 44 more 七月 21, 2019 11:33:06 下午 org.springframework.context.support.ClassPathXmlApplicationContext refresh 警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [D:\Java\Java项目\SSMIntegration\build\classes\com\jiayuewen\mapper\UserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'com/jiayuewen/mapper/UserMapper.xml'. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.jiayuewen.mapper.UserMapper.BaseResult ``` 上面是报错信息,下面是xml相关代码 ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.jiayuewen.mapper.UserMapper"> <resultMap id="BaseResult" type="com.jiayuewen.bean.User"> <id column="id" jdbcType="INTEGER" property="id" /> <result column="username" jdbcType="VARCHAR" property="username" /> <result column="password" jdbcType="VARCHAR" property="password" /> <result column="sex" jdbcType="VARCHAR" property="sex" /> <result column="createTime" jdbcType="TIMESTAMP" property="createtime" /> <result column="cid" jdbcType="INTEGER" property="cid" /> </resultMap> ``` resultMap的id我也改过,还是不行

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

点沙成金:英特尔芯片制造全过程揭密

“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

外包程序员的幸福生活

今天给你们讲述一个外包程序员的幸福生活。男主是Z哥,不是在外包公司上班的那种,是一名自由职业者,接外包项目自己干。接下来讲的都是真人真事。 先给大家介绍一下男主,Z哥,老程序员,是我十多年前的老同事,技术大牛,当过CTO,也创过业。因为我俩都爱好喝酒、踢球,再加上住的距离不算远,所以一直也断断续续的联系着,我对Z哥的状况也有大概了解。 Z哥几年前创业失败,后来他开始干起了外包,利用自己的技术能...

C++11:一些微小的变化(新的数据类型、template表达式内的空格、nullptr、std::nullptr_t)

本文介绍一些C++的两个新特性,它们虽然微小,但对你的编程十分重要 一、Template表达式内的空格 C++11标准之前建议在“在两个template表达式的闭符之间放一个空格”的要求已经过时了 例如: vector&lt;list&lt;int&gt; &gt;; //C++11之前 vector&lt;list&lt;int&gt;&gt;; //C++11 二、nullptr ...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

深入剖析Springboot启动原理的底层源码,再也不怕面试官问了!

大家现在应该都对Springboot很熟悉,但是你对他的启动原理了解吗?

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

【阿里P6面经】二本,curd两年,疯狂复习,拿下阿里offer

二本的读者,在老东家不断学习,最后逆袭

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

微软为一人收购一公司?破解索尼程序、写黑客小说,看他彪悍的程序人生!...

作者 | 伍杏玲出品 | CSDN(ID:CSDNnews)格子衬衫、常掉发、双肩包、修电脑、加班多……这些似乎成了大众给程序员的固定标签。近几年流行的“跨界风”开始刷新人们对程序员的...

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

我说我懂多线程,面试官立马给我发了offer

不小心拿了几个offer,有点烦

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

立即提问
相关内容推荐