1.在"catalina.sh"增加此行效果不大
JAVA_OPTS="$JAVA_OPTS -Xms1024m -Xmx1024m"
2.研究spring設定檔 “applicationContext.xml" 讀取hibernate hbm.xml,
因為似乎是加上新的db schema在設定了hbm.xml後才變慢的~~
原本設定是遞迴讀此目錄下的所有檔案,但此目錄下有其它的class (非hbm.xml)
<property name="mappingDirectoryLocations">
<list>
<value>classpath:com/test/bean/</value>
</list>
</property>
改成如下
<property name="mappingLocations">
<list>
<value>classpath:com/test/bean/*.hbm.xml</value>
<value>classpath:com/test/bean/derivadm/*.hbm.xml</value>
<value>classpath:com/test/bean/futadm/*.hbm.xml</value>
<value>classpath:com/test/bean/job/*.hbm.xml</value>
<value>classpath:com/test/bean/warrantadm/*.hbm.xml</value>
</list>
</property>
收到不錯的效果,啟動時間由原本的10多分鐘,縮短至4分鐘,
但仍需有努力的空間…
hibernate設定hbm.xml還有一個方式就是逐檔設定,當初就是嫌麻煩才用路徑,
也這之後要改回這個方式再試試吧~
<property name="mappingResources">
<list>
<value>au/com/test/bean/Address.hbm.xml</value>
<value>au/com/test/bean/Country.hbm.xml</value>
<!-- repeat for their mapping files -->
</list>
</property>
3.後來再調整applicationContext.xml
於bean加上lazy-init=true
<bean id="IFServiceDao" class="com.xxx.xxx.transactional.IFServiceImpl"
scope="singleton" lazy-init="true">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
但效果不大
故於beans加上default-lazy-init=true
<beans xmlns="http://www.springframework.org/schema/beans"
....
default-lazy-init="true">
看似有點效果,但tomcat啟動還是要5分鐘。
最後再將hibernate.hbm2ddl.auto整個移除Tomcat竟然1分鐘內就啟動好了,
雖然執行application的程式仍需要3~4分鐘,
但至少其它application可以早點執行了~
會想要調整這個參數是因每次都在log看到此行以後Tomcat才算啟動完成。
INFO [http-bio-80-exec-4] SchemaUpdate [execute] [101] HHH000228: Running hbm2ddl schema update
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
...
<property name="hibernateProperties">
<props>
...
<!--
<prop key="hibernate.hbm2ddl.auto">update</prop>
-->
...
</props>
</property>
</bean>
