ssh框架加入atomikos分布式事务管理

一、概念

 

 

 

分布式事务
分布式事务是指事务的参与者、支持事务的服务器、资源服务器以及事务管理器分别位于不同的分布式系统的不同节点之上。简言之,同时操作多个数据库保持事务的统一,达到跨库事务的效果。

 

 

 

JTA
JTA,即Java Transaction API,JTA允许应用程序执行分布式事务处理———在两个或多个网络计算机资源上访问并且更新数据。JDBC驱动程序的JTA支持极大地增强了数据访问能力。

 

 

 

JTA和JTS

 

Java事务API(JTA:Java Transaction API)和它的同胞Java事务服务(JTS:Java Transaction Service),为J2EE平台提供了分布式事务服务(distributed transaction)。
一个分布式事务(distributed transaction)包括一个事务管理器(transaction manager)和一个或多个资源管理器(resource manager)。
一个资源管理器(resource manager)是任意类型的持久化数据存储。
事务管理器(transaction manager)承担着所有事务参与单元者的相互通讯的责任。

 

 

 

JTA与JDBC

 

JTA事务比JDBC事务更强大。一个JTA事务可以有多个参与者,而一个JDBC事务则被限定在一个单一的数据库连接。下列任一个Java平台的组件都可以参与到一个JTA事务中:JDBC连接、JDO PersistenceManager 对象、JMS 队列、JMS 主题、企业JavaBeans(EJB)、一个用J2EE Connector Architecture 规范编译的资源分配器。

 

 

 

JOTM
JOTM (Java Open Transaction Manager)是一个开源独立的事务管理器,支持分布式事务,Spring3.X已经不再支持JOTM。

 

 

 

Atomikos
Atomikos TransactionsEssentials是一个为Java平台提供增值服务的并且开源类事务管理器,支持分布式事务,本文所采用的技术。

 

Atomikos是目前在分布式事务管理中做得相当不错的开源软件。有10年以上的经验,Atomikos保障您的关键事务和防止昂贵的数据丢失在发生系统故障或事故中.Atomikos支持XA(全局事务)和NON-XA(非全局事务),NON-XA效率高于XA。本文主要是讲XA事件,因为要在不同的数据库中操作多张表。

 

接下来说一下Spring.x+Hibernate中集成Atomikos构建JTA的分布式事务

 

二、准备

 

 

Atomikos TransactionsEssentials 是一个为Java平台提供增值服务的并且开源类事务管理器,官方地址:http://www.atomikos.com/,使用最新版本3.9.3,下载以下jar包:

atomikos-util-3.9.3.jar

transactions-3.9.3.jar

transactions-api-3.9.3.jar

transactions-hibernate3-3.9.3.jar

transactions-jdbc-3.9.3.jar

transactions-jms-3.9.3.jar

transactions-jta-3.9.3.jar

官方地址经常打不开,需要国外vpn访问。可以通过maven地址进行下载。

 

       SSH框架版本为,struts2的版本为2.3.20,spring的版本为3.0.6,Hibernate的版本为 3.6.8.Final

 

三、配置

 

3.1 spring的配置如下:

 

<!-- mysql数据源 -->
	<bean id="mysqlDataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean"
		init-method="init" destroy-method="close">
			<property name="uniqueResourceName" value="mysqlWebXADBMS" />
			<property name="xaDataSourceClassName"
				value="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" />
			<property name="xaProperties">
				<props>
					<prop key="user">${jdbc.username.mysql}</prop>
					<prop key="password">${jdbc.password.mysql}</prop>
					<prop key="URL">${jdbc.url.mysql}</prop>
					<prop key="pinGlobalTxToPhysicalConnection">true</prop>
					<prop key="autoReconnect">true</prop>
					
				</props>
			</property>
			<property name="poolSize" value="${pool.initialPoolSize}" />
			<property name="minPoolSize" value="${pool.minPoolSize}" />
			<property name="maxPoolSize" value="${pool.maxPoolSize}" />
			<property name="maxIdleTime" value="${pool.maxIdleTime}" />
			
			<property name="testQuery" value="select 1" />
	</bean>

<!-- oracle数据源 -->
	<bean id="oracleDataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean"
		init-method="init" destroy-method="close">
			<property name="uniqueResourceName" value="oracleWebXADBMS" />
			<property name="xaDataSourceClassName" value="oracle.jdbc.xa.client.OracleXADataSource" />
			<property name="xaProperties">
				<props>
					<prop key="user">${jdbc.username}</prop>
					<prop key="password">${jdbc.password}</prop>
					<prop key="URL">${jdbc.url}</prop>
				</props>
			</property>
			<property name="poolSize" value="${pool.initialPoolSize}" />
			<property name="minPoolSize" value="${pool.minPoolSize}" />
			<property name="maxPoolSize" value="${pool.maxPoolSize}" />
			<property name="maxIdleTime" value="${pool.maxIdleTime}" />
			
			<property name="testQuery" value="select 1 from dual" />
	</bean>


<!-- 对应的oracleSessionFactory配置(Hibernate的): -->
	<bean id="oracleSessionFactory"
		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		
		<!---采用注解扫描实体 -->
		<property name="packagesToScan" value="org.gjwu.web.entity" />
		<property name="dataSource" ref="oracleDataSource" />
		
		<property name="namingStrategy">
			<bean class="org.hibernate.cfg.ImprovedNamingStrategy" />
		</property>
		<property name="jtaTransactionManager" ref="atomikosTransactionManager" />

		<!--hibernate 配置属性,可以参考Hibernate帮助文档这里只罗列和jta相关的配置 -->
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
				<prop key="hibernate.current_session_context_class">jta</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.format_sql">false</prop>
				<prop key="hibernate.cache.use_query_cache">false</prop>
				<prop key="hibernate.cache.use_second_level_cache">false</prop>
				<prop key="hibernate.transaction.factory_class">
					com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory
				</prop>
				<prop key="hibernate.transcation.manager_lookup_class">
					com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup
				</prop>
<!-- 				<prop key="hibernate.connection.release_mode">after_statement</prop> -->

			</props>
		</property>
	</bean>
	
<!-- 对应的mysqlSessionFactory配置(Hibernate的): -->
	<bean id="mysqlSessionFactory"
		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<!---采用注解扫描实体 -->
		<property name="packagesToScan" value="org.gjwu.web.mysql.entity" />
		<property name="dataSource" ref="mysqlDataSource" />
		
		<property name="namingStrategy">
			<bean class="org.hibernate.cfg.ImprovedNamingStrategy" />
		</property>
		<property name="jtaTransactionManager" ref="atomikosTransactionManager" />

		<!--hibernate 配置属性,可以参考Hibernate帮助文档这里只罗列和jta相关的配置 -->
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
				<prop key="hibernate.current_session_context_class">jta</prop>
				<prop key="hibernate.transaction.factory_class">
					com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory
				</prop>
				<prop key="hibernate.transcation.manager_lookup_class">
					com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup
				</prop>
<!-- 				<prop key="hibernate.connection.release_mode">after_statement</prop> -->

			</props>
		</property>
	</bean>
	
<!-- 定义 oracleHibernateTemplate 用于注入到对应dao -->
	<bean id="oracleHibernateTemplate"
        class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="alwaysUseNewSession" value="false"></property>
        <property name="sessionFactory" ref="oracleSessionFactory"></property>
    </bean>

<!-- 定义 mysqlHibernateTemplate 用于注入到对应dao -->    
    <bean id="mysqlHibernateTemplate"
        class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="alwaysUseNewSession" value="false"></property>
        <property name="sessionFactory" ref="mysqlSessionFactory"></property>
    </bean>
    
	
<!--进行jta的配置 -->
	<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
		init-method="init" destroy-method="close">
		<property name="forceShutdown">
			<value>true</value>
		</property>
	</bean>

	<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
		<property name="transactionTimeout" value="240" />
	</bean>

	<bean id="transactionManager"
		class="org.springframework.transaction.jta.JtaTransactionManager">
		<property name="transactionManager" ref="atomikosTransactionManager" />
		<property name="userTransaction" ref="atomikosUserTransaction" />
		<property name="allowCustomIsolationLevels" value="true" />
	</bean>
	
        
	<context:annotation-config />
	<tx:annotation-driven proxy-target-class="true" transaction-manager="transactionManager" />
    <context:component-scan base-package="org.gjwu.web" />

 

3.2 新增Atomikos配置文件:transactions.properties,放入到src目录下

# SAMPLE PROPERTIES FILE FOR THE TRANSACTION SERVICE

    # THIS FILE ILLUSTRATES THE DIFFERENT SETTINGS FOR THE TRANSACTION MANAGER

    # UNCOMMENT THE ASSIGNMENTS TO OVERRIDE DEFAULT VALUES;

    # Required: factory implementation class of the transaction core.

    # NOTE: there is no default for this, so it MUST be specified!

    #

    com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory

    # Set base name of file where messages are output

    # \uFF08also known as the 'console file'\uFF09\u3002

    #

    # com.atomikos.icatch.console_file_name = tm.out

    # Size limit \uFF08in bytes\uFF09 for the console file;

    # negative means unlimited.

    #

    # com.atomikos.icatch.console_file_limit=-1

    # For size-limited console files, this option

    # specifies a number of rotating files to

    # maintain.

    #

    # com.atomikos.icatch.console_file_count=1

    # Set the number of log writes between checkpoints

    #

    # com.atomikos.icatch.checkpoint_interval=500

    # Set output directory where console file and other files are to be put

    # make sure this directory exists!

    #

    com.atomikos.icatch.output_dir = ${app.path.log}

    # Set directory of log files; make sure this directory exists!

    #

    com.atomikos.icatch.log_base_dir = ${app.path.log}

    # Set base name of log file

    # this name will be  used as the first part of

    # the system-generated log file name

    #

    #com.atomikos.icatch.log_base_name = tmlog

    # Set the max number of active local transactions

    # or -1 for unlimited.

    #

    # com.atomikos.icatch.max_actives = 50

    # Set the default timeout \uFF08in milliseconds\uFF09 for local transactions

    #

    # com.atomikos.icatch.default_jta_timeout = 10000

    # Set the max timeout \uFF08in milliseconds\uFF09 for local transactions

    #

    # com.atomikos.icatch.max_timeout = 300000

    # The globally unique name of this transaction manager process

    # override this value with a globally unique name

    #

    # com.atomikos.icatch.tm_unique_name = tm

    # Do we want to use parallel subtransactions? JTA's default

    # is NO for J2EE compatibility

    #

    # com.atomikos.icatch.serial_jta_transactions=true

    # If you want to do explicit resource registration then

    # you need to set this value to false.

    #

    # com.atomikos.icatch.automatic_resource_registration=true

    # Set this to WARN, INFO or DEBUG to control the granularity

    # of output to the console file.

    #

     com.atomikos.icatch.console_log_level=WARN

    # Do you want transaction logging to be enabled or not?

    # If set to false, then no logging overhead will be done

    # at the risk of losing data after restart or crash.

    #

    com.atomikos.icatch.enable_logging=false

    # Should two-phase commit be done in \uFF08multi-\uFF09threaded mode or not?

    # Set this to false if you want commits to be ordered according

    # to the order in which resources are added to the transaction.

    #

    # NOTE: threads are reused on JDK 1.5 or higher.

    # For JDK 1.4, thread reuse is enabled as soon as the

    # concurrent backport is in the classpath - see

    # http://mirrors.ibiblio.org/pub/mirrors/maven2/backport-util-concurrent/backport-util-concurrent/

    #

    # com.atomikos.icatch.threaded_2pc=false

    # Should shutdown of the VM trigger shutdown of the transaction core too?

    #

    # com.atomikos.icatch.force_shutdown_on_vm_exit=false

 

 

主要修改这四项:

com.atomikos.icatch.output_dir = ${app.path.log}
com.atomikos.icatch.log_base_dir = ${app.path.log}
com.atomikos.icatch.console_log_level=WARN
com.atomikos.icatch.enable_logging=false

 

3.3为dao层注入hibernateTemplate

即可使用

 

 

四、遇到的问题

4.1 启动的时候报没设置hibernateTemplate或者SessionFactory

原因:没有注入HibernateTemplate模板

 4.2 启动成功后经常有以下异常:
com.atomikos.datasource.ResourceException: XA resource 'mysqlMessage2XADBMS': resume for XID '3231382E36382E3235302E3132302E746D32313734343030323732:3231382E36382E3235302E3132302E746D3533383839' raised -5: invalid arguments were given for the XA operation

这个mysql的XA的bug,需要在数据源中设置

<prop key="pinGlobalTxToPhysicalConnection">true</prop>
<prop key="autoReconnect">true</prop>

 

4.3 同一台机子或代码启动多个应用程序失败

需要在Atomikos的配置文件中transactions.properties

com.atomikos.icatch.enable_logging=false

进行禁用

 

 

SSM框架整合实战:SpringMVC4+MyBatis全栈开发指南 SSM框架整合是Java企业级开发中的核心技术组合,通过SpringMVC处理Web层逻辑、MyBatis实现数据持久化,构建高可维护性的分层架构。该技术栈采用控制反转和ORM映射原理,显著提升开发效率和系统性能,特别适合电商、ERP等需要快速迭代的中大型项目。结合Bootstrap和HTML5可实现响应式前端,而Maven的多环境配置支持DevOps持续集成。实战中需重点解决MyBatis批量操作优化、分布式事务管理等典型问题,通过二级缓存和SQL监控可进一步提升系统吞吐量。 阅读详情

相关推荐

【信息科学与工程学】【数据中心】第三十五篇 云计算数据中心的学科知识04

编号学科(课程)核心知识点在云计算/云存储/云网络/云安全/云MaaS中的作用代表教材/资料/论文 + 数学方程式列表工业界应用D1421​云原生数据库:TiDB​HTAP(混合事务/分析处理)、分布式SQL、水平扩展、强一致(Raft)、自动故障恢复、与MySQL兼容、TiFlash列式引擎提供弹性扩展的分布式数据库;支撑高并发在线交易与实时分析教材:《TiDB in Action》PingCAP(2020) 论文:《TiDB: A Raft-based HTAP Database》(2017)

weixin_49199313的博客 399

分布式事务管理Atomikos

Atomikos是一个非常流行的开源事务管理器,并且可以嵌入到你的Spring Boot应用中。Tomcat应用服务器没有实现JTA规范,当使用Tomcat作为应用服务器的时候,需要使用第三方的事务管理器类来作为全局的事务管理器,而Atomikos框架就是这个作用,将事务管理整合到应用中,而不依赖于application server。

zhangm2020的博客 5385

SSH + atomikos 打造Java分布式事务

SSH + atomikos 打造Java分布式事务 web工程 直接导入myeclipse即可运行 数据库可参照mutilDataSource/model下的实体类进行创建(两个表)数据库使用的是oracle

atomikos 使用说明

atomikos使用说明 作用:atomikos使用两阶段事务操作,常用来对单机多数据源进行事务管理 ********************************** 引入jar包 <dependency> <groupId>org.springframework.boot</groupId> <artif...

weixin_43931625的博客 3341

Atomikos3.9官方包文档以及实例

Atomikos TransactionsEssentials 是一个为Java平台提供增值服务的并且开源类事务管理器,以下是包括在这个开源版本中的一些功能: l 全面崩溃 / 重启恢复 l 兼容标准的SUN公司JTA API l 嵌套事务 l 为XA和非XA提供内置的JDBC适配器 注释:XA:XA协议由Tuxedo首先提出的,并交给X/Open组织,作为资源管理器(数据库)与事务管理器的接口标准。目前,Oracle、Informix、DB2和Sybase等各大数据库厂家都提供对XA的支持。XA协议采用两阶段提交方式来管理分布式事务。XA接口提供资源管理器与事务管理器之间进行通信的标准接口。XA协议包括两套函数,以xa_开头的及以ax_开头的。 以下的函数使事务管理器可以对资源管理器进行的操作: 1)xa_open,xa_close:建立和关闭与资源管理器的连接。 2)xa_start,xa_end:开始和结束一个本地事务。 3)xa_prepare,xa_commit,xa_rollback:预提交、提交和回滚一个本地事务。 4)xa_recover:回滚一个已进行预提交的事务。 5)ax_开头的函数使资源管理器可以动态地在事务管理器中进行注册,并可以对XID(TRANSACTION IDS)进行操作。 6)ax_reg,ax_unreg;允许一个资源管理器在一个TMS(TRANSACTION MANAGER SERVER)中动态注册或撤消注册。 l 内置的JMS适配器XA-capable JMS队列连接器 注释:JMS:jms即Java消息服务(Java Message Service)应用程序接口是一个Java平台中关于面向消息中间件(MOM)的API,用于在两个应用程序之间,或分布式系统中发送消息,进行异步通信。Java消息服务是一个与具体平台无关的API,绝大多数MOM提供商都对JMS提供支持。 l 通过XA API兼容第三方适配器 l 更好的整合您的项目 l 集成Hibernate 如何使用Atomikos TransactionsEssentials Atomikos TransactionsEssentials 是一个可靠的库,可以加入到您的Java应用程序,也就是说为了使用这个产品,您必须添加一些jar文件(包括在dist和lib文件夹下)到您的应用程序或者应用程序服务器。 请注意:Atomikos TransactionsEssentials是一个非常快速的嵌入式事务管理器,这就意味着,您不需要另外启动一个单独的事务管理器进程(不要查找任何的bin文件夹)。相反,您的应用服务器将有它自己的intra-VM事务管理器。 配置需求:至少Java1.5 jdk,并且最少128M的内存 性能优化:尽管这个软件有着很大的优势,但是想要更好的发挥其作用,可以按以下的方法优化: l 更高的内存,意味着更高的吞吐量(每秒的事务数目) l 使连接池尽可能的大 l 一旦你不需要的连接请马上关闭它们。不要把你的应用程序放在缓存里,让内部连接池为你做这些,这将促使更高效的连接使用 l 不要让活动的事务闲置:终止所有情况下的事务,尤其是在异常报错情况下的事务。这将减少数据库的锁定时间,并且最大效率的处理启用的使用。 如果想获取这些细节的更多信息,也要参阅文档说明部分。 值得注意的是,在我们所有的压力测试中,Atomikos TransactionsEssentials比J2EE的web容器更高效的吞吐量。这些测量值包括日志记录的高效的事务状态,同样,在我们所有的测量中,包括XA和non-XA,高效的效率是一样的。 在J2SE中使用Atomikos Transactions Essentials,只需要按以下步骤 将idst和lib中的jar包全部放入的项目中 创建或者自定义你应用的transactions.properties(或者jta.properties)文件(事务管理器的配置),然后将它放入到classpath中,安装文件夹中包涵一个实例文件;在properties文件中注释(#)后面的是默认值,取消一行并且改变默认值。

别再只会调速度了!用STM32的定时器中断精准控制伺服电机转角(避坑指南)

本文详细介绍了如何利用STM32的定时器中断和PWM输出实现伺服电机的精准转角控制,避免常见的速度控制误区。通过硬件配置、脉冲计数逻辑和优化技巧的实战讲解,帮助开发者掌握高精度位置控制方法,适用于工业自动化和机器人控制等场景。

weixin_42531163的博客 414

【SpringBoot框架篇】4.集成jta-atomikos实现分布式事务

springboot集成jta-atomikos实现分布式事务简介引入依赖修改配置文件添加配置读取类创建多数据源,管理事务数据持久化数据库DLL文件模拟事务回滚 简介 1.分布式事务 说到分布式事务,可以理解为,由于分布式而引起的事务不一致的问题。随着项目做大,模块拆分,数据库拆分。一次包含增删改操作数据库涉及到了更新两个不同物理节点的数据库,这样的数据库事务只能保证自己处理的部分的事务,但是整个...

皓亮君的博客 6126

从厘米级到公里级:北斗网格10级精度在ArcPro中的完整应用指南

本文提供了北斗网格十级精度体系在ArcGIS Pro中的完整应用指南。详细解析了从660公里到1.5厘米的十级网格尺度及其编码逻辑,并重点演示了如何在ArcPro中生成网格、计算编码,以及根据项目需求(如滑坡监测)选择合适精度层级的实战策略。指南旨在帮助GIS专业人士利用这套统一的网格框架,高效管理多尺度空间数据并优化分析工作流。

Black的专栏 471

分布式事务解决方案之Atomikos

12Atomikos是一款Java/JTA事务处理工具,在SpringBoot的官网文档的分布式事务处理中Atomikos作为一种分布式事务的解决方案.文档地址: https://docs.spring.io/spring-boot/docs/2.1.18.RELEASE/reference/html/boot-features-jta.html123456789101112131415。

tiantiantbtb的博客 682

基于立创EDA的IP5389BZ+IP6829 100W有线15W无线带屏充电宝DIY全流程解析

本文详细解析了基于立创EDA平台,采用IP5389BZ和IP6829芯片DIY一款100W有线快充、15W无线充电并带显示屏的移动电源的全过程。内容涵盖核心功能规划、硬件选型、电路设计、PCB布局、焊接组装、分步调试以及软件逻辑,为电子爱好者提供了一份从原理到实践的完整指南,并重点强调了电池安全与IP6829供电电压等关键注意事项。

weixin_34374684的博客 306

【FDTD运行引擎错误解决方法】

我用的是2024R1版的FDTD,第一次安装好的时候点“RUN”可以正常运行,后来不知道什么问题就无法运行了。我从网上找相关的解决办法,并未找到,将软件卸载重装,重启等方法都没有解决,后来在官网按照提示解决了,我把官网提供的方式和我的情况相结合,提供一个解决方式。提示:以下是本篇文章正文内容,下面案例可供参考最后说一下两个MPI和Local computer(不使用MPI)的区别使用MPI进行仿真可以显著提高计算速度和效率,特别是对于大规模和复杂的仿真任务,但需要额外的设置和配置。(多线程并行计算)

m0_57410975的博客 8171

linux ssh 试题,SSH面试题,ssh试题

SSH面试题,ssh试题一、SSH框架SSH作为struts2+spring+hibernate的一个集成框架,是目前较流行的一种Web应用程序开源框架。集成SSH框架的系统从职责上分为四层:表示层、业务逻辑层、数据持久层和域模块层,帮助开发人员在短期内搭建Web应用程序。其中使用Struts作为系统的整体基础架构,负责MVC的分离,控制业务跳转,利用Hibernate框架对持久层提供支持,Spr...

weixin_36268255的博客 451

让 ABAP 开发更聪明的搭档:SAP Joule for Developers 与 ABAP AI Capabilities 全面实战

摘要:SAP已将生成式AI集成到ABAP开发工具中,推出Joule for Developers功能。该功能直接嵌入Eclipse开发环境,提供代码解释、生成、测试构造和遗留代码迁移等辅助功能。Joule支持ABAP Cloud项目开发,能围绕当前开发对象提供上下文相关的建议,帮助开发者高效完成应用开发与迁移任务。启用该功能需升级ADT并获取相应许可,典型应用场景包括RAP应用构建和S/4HANA迁移中的代码重构。官方资源提供了多个实践案例,帮助开发者快速上手这一AI辅助开发功能。(149字)

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 489

使用atomikos在spring3、jpa2/hibernate4中实现JTA

公司使用ssh框架,近期因为项目使用到多数据源,web服务器为tomcat,为了数据的一致性,需要使用jta。在spring中使用jta现有两个主要的开源项目:jotm、atomikos。spring3中己移除了对jotm支持,所以只能使用atomikos,按照网上资料学习,将实践过程记录下来,以备参考。1、atomikos需要的jar transactions-3.9.0.M1.jar ...

曾文锋开发日志 380

【数字孪生与仿真技术】05:从原理到实战:MATLAB/Simulink在航空航天GNC系统开发中的深度解析(含全流程代码与认证指南)

摘要:本文系统阐述MATLAB/Simulink在航空航天制导、导航与控制(GNC)系统开发中的核心应用。通过解析GNC系统高保真动力学建模、多源导航传感器融合、鲁棒控制算法设计等关键技术原理,结合Virgin Orbit运载火箭、CubeSat等真实案例,展示从需求分析、模型搭建、仿真验证到代码生成与认证的完整开发流程。文中提供1200余行关键代码、8个可复用Simulink模型及详细执行结果展示,涵盖DO-178C认证支持、实时性能优化等工业级开发规范,为航空航天工程师、科研人员提供可落地的参考方案。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 1656

【Unity】NGUI下载与导入

Unity3D插件NGUI的下载和导入。

Get your hands dirty 3万+

SSH面试题

一、SSH框架 SSH作为struts2+spring+hibernate的一个集成框架,是目前较流行的一种Web应用程序开源框架。 集成SSH框架的系统从职责上分为四层:表示层、业务逻辑层、数据持久层和域模块层,帮助开发人员在短期内搭建Web应用程序。其中使用Struts作为系统的整体基础架构,负责MVC的分离,控制业务跳转,利用Hibernate框架对持久层提供支持,Spring做管理,管...

weixin_30699443的博客 63

华为非AI方向0603笔试真题-爆破小游戏(详细思路+多语言题解)

华为非AI方向0603笔试第二题【爆破小游戏】,提供详细思路讲解以及代码实现。

qq_45776114的博客 358

Sping +hibernate+JTA 注解配置

    随着业务的不断扩展数据库的压力越来越大,为了减少数据库的压力我们要从多方面考虑分析,并提出多个解决数据库压力大的问题,比如说根据业务分表、分库、增加缓存机制等等。如果是分库,如何做分布式呢?我就做分布式的库来讨论一下如何使用jta事务。     什么是jta网上有很多很详细的解释,我不在这里介绍。为了开发效率现在的传统行业的大部分中小企业还是采用SSH架构,那我们就从SSH+JTA的架...

开发小兵 296

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

tomcat + jta + spring (3)

最近因为业务需要,因为客票系统的数据量非常之大,需要对数据进行分散部署,而且数据库分布在不同城市,对于单数据库的操作来说事物很简单就可以处理好,但是对于多数据库来说,如何保持数据的一致性,则需要分布式事物处理。 所谓分布式事务,就是数据源不止一个,可能有两个或更多,在一些大型应用中常常出现,常用的解决办法就是使用JTA,但是如果使用tomcat(用其他容器也一样可以使用此方式操作,当然直接使

自由自在的生活! 905

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

Cannot unwrap to requested type [javax.sql.DataSource]

这个错误找了一些文章说的不太全,弄了好久,记录一下在搭建SSH框架时遇到这个问题,我把DataSource的配置内容放到hibernate.cfg.xml里,开始没有定义Hibernate的事务管理器HibernateTransactionManager时,没有什么问题,但是在applicationContext.xml中一定义HibernateTransactionManager,就报上面这个错误

whxwkb的博客 356

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

eclipse + tomcat 开发问题

对eclipse中tomcat做clean时报: [color=red]resource is out of sync with the file system[/color] 原因、解决方法: 这是文件系统不同步的问题,是因为在eclipse之外对工程中的resource进行修改引起的;但是,有时没有在eclipse之外进行修改,也会报类似的错误。 解决办法:需要手动刷新一下资源管理器。...

Wuaner的博客 328

Corosync 和pacemaker实现高可用性群集

Corosync 和pacemaker实现高可用性群集 简介:Corosync是实现高可用性群集的一款软件,它的前身是openais ,openais是一个研究高可用性群集的项目,后来项目停止。Corosync能够满足高可用性群集架构的第一 第二 第四层,第一层是message layer心跳探测,corosync 的心跳检测端口是与用户相连的接口,没有心跳线,第二层是 ...

weixin_33788244的博客 145

SSH Write operations are not allowed in read-only mode 错误解决--OpenSessionInViewFilter配置

最近在配置 Structs, Spring 和Hibernate整合的问题: 开启OpenSessionInViewFilter来阻止延迟加载的错误的时候抛出了这个异常:     org.springframework.dao.InvalidDataAccessApiUsageException错误 但是在我们开启OpenSessionInViewFilter这个过滤器的时候FlushMod

朕是白白编码小王子 668

工作中使用到的单词(软件开发)_第四版

本文汇总了2020-2025年间软件开发相关的工作笔记,主要包括三版技术词汇整理(2020-2025)、优快云文章导出PDF情况,以及2025年6月的专题整理。重点内容涉及:WebSphere中jackson包加载路径问题、Java异步线程类型(守护/非守护线程)的区分与解决方案、DB2数据库连接相关指令(db2listapplications等)、AWS托管服务优势,以及OSGi框架与Java的关系说明。特别标注了技术术语的英文发音(如initiative)和敏感信息处理注意事项(敏感度标签设置)。后续

sun0322 1344
上一篇: Spring+Hibernate实现动态SessionFactory切换(改进版)
danwind
博客等级 码龄19年 6粉丝 118原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值