beans的配置
来源:互联网 发布:上海交大宿舍网络 编辑:程序博客网 时间:2024/06/03 23:56
连接mysql的配置:
<?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: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/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-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<context:annotation-config />
<context:component-scan base-package="com.register" />
<bean id="userService" class="com.bjsxt.service.UserService"/>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="add*"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="serviceOperation"
expression="execution(public * com.bjsxt.service..*.*(..))"/>
<aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice"/>
</aop:config>
<context:property-placeholder location="classpath:jdbc.properties"/>
<bean id="dataSource" destroy-method="close"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<value>com.register.model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean></beans>
jdbc.properties的配置:
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3307/spring
jdbc.username=root
jdbc.password=123
hibernate.cfg.xml的配置:
<?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>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3307/spring</property>
<property name="connection.username">root</property>
<property name="connection.password">123</property>
<!-- JDBC connection pool (use the built-in) -->
<!-- <property name="connection.pool_size">1</property> -->
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!--disable the second-level cache -->
<!-- <property name="cache.use_second_level_cache">true</property> -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<!-- <property name="hbm2ddl.auto">update</property> -->
<mapping class="com.register.model.User"/>
</session-factory>
</hibernate-configuration>
这是按自己机子上配的。
- beans的配置
- hibernate的beans.xml配置
- beans配置
- 用spring的beans配置mysql数据库
- 用spring的beans配置mysql数据库
- beans.xml配置
- 运用jpa技术的beans.xml文件配置
- maven ,spring,mybatis配置beans和contex,aop的问题
- 4.1 Spring beans的创建和配置(XML方式)
- 操作Beans的属性
- Spring - beans的xmlns
- spring 的 beans schema
- spring 的以来注入的基本注入(IOC)的beans配置。
- Beans
- Beans
- struts-config.xml中配置视图层和控制器层的接口:form-beans元素
- eclipse luna4.4配置beans.xml和hibernate.cfg.xml提示类的包路径信息
- Heritrix3.3.0源码阅读 crawler-beans.cxml中处理器链的配置
- 集群高可用性技术讨论
- 交通灯管理系统
- SQL*PLUS使用总结
- AndroidRuntimeException:This message is already in use
- XP不能执行aspx,IIS HTTP 500 内部服务器错误 服务器无法加载应用程序 '/LM/W3SVC''/LM/W3SVC' '找不到指定的元数据
- beans的配置
- shell脚本加密
- 关于编程,大学没有传授的10件事
- asp。net 和 extjs 结合grid 分页
- android搜索框实现
- 引用学习
- Cannot declare member function ‘static int Foo::bar()’ to have static linkage
- 《STL源码剖析》-- stl_alloc.h
- 定时任务:Java中Timer和TimerTask的使用