Maven Hibernate 错误 void org.hibernate.cfg.AnnotationBinder.bindDefaults(org.hibernate.boot.spi.MetadataBuildingContext)

问题描述 投票:0回答:0

我认为 pom 文件中版本的配置相互之间没有正确匹配。有人可以帮我解决这个问题吗?

我多次更改与休眠相关的版本和组合,但无法找出正确的版本。 在持久性文件中定义了 2 个上下文,因为我需要它们。

有一个基本的 JPA 初始化类和一个实现类。

POM.XML

<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
    <artifactId>ParentServer</artifactId>
    <groupId>com.gncc.srv</groupId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>api.rest</artifactId>
<packaging>war</packaging>
<name>GNCC Base Rest Api Server</name>
<!-- FIXME change it to the project's website -->
<url>http://localhost:8080</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>

    <swagger-core-version>2.0.9</swagger-core-version>
    <jackson-version>2.11.2</jackson-version>
    <resteasy-version>6.2.2.Final</resteasy-version>
    
    <jetty-version>9.2.9.v20150224</jetty-version>

    <junit-version>4.13.1</junit-version>
    <servlet-api-version>5.0.0</servlet-api-version>
    <jakarta-annotation-version>1.3.5</jakarta-annotation-version>
    <beanvalidation-version>2.0.2</beanvalidation-version>
    
    <hibernate>6.1.7.Final</hibernate>
    <hibernate-search>6.1.8.Final</hibernate-search>
    <hibernate-tools>5.6.15.Final</hibernate-tools>
    <hibernate-validator>8.0.0.Final</hibernate-validator>
    <hibernate-annotations>3.5.5-Final</hibernate-annotations>
    <hibernate-java-relocation>5.6.15.Final</hibernate-java-relocation>
    
    <slf4j-api>2.0.6</slf4j-api>
    <gson>2.10.1</gson>
</properties>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api -->
    <dependency>
        <groupId>jakarta.servlet</groupId>
        <artifactId>jakarta.servlet-api</artifactId>
        <version>6.0.0</version>
        <scope>provided</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-bom -->
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-bom</artifactId>
        <version>6.2.2.Final</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
    
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-client</artifactId>
        <version>${resteasy-version}</version>
    </dependency>
    
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-core</artifactId>
        <version>${resteasy-version}</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxb-provider -->
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jaxb-provider</artifactId>
        <version>${resteasy-version}</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-servlet-initializer -->
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-servlet-initializer</artifactId>
        <version>${resteasy-version}</version>
    </dependency>

    <!-- swagger v3 -->
    <dependency>
        <groupId>io.swagger.core.v3</groupId>
        <artifactId>swagger-annotations</artifactId>
        <version>${swagger-core-version}</version>
    </dependency>
    
    <dependency>
        <groupId>io.swagger.core.v3</groupId>
        <artifactId>swagger-jaxrs2</artifactId>
        <version>${swagger-core-version}</version>
    </dependency>
    
    <!-- ####################################################################### -->
    
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate}</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-java8 -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-java8</artifactId>
        <version>${hibernate-java-relocation}</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-tools -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-tools</artifactId>
        <version>${hibernate-tools}</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-annotations -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-annotations</artifactId>
        <version>${hibernate-annotations}</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>${hibernate-validator}</version>
    </dependency>

    <!-- ####################################################################### -->

    <!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
    <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
        <version>3.1.2</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.firebirdsql.jdbc/jaybird -->
    <dependency>
        <groupId>org.firebirdsql.jdbc</groupId>
        <artifactId>jaybird</artifactId>
        <version>5.0.1.java11</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>${gson}</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.11.0</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j-api}</version>
    </dependency>

</dependencies>

<build>
    <finalName>GsbApi</finalName>
    <pluginManagement>
        <!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
        <plugins>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.1.0</version>
            </plugin>
            <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.2</version>
            </plugin>
            <plugin>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.2</version>
            </plugin>
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

PERSISTENCE.XML

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">

<persistence-unit name="GSBIntranet">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <properties>
        <property name="javax.persistence.jdbc.driver"   value="org.mariadb.jdbc.Driver" />
        <property name="javax.persistence.jdbc.url"      value="jdbc:mysql://192.168.86.155:3306/jpa_jbd?useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC&amp;useSSL=false" />
        <property name="javax.persistence.jdbc.user"     value="admin" />
        <property name="javax.persistence.jdbc.password" value="k!b098gTsF" />
        <property name="hibernate.show_sql"              value="true" />
        <property name="hibernate.dialect"               value="org.hibernate.dialect.MySQLInnoDBDialect" />
    </properties>
</persistence-unit>

<persistence-unit name="BauSU">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <properties>
        <property name="javax.persistence.jdbc.driver"   value="org.firebirdsql.jdbc.FBDriver" />
        <property name="javax.persistence.jdbc.url"      value="jdbc:firebirdsql://192.168.86.152:3050/D:\\Bau-SU\DATA\GSB\GSB.GDB/jpa_jbd?useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC&amp;useSSL=false" />
        <property name="javax.persistence.jdbc.user"     value="ODBCUSER" />
        <property name="javax.persistence.jdbc.password" value="ODBC" />
        <property name="hibernate.show_sql"              value="true" />
        <property name="hibernate.dialect"               value="org.hibernate.dialect.MySQLInnoDBDialect" />
    </properties>
</persistence-unit>

抽象类

    import org.hibernate.mapping.List;
import org.hibernate.query.Query;

import com.gncc.srv.api.jpa.dao.JPADao;

import de.gsb.srv.api.rest.domain.humanresources.modules.account.model.Account;
import jakarta.persistence.EntityManager;

/**
 * @author j.schindler
 *
 */
public class AccountDAO extends JPADao{

    /**
     * 
     */
    public AccountDAO() {
        // TODO Auto-generated constructor stub
    }

    public static java.util.List<Account> getAllAccountsQuery() {
        System.out.println("-- Employee by salary range --");
        EntityManager em = null;
        try {
            em = getEm( "GSBIntranet" );
            return (java.util.List<Account>) doNQuery(em, Account.QUERY_GET_ALL_ACCOUNTS, Account.class);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            em.close();
        }
        return null;
    }


}

实施类 ~ 导入 org.hibernate.mapping.List; 导入 org.hibernate.query.Query;

import com.gncc.srv.api.jpa.dao.JPADao;

import de.gsb.srv.api.rest.domain.humanresources.modules.account.model.Account;
import jakarta.persistence.EntityManager;

public class AccountDAO extends JPADao{

    /**
     * 
     */
    public AccountDAO() {
        // TODO Auto-generated constructor stub
    }

    public static java.util.List<Account> getAllAccountsQuery() {
        System.out.println("-- Employee by salary range --");
        EntityManager em = null;
        try {
            em = getEm( "GSBIntranet" );
            return (java.util.List<Account>) doNQuery(em, Account.QUERY_GET_ALL_ACCOUNTS, Account.class);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            em.close();
        }
        return null;
    }


}

~

hibernate maven annotations bind
© www.soinside.com 2019 - 2024. All rights reserved.