SpringMVC+MyBatis 相信已经是如今企业开发中经常使用技术了。

由于一些需求,我们须要集成JMS(我使用的是ActiveMQ)。大家应该都知道。MQ也能够觉得是一个数据源。数据也是数据源。

这样的情况下,假设我们在一个方法内操作JMS和数据库。我们就须要保证这种方法运行须要满足原子性。

这也就意味这一个问题,我们要多个数据源在同一个事务中。

这里不枚举市面上的全部解决方式,事实上atomikos JTA 是一个比較不错分布式事务管理器。

当然假设没有使用到JMS,在须要多数据源(也就是须要连接多个数据库)的情况相同适用。

以下将项目的主要配置贴出来共享:

1、applicationContext.xml

<?

xml version="1.0" encoding="GBK"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.13.0.xsd"> <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/> <!-- 配置扫描路径 -->
<context:component-scan base-package="com.hvgroup.zhuhai10086.jms">
<!-- 仅仅扫描Service。也能够加入Repostory,可是要把Controller排除在外,Controller由spring-mvc.xml去载入 -->
<!-- <context:include-filter type="annotation" expression="org.springframework.stereotype.Service" /> -->
<!-- <context:include-filter type="annotation" expression="org.springframework.stereotype.Repository" /> -->
<!-- <context:include-filter type="annotation" expression="org.springframework.stereotype.Component" /> -->
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan> <!-- 读取环境变量(自己定义扩展) -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:config/config.properties</value>
</list>
</property>
</bean> <import resource="classpath:spring/applicationContext-Service.xml" /> </beans>

2、applicationContext-Service.xml

<?

xml version="1.0" encoding="GBK"?

>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd"> <!-- JDBC连接数据库数据源 -->
<!-- <bean id="dataSource" -->
<!-- class="org.springframework.jdbc.datasource.DriverManagerDataSource"> -->
<!-- <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> --> <!-- DBCP连接池 -->
<!-- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" -->
<!-- destroy-method="close"> -->
<!-- <property name="driverClassName" value="${jdbc.driverClassName}" /> -->
<!-- <property name="url" value="${jdbc.url}" /> -->
<!-- <property name="username" value="${jdbc.username}" /> -->
<!-- <property name="password" value="${jdbc.password}" /> -->
<!-- <property name="initialSize" value="20" /> -->
<!-- <property name="maxActive" value="80" /> -->
<!-- <property name="maxIdle" value="100" /> -->
<!-- <property name="minIdle" value="20" /> -->
<!-- <property name="validationQuery" value="SELECT COUNT(*) FROM DUAL"></property> -->
<!-- <property name="testOnBorrow" value="true"></property> -->
<!-- <property name="testOnReturn" value="true"></property> -->
<!-- <property name="testWhileIdle" value="true"></property> -->
<!-- </bean> --> <bean id="dataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean"
init-method="init" destroy-method="close">
<property name="uniqueResourceName" value="ds1" />
<!-- <property name="xaDataSourceClassName" value="${jdbc.driverClassName}" /> -->
<property name="xaDataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" />
<property name="xaProperties">
<props>
<prop key="URL">${jdbc.url}</prop>
<prop key="user">${jdbc.username}</prop>
<prop key="password">${jdbc.password}</prop>
</props>
</property>
<!-- #连接池中保留的最小连接数 -->
<property name="minPoolSize" value="5" />
<!-- #连接池中保留的最大连接数 -->
<property name="maxPoolSize" value="20" />
<!-- #最大空暇时间,60秒内未使用则连接被丢弃。 若为0则永不丢弃。 Default: -->
<property name="maxIdleTime" value="60" />
<property name="testQuery">
<value>select 1</value>
</property>
</bean> <!-- JNDI连接池 -->
<!-- <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> -->
<!-- <property name="jndiName"> -->
<!-- <value>java:comp/env/jdbc/huiyzl</value> -->
<!-- </property> -->
<!-- </bean> --> <!-- 配置SqlSessionFactoryBean -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- mapper和resultmap配置路径 -->
<property name="mapperLocations">
<list>
<!-- 注意classpath后面的星号不可省略,否则不能载入jar包中的xml文件 -->
<value>classpath*:com/hvgroup/zhuhai10086/jms/**/sql/mysql/*Mapper.xml
</value>
</list>
</property>
<property name="plugins">
<array>
<!-- 关于分页插件的使用说明:http://git.oschina.net/free/Mybatis_PageHelper/blob/master/wikis/HowToUse.markdown -->
<bean class="com.github.pagehelper.PageHelper">
<property name="properties">
<value>
offsetAsPageNum=true
rowBoundsWithCount=true
reasonable=true
</value>
</property>
</bean>
</array>
</property>
</bean> <!-- 事务管理 -->
<!-- <bean id="transactionManager" -->
<!-- class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> -->
<!-- <property name="dataSource" ref="dataSource" /> -->
<!-- </bean> --> <!-- MapperScanner配置,Spring 自己主动去搜索mapper里的对象,并注入。指定markerInterface表示仅仅有继承SqlMapper接口的接口,才会被扫描映射 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.hvgroup.zhuhai10086.jms.**.mapper" />
<property name="markerInterface" value="com.hvgroup.zhuhai10086.jms.mapper.SqlMapper" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean> <bean id="userTransactionService" class="com.atomikos.icatch.config.UserTransactionServiceImp"
init-method="init" destroy-method="shutdownForce">
<constructor-arg>
<props>
<prop key="com.atomikos.icatch.service">com.atomikos.icatch.standalone.UserTransactionServiceFactory</prop>
</props>
</constructor-arg>
</bean> <bean id="atomikosTransactionManager"
class="com.atomikos.icatch.jta.UserTransactionManager"
depends-on="userTransactionService"
init-method="init" destroy-method="close" >
<property name="forceShutdown" value="false"/>
</bean> <bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp" >
<property name="transactionTimeout" value="300"/>
</bean> <!-- 分布式事务 -->
<bean id="jtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="atomikosTransactionManager"/>
<property name="userTransaction" ref="atomikosUserTransaction"/>
</bean> <!-- <tx:jta-transaction-manager /> -->
<!-- 可通过注解控制事务。也能够配置拦截器方式配置事务 -->
<tx:annotation-driven transaction-manager="jtaTransactionManager" /> </beans>

3、ActiveMQ-XA.xml

<?

xml version="1.0" encoding="GBK"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms-4.1.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.13.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.1.xsd"> <!-- 重发策略:最多重发次数=maximumRedeliveries -->
<amq:redeliveryPolicy id="redeliveryPolicy"
maximumRedeliveries="6" /> <!-- 抓取策略 -->
<amq:prefetchPolicy id="prefetchPolicy" queuePrefetch="5" topicPrefetch="5" /> <!-- activeMQ连接信息,XA事务 -->
<amq:xaConnectionFactory id="jmsXaConnectionFactory"
brokerURL="${activemq.brokerURL}"
userName="${activemq.username}"
password="${activemq.password}"
redeliveryPolicy="#redeliveryPolicy"
alwaysSessionAsync="false"
alwaysSyncSend="true"
prefetchPolicy="#prefetchPolicy"/> <bean id="amqConnectionFactory"
class="com.atomikos.jms.AtomikosConnectionFactoryBean" init-method="init" destroy-method="close">
<property name="uniqueResourceName" value="XAactiveMQ"/>
<property name="xaConnectionFactory" ref="jmsXaConnectionFactory"/>
<property name="poolSize" value="100"/>
</bean> <!-- ====Producer side start==== --> <!-- 定义JmsTemplate的Queue类型 -->
<bean id="jmsQueueTemplate" class="org.springframework.jms.core.JmsTemplate">
<constructor-arg ref="amqConnectionFactory" />
<!-- 非pub/sub模型(公布/订阅)。即队列模式 -->
<property name="pubSubDomain" value="false" />
</bean> <!-- 定义JmsTemplate的Topic类型 -->
<bean id="jmsTopicTemplate" class="org.springframework.jms.core.JmsTemplate">
<constructor-arg ref="amqConnectionFactory" />
<!-- pub/sub模型(公布/订阅) -->
<property name="pubSubDomain" value="true" />
</bean> <!-- ====Producer side end==== --> <!-- ====Consumer side start==== --> <!--这个是sessionAwareQueue目的地(响应消息)-->
<amq:queue id="queueReceiver2ResponseDestination" physicalName="test.queue2.response" /> <!-- 定义Queue监听器(无事务) -->
<jms:listener-container
destination-type="queue"
container-type="default"
connection-factory="amqConnectionFactory"
error-handler="jmsErrorHandler"
acknowledge="auto">
<jms:listener destination="xinge.queue.push" ref="xgMessageReceiver" concurrency="5-100" />
<jms:listener destination="xinge.queue.push.device.multiple" ref="xgMessageReceiverMultiple" concurrency="5-100" />
</jms:listener-container> <!-- 定义Queue监听器(有事务) -->
<jms:listener-container
destination-type="queue"
container-type="default"
connection-factory="amqConnectionFactory"
transaction-manager="jtaTransactionManager"
error-handler="jmsErrorHandler"
acknowledge="transacted">
<jms:listener destination="xinge.queue.push.invokelog" ref="xgMessageReceiverInvokeLog" concurrency="5-100" />
<!-- <jms:listener destination="test.queue" ref="queueReceiver" concurrency="10-100" /> -->
<!-- <jms:listener destination="test.queue2" ref="queueReceiver2" concurrency="2-10"/> -->
<!-- <jms:listener destination="test.queue2.response" ref="queueReceiver2Response" concurrency="2-10" /> -->
</jms:listener-container> <!-- 定义Topic监听器 -->
<!-- <jms:listener-container -->
<!-- destination-type="topic" -->
<!-- container-type="default" -->
<!-- connection-factory="amqConnectionFactory" -->
<!-- transaction-manager="jtaTransactionManager" -->
<!-- error-handler="jmsErrorHandler" -->
<!-- acknowledge="transacted" > -->
<!-- <jms:listener destination="test.topic" ref="topicReceiver" /> -->
<!-- <jms:listener destination="test.topic" ref="topicReceiver2" /> -->
<!-- </jms:listener-container> --> <!-- ====Consumer side end==== --> <bean id="xingeApp" class="com.tencent.xinge.XingeApp">
<constructor-arg index="0" value="2100170086"/><!-- accessId -->
<constructor-arg index="1" value="2d257b10220bc3849743ffe0e9bd233a"/><!-- secretKey -->
</bean> </beans>

4、spring-mvc.xml

<?

xml version="1.0" encoding="GBK"?

>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"> <!-- 启用MVC注解 -->
<mvc:annotation-driven /> <!-- 静态资源文件。不会被Spring MVC拦截 -->
<mvc:resources location="/resources/" mapping="/resources/**"/> <!-- 指定Sping组件扫描的基本包路径 -->
<context:component-scan base-package="com.hvgroup.zhuhai10086.jms" >
<!-- 这里仅仅扫描Controller,不可反复载入Service -->
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan> <!-- JSP视图解析器-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
<property name="order" value="1" />
</bean> </beans>

5、config.properties

jdbc.url=jdbc:mysql://localhost:3306/xgmessage?useUnicode=true&amp;characterEncoding=utf-8&amp;relaxAutoCommit=true
jdbc.username=root
jdbc.password=123456 activemq.brokerURL=tcp://localhost:61616
activemq.username=admin
activemq.password=admin

6、web.xml

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

>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://java.sun.com/xml/ns/javaee" xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>zhuhai10086-jms</display-name>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>zhuhai10086-jms</param-value>
</context-param>
<!-- Log4j配置 -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j/log4j.xml</param-value>
</context-param>
<!-- 载入log4j配置文件 -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<filter>
<filter-name>characterEncoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/applicationContext.xml,classpath*:activemq/ActiveMQ-XA.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>SpringMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringMVC</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>

7、把log4j.xml 也贴出来吧,后续有的同学能用上

<?

xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//LOGGER" "log4j.dtd">
<log4j:configuration debug="true" xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d][%p][%13F:%L] %m%n" />
</layout>
</appender>
<appender name="DEBUG" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="${log4j.logfile.path}" />
<param name="Encoding" value="UTF-8" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="ImmediateFlush" value="true" />
<param name="Append" value="true" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d][%p] %m%n" />
</layout>
</appender> <logger name="java.sql.Connection">
<level value="DEBUG" />
<appender-ref ref="DEBUG" />
<appender-ref ref="CONSOLE" />
</logger>
<logger name="java.sql.PreparedStatement">
<level value="DEBUG" />
<appender-ref ref="DEBUG" />
<appender-ref ref="CONSOLE" />
</logger>
<logger name="java.sql.Statement">
<level value="DEBUG" />
<appender-ref ref="DEBUG" />
<appender-ref ref="CONSOLE" />
</logger>
<logger name="java.sql.ResultSet">
<level value="DEBUG" />
<appender-ref ref="DEBUG" />
<appender-ref ref="CONSOLE" />
</logger>
<logger name="org.mybatis">
<level value="DEBUG" />
<appender-ref ref="DEBUG" />
<appender-ref ref="CONSOLE" />
</logger>
<logger name="org.springframework">
<level value="INFO" />
<appender-ref ref="DEBUG" />
<appender-ref ref="CONSOLE" />
</logger>
<logger name="org.apache.ibatis">
<level value="INFO" />
<appender-ref ref="DEBUG" />
<appender-ref ref="CONSOLE" />
</logger>
<logger name="org.apache.xbean.spring">
<level value="INFO" />
<appender-ref ref="DEBUG" />
<appender-ref ref="CONSOLE" />
</logger>
<logger name="com.atomikos">
<level value="ERROR" />
<appender-ref ref="DEBUG" />
<appender-ref ref="CONSOLE" />
</logger>
<logger name="org.apache.activemq">
<level value="INFO" />
<appender-ref ref="DEBUG" />
<appender-ref ref="CONSOLE" />
</logger> <logger name="com.hvgroup">
<level value="DEBUG"/>
<appender-ref ref="DEBUG" />
<appender-ref ref="CONSOLE" />
</logger> <!-- Root Logger -->
<root>
<level value="DEBUG"/>
</root> </log4j:configuration>

对须要使用数据库数据源的方法使用 @Transactional 注解就可以,在配置上,JMS的事务我们已经在配置文件里指定了。例如以下代码中指定的 transaction-manager=”jtaTransactionManager”:

    <!-- 定义Queue监听器(有事务) -->
<jms:listener-container
destination-type="queue"
container-type="default"
connection-factory="amqConnectionFactory"
transaction-manager="jtaTransactionManager"
error-handler="jmsErrorHandler"
acknowledge="transacted">
<jms:listener destination="xinge.queue.push.invokelog" ref="xgMessageReceiverInvokeLog" concurrency="5-100" />
</jms:listener-container>

最后贴上project代码的结构图:

声明:本文是我在项目实际业务开发之前搭建的框架,当中如出现一些敏感字。声明不涉及版权问题。

贴出的配置。仅供大家学习。

SpringMVC+MyBatis+JMS+JTA(分布式事务)的更多相关文章

  1. Springboot+Atomikos+Jpa+Mysql实现JTA分布式事务

    1 前言 之前整理了一个spring+jotm实现的分布式事务实现,但是听说spring3.X后不再支持jotm了,jotm也有好几年没更新了,所以今天整理springboot+Atomikos+jp ...

  2. 使用Atomikos Transactions Essentials实现多数据源JTA分布式事务--转载

    原文:http://www.ite/topic/122700 9.17 update:使用NonXADataSourceBean. Mysql在5.0版本和Connecter/J5.0版本后提供了XA ...

  3. 事务隔离级别与传播机制,spring+mybatis+atomikos实现分布式事务管理

    1.事务的定义:事务是指多个操作单元组成的合集,多个单元操作是整体不可分割的,要么都操作不成功,要么都成功.其必须遵循四个原则(ACID). 原子性(Atomicity):即事务是不可分割的最小工作单 ...

  4. Spring事务隔离级别与传播机制详解,spring+mybatis+atomikos实现分布式事务管理

    原创说明:本文为本人原创作品,绝非他处转载,转账请注明出处 1.事务的定义:事务是指多个操作单元组成的合集,多个单元操作是整体不可分割的,要么都操作不成功,要么都成功.其必须遵循四个原则(ACID). ...

  5. JTA 分布式事务

    什么是JTA - 2009-07-25 18:31:06|  分类: 技术文章|举报|字号 订阅     什么是JTA? Java Transaction API(Java事务API) (JTA)Ja ...

  6. Spring 3.0 + Atomikos构建jta分布式事务

    Spring3.0已经不再支持jtom了,不过我们可以用第三方开源软件atomikos(http://www.atomikos.com/)来实现.Atomikos是目前在分布式事务管理中做得相当不错的 ...

  7. j2ee分布式架构 dubbo + springmvc + mybatis + ehcache + redis 分布式架构

    介绍 <modules>        <!-- jeesz 工具jar -->        <module>jeesz-utils</module> ...

  8. spring+jotm+ibatis+mysql实现JTA分布式事务

    1 环境 1.1 软件环境  spring-framework-2.5.6.SEC01-with-dependencies.zip ibatis-2.3.4 ow2-jotm-dist-2.1.4-b ...

  9. Springboot + Atomikos + Druid + Mysql 实现JTA分布式事务

    DataSource 配置 package com.cheng.dynamic.config; import java.util.Properties; import javax.sql.DataSo ...

随机推荐

  1. springmvc请求方法那些事

    @RequestMapping 用法详解之地址映射 (2013-08-11 16:06:58) 转载▼ 标签: it   前段时间项目中用到了RESTful模式来开发程序,但是当用POST.PUT模式 ...

  2. ios之数据持久化

    9.1 数据持久化概述 iOS中可以有四种持久化数据的方式: 属性列表.对象归档.SQLite3和Core Data 9.2 iOS应用程序目录结构 iOS应用程序运行在Mac os模拟器时候,有一下 ...

  3. OpenJudge-百练-2755-动规

    动态规划的话,我们中心思想就是,设一个num数组,num[ i ][ j ] 代表从i的大小中,取出 j 种物品的方法数. 当不取j种物品的时候,我们就让num[ i ][ j ] =num[ i ] ...

  4. <c:foreach> <c:forTokens>

    <c:choose>标签与Java switch语句的功能一样,用于在众多选项中做出选择. switch语句中有case,而<c:choose>标签中对应有<c:when ...

  5. [bzoj1022][SHOI2008]小约翰的游戏John (反Nim游戏)

    Description 小约翰经常和他的哥哥玩一个非常有趣的游戏:桌子上有n堆石子,小约翰和他的哥哥轮流取石子,每个人取 的时候,可以随意选择一堆石子,在这堆石子中取走任意多的石子,但不能一粒石子也不 ...

  6. 论MySQL中如何代替Oracle中select into new_table from old_table

    v_receipt         warehouse_receipt%ROWTYPE;-- 这里创建表类型,v_receipt复刻了warehouse_receipt的类型(相当于拥有了所有相同的字 ...

  7. 简单的MVC 权限管理

    花了3天时间研究了下对于 NHibernate+MVC4+bootstrap+Redis(这个是选配只做了登陆测试)+T4 这些都是第一次使用.用着有些生硬权当鼓励下自己,记录下来有空就继续完善. 思 ...

  8. 大数据学习——ip改成固定ip

    vi /etc/sysconfig/network-scripts/ifcfg-eth0 修改BOOTPROTO为static 添加IPADDR=192.168.74.100 添加NETMASK=25 ...

  9. httpclient调用webservice接口的方法实例

    这几天在写webservice接口,其他的调用方式要生成客户端代码,比较麻烦,不够灵活,今天学习了一下httpclient调用ws的方式,感觉很实用,话不多说,上代码 http://testhcm.y ...

  10. xtu summer individual 1 D - Round Numbers

    D - Round Numbers Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u D ...