- @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>
- 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包,成功运行
-
在jsp页面引入pageContext.setAttribute爆红
解决方法:
在pom.xml文件中导入<dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>javax.servlet.jsp-api</artifactId> <version>2.3.1</version> </dependency>
-
注册时出现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的接口文件中定义时候未加注解: