1.org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.mybatis.spring.mapper.MapperScannerConfigurer#0‘ defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type [java.lang.String] to required type [org.apache.ibatis.session.SqlSessionFactory] for property ‘sqlSessionFactory‘; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.apache.ibatis.session.SqlSessionFactory] for property ‘sqlSessionFactory‘: no matching editors or conversion strategy found
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type [java.lang.String] to required type [org.apache.ibatis.session.SqlSessionFactory] for property ‘sqlSessionFactory‘; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.apache.ibatis.session.SqlSessionFactory] for property ‘sqlSessionFactory‘: no matching editors or conversion strategy found
Caused by: java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.apache.ibatis.session.SqlSessionFactory] for property ‘sqlSessionFactory‘: no matching editors or conversion strategy found
原因可能如下:1)@RequestMapping(value="/userlogin",method=RequestMethod.POST)
2)<!-- 配置映射接口 -->中property name="sqlSessionFactoryBeanName"
2.org.apache.ibatis.executor.ExecutorException:A query was run and no Result Maps were found for the Mapped Statement ‘com.blog.mapper.BlogMapper.findAllBlog‘. It‘s likely that neither a Result Type nor a Result Map was specified.
解决:仔细查看mybatis的配置文件,发现遗漏一个属性:resultType
报错的配置是:<select id="ID" parameterType="java.util.Map">
正确的配置应该是<select id="ID" parameterType="java.util.Map" resultType="java.util.Map">
最后总结下,就是mybatis中的所有查询,都必须返回resultType或者resultMap的值,否则就会报如上错误的。
3.java.lang.NullPointerException
at com.blog.service.impl.BlogServiceImpl.findAllBlog(BlogServiceImpl.java:31)
at com.blog.controller.BlogController.findAllBlog(BlogController.java:27)
解决:空指针异常,可能是依赖关系没有确定,看看属性上是否添加@Autowired
4.java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
严重: Servlet.service() for servlet [springmvc] in context with path [/blog] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter ‘username‘ not found. Available parameters are [arg1, arg0, param1, param2]] with root cause
org.apache.ibatis.binding.BindingException: Parameter ‘username‘ not found. Available parameters are [arg1, arg0, param1, param2]
解决: 查询中参数没有指定,比如://根据用户名和密码查询 User find(String username,String password)应写成//根据用户名和密码查询
User find(@Param("username")String username,@Param("password")String password);
5.java.lang.NoSuchMethodException: com.opensymphony.xwork2.ActionSupport.login()
解决:applicationContext.xml中的依赖关系没有注入
6.Caused by: java.lang.IllegalArgumentException: ‘sessionFactory‘ or ‘hibernateTemplate‘ is required
解决:applicationContext.xml中的依赖关系dao中没有主人sessionFactory
7.Caused by: Action class [userAction] not found - action
解决:其实是缺少包struts2-sping-plugin 2.0.1.jar
8.使用c3p0数据源时,下边的数据库属性分别是:driverClass,jdbcUrl,user,password
使用springjdbc数据源时,下边的数据库属性分别是:driverClassName,url,username,password