ssm增删改查出现的问题总结

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 foundCaused 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 foundCaused 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.NullPointerExceptionat 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 causeorg.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

9.Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property ‘dataSource’ of bean class [org.mybatis.spring.transaction.SpringManagedTransactionFactory]: Bean property ‘dataSource’ is not writable or has an invalid setter method. Do

原因:<property name=”dataSource”>应该驼峰命名,结果直接复制粘贴成小写了

人若软弱就是自己最大的敌人

ssm增删改查出现的问题总结

相关文章:

你感兴趣的文章:

标签云: