Spring Boot错误创建Bean,名称为Error。

huangapple 未分类评论48阅读模式
英文:

Spring boot Error creating bean with name Error

问题

My project works correctly on a PC in the LAN, but when I copy it to my computer, it doesn't work. The error message indicates a problem with bean creation and autowired dependencies in the Spring framework. The primary issue seems to be related to the org.hibernate.annotations.common.reflection.ReflectionManager class not being found. This issue is likely due to a classpath mismatch or version conflict.

Here's the relevant part of your error message:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ChemiSectionDao': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mainEntityManagerFactory' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ReflectionManager
...
Caused by: java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ReflectionManager
...
Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.ReflectionManager

To resolve this issue, you should consider the following steps:

  1. Check your dependencies: Ensure that your project's dependencies and versions are compatible. The error could be caused by a mismatch between the Hibernate version you're using and the version of the Hibernate annotations library. Make sure all your dependencies are properly aligned.

  2. Hibernate Compatibility: The error message suggests a class not being found in the org.hibernate.annotations.common.reflection package. This package is associated with Hibernate's annotation processing. Ensure that your Hibernate version is compatible with the Spring Boot version you're using.

  3. MySQL Connector Version: The version of the MySQL Connector you're using (8.0.20) might still not be compatible with the specific version of Hibernate or Spring Boot. You might want to try a version that is known to work well with both Spring Boot and Hibernate. You could try downgrading to a version like 8.0.14 or 5.1.25 to see if it resolves the issue.

  4. Classpath and Dependencies: Make sure that your project's classpath is set up correctly and that there are no conflicts between different versions of the same libraries. Check your project's dependency hierarchy to see if there are any transitive dependencies causing issues.

  5. Review Configuration Files: Carefully review your XML configuration files (mvc-dispatcher-servlet.xml and persist.xml) to ensure that all configurations are correctly defined and that there are no typos or errors.

  6. Spring Boot Compatibility: If you're using Spring Boot, consider using the version of Hibernate that comes bundled with your Spring Boot version. Spring Boot manages dependency versions to ensure compatibility.

  7. Logging and Debugging: Enable detailed logging for Spring and Hibernate to get more information about what's happening during bean creation and initialization. This can help identify the specific point of failure.

  8. Clear the Build and Run Again: Sometimes, issues can arise due to corrupted build artifacts. Try cleaning your project build, deleting any cached files, and rebuilding it from scratch.

  9. Internet Connection: If you're using Maven, make sure your internet connection is stable when you're building the project. This ensures that all dependencies are downloaded correctly.

Remember to back up your project before making significant changes to your dependencies or configurations. Additionally, consult the official documentation for Spring, Spring Boot, Hibernate, and MySQL Connector to get more information on compatibility and troubleshooting.

英文:

My project work correctly on a PC in LAN, but when I copy it to my Computer it doesn't work.
the error

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'blowDownFilterController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.dem.cit.chemi.dao.ChemiSectionDao com.dem.cit.chemi.controller.BlowDownFilterController.chemiSectionDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ChemiSectionDao': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mainEntityManagerFactory' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ReflectionManager
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
...
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.dem.cit.chemi.dao.ChemiSectionDao com.dem.cit.chemi.controller.BlowDownFilterController.chemiSectionDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ChemiSectionDao': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mainEntityManagerFactory' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ReflectionManager
...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ChemiSectionDao': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mainEntityManagerFactory' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ReflectionManager
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:357) ~[spring-orm-4.1.6.RELEASE.jar:4.1.6.RELEASE]
...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mainEntityManagerFactory' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ReflectionManager
...
Caused by: java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ReflectionManager
...
Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.ReflectionManager
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1358) ~[catalina.jar:8.5.54]
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1180) ~[catalina.jar:8.5.54]
... 99 common frames omitted

and pom

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.3.RELEASE</version>
    <relativePath/>
    <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-ws</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.25</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20141113</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.3.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-c3p0</artifactId>
        <version>4.3.5.Final</version>
    </dependency>
    <dependency>
        <groupId>net.sf.jasperreports</groupId>
        <artifactId>jasperreports</artifactId>
        <version>3.7.6</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.6</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.lowagie</groupId>
        <artifactId>itext</artifactId>
        <version>2.1.7</version>
    </dependency>
    <dependency>
        <groupId>commons-digester</groupId>
        <artifactId>commons-digester</artifactId>
        <version>2.1</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>1.7.0</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.13</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.6.2</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.logging</groupId>
        <artifactId>jboss-logging</artifactId>
        <version>3.4.1.Final</version>
    </dependency>

</dependencies>

<repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>http://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>com.samaxes.maven</groupId>
            <artifactId>minify-maven-plugin</artifactId>
            <version>1.7.6</version>
            <executions>
                <execution>
                    <id>default-minify</id>
                    <phase>package</phase><!-- When omitted defaults to 'process-resources' -->
                    <configuration>
                        <charset>UTF-8</charset>

                        <cssSourceDir>resources/css/web</cssSourceDir>
                        <cssSourceIncludes>
                            <cssSourceInclude>**</cssSourceInclude>
                        </cssSourceIncludes>

                        <jsSourceDir>resources/js</jsSourceDir>
                        <jsSourceIncludes>
                            <jsSourceInclude>**</jsSourceInclude>
                        </jsSourceIncludes>

                    </configuration>
                    <goals>
                        <goal>minify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <!-- in order to use minify filed listed bellow -->
                <warSourceExcludes>**/*.css, **/*.js</warSourceExcludes>
            </configuration>
        </plugin>

    </plugins>
</build>

and mvc-dispathcher-servelet.xml

   <beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xmlns:jpa="http://www.springframework.org/schema/data/jpa"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   xmlns:p="http://www.springframework.org/schema/p"
   xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">

<context:component-scan base-package="com.dem.cit"/>

<mvc:resources mapping="/resources/**" location="/resources/" />

<mvc:resources mapping="/css/**" location="/resources/css/">
    <mvc:resource-chain resource-cache="true" auto-registration="true">
        <mvc:resolvers>
            <mvc:version-resolver>
                <mvc:content-version-strategy patterns="/**"/>
            </mvc:version-resolver>
        </mvc:resolvers>
    </mvc:resource-chain>
</mvc:resources>
<mvc:resources mapping="/js/**" location="/resources/js/">
    <mvc:resource-chain resource-cache="true" auto-registration="true">
        <mvc:resolvers>
            <mvc:version-resolver>
                <mvc:content-version-strategy patterns="/**"/>
            </mvc:version-resolver>
        </mvc:resolvers>
    </mvc:resource-chain>
</mvc:resources>

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/pages/"/>
    <property name="suffix" value=".jsp"/>
</bean>

<jpa:repositories base-package="com.dem.cit.main.entity"/>

<bean id="mainEntityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="mainPersistenceUnit"/>
</bean>
<bean id="mainTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="mainEntityManagerFactory" />
</bean>

<tx:annotation-driven transaction-manager="mainTransactionManager"/>

<jpa:repositories base-package="com.dem.cit.report.entity"/>

<bean id="reportEntityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="reportPersistenceUnit"/>
</bean>

<bean id="reportTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="reportEntityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="reportTransactionManager"/>

<jpa:repositories base-package="com.dem.cit.exam.entity"/>

<bean id="examMainEntityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="examMainPersistenceUnit"/>
</bean>

<bean id="examMainTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="examMainEntityManagerFactory" />
</bean>

<tx:annotation-driven transaction-manager="examMainTransactionManager"/>

<jpa:repositories base-package="com.dem.cit.fuel.entity"/>

<bean id="fuelMainEntityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="fuelMainPersistenceUnit"/>
</bean>

<bean id="fuelMainTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="fuelMainEntityManagerFactory" />
</bean>

<tx:annotation-driven transaction-manager="fuelMainTransactionManager"/>

<jpa:repositories base-package="com.dem.cit.gate.entity"/>

<bean id="gateMainEntityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="gateMainPersistenceUnit"/>
</bean>

<bean id="gateMainTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="gateMainEntityManagerFactory" />
</bean>

<tx:annotation-driven transaction-manager="gateMainTransactionManager"/>

<jpa:repositories base-package="com.dem.cit.ticket.entity"/>

<bean id="ticketEntityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="ticketPersistenceUnit"/>
</bean>

<bean id="ticketTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="ticketEntityManagerFactory" />
</bean>

<tx:annotation-driven transaction-manager="ticketTransactionManager"/>

<jpa:repositories base-package="com.dem.cit.chemi.entity"/>

<bean id="chemiEntityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="chemiMainPersistenceUnit"/>
</bean>

<bean id="chemiTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="chemiEntityManagerFactory" />
</bean>

<tx:annotation-driven transaction-manager="chemiTransactionManager"/>

<jpa:repositories base-package="com.dem.cit.guard.entity"/>

<bean id="guardEntityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="securityGuardPersistenceUnit"/>
</bean>

<bean id="guardTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="guardEntityManagerFactory" />
</bean>

<tx:annotation-driven transaction-manager="guardTransactionManager"/>

<mvc:annotation-driven/>
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />

</beans>

and persist.xml

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;persistence xmlns=&quot;http://java.sun.com/xml/ns/persistence&quot; version=&quot;2.0&quot;&gt;
&lt;persistence-unit name=&quot;mainPersistenceUnit&quot;&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.Config&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.Location&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.Logs&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.Permission&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.Role&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.RolePermission&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.RoleWidget&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.ShariaTime&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.SubSystem&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.Tab&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.TabPermission&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.User&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.User2&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.UserConfig&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.UserConfigDefault&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.UserNote&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.UserRole&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.UserSystemConfig&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.UserSystemConfigDefault&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.UserWidget&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.Widget&lt;/class&gt;
    &lt;class&gt;com.dem.cit.main.entity.main.Zone&lt;/class&gt;
    &lt;properties&gt;
        &lt;property name=&quot;hibernate.connection.url&quot; value=&quot;jdbc:mysql://....:3306/psc_main&quot;/&gt;
        &lt;property name=&quot;hibernate.connection.driver_class&quot; value=&quot;com.mysql.jdbc.Driver&quot;/&gt;

        &lt;property name=&quot;hibernate.connection.username&quot; value=&quot;admin&quot;/&gt;
        &lt;property name=&quot;hibernate.connection.password&quot; value=&quot;***&quot;/&gt;

        &lt;property name=&quot;hibernate.show_sql&quot; value=&quot;false&quot;/&gt;

        &lt;property name=&quot;hibernate.c3p0.min_size&quot; value=&quot;5&quot;/&gt;
        &lt;property name=&quot;hibernate.c3p0.max_size&quot; value=&quot;20&quot;/&gt;
        &lt;property name=&quot;hibernate.c3p0.timeout&quot; value=&quot;300&quot;/&gt;
        &lt;property name=&quot;hibernate.c3p0.max_statements&quot; value=&quot;50&quot;/&gt;
        &lt;property name=&quot;hibernate.c3p0.idle_test_period&quot; value=&quot;3000&quot;/&gt;
    &lt;/properties&gt;
&lt;/persistence-unit&gt;

&lt;persistence-unit name=&quot;examMainPersistenceUnit&quot;&gt;
    &lt;class&gt;com.dem.cit.exam.entity.DefaultQuestionOption&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.DefaultQuestionOptionTitle&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.DutyStatus&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.Education&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.Exam&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.ExamGroup&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.Examinee&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.ExamineeGroup&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.ExamineeStatus&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.Gender&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.Group&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.Post&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.Question&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.QuestionAnswer&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.QuestionOption&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.QuestionType&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.Result&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.Score&lt;/class&gt;
    &lt;class&gt;com.dem.cit.exam.entity.StatusType&lt;/class&gt;
    &lt;properties&gt;
        &lt;property name=&quot;hibernate.connection.url&quot; value=&quot;jdbc:mysql://....:3306/psc_exam&quot;/&gt;
        &lt;property name=&quot;hibernate.connection.driver_class&quot; value=&quot;com.mysql.jdbc.Driver&quot;/&gt;

        &lt;property name=&quot;hibernate.connection.username&quot; value=&quot;admin&quot;/&gt;
        &lt;property name=&quot;hibernate.connection.password&quot; value=&quot;***&quot;/&gt;

        &lt;property name=&quot;hibernate.show_sql&quot; value=&quot;false&quot;/&gt;

        &lt;property name=&quot;hibernate.c3p0.min_size&quot; value=&quot;5&quot;/&gt;
        &lt;property name=&quot;hibernate.c3p0.max_size&quot; value=&quot;20&quot;/&gt;
        &lt;property name=&quot;hibernate.c3p0.timeout&quot; value=&quot;300&quot;/&gt;
        &lt;property name=&quot;hibernate.c3p0.max_statements&quot; value=&quot;50&quot;/&gt;
        &lt;property name=&quot;hibernate.c3p0.idle_test_period&quot; value=&quot;3000&quot;/&gt;
    &lt;/properties&gt;
&lt;/persistence-unit&gt;
....
&lt;/persistence&gt;

I think it 's my different mysql version and I change dependency version for mysql but there is may problem. the version of mysql is "mysql Ver 8.0.14" and I tested this dependancy

&lt;!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --&gt;
&lt;dependency&gt;
    &lt;groupId&gt;mysql&lt;/groupId&gt;
    &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
    &lt;version&gt;8.0.20&lt;/version&gt;
&lt;/dependency&gt;

答案1

得分: 0

这可能是因为您完全依赖于Hibernate。由于Spring Boot还包含Hibernate依赖关系,在类路径中会发生冲突,JVM无法决定使用哪个依赖关系。当类路径中存在相同的依赖项时,JVM会抛出NoClassDefFoundError。尝试从pom.xml中移除Hibernate。

英文:

This is probably happening because you exclusively have a dependency on Hibernate. Since Spring Boot also includes Hibernate dependency, conflict happens in the classpath, and JVM can not decide which dependency to use. NoClassDefFoundError is thrown by JVM when the same dependencies exist in the classpath. Try removing Hibernate from pom.xml

huangapple
  • 本文由 发表于 2020年5月4日 19:33:52
  • 转载请务必保留本文链接:https://java.coder-hub.com/61591283.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定