web-dev-qa-db-fra.com

Spring 4.3.0.RELEASE + Hibernate 5.2.0.Final + Référentiel JPA

J'ai cette erreur en essayant de travailler avec Spring JPA:

Impossible d'ouvrir JPA EntityManager pour la transaction; L'exception imbriquée est Java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode () Lorg/hibernate/FlushMode;

** Mise à jour: trace de pile complète

Il fonctionne dans la même configuration dans différents projets

Quelle pourrait être la raison? J'utilise Java 1.8 & Dynamic Web Application 3.1 (En tant que projet parallèle qui fonctionne)

pom.xml:

<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>Test</groupId>
    <artifactId>Test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.Apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                    <webXml>WebContent\WEB-INF\web.xml</webXml>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>org.test.int1.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.3.0.RELEASE</version>
            <exclusions>
            <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                 </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.3.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>4.3.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.3.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>1.10.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>4.1.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>4.1.0.RELEASE</version>
        </dependency>

        <!-- Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.2.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.3.0.Alpha1</version>
        </dependency>

        <!-- AspectJ -->
        <dependency>
            <groupId>aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.5.4</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.21</version>
        </dependency>
            <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.7.21</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.21</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.Sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.Sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
            <scope>runtime</scope>
        </dependency>

        <!-- Apache Commons DBCP -->
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
        </dependency>

        <!-- Javax -->
        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>jta</artifactId>
            <version>1.1</version>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

    </dependencies>

</project>

Erreur complète:

[16/08/16 10:41:57:057 IDT]  INFO web.DefaultSecurityFilterChain: Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.SecurityContextPersistenceFilter@2b00cbc, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@1e44b04e, org.springframework.security.web.header.HeaderWriterFilter@46828666, org.springframework.security.web.csrf.CsrfFilter@7d5376a4, org.springframework.security.web.authentication.logout.LogoutFilter@7f04505e, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@44f95930, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@161a567f, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@709ae44e, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@2d41cca3, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@23ff20e2, org.springframework.security.web.session.SessionManagementFilter@6792334c, org.springframework.security.web.access.ExceptionTranslationFilter@408d1364, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@638afb02]
[16/08/16 10:41:57:057 IDT]  INFO http.DefaultFilterChainValidator: Checking whether login URL '/login' is accessible with your configuration
[16/08/16 10:41:57:057 IDT]  INFO startup.StartupDbDataInit: -------------------------------------------------------
[16/08/16 10:41:57:057 IDT]  INFO startup.StartupDbDataInit:          StartupDbDataInit Working - Starting...       
[16/08/16 10:41:57:057 IDT]  INFO startup.StartupDbDataInit: -------------------------------------------------------
[16/08/16 10:41:57:057 IDT] DEBUG internal.TransactionImpl: begin
[16/08/16 10:41:57:057 IDT] DEBUG internal.TransactionImpl: rolling back
[16/08/16 10:41:57:057 IDT] DEBUG internal.LogicalConnectionManagedImpl: Initiating JDBC connection release from afterTransaction
[16/08/16 10:41:57:057 IDT] DEBUG internal.LogicalConnectionManagedImpl: Initiating JDBC connection release from afterTransaction
[16/08/16 10:41:57:057 IDT]  INFO startup.StartupDbDataInit: StartupDbDataInit Failed!!!!!, Details=>>> Could not open JPA EntityManager for transaction; nested exception is Java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode()Lorg/hibernate/FlushMode;
[16/08/16 10:41:57:057 IDT]  WARN support.XmlWebApplicationContext: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'startupDbDataInit': Invocation of init method failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is Java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode()Lorg/hibernate/FlushMode;
[16/08/16 10:41:57:057 IDT]  INFO jpa.LocalContainerEntityManagerFactoryBean: Closing JPA EntityManagerFactory for persistence unit 'default'
[16/08/16 10:41:57:057 IDT] DEBUG internal.SessionFactoryImpl: HHH000031: Closing
[16/08/16 10:41:57:057 IDT] DEBUG spi.CascadeStyles: External cascade style regsitration [persist : STYLE_PERSIST] overrode base registration [STYLE_PERSIST_SKIPLAZY]
[16/08/16 10:41:57:057 IDT] DEBUG internal.AbstractServiceRegistryImpl: Implicitly destroying ServiceRegistry on de-registration of all child ServiceRegistries
[16/08/16 10:41:57:057 IDT] DEBUG internal.BootstrapServiceRegistryImpl: Implicitly destroying Boot-strap registry on de-registration of all child ServiceRegistries
[16/08/16 10:41:57:057 IDT] ERROR context.ContextLoader: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'startupDbDataInit': Invocation of init method failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is Java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode()Lorg/hibernate/FlushMode;
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.Java:136)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.Java:408)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.Java:1570)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.Java:545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.Java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.Java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.Java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.Java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.Java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.Java:775)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.Java:861)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.Java:541)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.Java:444)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.Java:326)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.Java:107)
    at org.Apache.catalina.core.StandardContext.listenerStart(StandardContext.Java:4842)
    at org.Apache.catalina.core.StandardContext.startInternal(StandardContext.Java:5303)
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:147)
    at org.Apache.catalina.core.StandardContext.reload(StandardContext.Java:3858)
    at org.Apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.Java:291)
    at org.Apache.catalina.core.StandardContext.backgroundProcess(StandardContext.Java:5660)
    at org.Apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.Java:1376)
    at org.Apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.Java:1380)
    at org.Apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.Java:1380)
    at org.Apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.Java:1348)
    at Java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is Java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode()Lorg/hibernate/FlushMode;
    at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.Java:431)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.Java:373)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.Java:427)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.Java:276)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.Java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.Java:179)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.Java:136)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.Java:179)
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.Java:133)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.Java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.Java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.Java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.Java:213)
    at com.Sun.proxy.$Proxy83.count(Unknown Source)
    at com.test.startup.StartupDbDataInit.onApplicationInit(StartupDbDataInit.Java:38)
    at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at Sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at Sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at Java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.Java:365)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.Java:310)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.Java:133)
    ... 25 more
Caused by: Java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode()Lorg/hibernate/FlushMode;
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.prepareFlushMode(HibernateJpaDialect.Java:187)
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.beginTransaction(HibernateJpaDialect.Java:173)
    at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.Java:380)
    ... 46 more

Dépendance: arbre

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Monitor 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The artifact aspectj:aspectjrt:jar:1.5.4 has been relocated to org.aspectj:aspectjrt:jar:1.5.4
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ Monitor ---
[WARNING] The artifact aspectj:aspectjrt:jar:1.5.4 has been relocated to org.aspectj:aspectjrt:jar:1.5.4
[INFO] Monitor:Monitor:war:0.0.1-SNAPSHOT
[INFO] +- org.springframework:spring-context:jar:4.3.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:4.3.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:4.3.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-core:jar:4.3.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-expression:jar:4.3.0.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.3.0.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:4.3.0.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:4.3.0.RELEASE:compile
[INFO] +- org.springframework.data:spring-data-jpa:jar:1.10.2.RELEASE:compile
[INFO] |  +- org.springframework.data:spring-data-commons:jar:1.12.2.RELEASE:compile
[INFO] |  \- org.springframework:spring-orm:jar:4.2.6.RELEASE:compile
[INFO] |     \- org.springframework:spring-jdbc:jar:4.2.6.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:4.1.0.RELEASE:compile
[INFO] |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  \- org.springframework.security:spring-security-core:jar:4.1.0.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-web:jar:4.1.0.RELEASE:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:5.2.2.Final:compile
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  +- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] |  +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] |  \- org.Apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] +- org.hibernate:hibernate-core:jar:5.2.2.Final:compile
[INFO] |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  +- org.jboss:jandex:jar:2.0.0.Final:compile
[INFO] |  +- com.fasterxml:classmate:jar:1.3.0:compile
[INFO] |  \- javax.enterprise:cdi-api:jar:1.1:compile
[INFO] |     +- javax.el:el-api:jar:2.2:compile
[INFO] |     +- org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.1_spec:jar:1.0.0.Beta1:compile
[INFO] |     +- javax.annotation:jsr250-api:jar:1.0:compile
[INFO] |     \- javax.inject:javax.inject:jar:1:compile
[INFO] +- org.hibernate:hibernate-validator:jar:5.3.0.Alpha1:compile
[INFO] |  \- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] +- org.aspectj:aspectjrt:jar:1.5.4:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.21:runtime
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.21:runtime
[INFO] +- log4j:log4j:jar:1.2.17:runtime
[INFO] +- commons-dbcp:commons-dbcp:jar:1.4:compile
[INFO] |  \- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] +- javax.transaction:jta:jar:1.1:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- javax.servlet.jsp:jsp-api:jar:2.2:compile
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- org.jsoup:jsoup:jar:1.7.2:compile
[INFO] +- javax.mail:mail:jar:1.4.7:compile
[INFO] |  \- javax.activation:activation:jar:1.1:compile
[INFO] \- javax.mail:javax.mail-api:jar:1.5.5:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.467 s
[INFO] Finished at: 2016-08-16T12:18:23+03:00
[INFO] Final Memory: 13M/245M
[INFO] ------------------------------------------------------------------------
6
Guyb

Le module hibernate-entitymanager a été supprimé dans Hibernate 5.2.0 et la fonctionnalité a été déplacée vers hibernate-core. Vous pouvez donc simplement supprimer la dépendance hibernate-entitymanager (et utiliser la dernière version 5.2.2 pendant que vous y êtes):

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>5.2.2.Final</version>
</dependency>

Si vous avez toujours la même erreur par la suite, il se peut qu'une autre dépendance dépende d'une version plus ancienne de hibernate-entitymanager, ce qui entraîne des conflits. Dans ce cas, ajoutez à nouveau hibernate-entitymanager avec la version la plus récente:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>5.2.2.Final</version>
</dependency>

De plus, comme spring-data-jpa 1.10.2 dépend de spring-orm 4.2.6, vous devez ajouter la dépendance explicite à spring-orm avec la version correcte:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
    <version>4.3.0.RELEASE</version>
</dependency>
14
dunni

Vous utilisez des bibliothèques incompatibles. L’API a changé en veille prolongée 5:

FlushModeType getFlushMode () 

Pour les utilisateurs des API natives Hibernate, nous avons dû renommer cette méthode Telle que définie par Hibernate de manière historique, car le contrat JPA Définit une méthode du même nom, mais renvoie le fichier JPA FlushModeType plutôt que FlushMode d'Hibernate.

2
Jens

La combinaison suivante fonctionne bien pour moi:

<properties>
  <project.mysql.connector.version>5.1.30</project.mysql.connector.version>
  <project.hibernate.version>5.2.2.Final</project.hibernate.version>
  <project.spring.orm.version>4.3.3.RELEASE</project.spring.orm.version>
  <project.spring.data.jpa.version>1.10.3.RELEASE</project.spring.data.jpa.version>
</properties>


<dependency>
   <groupId>mysql</groupId>
   <artifactId>mysql-connector-Java</artifactId>
   <version>${project.mysql.connector.version}</version>
</dependency>
<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-entitymanager</artifactId>
   <version>${project.hibernate.version}</version>
</dependency>
<dependency>
   <groupId>org.springframework.data</groupId>
   <artifactId>spring-data-jpa</artifactId>
   <version>${project.spring.data.jpa.version}</version>
</dependency>
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-orm</artifactId>
   <version>${project.spring.orm.version}</version>
</dependency>

Cependant, lorsqu’il utilise MULTI-TENANCY (actuellement configuré pour SCHEMA), il n’est pas possible de créer les tables avant d’essayer d’insérer des données et lève une exception: cette table n’est pas présente. Je ne souhaite vraiment pas utiliser l'importation SQL, car cela enlève tous les avantages de la gestion automatique des schémas.

0
Arun S

Cela ressemble à un conflit de Jar. J'utilise la version Spring Framework 4.3.5.RELEASE et je rétrograde le hibernation en hibernate-core-5.1.0.Final. Cela fonctionne pour moi.

0
Aliti