PinkGuy / Ssh框架搭建步骤
Created 2019-12-13 Modifyd 2019-12-13

154 Words

1.导入相关jar包

  • hibaernate
  • spring
  • hibernate+spring
  • 连接池(ommons-dbcp)
  • struts2
  • struts2+spring
  • 数据库驱动
  • servlet-api(看情况)

2.配置hibernate并测试

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="connection.driver_class">
            oracle.jdbc.OracleDriver
        </property>

        <property name="connection.url">
            jdbc:oracle:thin:@192.168.206.1:1521:orcl
        </property>
        <property name="connection.username">scott</property>
        <property name="connection.password">333</property>
        <property name="dialect">
            org.hibernate.dialect.Oracle10gDialect
        </property>
    </session-factory>
</hibernate-configuration>
  • 再写个工具类测试

3.将 hibernate 关联到 spring 并测试

  <!-- 关联hibernate配置文件 -->
    <bean id="sessionFactory" 			class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="configLocation">
            <value>classpath:hibernate.cfg.xml</value>
        </property>
    </bean>

4.配置Struts2