大神指点: No matching bean of type [****.UserInfoService] found for dependency:
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了大神指点: No matching bean of type [****.UserInfoService] found for dependency:相关的知识,希望对你有一定的参考价值。
SpringMVC+mybatis框架出现了差错
No matching bean of type [com.basic.readygo.service.UserInfoService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations:
package com.basic.readygo.service;
public interface UserInfoService
/**
* 根据前台传递的账户名和密码查询数据库,是否有木有相应的对象
* @author
* @param userAccount 用户账号
* @param userPassword 密码
* @return 用户信息对象
* */
public Object getObjByNameAndPwd(String username,String password);
package com.basic.readygo.service;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.basic.readygo.mapper.UserInfoMapper;
@Service("userInfoService")
public class UserInfoServiceImpl implements UserInfoService
@Resource
private UserInfoMapper userInfoMapper;
@Override
public Object getObjByNameAndPwd(String username, String password)
// TODO Auto-generated method stub
return userInfoMapper.getObjByNameAndPwd(username, password);
@Controller
@RequestMapping(value="/user")
public class UserInfoController
@Resource
private UserInfoService userInfoService;
//@RequestMapping(method = RequestMethod.POST)
@RequestMapping(value="/login")
public ModelAndView list(HttpServletRequest request)
System.out.println("administrator");
ModelAndView mav = new ModelAndView();
String username="admin";
String password="123456";
UserInfo userInfo=(UserInfo) userInfoService.getObjByNameAndPwd(username, password);
mav.setViewName("/user/ok");
return mav;
applicationContext.xml相应的配置
<!-- spring 自动注入bean -->
<context:annotation-config/>
<context:component-scan base-package="***.model"/>
<context:component-scan base-package="***.service"/>
<context:component-scan base-package="***.mapper"/>
出现这个错误是由于在执行sql的时候无法匹配sql语句的通配符造成的,有两个解决方法
具体步骤
org.apache.ibatis.binding.BindingException: Parameter 'username' not found. Available parameters are [0, 1, param1, param2]1
出现这个错误是由于在执行sql的时候无法匹配sql语句的通配符造成的,有两个解决方法。
1.在对应dao的xml文件的sql语句要这样写
<select id="findByUsernameAndPassword" resultType="com.lzcc.model.User"> select * from user where username = #0 and password = #1;</select>123
2.在dao接口的方法中的参数中添加@param注解
List<User> findByUsernameAndPassword(@Param("username") String username,@Param("password") String password) throws SQLException;1
3.如果上述两点都正常有可能是springmvc把静态资源给拦截了。要在springmvc的配置文件中加入以下代码:
<mvc:resources location="/images/" mapping="/images/**"/>
<mvc:resources location="/js/" mapping="/js/**"/>
<mvc:resources location="/css" mapping="/css/**"/>
参考技术A @Resource换成@Autowire追问所有的@Resource吗?所有的@Resource换成@Autowire,我已经试过了,失败了。
参考技术B <context:component-scan base-package="com.basic.readygo"/><mvc:annotation-driven/>
以上是关于大神指点: No matching bean of type [****.UserInfoService] found for dependency:的主要内容,如果未能解决你的问题,请参考以下文章
No matching bean of type dao found for depende
Spring报错No unique bean of type [com.xxx.Task] is defined: expected single matching bean but found 3(
No rule to make target,怎么解决啊,求大神指点
No matching configuration of project :libusb was found.