user.xml

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd"> <sqlMap namespace="user"> <!-- Use type aliases to avoid typing the full classname every time. -->
<typeAlias alias="User" type="****.beans.User"/> <!-- Result maps describe the mapping between the columns returned
from a query, and the class properties. A result map isn't
necessary if the columns (or aliases) match to the properties
exactly. -->
<resultMap id="UserResult" class="User">
<result property="userName" column="name"/>
<result property="password" column="password"/>
</resultMap> <!-- Select with no parameters using the result map for Account class. -->
<select id="selectAllUser" resultMap="UserResult">
select * from User
</select> <!-- A simpler select example without the result map. Note the
aliases to match the properties of the target result class. -->
<select id="selectUserByName" parameterClass="java.lang.String" resultClass="User">
select
name as userName,
password as password
from user
where name = #userName#
</select> <!-- Insert example, using the User parameter class-->
<insert id="insertUser" parameterClass="User">
insert into User (
name,
password )
values (#userName#,#password#)
</insert>
</sqlMap>

SqlMapConfig.xml

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd"> <sqlMapConfig> <!-- The properties (name=value) in the file specified here can be used
placeholders in this config file (e.g. “${driver}”. The file is relative
to the classpath and is completely optional.
<properties resource="db.properties" /> --> <!-- These settings control SqlMapClient configuration details, primarily
to do with transaction management. They are all optional (more detail
later in this document).
<settings
cacheModelsEnabled="true"
enhancementEnabled="true"
lazyLoadingEnabled="true"
maxRequests="32"
maxSessions="10"
maxTransactions="5"
useStatementNamespaces="false"/> --> <!-- Configure a built-in transaction manager. If you're using an
app server, you probably want to use its transaction manager
and a managed datasource <transactionManager type="JDBC" commitRequired="false">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driver}"/>
<property name="JDBC.ConnectionURL" value="${url}"/>
<property name="JDBC.Username" value="${username}"/>
<property name="JDBC.Password" value="${password}"/>
<property name="JDBC.DefaultAutoCommit" value="true" />
<property name="Pool.MaximumActiveConnections" value="10"/>
<property name="Pool.MaximumIdleConnections" value="5"/>
<property name="Pool.MaximumCheckoutTime" value="120000"/>
<property name="Pool.TimeToWait" value="500"/>
<property name="Pool.PingQuery" value="select 1 from User"/>
<property name="Pool.PingEnabled" value="false"/>
<property name="Pool.PingConnectionsOlderThan" value="1"/>
<property name="Pool.PingConnectionsNotUsedFor" value="1"/>
</dataSource>
</transactionManager> --> <!-- List the SQL Map XML files. They can be loaded from the classpath, as they are here (com.domain.data...) -->
<!-- List more here...
<sqlMap resource="com/mydomain/data/Order.xml"/>
<sqlMap resource="com/mydomain/data/Documents.xml"/>
-->
<sqlMap resource="******/beans/User.xml"/> </sqlMapConfig>

beans.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"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:property-placeholder location="classpath:db.properties"/>
<context:annotation-config/>
<context:component-scan base-package="com.***"/>
<!--此bean用来告诉Spring去何处找数据库信息,有此Bean才会有下面dataSource中用${}标记来取变量的语句
<bean id="propertyConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:db.properties</value>
</property>
</bean>
-->
<!--配置一个数据源,根据上面propertyConfig指定的location去找数据库连接的配置信息 -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>${driver}</value>
</property>
<property name="url">
<value>${url}</value>
</property>
<property name="username">
<value>${username}</value>
</property>
<property name="password">
<value>${password}</value>
</property>
</bean> <!--根据dataSource和configLocation创建一个SqlMapClient -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocations">
<list>
<!-- sql语句配置xml文件 -->
<value>classpath:SqlMapConfig.xml</value>
</list>
</property>
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean> <!--根据sqlMapClien创建一个sqlMapClientTemplate模版类 -->
<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient">
<ref bean="sqlMapClient" />
</property>
</bean>
<bean name="userServiceSpring" class="*****.service.UserServiceSpring">
<property name="sqlMapClientTemplate">
<ref bean="sqlMapClientTemplate"/>
</property>
</bean>
<bean id="user" class="****.beans.User"/>
</beans>

faces-config.xml

<?xml version='1.0' encoding='UTF-8'?>

<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2">
<!--此配置把jsf bean 交给spring管理-->
<application>
<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
</application>
<!--
<managed-bean>
<managed-bean-name>user</managed-bean-name>
<managed-bean-class>*****.beans.User</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
-->
<navigation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/sucess.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
//jsf  中获取spring实例的对象            
ServletContext context = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(context);

spring3.0+jsf+ibatis整合的更多相关文章

  1. spring3.0+struts2+ibatis整合

    User.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE sqlMap PUBLI ...

  2. MyEclipse-10.0下Struts2.1+Spring3.0+Hibernate3.3整合过程

    新建web project: 命名为SSH,做如下设置: 新建后的工程目录如下: 然后开始添加SSH框架,这里我按照struts-spring-hibernate顺序进行添加. 首先添加struts2 ...

  3. Struts2.1.8 + Spring3.0+ Hibernate3.2整合笔记

    body, p, th, td, li, ul, ol, h1, h2, h3, h4, h5, h6, pre { font-family: simsun; line-height: 1.4; } ...

  4. Spring3.0 与 MyBatis框架 整合小实例

    本文将在Eclipse开发环境下,采用Spring MVC + Spring + MyBatis + Maven + Log4J 框架搭建一个Java web 项目. 1. 环境准备: 1.1 创建数 ...

  5. Jbpm4.4+hibernate3.5.4+spring3.0.4+struts2.1.8整合例子(附完整的请假流程例子,jbpm基础,常见问题解决)

    Jbpm4.4+hibernate3.5.4+spring3.0.4+struts2.1.8 整合例子(附完整的请假流程例子). 1.jbpm4.4 测试环境搭建 2.Jbpm4.4+hibernat ...

  6. Maven整合Spring3.0+Mybatis3.2+Struts2.3+查找坐标+jar包依赖(五)

    依赖传递 只添加了一个struts2-core依赖,发现项目中出现了很多jar,这种情况 叫 依赖传递

  7. Jbpm4.4+hibernate3.5.4+spring3.0.4+struts2.1.8 整合例子

    转自:http://www.blogjava.net/wangxinsh55/archive/2011/07/24/354925.html   Jbpm4.4+hibernate3.5.4+sprin ...

  8. spring3.0的jar包详解

    1. spring.jar 是包含有完整发布模块的单个jar 包. 2. org.springframework.aop 包含在应用中使用Spring的AOP特性时所需的类. 3. org.sprin ...

  9. Spring3.0.5jar包用法详解 [转载]

    Spring3.X以后jar包进行了重构,取消了原来2.X版本中的总的spring.jar包,而是把总包中的功能全部分开打包.正在向osgi靠拢. 各个jar包详解如下: 1. org.springf ...

随机推荐

  1. 2018-2-13-C#-Find-vs-FirstOrDefault

    title author date CreateTime categories C# Find vs FirstOrDefault lindexi 2018-2-13 17:23:3 +0800 20 ...

  2. smbsh - 允许用UNIX命令访问NT文件系统

    总览 smbsh 描述 此程序是Samba套件的一部分. smbsh允许你用UNIX命令诸如ls,egrep和rcp等来访问NT文件系统.必须用动态链接的shell以便使smbsh工作正常. 从命令提 ...

  3. 【LeetCode】从contest-21开始。(一般是10个contest写一篇文章)

    [LeetCode Weekly Contest 29][2017/04/23] 第17周 Binary Tree Tilt (3) Array Partition I (6) Longest Lin ...

  4. Sass-@while

    @while 指令也需要 SassScript 表达式(像其他指令一样),并且会生成不同的样式块,直到表达式值为 false 时停止循环.这个和 @for 指令很相似,只要 @while 后面的条件为 ...

  5. Spring-quartz定时系统多任务配置

    <!-- 启动触发器的配置开始 --> <bean name="startQuertz" lazy-init="false" autowire ...

  6. Ubuntu下使用天河注意事项

    把下载的.cgi登陆文件用文本编辑器打开,修改端口 用管理员权限打开.cgi才能绑定端口 $ gksu nautilus # browse files as root $ gksu gedit /et ...

  7. JS中关于引用类型数据及函数的参数传递

    (JavaScript 中,函数的参数传递方式都是按值传递,没有按引用传递的参数) 一.数据类型 在 javascript 中数据类型可以分为两类: 基本类型值 primitive type,比如Un ...

  8. kafka-producer.properties

    # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreement ...

  9. Sumdiv

    题目链接 题意:求a^b的所有约数之和mod9901. 思路:因为一个数A能够表示成多个素数的幂相乘的形式.即A=(a1^n1)*(a2^n2)*(a3^n3)...(am^nm).所以这个题就是要求 ...

  10. 文字在线中间,CSS巧妙实现分隔线的几种方法

    单个标签实现分隔线: .demo_line_01{ padding: 0 20px 0; margin: 20px 0; line-height: 1px; border-left: 200px so ...