异常小记

来源:互联网 发布:如何在淘宝上卖鱼 资质 编辑:程序博客网 时间:2024/06/07 09:37

一直报以下错误:

Exception sending context initialized event to listener instance of classcom.demo.web.listener.InitApplicationListener

java.lang.IllegalArgumentException

at org.springframework.asm.ClassReader.<init>(Unknown Source)

<properties>
  <!-- spring版本号-->
  <jackson.version>2.4.4</jackson.version>
  <spring.version>4.0.2.RELEASE</spring.version>
  <!-- mybatis版本号-->
  <mybatis.version>3.3.0</mybatis.version>
  <!-- log4j日志文件管理包版本-->
  <slf4j.version>1.7.7</slf4j.version>
  <log4j.version>1.2.17</log4j.version>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

1.8jdk对于spring的版本需要在4.0以上。


一直报以下错误:

Not found org.springframework.http.converter.json.MappingJacksonHttpMessageConverter

这种配置用的是jackson1.X版本的,如果你项目里是2.X的,请用org.springframework.http.converter.json.MappingJacksonHttp2MessageConverter或者下载1.X的。

<!--避免IE执行AJAX,返回JSON出现下载文件-->
<bean id="mappingJacksonHttpMessageConverter"
   class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
   <property name="supportedMediaTypes">
      <list>
         <value>text/html;charset=UTF-8</value>
      </list>
   </property>
</bean>

 

一直报以下错误:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.changyu.foryou.mapper.SellerMapper.selectByCampusAdmin

原因:mybatis未扫描到xml文件, IDEA中在编译的时候,如果配置文件不是放在Resources文件夹下就不会被执行编译

解决方法:

<!-- sessionFactoryspringmybatis整合-->
<bean id="sqlSessionFactory"class="org.mybatis.spring.SqlSessionFactoryBean">
   <property name="dataSource"ref="dataSource"/>

   <!--不能扫描java-->
   <!--<property name="mapperLocations" value="classpath:com/changyu/foryou/mapping/*.xml" />-->
   <!--<property name="mapperLocations" value="classpath:/**/mapping/*Mapper.xml" />    <!–加载mapper文件–>-->

   <!--扫描resources目录下的xml文件(貌似idea中在编译的时候,如果配置文件不是放在Resources文件夹下就不会被执行编译,导致运行时找不到的问题)-->
   <!--建议把xml文件放到resources目录下-->
   <propertyname="mapperLocations"value="classpath*:mapping/*.xml"/>
</bean>

<!-- 通过扫描的模式,扫描目录在com/hoo/mapper目录下,所有的mapper都继承SqlMapper接口的接口, 这样一个bean就可以了-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
   <property name="basePackage"value="com.changyu.foryou.mapper"/>
   <property name="sqlSessionFactoryBeanName"value="sqlSessionFactory"/>
</bean>


一直报以下错误:

java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result

原因:通过BigDecimaldivide方法进行除法时当不整除,出现无限循环小数时,就会抛异常:java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result. 

解决方法:

解决的办法就是给divide方法设置精确的小数点,如:divide(xxxxx,2)

tpodetail.setNotaxunitprice(taxunitprice.divide((newBigDecimal(1).add(taxrate.divide(newBigDecimal(100),4))),4));

 

偶尔启动Debug模式用Tomcat来调试会报以下错误:

Unable to open debugger port (127.0.0.1:63777): Java.NET.BindException "Address already in use: JVM_Bind"

原因:出来Tomcat Server的配置上。

解决方法:

问题解决之前端口用的是63777,后来我索性把这个Tomcat Server删掉重新创建一下,它就自动使用50424这个端口了,启动Debug模式,问题解决成功!

(当然,你不删除Tomcat Server配置,手动修改端口号估计也行,但是我试了它只能用上下箭头去改端口,好麻烦。而且手动改了之后也不一定能用,所以不如重建让Intellij IDEA自动找的好)。


一直报以下错误:

java.sql.SQLException: Column count doesn't match value count at row 1

原因:是由于写的SQL语句里列的数目和后面的值的数目不一致

比如insert into表名(field1,field2,field3) values('a','b')这样前面的是三列,后面却只有二个值,这就会出现这个错误的。 

解决方法:检查sql


一直报以下错误:

Error:java: Annotation processing is not supported for module cycles. Please ensure that all modules from cycle [common,util] are excluded from annotation processing

原因:分布式各模块循环依赖

解决方法:检查各模块pom.xml文件依赖情况




0 0
原创粉丝点击