启动Tomcat,显示如下:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
信息: Creating new Registry instance
2004-3-20 <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><time hour="22" minute="58"><span lang="EN" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: red; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-highlight: white">22:58:04</span></time> org.apache.commons.modeler.Registry getServer
信息: Creating MBeanServer
2004-3-20 <time hour="22" minute="58"><span lang="EN" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: red; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-highlight: white">22:58:05</span></time> org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on port 80
Starting service Tomcat-Standalone
Apache Tomcat/4.1.27-LE-jdk14
2004-03-20 22:58:11,734 INFO [main] web.TestHBMServlet (TestHBMServlet.java:58) - Open Session OK
2004-03-20 22:58:11,890 INFO [main] web.TestHBMServlet (TestHBMServlet.java:77) - 140
2004-3-20 <time hour="22" minute="58"><span lang="EN" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: red; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-highlight: white">22:58:13</span></time> org.apache.struts.util.PropertyMessageResources <init>
信息: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
2004-3-20 <time hour="22" minute="58"><span lang="EN" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: red; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-highlight: white">22:58:13</span></time> org.apache.struts.util.PropertyMessageResources <init>
这样 Hibernate配置利用Tomcat的连接池成功。
注意点:
l 不能利用cfg = new Configuration().configure("/hibernate.cfg.xml");创建Configure以后再利用cfg.addClass(…)这样配置以后只能利用配置文件中的<mapping resource=“”/>
l 因为已经利用了hibernate.properties所以在编写其他时候一定要用cfg = new Configuration().configure("/hibernate.cfg.xml")来配置Configure
l 删除文件hibernate.properties