Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select the right version of spring, struts and hibernate, what's the difference?

I want to select the lastest frameworks to integrate spring, struts and hibernate, but seems that there are so many versions out there, and their api are different too, so I was confused that how can I select the right version to integrate them ? And What's the differences between them ?

For example, can I have the following integration: Spring Framework 3.0 Struts 2.0 Hibernate 3.2

As I am new to these frameworks, please point me the right direction, and let me know how can I select the right version to work on?

Thanks in advance !

like image 722
MemoryLeak Avatar asked Apr 09 '11 17:04

MemoryLeak


People also ask

What is spring Struts and Hibernate?

Spring, Hibernate and Struts are not a language, all these are frameworks that was used in Java Language. It is difficult to build the mobile application without Java framework. Spring is used to develop application from desktop to Web. Hibernate is used to access data layer and Struts is used for Web frameworks.

Are spring and Hibernate different?

Spring is an open-source, light-weight and cross-platform application framework for easy application development as it takes care of infrastructure and developers need to concentrate on business logic whereas Hibernate is an entirely different framework for ORM (object-relational mapping) between Java classes and ...


1 Answers

Here is what I do hope it helps others (first how I set up in Netbeans, at the end is a pom for the general approach).

Note when I say add a certain jar I mean, in Netbeans:

  • Right click Dependencies, Select "Add Dependency..."
  • In the Query field ender the first part the jar not including the version, ie for: spring-orm-3.0.5.RELEASE.jar just enter spring-orm, the search will show several different results but only "org.springframework : spring-orm" contains version 3.0.5.RELEASE so that is the one to use... If this seems too wishy washy, the pom in this answer provides the exact co-ordinates so feel free to use those.

Create a new Maven Web application. Follow: http://struts.apache.org/2.2.1.1/docs/create-struts-2-web-application-using-maven-to-manage-artifacts-and-to-build-the-application.html

add stuts2-spring-plugin (v 2.2.1.1) - this then adds a number of unneeded jars in the 2.5 series, right click these files and exclude them. - now add the following:

spring-orm-3.0.5.RELEASE.jar   
spring-tx-3.0.5.RELEASE.jar
spring-web-3.0.5.RELEASE.jar
slf4j-log412-1.5.5.jar (NOTE: there are later version but you must use this version)

I always add struts2-convention-plugin-2.2.1.1.jar (but this is optional).

For hibernate dependencies add:

hibernate-annotation-3.5.1-Final.jar
hibernate-entitymanager-3.5.1-Final.jar
hibernate-jpamodelgen-1.1.1.Final.jar    

Here is my pom:

<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.aerose</groupId>
    <artifactId>PartGroupMaster</artifactId>
    <version>2011.04.12</version>
    <packaging>war</packaging>

    <name>PartGroupMaster Web App</name>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server>
    </properties>

    <repositories>
        <repository>
            <id>JBoss Repo</id>
            <url>http://repository.jboss.com/maven2</url>
            <name>JBoss Repo</name>
        </repository>
        <repository>
            <id>ibiblio mirror</id>
            <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
        </repository>
        <repository>
            <id>jboss-public-repository-group</id>
            <name>JBoss Public Maven Repository Group</name>
            <url>https://repository.jboss.org/nexus/content/groups/public/</url>
            <layout>default</layout>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
            </snapshots>
        </repository>
        <repository>
            <url>http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo</url>
            <id>eclipselink</id>
            <layout>default</layout>
            <name>Repository for library Library[eclipselink]</name>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
            <version>2.2.1.1</version>
        </dependency>
        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.8.0.GA</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-convention-plugin</artifactId>
            <version>2.2.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-spring-plugin</artifactId>
            <version>2.2.1.1</version>
            <exclusions>
                <exclusion>
                    <artifactId>spring-beans</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-context</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-core</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-web</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.0.2.GA</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.15</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.5</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.5.1-Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>3.5.1-Final</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-config-browser-plugin</artifactId>
            <version>2.2.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>javax.persistence</artifactId>
            <version>2.0.3</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
            <version>1.1.1.Final</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>6.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <finalName>PartGroupMaster</finalName>
    </build>
</project>

This provides a rather current version of Struts2, Spring and Hibernate. Then comes the fun of configuring the configuration files... but that's for another question.

like image 154
Quaternion Avatar answered Sep 21 '22 09:09

Quaternion