搭建SSM环境所遇到的问题汇总

  1. @Autowired注入找不到对应对象

org.springframework.beans.factory.NoSuchBeanDefinitionException: No
qualifying bean of type ‘com.ssm.service.EmployeeService’ available:
expected at least 1 bean which qualifies as autowire candidate.
Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}

解决方法:
ContextLoaderListener的作用就是启动Web容器时,自动装配ApplicationContext.xml的配置信息。 故在web.xml中加入以下代码:

      <listener>
         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     </listener>
  1. Junit测试出错

java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing

解决方法:
在pom中导入hamcrest-all包

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>

之前查阅过问题,需要加入hamcrest-library包,但我加入之后还是会出现上述错误,所以直接导入hamcrest-all包,成功运行

  1. 在jsp页面引入pageContext.setAttribute爆红
    在这里插入图片描述
    解决方法:
    在pom.xml文件中导入

        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.1</version>
        </dependency>
    
  2. 注册时出现sql语句找不到username

    org.mybatis.spring.MyBatisSystemException: nested exception is
    org.apache.ibatis.binding.BindingException: Parameter ‘username’ not
    found. Available parameters are [arg1, arg0, param1, param2]

    解决方法:
    Mapper的接口文件中定义时候未加注解:
    在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值