如何使用Netbeans在Maven,Spring,Hibernate项目中的开发过程中加快Hibernate初始化

时间:2019-02-06 18:55:33

标签: java hibernate maven tomcat netbeans

我正在使用Netbeans 8.2通过将Spring MVC和Hibernate设置为Maven项目来开发Web应用程序。该应用程序连接到本地MySQL数据库。该应用程序正在Tomcat上运行。

我习惯于在不休眠的情况下使用非Maven构建,在保存后我可以立即看到对已编译类的更改。我已启用“保存时部署”选项,但部署速度非常慢,看起来主要是由于Hibernate所致。我养成了经常打ctrl -s的习惯,这很难被打破。

至少在开发中,是否可以使用一些选项来加速Hibernate初始化?

这是tomcat日志的示例

06-Feb-2019 12:01:08.224 INFO [http-nio-8085-exec-115] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
log4j:WARN No appenders could be found for logger (org.springframework.core.io.support.PathMatchingResourcePatternResolver).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
06-Feb-2019 12:01:13.179 INFO [http-nio-8085-exec-115] org.hibernate.Version.logVersion HHH000412: Hibernate Core {5.3.6.Final}
06-Feb-2019 12:01:13.186 INFO [http-nio-8085-exec-115] org.hibernate.cfg.Environment.<clinit> HHH000206: hibernate.properties not found
06-Feb-2019 12:01:14.709 INFO [http-nio-8085-exec-115] org.hibernate.annotations.common.reflection.java.JavaReflectionManager.<clinit> HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
06-Feb-2019 12:01:18.955 INFO [http-nio-8085-exec-115] org.hibernate.dialect.Dialect.<init> HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
06-Feb-2019 12:01:19.150 INFO [http-nio-8085-exec-115] org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl.makeLobCreatorBuilder HHH000422: Disabling contextual LOB creation as connection was null
06-Feb-2019 12:01:22.138 INFO [http-nio-8085-exec-115] org.hibernate.validator.internal.util.Version.<clinit> HV000001: Hibernate Validator 6.0.13.Final
06-Feb-2019 12:01:28.908 INFO [http-nio-8085-exec-115] org.hibernate.c3p0.internal.C3P0ConnectionProvider.configure HHH010002: C3P0 using driver: com.mysql.cj.jdbc.Driver at URL: jdbc:mysql://localhost:3306/database?zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&useLegacyDatetimeCode=false
06-Feb-2019 12:01:28.909 INFO [http-nio-8085-exec-115] org.hibernate.c3p0.internal.C3P0ConnectionProvider.configure HHH10001001: Connection properties: {handling_mode=DELAYED_ACQUISITION_AND_HOLD, user=username, password=****, autocommit=true}
06-Feb-2019 12:01:28.910 INFO [http-nio-8085-exec-115] org.hibernate.c3p0.internal.C3P0ConnectionProvider.configure HHH10001003: Autocommit mode: true
06-Feb-2019 12:01:30.018 INFO [http-nio-8085-exec-115] org.hibernate.c3p0.internal.C3P0ConnectionProvider.configure HHH10001007: JDBC isolation level: <unknown>
06-Feb-2019 12:01:34.093 INFO [http-nio-8085-exec-115] org.hibernate.dialect.Dialect.<init> HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
06-Feb-2019 12:01:34.094 INFO [http-nio-8085-exec-115] org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl.makeLobCreatorBuilder HHH000422: Disabling contextual LOB creation as connection was null
06-Feb-2019 12:01:35.351 INFO [http-nio-8085-exec-115] org.hibernate.c3p0.internal.C3P0ConnectionProvider.configure HHH010002: C3P0 using driver: com.mysql.cj.jdbc.Driver at URL: jdbc:mysql://localhost:3306/database?zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&useLegacyDatetimeCode=false
06-Feb-2019 12:01:35.352 INFO [http-nio-8085-exec-115] org.hibernate.c3p0.internal.C3P0ConnectionProvider.configure HHH10001001: Connection properties: {handling_mode=DELAYED_ACQUISITION_AND_HOLD, user=username, password=****, autocommit=true}
06-Feb-2019 12:01:35.352 INFO [http-nio-8085-exec-115] org.hibernate.c3p0.internal.C3P0ConnectionProvider.configure HHH10001003: Autocommit mode: true
06-Feb-2019 12:01:35.706 INFO [http-nio-8085-exec-115] org.hibernate.c3p0.internal.C3P0ConnectionProvider.configure HHH10001007: JDBC isolation level: <unknown>
06-Feb-2019 12:01:40.090 INFO [http-nio-8085-exec-115] org.apache.catalina.core.StandardContext.reload Reloading Context with name [] is completed
  • 春季版本为5.0.0 RELEASE
  • 休眠是5.3.6最终休眠
  • 验证程序为6.0.13 FINAL

我尝试了从c3p0切换到内置的连接池,但这没有什么不同。都没有将以下内容添加到hibernate.cfg.xml

<property name="hibernate.query.startup_check">false</property>
<property name="javax.persistence.validation.mode">none</property>
<property name="hibernate.validator.autoregister_listeners">false</property>
<property name="hibernate.validator.apply_to_ddl">false</property>
<property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>

0 个答案:

没有答案