spring hibernate struts 整合开发(1)
编程技术  /  houtizong 发布于 3年前   140
<?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:context="http://www.springframework.org/schema/context" 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/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"><!-- 数据库连接和连接池配置 --><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/test?useUnicode=true&characterEncoding=UTF-8"/><property name="username" value="root"/><property name="password" value="123456"/><!-- Initial value when starting up --><property name="initialSize" value="1"/><!-- Maximum value of the pool --><property name="maxActive" value="500"/><!-- Maximum idle value of the pool --><property name="maxIdle" value="2"/><!-- Minimum idle value of the pool --><property name="minIdle" value="1"/></bean><!-- Hibernate二级缓存配置 --><bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><property name="dataSource" ref="dataSource"/><property name="mappingResources"><list><value>com/john/bean/Person.hbm.xml</value></list></property><property name="hibernateProperties"><value>hibernate.dialect=org.hibernate.dialect.MySQLDialecthibernate.hbm2ddl.auto=updatehibernate.show_sql=truehibernate.format_sql=false</value></property></bean><!-- 侦测并激活bean类中的注解:Spring的@Required和@Autowired, JSR 250的@PostConstruct, @PreDestroy和@Resource, JAX-WS的@WebServiceRef, EJB3的@EJB, JPA的@PersistenceContext和@PersistenceUnit。这个标签并不激活Spring的@Transactional或者EJB的@TransactionAttribute。如果这个标签没有,这些注解的注入将无法执行。--><context:annotation-config /><!-- 事务管理器配置 --><bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"><property name="sessionFactory" ref="sessionFactory"/></bean><!-- 注解事务驱动 --><tx:annotation-driven transaction-manager="txManager"/><!-- 业务bean --><bean id="personService" class="com.john.service.impl.PersonServiceBean"/></beans>
public class Person {private Integer id;private String name;// Setters and getters are omitted}
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE hibernate-mapping PUBLIC"-//Hibernate/Hibernate Mapping DTD 3.0//EN""http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"><hibernate-mapping package="com.john.bean"><class name="Person" table="person"><id name="id"><generator class="native"/></id><property name="name" length="20" not-null="true" /></class></hibernate-mapping>
请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!
技术博客集 - 网站简介:
前后端技术:
后端基于Hyperf2.1框架开发,前端使用Bootstrap可视化布局系统生成
网站主要作用:
1.编程技术分享及讨论交流,内置聊天系统;
2.测试交流框架问题,比如:Hyperf、Laravel、TP、beego;
3.本站数据是基于大数据采集等爬虫技术为基础助力分享知识,如有侵权请发邮件到站长邮箱,站长会尽快处理;
4.站长邮箱:[email protected];
文章归档
文章标签
友情链接