2016-11-12 108 views
2

我试图重新安排我的pom.xml来解决我的应用程序的一些问题和新的错误出现时运行一​​个Maven安装:春:NoClassDefFoundError的

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/bloombooking/spring/PersistenceJPAConfig.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/tool/schema/spi/DelayedDropRegistry 

我不知道我怎么样了搞砸用它来创建和我找不到任何地方帮助... 这里是我的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> 

    <groupId>com.bloombooking</groupId> 
    <artifactId>bloombookingapi</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>bloombookingapi</name> 
    <description></description> 

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

    <parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.4.2.RELEASE</version> 
    </parent> 

    <dependencies> 

    <!-- Servlet api --> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>javax.servlet-api</artifactId> 
     <version>3.1.0</version> 
    </dependency> 

    <!-- Spring context --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>4.3.3.RELEASE</version> 
    </dependency> 
    <!-- Spring orm --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-orm</artifactId> 
     <version>4.3.3.RELEASE</version> 
    </dependency> 
    <!-- Spring boot web--> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
    </dependency> 
    <!-- Spring boot test--> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-test</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <!-- Spring boot jpa--> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-data-jpa</artifactId> 
    </dependency> 
    <!-- Spring jersey --> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-jersey</artifactId> 
    </dependency> 

    <!-- Hibernate --> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-entitymanager</artifactId> 
     <version>5.1.0.Final</version> 
    </dependency> 

    <!-- PostgreSQL --> 
    <dependency> 
     <groupId>postgresql</groupId> 
     <artifactId>postgresql</artifactId> 
     <version>9.1-901.jdbc4</version> 
    </dependency> 

    <!-- Log4j --> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.17</version> 
    </dependency> 

    <!-- Junit --> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.12</version> 
    </dependency> 

    <!-- Gson --> 
    <dependency> 
     <groupId>com.google.code.gson</groupId> 
     <artifactId>gson</artifactId> 
     <version>2.3.1</version> 
    </dependency> 

    <!-- JavaMail --> 
    <dependency> 
     <groupId>javax.mail</groupId> 
     <artifactId>mail</artifactId> 
     <version>1.4.7</version> 
    </dependency> 

    <!-- Jersey Java WS RS --> 
    <dependency> 
     <groupId>com.sun.jersey.contribs</groupId> 
     <artifactId>jersey-multipart</artifactId> 
     <version>1.19.2</version> 
    </dependency> 

    <!-- Apache commons codec (for easy SHA256 parsing) --> 
    <dependency> 
     <groupId>commons-codec</groupId> 
     <artifactId>commons-codec</artifactId> 
     <version>1.4</version> 
    </dependency> 


    </dependencies> 

    <build> 
    <plugins> 

     <!-- Maven compiler with java 1.8 --> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.1</version> 
      <configuration> 
       <source>1.8</source> 
       <target>1.8</target> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-maven-plugin</artifactId> 
     </plugin> 
    </plugins> 
    </build> 

</project> 

有人可以给我一些帮助? 谢谢

+0

如果您使用的是Spring Boot,是否有特殊原因需要手动完成所有配置,而不是仅使用JPA启动器? – chrylis

+0

“手动配置所有配置”是什么意思?使用PersistenceJPAConfig.java? – Antoine

+0

是的。整个类可以由'application.properties'中的四行代替,这也使得在运行时注入JDBC连接信息变得更加容易。 – chrylis

回答

2

您不必在您的pom.xml中指定spring-context,spring-orm和hibernate-entitymanager的依赖关系,因为您正在使用Spring Boot starter web和jpa依赖项来提取所需的jar文件。请清理你的pom文件。类别DelayedDropRegistry您得到的NoClassDefFoundError自5.1版本以来在hibernate-core jar文件中可用。检查你的本地Maven仓库中的hibernate-core jar文件和版本。您可以使用maven> update项目来更新依赖项并清理构建您的项目。希望这可以帮助。

+0

Thx @abaghel你解决了我的问题,甚至解释了什么是错的:) – Antoine