applicationContext.xml文件配置模板
<?xml version="1.0" encoding="gb2312"?>
<!-- Spring配置文件的DTD定义-->
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<!-- Spring配置文件的根元素是beans-->
<beans>
<!--定义数据源,该bean的ID为dataSource-->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<!-- 指定数据库驱动-->
<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<!-- 指定连接数据库的URL-->
<property name="url"><value>jdbc:mysql://wonder:3306/j2ee</value></property>
<!-- root为数据库的用户名-->
<property name="username"><value>root</value></property>
<!-- pass为数据库密码-->
<property name="password"><value>pass</value></property>
</bean>
<!--定义Hibernate的SessionFactory-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 依赖注入数据源,注入正是上文定义的dataSource-->
<property name="dataSource"><ref local="dataSource"/></property>
<!-- mappingResouces属性用来列出全部映射文件>
<property name="mappingResources">
<list>
<!--以下用来列出所有的PO映射文件-->
<value>lee/Person.hbm.xml</value>
</list>
</property>
<!--定义Hibernate的SessionFactory的属性 -->
<property name="hibernateProperties">
<props>
<!-- 指定Hibernate的连接方言-->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<!-- 不同数据库连接,启动时选择create,update,create-drop-->
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<!-- 配置Person持久化类的DAO bean-->
<bean id="personDao" class="lee.PersonDaoImpl">
<!-- 采用依赖注入来传入SessionFactory的引用-->
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
</beans>
applicationContext.xml文件配置模板的更多相关文章
- web.xml文件配置模板
直接贴完整代码,当然,spring的核心控制器依赖包需要通过mean提前配置 <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.// ...
- spring +springmvc+mybatis组合applicationContext.xml文件配置
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...
- SSH框架整合--applicationContext.xml文件配置实例
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...
- dispatcher-servlet.xml文件配置模板
完整代码如下: <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http:/ ...
- SSH applicationContext.xml文件配置
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- ssh2学习-applicationContext.xml文件配置-----<context:annotation-config/>详解
当我们需要使用BeanPostProcessor时,直接在Spring配置文件中定义这些Bean显得比较笨拙,例如: 使用@Autowired注解,必须事先在Spring容器中声明AutowiredA ...
- Spring框架入门之基于xml文件配置bean详解
关于Spring中基于xml文件配置bean的详细总结(spring 4.1.0) 一.Spring中的依赖注入方式介绍 依赖注入有三种方式 属性注入 构造方法注入 工厂方法注入(很少使用,不推荐,本 ...
- Spring MVC框架下在java代码中访问applicationContext.xml文件中配置的文件(可以用于读取配置文件内容)
<bean id="propertyConfigurer" class="com.****.framework.core.SpringPropertiesUtil& ...
- SSH整合,applicationContext.xml中配置hibernate映射文件问题
今天在applicationContext.xml中配置sessionFactory时遇到了各种头疼的问题,现在总结一下: 1.<property name="mappingDirec ...
随机推荐
- chrome浏览器调试工具的使用
废话不多说,给大家介绍一下最基本的浏览器调试工具
- iOS可变字符串的所有操作
可直接把代码复制即可结合输出看结果加深记忆 //创建一个可变字符串 NSMutableString * ms1 = [[NSMutableString alloc]init]; //可以通过类方法来创 ...
- java发布项目后注意小点,以及对于金额在java中的处理
项目在发布之后,有时会进行一些小的地方的修改,特别是对于一些常量的修改,如定义的一些特殊账户,第三方的key值,当修改的时候,我之前就偷懒过,因为项目在服务器上面,访问速度也受到限制,替换整个项目很麻 ...
- linux文件特殊属性介绍(s,s,t)
文件的权限有rwx这3个读.写.执行的权限.但是,怎么 /tmp权限有些奇怪?还有, /usr/bin/passwd也有些奇怪,怎么回事呢? [root@linux ~]# ls -ld /tmp ; ...
- A框架 第二部 实例化接收到的get类,调用父类抽象方法,自动执行方法call_user_func_array()
01父类抽象类 abstract.php <?phpabstract class controller_abstract{ protected $app; function __construc ...
- Entity Framework技巧系列之十三 - Tip 51 - 55
提示51. 怎样由任意形式的流中加载EF元数据 在提示45中我展示了怎样在运行时生成一个连接字符串,这相当漂亮. 其问题在于它依赖于元数据文件(.csdl .ssdl .msl)存在于本地磁盘上. 但 ...
- malloc without free, what happens?
It's per-process. Once your process exits, the allocated memory is returned to the OS for use by oth ...
- AngularJs多重视图和路由的使用
使用AngularJs来做多重视图和路由是在方便不过了,在开发过程中,都有许多的页面,而这些页面都有相同的部分,比如页面的头部和尾部通常都是一样的,变化的都是主体部分,还有就是一些后端管理的一些项目, ...
- rsync unison+inotify双向实时同步
rsync多线程同步 A:文件服务器 ip:10.10.1.10 B:备份服务器 ip:10.10.1.11 1.在B服务器上安装rsync软件 tar xzvf rsync-3.1.0.tar.gz ...
- 报错 BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext 的解决方法
这个普遍是因为tomcat 的 jar包问题,重新导入一下tomcat的jar包就OK了.