当前位置: 首页 > 知识库问答 >
问题:

更正应用程序的类路径,使其包含一个兼容的javax.persistence.table版本

松涵容
2023-03-14

试图调用不存在的方法。尝试是从以下位置进行的:

org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:1236)

以下方法不存在:

javax.persistence.Table.indexes()[Ljavax/persistence/Index;

该方法的类javax.persistence.table可从以下位置获得:

jar:file:/C:/jboss-eap-6.4.0/jboss-eap-6.4/modules/system/layers/base/javax/persistence/api/main/hibernate-jpa-2.0-api-1.0.1.Final-redhat-3.jar!/javax/persistence/Table.class
vfs:/C:/jboss-eap-6.4.0/jboss-eap-6.4/bin/content/bancaws.war/WEB-INF/lib/javax.persistence-api-2.2.jar/javax/persistence/Table.class
jar:file:/C:/jboss-eap-6.4.0/jboss-eap-6.4/modules/system/layers/base/javax/persistence/api/main/hibernate-jpa-2.0-api-1.0.1.Final-redhat-3.jar!/
            <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
                <modelVersion>4.0.0</modelVersion>
                <groupId>xxxx</groupId>
                <artifactId>xxxx</artifactId>
                <version>0.0.1-SNAPSHOT</version>
                <packaging>war</packaging>
                <parent>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-parent</artifactId>
                    <version>2.1.7.RELEASE</version>
                </parent>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-data-jpa</artifactId>
                        <version>2.1.7.RELEASE</version>
                    </dependency>

            <dependency>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.1-api</artifactId>
                <version>1.0.0.Final</version>
            </dependency>       

                    <!-- testing dependency -->   
                    <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-test</artifactId>
                        <scope>test</scope>
                        <exclusions>
                            <exclusion>
                                <groupId>junit</groupId>
                                <artifactId>junit</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency> 

                    <dependency>
                        <groupId>org.junit.jupiter</groupId>
                        <artifactId>junit-jupiter-api</artifactId>
                        <version>5.3.2</version>
                        <scope>test</scope>

                    </dependency>
                    <dependency>
                        <groupId>org.junit.jupiter</groupId>
                        <artifactId>junit-jupiter-engine</artifactId>
                        <version>5.3.2</version>
                        <scope>test</scope>
                    </dependency>

                    <!--Oracle JDBC -->
                    <dependency>
                        <groupId>com.oracle</groupId>
                        <artifactId>ojdbc8</artifactId>
                        <version>18.3</version>
                    </dependency>

                    <!-- HikariCP connection pool -->
                    <dependency>
                        <groupId>com.zaxxer</groupId>
                        <artifactId>HikariCP</artifactId>
                        <version>2.6.0</version>
                    </dependency>  
            <!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>5.1.9.RELEASE</version>
            </dependency>

            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
                <version>8.0</version>
                <scope>provided</scope>
            </dependency>

                </dependencies>  
                <build>
                    <finalName>xxxx</finalName> 
                    <plugins>
                        <plugin>
                            <artifactId>maven-compiler-plugin</artifactId>
                            <version>3.8.0</version>
                            <configuration>
                                <source>1.8</source>
                                <target>1.8</target>
                            </configuration>
                        </plugin>
                        <plugin>
                            <artifactId>maven-war-plugin</artifactId>
                            <version>3.2.1</version>
                            <configuration>
                                <warSourceDirectory>WebContent</warSourceDirectory>
                            </configuration>
                        </plugin>
                        <plugin>
                            <artifactId>maven-surefire-plugin</artifactId>
                            <version>2.22.0</version>
                        </plugin>            
                    </plugins>
                </build>
            </project>

共有1个答案

诸葛令
2023-03-14

此错误是由于依赖项JAR的版本冲突造成的。我发现您在pom.xml中使用了hibernate-jpa-2.1-api,它与以下错误消息相冲突:

jar:file:/C:/jboss-eap-6.4.0/jboss-eap-6.4/modules/system/layers/base/javax/persistence/api/main/hibernate-jpa-2.0-api-1.0.1.Final-redhat-3.jar!/

在我看来,您的JBoss版本支持hibernate JPA2.0版。因此,如果您没有在代码中显式使用2.1jpa版本之外的任何接口,则可以尝试删除以下依赖项:

        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <version>1.0.0.Final</version>
        </dependency>   

如果您打算使用JPA2.1版,可能需要将war部署到支持该版本的web容器中。

 类似资料: