Spring Boot 启动的时候报的错
使用Drools 5.6版本,Spring Boot1.5.8版本,JAVA8版本,Eclipse4.4.2版本。
Google后在Stack上发现一个,中文较少,贴一下。
原因是因为Eclipse不支持Java8编译Drools5.6版本。
解决方案:
给项目添加依赖:
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>4.5.1</version>
</dependency>
再次启动,OK
报错内容:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'knowledgeBase': Invocation of init method failed; nested exception is java.lang.RuntimeException: wrong class format at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] ... 19 common frames omitted Caused by: java.lang.RuntimeException: wrong class format at org.drools.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:263) ~[drools-compiler-5.6.0.Final.jar:5.6.0.Final] at org.drools.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:203) ~[drools-compiler-5.6.0.Final.jar:5.6.0.Final] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:102) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:49) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:122) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromTypeSignature(LookupEnvironment.java:1188) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromVariantTypeSignature(LookupEnvironment.java:1244) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeArgumentsFromSignature(LookupEnvironment.java:1031) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromTypeSignature(LookupEnvironment.java:1193) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethod(BinaryTypeBinding.java:495) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethods(BinaryTypeBinding.java:577) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(BinaryTypeBinding.java:327) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:640) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:619) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:295) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:107) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:49) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:122) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.resolve(ParameterizedTypeBinding.java:851) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:100) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveTypesFor(BinaryTypeBinding.java:1016) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.getExactMethod(BinaryTypeBinding.java:771) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.Scope.findExactMethod(Scope.java:893) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.lookup.Scope.getMethod(Scope.java:2234) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:401) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:314) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:913) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:447) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:189) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:406) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1131) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1219) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:528) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:759) ~[ecj-3.5.1.jar:na] at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:464) ~[ecj-3.5.1.jar:na] at org.drools.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaCompiler.java:389) ~[drools-compiler-5.6.0.Final.jar:5.6.0.Final] at org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:49) ~[drools-compiler-5.6.0.Final.jar:5.6.0.Final] at org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:410) ~[drools-compiler-5.6.0.Final.jar:5.6.0.Final] at org.drools.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.java:46) ~[drools-compiler-5.6.0.Final.jar:5.6.0.Final] at org.drools.compiler.PackageRegistry.compileAll(PackageRegistry.java:103) ~[drools-compiler-5.6.0.Final.jar:5.6.0.Final] at org.drools.compiler.PackageBuilder.compileAll(PackageBuilder.java:1196) ~[drools-compiler-5.6.0.Final.jar:5.6.0.Final] at org.drools.compiler.PackageBuilder.compileAllRules(PackageBuilder.java:949) ~[drools-compiler-5.6.0.Final.jar:5.6.0.Final] at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:938) ~[drools-compiler-5.6.0.Final.jar:5.6.0.Final] at org.drools.compiler.PackageBuilder.addPackageFromDecisionTable(PackageBuilder.java:451) ~[drools-compiler-5.6.0.Final.jar:5.6.0.Final] at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:715) ~[drools-compiler-5.6.0.Final.jar:5.6.0.Final] at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:51) ~[drools-compiler-5.6.0.Final.jar:5.6.0.Final] at org.drools.container.spring.beans.KnowledgeBaseBeanFactory.afterPropertiesSet(KnowledgeBaseBeanFactory.java:113) ~[drools-spring-5.6.0.Final.jar:5.6.0.Final] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE] ... 26 common frames omitted Caused by: org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException: null at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>(ClassFileReader.java:372) ~[ecj-3.5.1.jar:na] at org.drools.commons.jci.compilers.EclipseJavaCompiler$2.createNameEnvironmentAnswer(EclipseJavaCompiler.java:287) ~[drools-compiler-5.6.0.Final.jar:5.6.0.Final] at org.drools.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:258) ~[drools-compiler-5.6.0.Final.jar:5.6.0.Final] ... 74 common frames omitted