整个生产环境采用JDK1.8 + Tomcat 7.0.65
代码重构后,启动报错,主要异常如下:
严重: Unable to process Jar entry [module-info.class] from Jar [jar:file:/home/unisound/private_cloud_platform/device_center/apache-tomcat-7.0.65/webapps/device-center/WEB-INF/lib/lombok-1.18.2.jar!/] for annotationsorg.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19
ERROR localhost-startStop-1 (FrameworkServlet.java:502) - Context initialization failedorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/el/ELManager
根据提示,明确是由于lombok 和 validatation校验框架引起的;
查看当前引入的jar包版本:
1.18.2 2.0.1.Final 6.0.9.Final org.hibernate.validator hibernate-validator ${version.hibernate-validator} javax.validation validation-api ${version.validation-api} org.projectlombok lombok ${version.lombok}
原来是因为lombok 和 hibernate-validator引起的,当前版本Tomcaat7是不支持滴。
解决方案:
1、lombok 和 hibernate-validator版本降级
1.14.8 2.0.0.Final 5.4.3.Final
2、升级tomcat8
强烈建议使用第二种方案!tomcat7的bug也可以解决掉,当然代价就是所有功能的回归测试。。。