学习中遇到问题--记录

来源:互联网 发布:丹尼斯约翰逊数据 编辑:程序博客网 时间:2024/06/05 17:44

异常

1.spring依赖于日志

异常:

Java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
解决:加入commons-logging-1.1.3.jar

2.

异常:

java.lang.IllegalStateException: BeanFactory not initialized or already closed - call ‘refresh’ before accessing beans via the ApplicationContext
解决:
ApplicationContext ctx = new ClassPathXmlApplicationContext();
改为ApplicationContext ctx = new ClassPathXmlApplicationContext(“beans.xml”);
其中beans.xml是spring bean的配置文件

3.spring2.5

异常:
Error creating bean with name ‘userService’: Autowiring of methods failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void com.mashibing.service.UserService.setUserDao(com.mashibing.dao.UserDao); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.mashibing.dao.UserDao] is defined: Unsatisfied dependency of type [interface com.mashibing.dao.UserDao]: expected at least 1 matching bean
解决:
设置自动注入(@Autowired )的bean(setUserDao)没有在xml文件中定义

4.

异常:
error at ::0 can’t find referenced pointcut performance
解决:
如果要使用AspectJ完成注解切面需要注意下面的JDK与AspectJ的匹配:
  JDK1.6 —— aspectJ1.6
  JDK1.7 —— aspectJ1.7.3+

5.

异常:
cannot proxy target class because CGLIB2 is not available
解决:
加入CGLIB2的包cglib-nodep-2.1_3.jar
注:
一个类若实现了接口,会用jdk自带的proxy和invocationhandler来产生代理;若没有实现接口,会采用直接操作二进制码的方式(即CGLIB)来帮你产生代理的代码

6.

异常:
nested exception is java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPoo
解决:
加入commons-pool.jar

7.

异常:
Cannot load JDBC driver class ‘com.mysql.jdbc.Driver’
解决:
缺少驱动,加入mysql驱动

8建立maven工程报错

异常:
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:RELEASE from any of the configured repositories
解决:
将本地maven仓库中maven-archetype-quickstart文件夹全部删除,再重新建立maven工程,会自动重新下载

9.maven工程测试连接mysql数据库

异常:
Error creating bean with name ‘dataSource’ defined in class path resource [conf/dbconfig.xml]: Invocation of init method failed; nested exception is java.sql.SQLException: com.mysql.jdbc.Driver
解决:
驱动没有加载进来,maven工程pom.xml中加入依赖mysql

10.

异常:
generate mybatis config执行后生成bean类报错alias cannot resolved to a type
解决:
缺少mybatis包,maven工程加入依赖

11.

异常:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): ….TTestMybatisMapper.selectByPrimaryKey
解决:
Mapper.xml文件中mapper namespace定义错误

0 0
原创粉丝点击