关于struts2+spring3+jpa项目的构建

环境:eclipse  Juno

ssh的版本:

 
 项目的结构如下:
 
其中:applicationContext.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"
 xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd">
    <!--以下Service采用自动注入-->
    <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>
    <!--在Dao层使用@PersistenceContext注入实体管理器-->
    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
   
<!--jpa支持-->
 <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="locations">
   <list>
    <value>classpath:jdbc.properties</value>
   </list>
  </property>
 </bean>
 <bean id="dataSource"
  class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  <property name="driverClassName" value="${jdbc.driver}" />
  <property name="url" value="${jdbc.url}" />
  <property name="username" value="${jdbc.username}" />
  <property name="password" value="${jdbc.password}" />
 </bean>
 <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  <property name="persistenceUnitName" value="jpaUnit"/>
        <property name="dataSource" ref="dataSource"/>
  <property name="persistenceXmlLocation" value="classpath:persistence.xml" />
  <property name="jpaVendorAdapter">
    <bean
     class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
     <property name="databasePlatform" value="org.hibernate.dialect.SQLServerDialect"/>
                    <property name="generateDdl" value="true"/>
     <property name="showSql" value="true" />
    </bean>
  </property>
 </bean>
 
 <bean id="transactionManager"
  class="org.springframework.orm.jpa.JpaTransactionManager">
  <property name="entityManagerFactory" ref="entityManagerFactory" />
 </bean>

 <bean id="userDAO" class="com.ssh.rbac.dao.impl.RbacUserDaoImpl"/>
    <bean id="userService" class="com.ssh.rbac.service.impl.RbacUserServiceImpl"/>
   
</beans>

persistence.xml如下:
 
 <?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns=" http://java.sun.com/xml/ns/persistence"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
 <persistence-unit name="jpaUnit"
 transaction-type="RESOURCE_LOCAL">
  <provider>org.hibernate.ejb.HibernatePersistence</provider>
  <class>com.dreamity.rbac.domain.RbacUser</class>
  <properties/>
 </persistence-unit>
</persistence>
 
 jdbc.properties如下:
jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.url=jdbc:sqlserver://localhost:1456;databaseName=DreamityFramework
jdbc.username=sa
jdbc.password=nariacc
hibernate.dialect=org.hibernate.dialect.SQLServerDialect
hibernate.show_sql=true
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值