是否可以使用Maven集成spring,Hibernate和Restful?

时间:2016-01-11 14:40:27

标签: spring hibernate

我需要使用spring和hibernate构建Restful web服务吗?我想使用Spring 4.2.2和Spring security 4.0.3以及hibernate 4.3.0是否有人已经使用过这种集成。我正在寻找一个合适的POM.xml,我比较新,所以任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

你的pom.xml实际上取决于你在做什么,但是这个典型pom的小节应该让你前进(展示如何使用属性)。您需要根据需要添加更多依赖项(或删除不需要的依赖项),并更改hiberate版本:

    <properties>

    <!-- Spring -->
    <!-- NOTE Spring-security 4.0.3 is tied to core version 4.2.2; don't change one without the other!! -->
    <spring.version>4.2.2.RELEASE</spring.version>
    <spring-security.version>4.0.3.RELEASE</spring-security.version>

    <!-- persistence -->
    <hibernate.version>4.2.13.Final</hibernate.version>

</properties>

<dependencies>
    <!-- Spring Security Modules -->
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>${spring-security.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>${spring-security.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>${hibernate.version}</version>
    </dependency>
</dependencies>