web编程常用配置2
c3p0.jar:
C3PO是一个数据库连接池,Hibernate可以配置为使用C3PO连接池。如果你准备用这个连接池,就需要这个jar包。
proxool.jar:
也是一个连接池,同上。
commons-pool.jar,?commons-dbcp.jar:
DBCP数据库连接池,Apache的Jakarta组织开发的,Tomcat4的连接池也是DBCP。
实际上Hibernate自己也实现了一个非常非常简单的数据库连接池,加上上面3个,你实际上可以在Hibernate上选择4种不同的数据库连接?池,选择哪一个看个人的偏好,不过DBCP可能更通用一些。另外强调一点,如果在EJB中使用Hibernate,一定要用App?Server的连接池,不要用以上4种连接池,否则容器管理事务不起作用。
connector.jar:
JCA?规范,如果你在App?Server上把Hibernate配置为Connector的话,就需要这个jar。不过实际上一般App?Server肯定会带上这个包,所以实际上是多余的包。
jaas.jar:
JAAS是用来进行权限验证的,已经包含在JDK1.4里面了。所以实际上是多余的包。
jcs.jar:
如果你准备在Hibernate中使用JCS的话,那么必须包括它,否则就不用。
jdbc2_0-stdext.jar:
JDBC2.0的扩展包,一般来说数据库连接池会用上它。不过App?Server都会带上,所以也是多余的。
jta.jar:
JTA规范,当Hibernate使用JTA的时候需要,不过App?Server都会带上,所以也是多余的。
junit.jar:
Junit包,当你运行Hibernate自带的测试代码的时候需要,否则就不用。
xalan.jar,?xerces.jar,?xml-apis.jar:
Xerces是XML解析器,Xalan是格式化器,xml-apis实际上是JAXP。一般App?Server都会带上,JDK1.4也包含了解析器,不过不是Xerces,是Crimson,效率比较差,不过Hibernate用XML只不过是读取?配置文件,性能没什么紧要的,所以也是多余的。
ant-1.63.jar?Ant?的核心包,在构建Hibernate?时会用到
antlr-2.7.5H3.jar?语言转换工,Hibernate利用它实现?HQL?到?SQL的转换
asm.jar/asm-attrs.jar?ASM?字节转换库
c3p0-0.8.5.2.jar?C3PO?JDBC?连接池工具
cglib-2.1.jar?高效的代码生成工具,?Hibernate用它在运行时扩展?Java类和实现?Java?接口
commons-collections-2.1.1.jar?Apache?的工具集,用来增强Java对集合的处理能力
commons-logging-1.0.4.jar?Apache?软件基我组所提供的日志工具
concurrent-1.3.2.jar?线程同步工具,在使用JBoss?的树状缓存时需要用到
connector.jar?用连接多个应用服务器的标准连接器
dom4j-1.6.jar?dom4j?XML?解析器
ehcache-1.1.jar?缓存工具.在没有提供其他缓存工具时,这个缓存工具是必不可少的
jaas.jar?标准的?Java?权限和认证服务包
jaxen-1.1-beta-4.jar?通用的?XPath?处理引擎
jboss-cache.jar?JBoss?的一种树状缓存实现工具
jboss-common.jar?Jboss?的基础包,在使用?JBoss?的树状缓存时必须有此包
jboss-jmx.jar?JBoss?的?JMX?实现包
jboss-system.jar?JBoss?的核心,包括服务器和部署引擎
jdbc2_0-stdext.jar?标准的?JDBC?2.0?扩展API
jgroups2.2.7.jar?网络通信工具包
jta.jar?标准的?JAVA?事务处理接口
junit-3.8.1.jar?JUnit?测试框架
log4.j-1.2.9.jar?log4j?库,Apache?的日志工具
oscache-2.1.jar?Java?对象的缓存工具
proxool-0.8.3.jar?Proxool?JDBC?连接池?工具
swarmcache-1.0rc2.jar?Hibernate?可以使用的一种缓存工具
versioncheck.jar?版本检查工具包,用于在构建?Hibernate?的时候检查辅助?jar?包文件的版本
xerces-2.6.2.jar?SAX?XML?解析器
xml-apis.jar?Java语言中标准的XML?解析器
log4j.properties的配置信息(开发过程中才使用,一般用处不大)
###?direct?log?messages?to?stdout?###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE}?%5p?%c{1}:%L?-?%m%n
###?direct?messages?to?file?hibernate.log?###
#log4j.appender.file=org.apache.log4j.FileAppender
#log4j.appender.file.File=hibernate.log
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE}?%5p?%c{1}:%L?-?%m%n
###?set?log?levels?-?for?more?verbose?logging?change?'info'?to?'debug'?###
log4j.rootLogger=warn,?stdout
#log4j.logger.org.hibernate=info
#log4j.logger.org.hibernate=debug
###?log?HQL?query?parser?activity
#log4j.logger.org.hibernate.hql.ast.AST=debug
###?log?just?the?SQL
#log4j.logger.org.hibernate.SQL=debug
###?log?JDBC?bind?parameters?###
#log4j.logger.org.hibernate.type=info
#log4j.logger.org.hibernate.type=debug
###?log?schema?export/update?###
#log4j.logger.org.hibernate.tool.hbm2ddl=debug
###?log?HQL?parse?trees
#log4j.logger.org.hibernate.hql=debug
###?log?cache?activity?###
#log4j.logger.org.hibernate.cache=debug
###?log?transaction?activity
#log4j.logger.org.hibernate.transaction=debug
###?log?JDBC?resource?acquisition
#log4j.logger.org.hibernate.jdbc=debug
###?enable?the?following?line?if?you?want?to?track?down?connection?###
###?leakages?when?using?DriverManagerConnectionProvider?###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace
文件上传的jar包(共2个)
commons-fileupload-1.1.1.jar
commons-io-1.2.jar
Spring?中applicationContext-1.xml文件的配置(一般类的映射文件)
<?xml?version="1.0"?encoding="UTF-8"?>
<beans?xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans?http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop?http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx?http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean?id="demo1"?class="com.pk.spring.Demo1">
<property?name="intValue"?value="110"></property>
<property?name="str"?value="时间时间等等我"></property>
<property?name="list">
<list>
<value>无限风光在险峰</value>
<value>北京欢迎你</value>
</list>
</property>
<property?name="set">
<set>
<value>你好,中国</value>
<value>你好,北京</value>
</set>
</property>
<property?name="map">
<map>
<entry?key="xuye"?value="zhaolin"></entry>
<entry?key="liutengfei"?value="guodonghua"></entry>
</map>
</property>
<property?name="array">
<list>
<value>好好学习</value>
<value>天天向上</value>
</list>
</property>
<property?name="mydate">
<value>2011-6-25</value>
</property>
</bean>
</beans>
Spring?中applicationContext-2.xml的配置(将转化Date类型的文件配置方式)
<?xml?version="1.0"?encoding="UTF-8"?>
<beans?xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans?http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop?http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx?http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean?id="customEditorConfigurer"?
class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property?name="customEditors">
<map>
<entry?key="java.util.Date">
<bean?class="com.pk.spring.MyDatePropertyFormat">
<property?name="format"?value="yyyy-MM-dd"></property>
</bean>
</entry>
</map>
</property>
</bean>
</beans>
Spring?所需要的jar包(共3个)
commons-logging.jar
log4j-1.2.15.jar
spring.jar
spring-framework-2.5.6\lib\aspectj\aspectjrt.jar
spring-framework-2.5.6\lib\aspectj\aspectjweaver
在hibernate中若要使用factory.getCurrentSession()时需要在以上配置文件中加入如下语句:
<property?name="hibernate.current_session_context_class">thread</property>
<!--EndFragment-->