title: How Can I Reduce Spring Jpa Hibernate Project Deployment Time?
body: <p>I have a web project which is develop spring, jpa and hibernate and database mysql and server Apache Tomcat 8. My project size 87 MB. and my database size 1 GB. When I run my project It take more than 20 min to deploy. I also apply Hikari Connection Pool but problem not solve. I Provide configuration file and others related file.</p>
  
  <p><strong>This is my database.properties file</strong></p>
  
  <pre><code>################### JDBC Configuration ##########################
  jdbc.driverClassName=com.mysql.jdbc.Driver
  
   jdbc.url=jdbc:mysql://localhost:3306
  /emdemo_liza?verifyServerCertificate=false&amp;useSSL=false&amp;requireSSL=false
  jdbc.username=root
  jdbc.password=1234
  
  ################### Hibernate Configuration ##########################
  hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
  hibernate.show_sql=true
  hibernate.hbm2ddl.auto=update
  hibernate.generate_statistics=true
  hibernate.connection.charSet=UTF-8
  hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy
  hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
  
  ################## For List insertion Hiber Config ######################
  ###hibernate.order_inserts=true###
  ####hibernate.order_updates=true####
  </code></pre>
  
  <p><strong>This is my applicationContext-db.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:jdbc="http://www.springframework.org/schema/jdbc" 
  xmlns:p="http://www.springframework.org/schema/p"
  xmlns:tx="http://www.springframework.org/schema/tx"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context-4.2.xsd
  http://www.springframework.org/schema/jdbc http://www.springframework.org
  /schema/jdbc/spring-jdbc-4.2.xsd
  http://www.springframework.org/schema/tx http://www.springframework.org
  /schema/tx/spring-tx-4.2.xsd"&gt;
  
  &lt;!-- Scan for property files --&gt;
  &lt;context:property-placeholder location="classpath:META-INF/spring/*
   .properties" /&gt;
  
  &lt;!-- Transaction Manager --&gt;
  &lt;bean id="transactionManager"
    class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  
  &lt;!-- Detect @Transactional --&gt;
  &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  
  
  &lt;!-- Entity Manager Factory --&gt;
   &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa
   .LocalContainerEntityManagerFactoryBean"&gt;
  
   &lt;property name="dataSource" ref="dataSource" /&gt;
   &lt;property name="jpaVendorAdapter"&gt;
  
          &lt;!-- Define Hibernate JPA Vendor Adapter --&gt;
  &lt;bean class="org.springframework.orm.jpa.vendor
  .HibernateJpaVendorAdapter"&gt;
      &lt;property name="generateDdl" value="true" /&gt;
      &lt;property name="database" value="MYSQL" /&gt;
  &lt;/bean&gt;
  &lt;/property&gt;
      &lt;!-- Persistence Unit --&gt;
      &lt;property name="persistenceUnitName" value="persistenceUnit" /&gt;
  &lt;/bean&gt;
  
   &lt;bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource"
      p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"
      p:username="${jdbc.username}" p:password="${jdbc.password}" /&gt;
  
  
   &lt;bean class="org.springframework.orm.jpa.support
    .PersistenceAnnotationBeanPostProcessor" /&gt;
   &lt;bean id="jdbcTemplate"
     class="org.springframework.jdbc.core.JdbcTemplate"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p><strong>This is my entity manager class</strong></p>
  
  <pre><code>package com.netizenbd.dao.service;
  
  import java.lang.reflect.ParameterizedType;
  import java.lang.reflect.Type;
  import java.util.List;
  
  import javax.persistence.EntityManager;
  import javax.persistence.EntityManagerFactory;
  import javax.persistence.PersistenceContext;
  import javax.persistence.Query;
  
  import org.hibernate.HibernateException;
  import org.springframework.transaction.annotation.Transactional;
  
  import com.netizenbd.dao.EntityDao;
  
  import javassist.bytecode.SignatureAttribute.TypeVariable;
  
  public class EntityService&lt;E&gt;  implements EntityDao&lt;E&gt; {
  
      @PersistenceContext(unitName="persistenceUnit")
      protected EntityManager entityManager;
  
      protected E instance;
      private Class&lt;E&gt; entityClass;
  
      @Transactional
      public void persist(E e) throws HibernateException{     
          getEntityManager().persist(e);
          getEntityManager();
  
      }
      @Transactional
      public void merge(E e) throws HibernateException{     
          getEntityManager().merge(e);
      }
      @Transactional
      public void remove(Object id) throws Exception{     
          getEntityManager().remove((E)getEntityManager().find(getEntityClass(), id));
  
      }
  
      @Transactional(readOnly = true)
      public E findById(Object id) throws Exception {     
          return (E)getEntityManager().find(getEntityClass(), id);    
      }
  
      @Transactional(readOnly = true)
      public E findAcademicYearObj(Object id, Object year) throws Exception {     
          return (E)getEntityManager().find(getEntityClass(), id +"and"+ year);    
      }
  
      @Transactional(readOnly = true)
      @SuppressWarnings("unchecked")
      public List&lt;E&gt; findAll() throws Exception{
          return getEntityManager().createQuery("Select t from " + getEntityClass().getSimpleName() + " t").getResultList();
      }
  }
  </code></pre>
  
  <p>Please anybody help me how can I deploy quick within short time my project using tomcat server.</p>
  
  <p>Thanks</p>