本文介绍了Maven突然出现错误,截断类文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天Maven工作正常,今天它显示了这个问题,我尝试备份也不行,为了你的信息,tomcat工作正常,它的一个maven问题,我卸载maven并重新安装所有的东西,发布这个问题

  {Stack trace:
--------------- -------------------------------------------------- ------
线程main中的异常java.lang.ClassFormatError:截断的类文件
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:30)
at sun .reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
java.lang.reflect.Proxy.newProxyInstance(Proxy .java:588)
at sun.reflect.annotation.AnnotationParser.annotationForMap(AnnotationParser.java:239)
at sun.reflect.annotation.AnnotationP arser.parseAnnotation(AnnotationParser.java:229)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java: 52)
在java.lang.reflect.Field.declaredAnnotations(Field.java:1016)
在java.lang.reflect.Field.getAnnotation(Field.java:1000)
at com .google.inject.spi.InjectionPoint.getAtInject(InjectionPoint.java:468)
com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:653)
com.google.inject .spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:358)
com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:377)
com.google.inject.internal.BindingBuilder .toProvider(BindingBuilder.java:106)
在com.google.inject.internal.BindingBuilder.toProvider(BindingBuilder.java:43)
at或g.sonatype.guice.plexus.binders.PlexusTypeBinder.hear(PlexusTypeBinder.java:85)
在org.sonatype.guice.plexus.binders.PlexusXmlBeanModule.configure(PlexusXmlBeanModule.java:91)
at org.sonatype.guice.plexus.binders.PlexusBindingModule.configure(PlexusBindingModule.java:62)
com.google.inject.spi.Elements $ RecordingBinder.install(Elements.java:229)
at com.google.inject.spi.Elements.getElements(Elements.java:103)
在com.google.inject.spi.Elements.getElements(Elements.java:80)
在org.sonatype。 guice.bean.binders.MergedModule.configure(MergedModule.java:54)
com.google.inject.spi.Elements $ RecordingBinder.install(Elements.java:229)
在com.google。 inject.spi.Elements.getElements(Elements.java:103)
在com.google.inject.internal.InjectorShell $ Builder.build(InjectorShell.java:136)
com.google.inject。 internal.InternalInjectorCreator.build(InternalInjectorCreator.java :104)
com.google.inject.Guice.createInjector(Guice.java:94)
com.google.inject.Guice.createInjector(Guice.java:71)
at com.google.inject.Guice.createInjector(Guice.java:61)
在org.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector(DefaultPlexusContainer.java:470)
在org.codehaus.plexus.DefaultPlexusContainer。 < init>(DefaultPlexusContainer.java:196)
在org.codehaus.plexus.DefaultPlexusContainer。< init>(DefaultPlexusContainer.java:160)
在org.apache.maven.cli.MavenCli。 container(MavenCli.java:375)
在org.apache.maven.cli.MavenCli.doMain(MavenCli.java:191)
在org.apache.maven.cli.MavenCli.main(MavenCli。 java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl。调用(DelegatingMet hodAccessorImpl.java:25)
在java.lang.reflect.Method.invoke(Method.java:597)
在org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java: 290)
在org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
在org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java: 409)
在org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)}


解决方案

清理您的maven仓库:



(默认情况下在您的用户文件夹中)

 〜/ .m2 / repository 

然后执行一个干净的安装,以便它再次下载依赖项并重新编译整个项目:

  mvn clean install 


Yesterday Maven is working fine,,today it shows that problem,I tried backup also it does not work ,and for your information tomcat is working fine its a maven problem ,and I uninstall maven and install it again and all things before posting this question

{Stack trace:
    -----------------------------------------------------------------------
    Exception in thread "main" java.lang.ClassFormatError: Truncated class file
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:30)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:588)
        at sun.reflect.annotation.AnnotationParser.annotationForMap(AnnotationParser.java:239)
        at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:229)
        at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
        at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
        at java.lang.reflect.Field.declaredAnnotations(Field.java:1016)
        at java.lang.reflect.Field.getAnnotation(Field.java:1000)
        at com.google.inject.spi.InjectionPoint.getAtInject(InjectionPoint.java:468)
        at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:653)
        at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:358)
        at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:377)
        at com.google.inject.internal.BindingBuilder.toProvider(BindingBuilder.java:106)
        at com.google.inject.internal.BindingBuilder.toProvider(BindingBuilder.java:43)
        at org.sonatype.guice.plexus.binders.PlexusTypeBinder.hear(PlexusTypeBinder.java:85)
        at org.sonatype.guice.plexus.binders.PlexusXmlBeanModule.configure(PlexusXmlBeanModule.java:91)
        at org.sonatype.guice.plexus.binders.PlexusBindingModule.configure(PlexusBindingModule.java:62)
        at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:229)
        at com.google.inject.spi.Elements.getElements(Elements.java:103)
        at com.google.inject.spi.Elements.getElements(Elements.java:80)
        at org.sonatype.guice.bean.binders.MergedModule.configure(MergedModule.java:54)
        at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:229)
        at com.google.inject.spi.Elements.getElements(Elements.java:103)
        at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:136)
        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
        at com.google.inject.Guice.createInjector(Guice.java:94)
        at com.google.inject.Guice.createInjector(Guice.java:71)
        at com.google.inject.Guice.createInjector(Guice.java:61)
        at org.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector(DefaultPlexusContainer.java:470)
        at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:196)
        at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:160)
        at org.apache.maven.cli.MavenCli.container(MavenCli.java:375)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:191)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)}
解决方案

Clean your maven repository:

(By default in your user folder)

~/.m2/repository

Then perform a clean install so it download the dependencies again and recompile your entire project:

mvn clean install

这篇关于Maven突然出现错误,截断类文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 09:16