ssh,ssm框架使用中遇到的错误

(自己看的笔记,有些简陋,但若能帮到你,不甚荣幸)

1.log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.----配置一个log4j.properties文件
2.Error creating bean with name 'factoryServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: cn.itcast.jk.dao.FactoryDao cn.itcast.jk.service.impl.FactoryServiceImpl.factoryDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'factoryDaoImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void cn.itcast.jk.dao.impl.BaseDaoImpl.setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [beans.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.core.io.Resource[]' for property 'mapperLocations'; nested exception is java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:cn/itcast/jk/mapper/*.xml]: class path resource [cn/itcast/jk/mapper/] cannot be resolved to URL because it does not exist---------
mapper.xml文因路径错误或者名错误未被加载


3.java.lang.classCastEsception:子类=父类,子类强转为父类是不允许的
4.Illegal access: this web application instance has been stopped already.  Could not load com.mchange.v2.resourcepool.BasicResourcePool$5.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException----mapper.xml文件中有错误


5.The content of element type "mapper" must match "(cache-ref|cache|resultMap*|parameterMap*|sql*|
 insert*|update*|delete*|select*)+".----mapper.xml文件中sql语法或者标签错误


6.java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for cn.itcast.jk.mapper.FactoryMapper.get----mapper.xml文件中没有写与方法对应的标签方法




7.javax.el.PropertyNotFoundException: Property 'ctype' not found on type cn.itcast.jk.domain.Factory--bean中没有与表单对应的属性
8.com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ----SQL语句中字段有问题或者其他,可能就是语句中少加了一个逗号


9.Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contractDaoImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void cn.itcast.jk.dao.impl.BaseDaoImpl.setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [F:\javaWeb\apache-tomcat-6.0.39\webapps\Jxsm\WEB-INF\classes\cn\itcast\mapper\Contract.xml]'; nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'cn.itcast.jk.domain.contract'.  Cause: java.lang.ClassNotFoundException: Cannot find class: cn.itcast.jk.domain.contract----mapper.xml文件中有错误


10.java.lang.IllegalArgumentException: Result Maps collection does not contain value for cn.itcast.jk.mapper.ContractMapper.contractRM----<resultMap id="ContractRM"   resultMap="contractRM">,一个大写,一个小写<select>标签中的resultMap属性与resultMap标签不一致


11. Unknown column in 'field list' ----数据库中的字段与实体映射不一致


12. Cannot add or update a child row: a foreign key constraint fails----外键约束缚,可以先关闭外键。 SET FOREIGN_KEY_CHECKS=0;
来禁用外键约束.
 
之后再用
    SET FOREIGN_KEY_CHECKS=1;
来启动外键约束.


13.org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDaoImpl' defined in file [F:\javaWeb\apache-tomcat-6.0.39\webapps\bos\WEB-INF\classes\com\zx\dao\impl\user\UserDaoImpl.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required----


14.  the user must be a supply for connection ----<property name="dataSource" ref="dataSource"></property>sessionFactory中少了这一项配置导致hibernate不能链接数据库


15.  ids for this class must be manually assigned before calling save()----id的生成策略为assigned即手动设置


16. 当我们遇到懒加载异常的时候,又不像改变它的加载模式的时候,这时候,我们就可以在web.xml中配置        OpenSessionInviewFilter过滤器,来解决这个问题了。




17.Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into F。---这样配置<filter>
  <filter-name>OpenSessionInView</filter-name>
  <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
  <init-param> 
           <param-name>flushMode</param-name> 
           <param-value>AUTO</param-value> 
       </init-param>
  </filter>
  <filter-mapping>
  <filter-name>OpenSessionInView</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>


再不行的话可能是aop配置错误


18.


注意!!split(",")可能会造成findById(id)时出错,应该为split(", ");




19.  java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'foodTypeController' bean method ----controller中配置的方法requestmapping重复


20  js中的自定义方法点击没有反应,可能是方法名与内置方法名重复,换一个方法名试试。


21.Struts Problem Report


Struts has detected an unhandled exception:
Messages:


    object references an unsaved transient instance - save the transient instance before flushing: com.zx.domain.qp.QpNoticebill
    object references an unsaved transient instance - save the transient instance before flushing: com.zx.domain.qp.QpNoticebill; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.zx.domain.qp.QpNoticebill


File: org/hibernate/engine/ForeignKeys.java
Line number: 243
Stacktraces
org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: com.zx.domain.qp.QpNoticebill; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.zx.domain.qp.QpNoticebill


保存的目标对象的关联的对象还没有保存,应该先保存关联的对象到数据库中再保存对象


22.org.springframework.dao.InvalidDataAccessResourceUsageException :(存在非法参数)产生这个错误的原因很多。比如字段用了关键字、字段设置自动增长而.hbm.xml设置用程序生成ID等等。(此次错误中我使用了index关键字作为字段)

猜你喜欢

转载自blog.csdn.net/wwaannggxxtt/article/details/80024137