【原创】Flex4.5+BlazeDS+Mybatis3.0+Spring3.1+Proxool整合搭建 后台数据推送实例 全部开源 全部图文解说

本文为自己花了两天时间,查阅N多资料,整合而成,一直没时间发表上来。

 

本框架将全部使用注解的方式,从繁琐的配置文件中解脱出来,包括Flex,Java,Mybatis(当然可以自己选择是否使用注解方式)。

 

本着尊重创作的原则,希望大家不要转载!!!不然百度谷歌出来一推一样的文章,让我情何以堪啊,呵呵。

废话不多说了,开始...

 

 

开发工具:MyEclipse9.1+FlashBuilder4.5

运行坏境:Tomcat7+Oracle11g+JDK1.7(环境可由自己机器已安装环境决定,无硬性要求)

框 架:Flex4.5+BlazeDS+Mybatis3.0+Spring3.1+Proxool连接池

 

第一部分:创建项目,高手可直接跳过!

 

1.创建FlexWeb项目。

选择Flex项目。

【原创】Flex4.5+BlazeDS+Mybatis3.0+Spring3.1+Proxool整合搭建 后台数据推送实例 全部开源 全部图文解说_第1张图片

 

2.输入项目,然后下一步。

 

【原创】Flex4.5+BlazeDS+Mybatis3.0+Spring3.1+Proxool整合搭建 后台数据推送实例 全部开源 全部图文解说_第2张图片

 

3.配置服务器设置

服务器技术选择Java,然后勾上使用选择对象服务,选择BlazeDS,选择使用WTP创建Java/Flex组合项目

【原创】Flex4.5+BlazeDS+Mybatis3.0+Spring3.1+Proxool整合搭建 后台数据推送实例 全部开源 全部图文解说_第3张图片

 

4.Java设置

目标运行时,其实就是选择Web服务器Tomcat,没有的则点击旁边的新建

【原创】Flex4.5+BlazeDS+Mybatis3.0+Spring3.1+Proxool整合搭建 后台数据推送实例 全部开源 全部图文解说_第4张图片

 

5.选择Tomcat服务器

可根据自己机器上的Tomcat版本而定,不一定需要最新的版本

【原创】Flex4.5+BlazeDS+Mybatis3.0+Spring3.1+Proxool整合搭建 后台数据推送实例 全部开源 全部图文解说_第5张图片

 

6.完善Server服务器

然后点击完成

【原创】Flex4.5+BlazeDS+Mybatis3.0+Spring3.1+Proxool整合搭建 后台数据推送实例 全部开源 全部图文解说_第6张图片

 

7.选择BlazeDSWar文件

然后修改输出文件夹为WebContent,与内容文件夹保持一致。

【原创】Flex4.5+BlazeDS+Mybatis3.0+Spring3.1+Proxool整合搭建 后台数据推送实例 全部开源 全部图文解说_第7张图片

 

8.最后一步

在输出文件夹URL输入http://localhost:8080/Test,为了方便运行,可不设置。

【原创】Flex4.5+BlazeDS+Mybatis3.0+Spring3.1+Proxool整合搭建 后台数据推送实例 全部开源 全部图文解说_第8张图片

点击完成,大功告成!

 

9.整个项目的目录

【原创】Flex4.5+BlazeDS+Mybatis3.0+Spring3.1+Proxool整合搭建 后台数据推送实例 全部开源 全部图文解说_第9张图片

 

 

第二部分:整合框架

 

1.加入所需架包

架包示意图

【原创】Flex4.5+BlazeDS+Mybatis3.0+Spring3.1+Proxool整合搭建 后台数据推送实例 全部开源 全部图文解说_第10张图片

 

2.修改web.xml,整合Flex+Spring+log4j文件

 

 

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
	http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
	id="WebApp_ID" version="3.0">
	<display-name>GPSMonitoring</display-name>

	<!-- 定义 spring flex 集成的配置,使用单独的配置文件。
		 不使用在一个applicatonContext.xml中import springFlex.xml的方法,   
         spring flex 一定要用DispatcherServlet 方法,不能用ContextLoaderListener -->  
   <servlet>  
       <servlet-name>MessagebrokerServlet</servlet-name>  
       <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
       <init-param>  
           <param-name>contextConfigLocation</param-name>  
           <param-value>classpath:config/flex/applicationContext-flex.xml</param-value>
       </init-param>  
       <load-on-startup>1</load-on-startup>  
   </servlet>
   
   <!-- Map /spring/* requests to the DispatcherServlet -->  
   <servlet-mapping>  
       <servlet-name>MessagebrokerServlet</servlet-name>  
       <url-pattern>/messagebroker/*</url-pattern>  
   </servlet-mapping>
   <!-- 定义 spring flex 集成的配置  结束-->  
     
   <!--  访问RDS 定义开始-->  
   <servlet>  
       <servlet-name>RDSDispatchServlet</servlet-name>  
       <servlet-class>flex.rds.server.servlet.FrontEndServlet</servlet-class>  
       <init-param>  
           <param-name>useAppserverSecurity</param-name>  
           <param-value>false</param-value>  
       </init-param>  
       <init-param>  
           <param-name>messageBrokerId</param-name>  
           <param-value>_messageBroker</param-value>  
       </init-param>  
       <load-on-startup>10</load-on-startup>  
   </servlet>
   
   <servlet-mapping id="RDS_DISPATCH_MAPPING">  
       <servlet-name>RDSDispatchServlet</servlet-name>  
       <url-pattern>/CFIDE/main/ide.cfm</url-pattern>  
   </servlet-mapping>  
   <!--  访问RDS 定义结束 -->  

	<!-- 指定spring的配置文件,通过spring提供的classpath:前缀指定从类路径下寻找 -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:config/spring/applicationContext*.xml</param-value>
	</context-param>

	<!-- 对Spring容器进行实例化 -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	
	<!-- Spring 配置Log4j -->
	<context-param>
		<param-name>webAppRootKey</param-name>
		<param-value>GPSMonitoring.web</param-value>
	</context-param>
	
	<context-param>
		<param-name>log4jConfigLocation</param-name>
		<param-value>classpath:config/spring/log4j.properties</param-value>
	</context-param>
	
	<context-param>
		<param-name>log4jRefreshInterval</param-name>
		<param-value>3000</param-value>
	</context-param>
	
	<listener>
		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
	</listener>

	<!-- Spring 配置Log4j end -->
	
	<!-- 监控数据的servlet -->
	<servlet>
		<servlet-name>proxooladmin</servlet-name>
		<servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
	</servlet>
	
	<servlet-mapping>
		<servlet-name>proxooladmin</servlet-name>
		<url-pattern>/proxooladmin</url-pattern>
	</servlet-mapping>
	
	<!-- 配置受保护域,只有Tomcat管理员才能察看连接池的信息 -->
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>proxool</web-resource-name>
            <url-pattern>/proxooladmin</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>manager</role-name>
        </auth-constraint>
    </security-constraint>
    
    <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>proxool manager Application</realm-name>
    </login-config>
    
    <security-role>
        <description>The role that is required to log in to the Manager Application</description>
        <role-name>manager</role-name>
    </security-role>
    
	<welcome-file-list>
		<welcome-file>GPSMonitoring.html</welcome-file>
	</welcome-file-list>

</web-app>

 

 

3.修改WEB-INF下的flex文件夹中的service-config.xml

 

 

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

<!-- 不加载任何文件 -->

<!--    <services>-->
<!--        <service-include file-path="remoting-config.xml" />-->
<!--        <service-include file-path="proxy-config.xml" />-->
<!--        <service-include file-path="messaging-config.xml" />        -->
<!--    </services>-->

	
	<services>
		<default-channels>
			<channel ref="my-amf" />
		</default-channels>
	</services>

    <security>
        <login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat"/>
        <!-- Uncomment the correct app server
        <login-command class="flex.messaging.security.TomcatLoginCommand" server="JBoss">
		<login-command class="flex.messaging.security.JRunLoginCommand" server="JRun"/>        
        <login-command class="flex.messaging.security.WeblogicLoginCommand" server="Weblogic"/>
        <login-command class="flex.messaging.security.WebSphereLoginCommand" server="WebSphere"/>
        -->

        <!-- 
        <security-constraint id="basic-read-access">
            <auth-method>Basic</auth-method>
            <roles>
                <role>guests</role>
                <role>accountants</role>
                <role>employees</role>
                <role>managers</role>
            </roles>
        </security-constraint>
         -->
    </security>

    <channels>
        <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
        </channel-definition>

        <channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
            <endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
            <properties>
                <add-no-cache-headers>false</add-no-cache-headers>
            </properties>
        </channel-definition>

        <channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
            <properties>  
                <polling-enabled>true</polling-enabled>  
                <polling-interval-seconds>5</polling-interval-seconds>  
                <wait-interval-millis>1000</wait-interval-millis>  
                <client-wait-interval-millis>1</client-wait-interval-millis>  
                <max-waiting-poll-requests>200</max-waiting-poll-requests>  
                <user-agent-settings>  
					<!-- MSIE 5, 6, 7 default max number of permanent HTTP connections is 2.   -->
                    <user-agent match-on="MSIE" max-streaming-connections-per-session="1"/>  
					<!-- MSIE 8 max number is 6.   -->
                    <user-agent match-on="MSIE 8" max-streaming-connections-per-session="5"/>  
					<!-- Firefox 1, 2 max number is 2.    -->
                    <user-agent match-on="Firefox" max-streaming-connections-per-session="1"/>  
					<!-- Firefox 3 max number is 6.   -->
                    <user-agent match-on="Firefox/3" max-streaming-connections-per-session="5"/>  
					<!-- Safari 3, 4 max number is 4.     -->
                    <user-agent match-on="Safari" max-streaming-connections-per-session="3"/>  
					<!-- Chrome 0, 1, 2 max number is 6.   -->
                    <user-agent match-on="Chrome" max-streaming-connections-per-session="5"/>  
					<!-- Opera 7, 9 max number is 4.  -->
                    <user-agent match-on="Opera" max-streaming-connections-per-session="3"/>  
					<!-- Opera 8 max number is 8.     -->
                    <user-agent match-on="Opera 8" max-streaming-connections-per-session="7"/>  
					<!-- Opera 10 max number is 8.   -->
                    <user-agent match-on="Opera 10" max-streaming-connections-per-session="7"/>  
                </user-agent-settings>  
            </properties>  
        </channel-definition>
        
        <!--
        <channel-definition id="my-http" class="mx.messaging.channels.HTTPChannel">
            <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/http" class="flex.messaging.endpoints.HTTPEndpoint"/>
        </channel-definition>

        <channel-definition id="my-secure-http" class="mx.messaging.channels.SecureHTTPChannel">
            <endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/httpsecure" class="flex.messaging.endpoints.SecureHTTPEndpoint"/>
            <properties>
                <add-no-cache-headers>false</add-no-cache-headers>
            </properties>
        </channel-definition>
        -->
    </channels>

    <logging>
        <target class="flex.messaging.log.ConsoleTarget" level="Error">
            <properties>
                <prefix>[BlazeDS] </prefix>
                <includeDate>false</includeDate>
                <includeTime>false</includeTime>
                <includeLevel>false</includeLevel>
                <includeCategory>false</includeCategory>
            </properties>
            <filters>
                <pattern>Endpoint.*</pattern>
                <pattern>Service.*</pattern>
                <pattern>Configuration</pattern>
            </filters>
        </target>
    </logging>

    <system>
        <redeploy>
            <enabled>false</enabled>
            <!-- 
            <watch-interval>20</watch-interval>
            <watch-file>{context.root}/WEB-INF/flex/services-config.xml</watch-file>
            <watch-file>{context.root}/WEB-INF/flex/proxy-config.xml</watch-file>
            <watch-file>{context.root}/WEB-INF/flex/remoting-config.xml</watch-file>
            <watch-file>{context.root}/WEB-INF/flex/messaging-config.xml</watch-file>
            <watch-file>{context.root}/WEB-INF/flex/data-management-config.xml</watch-file>
            <touch-file>{context.root}/WEB-INF/web.xml</touch-file>
             -->
        </redeploy>
    </system>

</services-config>

4.Mybatis+Spring+Proxool连接池整合

 

1).准备proxool配置文件pool.properties

 

 

#pool-proxool
driver=oracle.jdbc.driver.OracleDriver
driverUrl=jdbc\:oracle\:thin\:@192.168.101.87\:1521\:PM2006
user=mcc2
password=mcc

alias=proxoolPool
houseKeepingSleepTime=30000
prototypeCount=20
minimumConnectionCount=5
maximumConnectionCount=30
maximumActiveTime=60000
trace=true
verbose=true
house-keeping-test-sql=select CURRENT_DATE
simultaneousBuildThrottle=50

 

2).Mybatis的sqlMapConfig.xml文件

 

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC
 "-//mybatis.org//DTD Config 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>
	<mappers>
		<!-- 配置sql语句文件 -->
		<mapper resource="config/sqlmap/test.xml"/> 
	</mappers>
</configuration>

3).applicationContext.xml文件

 

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:security="http://www.springframework.org/schema/security"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:p="http://www.springframework.org/schema/p"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	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.1.xsd
		http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">

	<!-- ====================================================================================== -->
    <!--                         启用基于注解(Annotation-based)的配置                           -->
    <!-- ====================================================================================== -->
	<context:annotation-config/>
	
	<!-- ====================================================================================== -->
    <!--                         启用Spring对@AspectJ切面配置的支持                               -->
    <!-- ====================================================================================== -->
	<aop:aspectj-autoproxy />
	
	<!-- ====================================================================================== -->
    <!--                                       加载属性文件                                      -->
    <!-- ====================================================================================== -->
	<context:property-placeholder location="classpath:config/myibatis/*.properties"/>	
	 
	<!-- ====================================================================================== -->
    <!--                                 配置  proxool  连接池                                   -->
    <!-- ====================================================================================== -->
	<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" 
		p:driver="${driver}"
		p:driverUrl="${driverUrl}"
		p:user="${user}"
		p:password="${password}"
		p:alias="${alias}"
		p:minimumConnectionCount="${minimumConnectionCount}"
		p:maximumConnectionCount="${maximumConnectionCount}"
		p:maximumActiveTime="${maximumActiveTime}"
		p:prototypeCount="${prototypeCount}"
		p:trace="${trace}"
		p:verbose="${verbose}"
		p:simultaneousBuildThrottle="${simultaneousBuildThrottle}"
	/>


<!--	<bean id="dataSourceFacade" class="org.logicalcobwebs.proxool.ProxoolFacade" destroy-method="shutdown"/>-->

	<!-- ====================================================================================== -->
    <!--                                 配置 SqlMapClient                                      -->
    <!-- ====================================================================================== -->
	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="configLocation" value="classpath:config/myibatis/sqlMapConfig.xml"/>
    </bean>
	
	<!-- ====================================================================================== -->
    <!--                                       事务配置                                          -->
    <!-- ====================================================================================== -->
<!--    <bean id="transactionManager"  class="org.springframework.orm.hibernate3.HibernateTransactionManager">-->
<!--    	<property name="sessionFactory" ref="sessionFactory"></property>-->
<!--    </bean>-->
<!--    <tx:annotation-driven transaction-manager="transactionManager"/>-->
</beans>

4).applicationContext-action.xml 文件

 

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:security="http://www.springframework.org/schema/security"
	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.1.xsd
		http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">

	<!-- ====================================================================================== -->
    <!--                         启用基于注解(Annotation-based)的配置                           -->
    <!-- ====================================================================================== -->
    <context:annotation-config/>
    
    <!-- ====================================================================================== -->
    <!--                                   Action 控制层的配置                                   -->
    <!-- ====================================================================================== -->
<!--	<bean id="testAction" class="com.consmation.action.TestAction" />-->
    
    <context:component-scan base-package="com.consmation.action" />
    <context:component-scan base-package="com.consmation.test" />
    
</beans>

5).applicationContext-dao.xml 文件

 

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:security="http://www.springframework.org/schema/security"
	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.1.xsd
		http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">

	<!-- ====================================================================================== -->
    <!--                         启用基于注解(Annotation-based)的配置                           -->
    <!-- ====================================================================================== -->
    <context:annotation-config/>
    
    <!-- ====================================================================================== -->
    <!--                                   DAO 数据访问层的配置                                  -->
    <!-- ====================================================================================== -->
    
<!--	<bean id="operatorGroupDao" class="com.consmation.dao.impl.OperatorGroupDaoImpl" />-->
	<context:component-scan base-package="com.consmation.dao.impl"></context:component-scan>
	
	<bean id="template" class="org.springframework.flex.messaging.MessageTemplate" />    
</beans>

 

6).applicationContext-security.xml 文件

 

 

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">

    <http entry-point-ref="entryPoint">
        <anonymous enabled="false"/>
    </http>
    
    <beans:bean id="entryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint"/>
    
    <authentication-manager>
       <authentication-provider>
           <user-service>
            <user name="john" password="john" authorities="ROLE_USER" />
            <user name="admin" password="admin" authorities="ROLE_USER, ROLE_ADMIN" />
            <user name="guest" password="guest" authorities="ROLE_GUEST" />
           </user-service>
       </authentication-provider>
    </authentication-manager>

</beans:beans>

 

7). applicationContext-flex.xml 由于项目中加入Spring-Flex框架,此配置文件必须与其它Spring文件分开放置

 

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:flex="http://www.springframework.org/schema/flex"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans
		http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
		http://www.springframework.org/schema/flex 
		http://www.springframework.org/schema/flex/spring-flex-1.5.xsd">
 

	</flex:message-broker>
		
</beans>

 

8).log4j.properties 文件

 

 

log4j.rootLogger=info,stdout,info,debug,error
#log4j.rootLogger=error
log4j.appender.stdout=org.apache.log4j.ConsoleAppender   
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout   
log4j.appender.stdout.layout.ConversionPattern=[%-5p] [%-d{yyyy-MM-dd HH:mm:ss}] %-20c %x %m%n
 
log4j.logger.info=info 
log4j.appender.info=org.apache.log4j.DailyRollingFileAppender   
log4j.appender.info.layout=org.apache.log4j.PatternLayout   
log4j.appender.info.layout.ConversionPattern=[%-5p] [%-d{yyyy-MM-dd HH:mm:ss}] %-20c %x %m%n
log4j.appender.info.datePattern='.'yyyy-MM-dd   
log4j.appender.info.Threshold = INFO    
log4j.appender.info.append=true  
log4j.appender.info.File=C\:/gpslogs/info/info.log   

log4j.logger.debug=debug   
log4j.appender.debug=org.apache.log4j.DailyRollingFileAppender   
log4j.appender.debug.layout=org.apache.log4j.PatternLayout   
log4j.appender.debug.layout.ConversionPattern=[%-5p] [%-d{yyyy-MM-dd HH:mm:ss}] %-20c %x %m%n
log4j.appender.debug.datePattern='.'yyyy-MM-dd   
log4j.appender.debug.Threshold = DEBUG    
log4j.appender.debug.append=true  
log4j.appender.debug.File=C\:/gpslogs/debug/debug.log   

log4j.logger.error=error   
log4j.appender.error=org.apache.log4j.DailyRollingFileAppender   
log4j.appender.error.layout=org.apache.log4j.PatternLayout   
log4j.appender.error.layout.ConversionPattern=[%-5p] [%-d{yyyy-MM-dd HH:mm:ss}] %-20c %x %m%n
log4j.appender.error.datePattern='.'yyyy-MM-dd   
log4j.appender.error.Threshold = ERROR    
log4j.appender.error.append=true  
log4j.appender.error.File=C\:/gpslogs/error/error.log

#SqlMap logging configuration...
log4j.logger.com.ibatis=DEBUG
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG,sqllog
log4j.logger.java.sql.ResultSet=DEBUG,sqllog

#sqllog
log4j.appender.sqllog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.sqllog.layout=org.apache.log4j.PatternLayout
log4j.appender.sqllog.layout.ConversionPattern=[%-5p] [%-d{yyyy-MM-dd HH:mm:ss}] %-20c %x %m%n
log4j.appender.sqllog.datePattern='.'yyyy-MM-dd
log4j.appender.sqllog.append=true
log4j.appender.sqllog.File=C\:/gpslogs/sql/sql.log

 

9).sqlmap文件test.xml

 

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">  
<!-- 操作员组 ibatis配置文件 -->

<mapper namespace="config.sqlmap.test">

	<!-- 查询所有操作组信息 -->
	<select id="query" resultType="HashMap">
		select * from CUSTOMER_EXT t
	</select>
  	
</mapper>

 

10).Java 文件

 

 

 

-- 加上了源码,但是由于文件大小限制,故把lib分开,各位同学导入的时候把lib文件夹copy进去就行了,删除了classes12,Oracle的架包,需要的自己手动添加。

 

你可能感兴趣的:(Mybatis3)