Validation中不是本机或抽象的方法中的缺少Code属性

Validation中不是本机或抽象的方法中的缺少Code属性

本文介绍了java.lang.ClassFormatError:类文件javax/validation/Validation中不是本机或抽象的方法中的缺少Code属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用maven添加activemq,在IDE中进行单元测试时存在与jar冲突的问题,异常消息为:

Using maven to add activemq, there is a problem about conflicting jar when I unit-test in IDE, the exception message is:

java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/validation/Validation

我已从javaee中排除了验证,如下所示:

i have excluded the validation from javaee, as following:

   <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
        <exclusions>
            <exclusion>
                <groupId>javax.validation</groupId>
                <artifactId>validation-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-jms_1.1_spec</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

,对activemq的依赖为

and dependency for activemq is

  <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-all</artifactId>
        <version>${activemq_version}</version>

        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
            </exclusion>

            <exclusion>
                <groupId>org.fusesource.fuse-extra</groupId>
                <artifactId>fusemq-leveldb</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

这是一个烦人的问题.

有人想提出一点吗?帮助非常感谢!

anyone would like to give some point? Help much appreciated!

推荐答案

依赖项 javax :: javaee-api 包含剥离的类,这些剥离的类不包含此处.您可以改用JBoss提供的API JAR:

The dependency javax::javaee-api contains stripped classes which contain no method implementations as described here. You can use the API JAR provided by JBoss instead:

<dependency>
    <groupId>org.jboss.spec</groupId>
    <artifactId>jboss-javaee-6.0</artifactId>
    <version>1.0.0.Final</version>
    <type>pom</type>
    <scope>provided</scope>
</dependency>

这篇关于java.lang.ClassFormatError:类文件javax/validation/Validation中不是本机或抽象的方法中的缺少Code属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 07:00