3个报错:
Failed to read candidate component class: file [D:\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\bootstrap-3.3.5\WEB-INF\classes\fish\code\dao\user\UserDao.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [D:\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\bootstrap-3.3.5\WEB-INF\classes\fish\code\dao\user\UserDao.class]; nested exception is java.lang.IllegalArgumentException
ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [D:\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\bootstrap-3.3.5\WEB-INF\classes\fish\code\dao\user\UserDao.class]; nested exception is java.lang.IllegalArgumentException
BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
代码:
@Repository
public class UserDao extends SqlSessionDaoSupport{
public UserModel getUserModel(){
return this.getSqlSession().selectOne("UserModel.getUserById",1L);
}
}
@Service
public class UserService {
@Resource
private UserDao userDao;
public UserModel getUserModel(){
return userDao.getUserModel();
}
}
@WebServlet(name = "userServlet", urlPatterns = { "/user" })
public class UserServlet extends HttpServlet {
public void init() throws ServletException {
WebApplicationContext context = WebApplicationContextUtils
.getWebApplicationContext(getServletContext());
this.setUserService((UserService) context.getBean("userService"));
}
}
spring配置扫描
之后就报上边3个错.
求大神指点.
写上这句话就报错.
不写这句话程序可以跑起来,但是在servlet里边获取不到userService.
应该是你UserDao这个类所对应的xml配置错误导致!好好检查下
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。