Set up a maven web project in Intellij with Spring and JPA - Part Two

Hello again, in this tutorial we will continue our MavenWebapp project we made earlier.
This part will focus on configuring maven.

When opening the pom.xml you should now have the following code:

    4.0.0

    MavenWebapp
    MavenWebapp
    war
    1.0

    



However, in this state maven will still be building a regular jar file instead of our desired WAR (Web application Archive) file. To fix this we will add the following lines of xml just before the tag:
    
        
            
                org.apache.maven.plugins
                maven-war-plugin
                2.1.1
                
                   web\WEB-INF\web.xml
                
            
        
    

(If you choose to place the web folder in another directory don't forget to change the webxml property)
Alright so far for the basic maven configuration, now let's add our Spring dependencies! Since we will be needing multiple Spring dependencies we will be using a properties element just above the tag
     

    
        3.1.0.RELEASE
    

All the dependencies we need will go under the tag, place the following code before the tag:
    
    
        
            org.springframework
            spring-core
            ${org.springframework.version}
        
          
        
            org.springframework
            spring-tx
            ${org.springframework.version}
        
         
        
          org.springframework
          spring-orm
          ${org.springframework.version}
        
        
        
          org.springframework
          spring-web
          ${org.springframework.version}
        
        
        
          org.springframework
          spring-webmvc
          ${org.springframework.version}
        
    


That are all the Spring dependencies we need for now, let's move on to the final step of this tutorial. The last step is to add our data-acces dependencies which is done by the following lines:
 
        
        
            org.hibernate
            hibernate-entitymanager
            4.0.0.Final
        


        
            org.hibernate.javax.persistence
            hibernate-jpa-2.0-api
            1.0.1.Final
        

        
            mysql
            mysql-connector-java
            5.1.18
        

That's all for this tutorial, we have done all maven configuration that we need for now. See you at the next tutorial!


More about this tutorial series can be found here:
Set up a maven web project in Intellij with Spring and JPA - Part One (Project setup)
Set up a maven web project in Intellij with Spring and JPA - Part Three (ORM mapping)
Set up a maven web project in Intellij with Spring and JPA - Part Four (Spring Configuration
Set up a maven web project in Intellij with Spring and JPA - Part Five (DAO)
Set up a maven web project in Intellij with Spring and JPA - Part Six (Configuring Spring MVC)
Set up a maven web project in Intellij with Spring and JPA - Part Seven (Implementing Spring MVC)