简体   繁体   中英

What exactly means the configuration of this Spring data model project used by a Spring MVC application?

I am pretty new in Spring + JPA and I am working on a web application that use a project named model-gen-myapp .

This project contain the entity class annotated to map the database table (so it contain the model used by my web application to represent the data on the DB).

This is the pom.xml content of this project:

<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>model-gen-profdb</groupId>
    <artifactId>model-gen-profdb</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <version>1.0.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.3.11.Final</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>1.8.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.3.3</version>
        </dependency>
    </dependencies>
</project>

As you can see in the previous configuration it add some dependencies related to some Hibernate stuff and the spring-data-jpa Spring project.

For what exactly are used the previous dependencies?

Then if I select this project into the Eclipse project explorer and I do: Properties ---> Project Facets I find that the following facets are checked Java (version 1.7) , JPA (version 2.1) and Utility Module .

What exactly is a project facets and what means the previous choice? I don't understand if this stuff add dependencies or if it something related to some project configuration?

Let me first introduce you to the mighty Maven here and please do some reading.

Dependency management is one of the most important features of Maven which is best known to its users and is one of the areas where Maven excels.

  • Your project is a JPA project, the hibernate-jpa-2.1-api is to provide you the JPA 2.1 APIs. You can access it here . It basically has these parent packages:

    javax.persistence
    javax.persistence.criteria
    javax.persistence.metamodel
    javax.persistence.spi

  • JPA is a specification from Oracle . The venders like Hibernate , Eclipse Link etc has the actual implementation of this specification. Hence you need the hibernate core hibernate-core jar. Read about Hibernate here .

  • Coming to spring-data-jpa . Spring Data JPA, part of the larger Spring Data family, makes it easy to implement JPA based repositories . This module deals with enhanced support for JPA based data access layers . It makes it easier to build Spring-powered applications that use data access technologies. Source: Spring Data JPA

  • Project Facets in Eclipse: An aspect which is to be used in the project, so that the IDE can intercept on it with regard to generators, wizards, auto-include libraries and so on. If you add for example the JPA facet, then you will get more options to do the IDE-magic with JPA. Here your project uses Java 1.7 , JPA 2.1 and so on. Source: What is 'Facet' in JavaEE?

I hope this helps you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM