java ssm常遇见的问题_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 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

报错的配置是:

正确的配置应该是

最后总结下,就是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

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值