问题描述
- hibernate的配置问题,,新人刚开始学
-
2015-5-13 19:21:54 org.apache.catalina.core.AprLifecycleListener init
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: f:UsersxuAppDataLocalMyEclipseCommonbinarycom.sun.java.jdk.win32.x86_64_1.6.0.013bin;F:UsersxuAppDataLocalMyEclipseCommonpluginscom.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806tomcatbin
2015-5-13 19:21:54 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2015-5-13 19:21:54 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1716 ms
2015-5-13 19:21:54 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2015-5-13 19:21:54 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.13
log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory).
log4j:WARN Please initialize the log4j system properly.
2015-5-13 19:21:58 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
Unable to load configuration. - action - file:/E:/%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9/workspace/.metadata/.me_tcat/webapps/userhaber/WEB-INF/classes/struts.xml:8:70
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:493)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3693)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4340)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: Unable to load configuration. - action - file:/E:/%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9/workspace/.metadata/.me_tcat/webapps/userhaber/WEB-INF/classes/struts.xml:8:70
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:967)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:435)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:479)
... 29 more
Caused by: Action class [com.xu.action] not found - action - file:/E:/%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9/workspace/.metadata/.me_tcat/webapps/userhaber/WEB-INF/classes/struts.xml:8:70
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:486)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:429)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:556)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:295)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:264)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 32 more
2015-5-13 19:21:58 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2015-5-13 19:21:58 org.apache.catalina.core.StandardContext start
严重: Context [/userhaber] startup failed due to previous errors
2015-5-13 19:22:00 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2015-5-13 19:22:00 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2015-5-13 19:22:00 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/16 config=null
2015-5-13 19:22:00 org.apache.catalina.startup.Catalina start
信息: Server startup in 5324 ms
解决方案
hibernate.cfg.xml
复制代码
<?xml version='1.0' encoding='gb2312'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!--声明Hibernate配置文件的开始-->
<hibernate-configuration>
<!--表明以下的配置是针对session-factory配置的,SessionFactory是Hibernate中的一个类,
这个类主要负责保存HIbernate的配置信息,以及对Session的操作-->
<!--配置数据库的驱动程序,Hibernate在连接数据库时,需要用到数据库的驱动程序-->
com.mysql.jdbc.Driver
<!--设置数据库的连接url:jdbc:mysql://localhost/hibernate,其中localhost表示mysql服务器名称,此处为本机, hibernate是数据库名-->
<property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate</hibernate>
<!--连接数据库是用户名-->
<property name="hibernate.connection.username">root</property>
<!--连接数据库是密码-->
<property name="hibernate.connection.password">123456 </property>
<!--数据库连接池的大小-->
<property name="hibernate.connection.pool.size">20 </property>
<!--是否在后台显示Hibernate用到的SQL语句,开发时设置为true,便于查错,程序运行时可以在Eclipse的控制台显示Hibernate的执行Sql语句。
项目部署后可以设置为false,提高运行效率-->
true
<!--jdbc.fetch_size是指Hibernate每次从数据库中取出并放到JDBC的Statement中的记录条数。Fetch Size设的越大,读数据库的次数越少,速度越快,
Fetch Size越小,读数据库的次数越多,速度越慢-->
50
<!--jdbc.batch_size是指Hibernate批量插入,删除和更新时每次操作的记录数。Batch Size越大,
批量操作的向数据库发送Sql的次数越少,速度就越快,同样耗用内存就越大-->
23
<!--jdbc.use_scrollable_resultset是否允许Hibernate用JDBC的可滚动的结果集。对分页的结果集。对分页时的设置非常有帮助-->
<property name="jdbc.use_scrollable_resultset">false </property>
<!--connection.useUnicode 连接数据库时是否使用Unicode编码-->
<property name="Connection.useUnicode">true </property>
<!--connection.characterEncoding连接数据库时数据的传输字符集编码方式,最好设置为gbk,用gb2312有的字符不全-->
<property name="connection.characterEncoding">gbk </property>
<!--hibernate.dialect 只是Hibernate使用的数据库方言,就是要用Hibernate连接那种类型的数据库服务器。-->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect </property>
<!--指定映射文件为“hibernate/ch1/UserInfo.hbm.xml”-->
<mapping resource="org/mxg/UserInfo.hbm.xml">
<!-- 连接驱动 -->
<!-- 连接url -->
<!-- 连接用户名 -->
<!-- 连接密码 -->
<!-- hibernate配置文件位置 -->
WEB-INF/hibernate.cfg.xml
<!--针对oracle数据库的方言,特定的关系数据库生成优化的SQL -->
org.hibernate.dialect.OracleDialect
<!--选择HQL解析器的实现 -->
org.hibernate.hql.ast.ASTQueryTranslatorFactory
<!-- 是否在控制台打印sql语句 -->
true
<!-- 在Hibernate系统参数中hibernate.use_outer_join被打开的情况下,该参数用来允许使用outer join来载入此集合的数据。 -->
true
<!-- 默认打开,启用cglib反射优化。cglib是用来在Hibernate中动态生成PO字节码的,打开优化可以加快字节码构造的速度 -->
true
<!-- 输出格式化后的sql,更方便查看 -->
true
<!-- “useUnicode”和“characterEncoding”决定了它是否在客户端和服务器端传输过程中进行Encode,以及如何进行Encode -->
true
<!-- 允许查询缓存, 个别查询仍然需要被设置为可缓存的. -->
false
16
<!--连接池的最大活动个数 -->
100
<!-- 当连接池中的连接已经被耗尽的时候,DBCP将怎样处理(0 = 失败,1 = 等待,2 = 增长) -->
1
<!-- 最大等待时间 -->
1200
<!-- 没有人用连接的时候,最大闲置的连接个数 -- >
10
<!-- 以下是对prepared statement的处理,同上。 -->
100
1
1200
10
解决方案二:
hibernate配置
http://jingyan.baidu.com/article/f00622283702cbfbd3f0c8c5.html
解决方案三:
hibernate环境配置和使用
http://www.2cto.com/kf/201405/304434.html
解决方案四:
可以直接右键工程---myeclipse---添加框架就可以自动帮你全部搞定···当然代码还是要自己写的···
解决方案五:
谢了,问题已经解决了