天天看点

Maven2 + tapestry5.0.18 + spring2 + hibernate3.2

用quickstart生成Tapestry架构,再进行相应的spring与hibernate配置。

1.依赖包

2.maven插件

3.web.xml

4.applicationContext.xml

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
             http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"
    default-lazy-init="true">

	<bean id="dataSource"
		class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName"
			value="com.mysql.jdbc.Driver" />
		<property name="url"
			value="jdbc:mysql://localhost:3306/logcd" />
		<property name="username" value="root"/>
		<property name="password" value=""/>
	</bean>	

	<bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="mappingLocations">
        	<value>classpath:/**/*.hbm.xml</value>
    	</property>

        <property name="annotatedClasses">
            <list>
                <value>com.logcd.myapp.models.User</value>
            </list>
        </property>
        <property name="annotatedPackages">
            <list>
                <value>com.logcd.myapp.models</value>
            </list>
        </property>

        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.show_sql">false</prop>
                <prop key="hibernate.format_sql">true</prop>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.connection.pool_size">0</prop>
        	    <prop key="hibernate.connection.autocommit">true</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property>
    </bean>

    <bean id="userDAO" class=" com.logcd.myapp.dao.impl.UserDaoImpl">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
 </beans>
           

5.User类

6.页面java文件