`
xkorey
  • 浏览: 154567 次
  • 性别: Icon_minigender_1
  • 来自: 石家庄
社区版块
存档分类
最新评论

spring3+hibernate4+maven+junit 多库/多数据源实现

阅读更多
1.核心思想:
思路 写道
通过spring对多数据源的管理,在dao中动态的指定相对应的datasource。

2.动态指定数据源的方法约定:
约定 写道
不同库的dao放到对应的包下例:Master库中的dao的包路径是com.***.db.master.*。slave库的dao包的路径应是com.***.db.slave.***。

判定数据原方法 写道
判定dao类的路径是否包含master或者slave从而加载对应的数据源

3.实现代码
private void fixSession(){
	String name=this.getClass().getName();
	/**
	 * 如果是master 包下的dao 全部指定为 masterSessionFactory
	 */
	if(name.indexOf("com.xkorey.db.master")>-1){
	    sessionFactory = masterSessionFactory;
	}
	/**
	 * 默认的dao是 slaveSessionFactory 下的库
	 */
	else{
	    sessionFactory =  slaveSessionFactory;
	}
    }

4.这样实现的缺点,暂时还未想到。欢迎网友补充。
缺陷 写道
未知

5.开始贴代码,附件(hsm.zip)是eclipse下的项目工程包。
6.建库、表sql
--create database

-- master database
create database master character set `gbk` collate `gbk_chinese_ci`;
-- slave database
create database slave character set `gbk` collate `gbk_chinese_ci`;


-- create tables 
use master;
create table users(
id int not null auto_increment,
name varchar(20),
age int,
primary key(id)) ENGINE = INNODB,AUTO_INCREMENT=1000;

use slave;
create table user_info(
id int not null auto_increment,
uid int,
info varchar(20),
primary key(id)) ENGINE = INNODB,AUTO_INCREMENT=1000;


--insert data

use master;
insert into users(name,age) values('xkorey',28);
use slave;
insert into user_info(uid,info) values(1000,'hello xkorey.');


7.maven jar包依赖 pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>hsm</groupId>
  <artifactId>hsm</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>hsm Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    
    	<!-- spring  -->
    <dependency>
	 	<groupId>org.springframework</groupId>
	 	<artifactId>spring-context</artifactId>
	 	<version>3.2.3.RELEASE</version>
	</dependency> 
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-context-support</artifactId>
		<version>3.2.3.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-orm</artifactId>
		<version>3.2.3.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-webmvc</artifactId>
		<version>3.2.3.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-web</artifactId>
		<version>3.2.3.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>org.springframework.security</groupId>
		<artifactId>spring-security-core</artifactId>
		<version>3.1.4.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-tx</artifactId>
		<version>3.2.3.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-test</artifactId>
		<version>3.2.1.RELEASE</version>
	</dependency>	
	<dependency>
		<groupId>org.aspectj</groupId>
		<artifactId>aspectjweaver</artifactId>
		<version>1.7.2</version>
	</dependency>
            
	            
            
            
	
	<!-- hibernate -->
	<dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate-core</artifactId>
	<version>4.2.2.Final</version>
	</dependency>
	<dependency>
		<groupId>org.hibernate</groupId>
		<artifactId>hibernate-validator</artifactId>
		<version>4.2.0.Final</version>
	</dependency>
	            
            
	            
	            
	            
	
	<!-- mysql -->
	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<version>5.1.25</version>
	</dependency>
    
    
  </dependencies>
  <build>
    <finalName>hsm</finalName>
  </build>
</project>



8.spring配置文件
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       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.2.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
       ">
       
	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
	        <property name="locations">
	            <list>
	                <value>classpath:hsm-db-master.properties</value>
	                <value>classpath:hsm-db-slave.properties</value>
	            </list>
	        </property>
	</bean>
	
	<context:annotation-config />
	
	<context:component-scan base-package="com.xkorey.db" />
	
    <import resource="db-master.xml" /> 
    <import resource="db-slave.xml" />
    
    
    </beans>


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       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.2.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
       ">
       
    <!-- Hibernate Data Source -->
    <bean id="masterDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName"><value>${connection.master.driver_class}</value></property>
        <property name="url"><value>${connection.master.url}</value></property>
        <property name="username"><value>${connection.master.username}</value></property>
        <property name="password"><value>${connection.master.password}</value></property>
    </bean>    
     <!-- Hibernate Session Factory -->
    <bean id="masterSessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource"><ref local="masterDataSource"/></property>
        <property name="packagesToScan" value="com.xkorey.db.master" />
        <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.master.dialect}</prop>
            <prop key="hibernate.show_sql">true</prop>
        </props>
        </property>
    </bean> 
    <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) HibernateTransactionManager -->
    <tx:annotation-driven transaction-manager="masterTransactionManager"/>
    <bean id="masterTransactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory"><ref local="masterSessionFactory"/></property>
    </bean> 
</beans>


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       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.2.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
       ">

    <!-- Hibernate Data Source -->
    <bean id="slaveDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName"><value>${connection.slave.driver_class}</value></property>
        <property name="url"><value>${connection.slave.url}</value></property>
        <property name="username"><value>${connection.slave.username}</value></property>
        <property name="password"><value>${connection.slave.password}</value></property>
    </bean>    
     <!-- Hibernate Session Factory -->
    <bean id="slaveSessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource"><ref local="slaveDataSource"/></property>
        <property name="packagesToScan" value="com.xkorey.db.slave" />
        <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.slave.dialect}</prop>
            <prop key="hibernate.show_sql">true</prop>
        </props>
        </property>
    </bean> 
    <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) HibernateTransactionManager -->
    <tx:annotation-driven transaction-manager="slaveTransactionManager"/>
    <bean id="slaveTransactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory"><ref local="slaveSessionFactory"/></property>
    </bean>
</beans>


9.properties 配置文件
hibernate.master.dialect=org.hibernate.dialect.MySQLInnoDBDialect


connection.master.driver_class=com.mysql.jdbc.Driver
connection.master.url=jdbc:mysql://localhost:3306/master?useUnicode=true&amp;characterEncoding=gbk
connection.master.username=root
connection.master.password=这里是你连库的密码


hibernate.slave.dialect=org.hibernate.dialect.MySQLInnoDBDialect


connection.slave.driver_class=com.mysql.jdbc.Driver
connection.slave.url=jdbc:mysql://localhost:3306/slave?useUnicode=true&amp;characterEncoding=gbk
connection.slave.username=root
connection.slave.password=这里是你连库的密码


10.java 代码 略去 java bean 即spring中的model代码只贴 dao 。

父类dao
public class GenericDao<T extends java.io.Serializable> {

    	
    @Autowired
    @Qualifier("masterSessionFactory")
    private SessionFactory masterSessionFactory;
    
    
    @Autowired
    @Qualifier("slaveSessionFactory")
    private SessionFactory slaveSessionFactory;
    
    
    private SessionFactory sessionFactory;
    
    
    private void fixSession(){
	String name=this.getClass().getName();
	/**
	 * 如果是master 包下的dao 全部指定为 masterSessionFactory
	 */
	if(name.indexOf("com.xkorey.db.master")>-1){
	    sessionFactory = masterSessionFactory;
	}
	/**
	 * 默认的dao是 slaveSessionFactory 下的库
	 */
	else{
	    sessionFactory =  slaveSessionFactory;
	}
    }
    
    public Session getSession() {
	fixSession();
        return sessionFactory.getCurrentSession();
    }


注意UsersDao的包路径是 package com.xkorey.db.master.dao;
@Repository("UsersDao")
public class UsersDao extends GenericDao<Users>{
//根据网友建议其实也可以在dao中直接注入 sessionFactory 像这样
//  @Autowired
//  @Qualifier("masterSessionFactory")
//  private SessionFactory sessionFactory;
}


注意UserinfoDao的包路径是 package com.xkorey.db.slave.dao;
@Repository("UserinfoDao")
public class UserinfoDao extends GenericDao<Userinfo>{
// 根据网友建议实也可以在dao中直接注入 sessionFactory 像这样
//    @Autowired
//    @Qualifier("slaveSessionFactory")
//    private SessionFactory sessionFactory;
}


@Service("UsersService")
@Transactional(value="masterTransactionManager")
public class UsersService {
    
    @Autowired
    @Qualifier("UsersDao")
    private UsersDao usersDao;
    
    public int findUserAgeById(int id){
	Users users = (Users) usersDao.getSession().get(Users.class,id);
	return users.age;
    }
}


@Service("UserinfoService")
@Transactional(value="slaveTransactionManager")
public class UserinfoService {

    @Autowired
    @Qualifier("UserinfoDao")
    private UserinfoDao userinfoDao;
    
    public String findUserInfoById(int id){
	Userinfo userinfo = (Userinfo) userinfoDao.getSession().get(Userinfo.class,id);
	return userinfo.info;
    }
}


11.junit 测试类

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:spring-base.xml"})
public class TestDao {

    
    @Autowired
    @Qualifier("UsersService")
    private UsersService usersService;
    
    @Autowired
    @Qualifier("UserinfoService")
    private UserinfoService userinfoService;
    
    
    @Test
    public void testMutilDataSource(){
	int id=1000;
	System.out.println(usersService.findUserAgeById(id));
	System.out.println(userinfoService.findUserInfoById(id));
    }
    

}


测试类运行结果:
Hibernate: select users0_.id as id1_0_0_, users0_.age as age2_0_0_, users0_.name as name3_0_0_ from users users0_ where users0_.id=?
28
Hibernate: select userinfo0_.id as id1_0_0_, userinfo0_.info as info2_0_0_, userinfo0_.uid as uid3_0_0_ from user_info userinfo0_ where userinfo0_.id=?
hello xkorey.


截图:


12.最后贴张工程截图



13.项目环境
jdk7,eclipse Version: Kepler Release.maven:apache-maven-3.0.4
  • 大小: 3.5 KB
  • 大小: 20 KB
  • hsm.zip (31.2 KB)
  • 下载次数: 344
1
3
分享到:
评论
5 楼 chenchunhuis 2015-06-10  
我们最近也在做这个事情,一楼的评论很有道理  
4 楼 mjs123 2015-03-11  
你好,我执行的时候 怎么老是报 No Session found for current thread 这个错误?
3 楼 youjianbo_han_87 2013-08-05  
追求技术 写道
你这是在提前已经知道了该使用哪个数据源的情况下使用多数据源,个人觉得完全没有必要再在代码里面通过class name来区别该使用哪个数据源。比如你把所有使用master数据源的dao都放到master包下面,既然你已经知道了某一dao是使用的master数据源,那么你完全可以在这个代码中直接注入一个master数据源对应的sessionFactory。

对的,对于读取的,全部从slave中读,插入和更新,都往主库里面操作。
2 楼 xkorey 2013-08-05  
追求技术 写道
你这是在提前已经知道了该使用哪个数据源的情况下使用多数据源,个人觉得完全没有必要再在代码里面通过class name来区别该使用哪个数据源。比如你把所有使用master数据源的dao都放到master包下面,既然你已经知道了某一dao是使用的master数据源,那么你完全可以在这个代码中直接注入一个master数据源对应的sessionFactory。

你说的有道理。这样做的话,那分包也就不用了。直接注入就可以了。
1 楼 追求技术 2013-08-05  
你这是在提前已经知道了该使用哪个数据源的情况下使用多数据源,个人觉得完全没有必要再在代码里面通过class name来区别该使用哪个数据源。比如你把所有使用master数据源的dao都放到master包下面,既然你已经知道了某一dao是使用的master数据源,那么你完全可以在这个代码中直接注入一个master数据源对应的sessionFactory。

相关推荐

    智能车竞赛介绍(竞赛目标和赛程安排).zip

    全国大学生智能汽车竞赛自2006年起,由教育部高等教育司委托高等学校自动化类教学指导委员会举办,旨在加强学生实践、创新能力和培养团队精神的一项创意性科技竞赛。该竞赛至今已成功举办多届,吸引了众多高校学生的积极参与,此文件为智能车竞赛介绍

    集字卡v4.3.4微信公众号原版三种UI+关键字卡控制+支持强制关注.zip

    字卡v4.3.4 原版 三种UI+关键字卡控制+支持获取用户信息+支持强制关注 集卡模块从一开始的版本到助力版本再到现在的新规则版本。 集卡模块难度主要在于 如何控制各种不同的字卡组合 被粉丝集齐的数量。 如果不控制那么一定会出现超过数量的粉丝集到指定的字卡组合,造成奖品不够的混乱,如果大奖价值高的话,超过数量的粉丝集到大奖后,就造成商家的活动费用超支了。我们冥思苦想如何才能限制集到指定字卡组合的粉丝数,后我们想到了和支付宝一样的选一张关键字卡来进行规则设置的方式来进行限制,根据奖品所需的关键字卡数,设定规则就可以控制每种奖品所需字卡组合被粉丝集到的数量,规则可以在活动进行中根据需要进行修改,活动规则灵活度高。新版的集卡规则,在此次政府发布号的活动中经受了考验,集到指定字卡组合的粉丝没有超出规则限制。有了这个规则限制后,您无需盯着活动,建好活动后就无人值守让活动进行就行了,您只需要时不时来看下蹭蹭上涨的活动数据即可。 被封? 无需担心,模块内置有防封功能,支持隐藏主域名,显示炮灰域名,保护活动安全进行。 活动准备? 只需要您有一个认证服务号即可,支持订阅号借用认证服务号来做活动。如果您

    出口设备线体程序详解:PLC通讯下的V90控制与开源FB284工艺对象实战指南,出口设备线体程序详解:PLC通讯与V90控制集成,工艺对象与FB284协同工作,开源学习V90控制技能,出口设备1200

    出口设备线体程序详解:PLC通讯下的V90控制与开源FB284工艺对象实战指南,出口设备线体程序详解:PLC通讯与V90控制集成,工艺对象与FB284协同工作,开源学习V90控制技能,出口设备1200线体程序,多个plc走通讯,内部有多个v90,采用工艺对象与fb284 共同控制,功能快全部开源,能快速学会v90的控制 ,出口设备; 1200线体程序; PLC通讯; 多个V90; 工艺对象; FB284; 功能开源; V90控制。,V90工艺控制:开源功能快,快速掌握1200线体程序与PLC通讯

    基于Arduino与DAC8031的心电信号模拟器资料:心电信号与正弦波的双重输出应用方案,Arduino与DAC8031心电信号模拟器:生成心电信号与正弦波输出功能详解,基于arduino +DAC

    基于Arduino与DAC8031的心电信号模拟器资料:心电信号与正弦波的双重输出应用方案,Arduino与DAC8031心电信号模拟器:生成心电信号与正弦波输出功能详解,基于arduino +DAC8031的心电信号模拟器资料,可输出心电信号,和正弦波 ,基于Arduino;DAC8031;心电信号模拟器;输出心电信号;正弦波输出;模拟器资料,基于Arduino与DAC8031的心电信号模拟器:输出心电与正弦波

    (参考项目)MATLAB口罩识别检测.zip

    MATLAB口罩检测的基本流程 图像采集:通过摄像头或其他图像采集设备获取包含面部的图像。 图像预处理:对采集到的图像进行灰度化、去噪、直方图均衡化等预处理操作,以提高图像质量,便于后续的人脸检测和口罩检测。 人脸检测:利用Haar特征、LBP特征等经典方法或深度学习模型(如MTCNN、FaceBoxes等)在预处理后的图像中定位人脸区域。 口罩检测:在检测到的人脸区域内,进一步分析是否佩戴口罩。这可以通过检测口罩的边缘、纹理等特征,或使用已经训练好的口罩检测模型来实现。 结果输出:将检测结果以可视化方式展示,如在图像上标注人脸和口罩区域,或输出文字提示是否佩戴口罩。

    kernel-debug-devel-3.10.0-1160.119.1.el7.x64-86.rpm.tar.gz

    1、文件内容:kernel-debug-devel-3.10.0-1160.119.1.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/kernel-debug-devel-3.10.0-1160.119.1.el7.tar.gz #Step2、进入解压后的目录,执行安装 sudo rpm -ivh *.rpm 4、更多资源/技术支持:公众号禅静编程坊

    day02供应链管理系统-补充.zip

    该文档提供了一个关于供应链管理系统开发的详细指南,重点介绍了项目安排、技术实现和框架搭建的相关内容。 文档分为以下几个关键部分: 项目安排:主要步骤包括搭建框架(1天),基础数据模块和权限管理(4天),以及应收应付和销售管理(5天)。 供应链概念:供应链系统的核心流程是通过采购商品放入仓库,并在销售时从仓库提取商品,涉及三个主要订单:采购订单、销售订单和调拨订单。 大数据的应用:介绍了数据挖掘、ETL(数据抽取)和BI(商业智能)在供应链管理中的应用。 技术实现:讲述了DAO(数据访问对象)的重用、服务层的重用、以及前端JS的继承机制、jQuery插件开发等技术细节。 系统框架搭建:包括Maven环境的配置、Web工程的创建、持久化类和映射文件的编写,以及Spring配置文件的实现。 DAO的需求和功能:供应链管理系统的各个模块都涉及分页查询、条件查询、删除、增加、修改操作等需求。 泛型的应用:通过示例说明了在Java语言中如何使用泛型来实现模块化和可扩展性。 文档非常技术导向,适合开发人员参考,用于构建供应链管理系统的架构和功能模块。

    基于四旋翼无人机的PD控制研究 附Matlab代码.rar

    1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。

    C#与VB实现欧姆龙PLC的Fins TCP通信案例源码:调用动态链接库进行数据读写,定时器与计数器数据区的简洁读写操作示例,C#与VB实现欧姆龙PLC的Fins TCP通信案例源码:调用动态链接库进

    C#与VB实现欧姆龙PLC的Fins TCP通信案例源码:调用动态链接库进行数据读写,定时器与计数器数据区的简洁读写操作示例,C#与VB实现欧姆龙PLC的Fins TCP通信案例源码:调用动态链接库进行读写操作,涵盖定时器计数器数据区学习案例,C#欧姆龙plc Fins Tcp通信案例上位机源码,有c#和VB的Demo,c#上位机和欧姆龙plc通讯案例源码,调用动态链接库,可以实现上位机的数据连接,可以简单实现D区W区定时器计数器等数据区的读写,是一个非常好的学习案例 ,C#; 欧姆龙PLC; Fins Tcp通信; 上位机源码; 动态链接库; 数据连接; D区W区读写; 定时器计数器; 学习案例,C#实现欧姆龙PLC Fins Tcp通信上位机源码,读写数据区高效学习案例

    可调谐石墨烯超材料吸收体的FDTD仿真模拟研究报告:吸收光谱的化学势调节策略与仿真源文件解析,可调谐石墨烯超材料吸收体:化学势调节光谱的FDTD仿真模拟研究,可调谐石墨烯超材料吸收体FDTD仿真模拟

    可调谐石墨烯超材料吸收体的FDTD仿真模拟研究报告:吸收光谱的化学势调节策略与仿真源文件解析,可调谐石墨烯超材料吸收体:化学势调节光谱的FDTD仿真模拟研究,可调谐石墨烯超材料吸收体FDTD仿真模拟 【案例内容】该案例提供了一种可调谐石墨烯超材料吸收体,其吸收光谱可以通过改变施加于石墨烯的化学势来进行调节。 【案例文件】仿真源文件 ,可调谐石墨烯超材料吸收体; FDTD仿真模拟; 化学势调节; 仿真源文件,石墨烯超材料吸收体:FDTD仿真调节吸收光谱案例解析

    RBF神经网络控制仿真-第二版

    RBF神经网络控制仿真-第二版

    松下PLC与威纶通触摸屏转盘设备控制:FPWINPRO7与EBPRO智能编程与宏指令应用,松下PLC与威纶通触摸屏转盘设备控制解决方案:FPWINPRO7与EBPRO协同工作,实现多工位转盘加工与IE

    松下PLC与威纶通触摸屏转盘设备控制:FPWINPRO7与EBPRO智能编程与宏指令应用,松下PLC与威纶通触摸屏转盘设备控制解决方案:FPWINPRO7与EBPRO协同工作,实现多工位转盘加工与IEC编程模式控制,松下PLC+威纶通触摸屏的转盘设备 松下PLC工程使用程序版本为FPWINPRO7 7.6.0.0版本 威纶通HMI工程使用程序版本为EBPRO 6.07.02.410S 1.多工位转盘加工控制。 2.国际标准IEC编程模式。 3.触摸屏宏指令应用控制。 ,松下PLC; 威纶通触摸屏; 转盘设备控制; 多工位加工控制; IEC编程模式; 触摸屏宏指令应用,松下PLC与威纶通HMI联控的转盘设备控制程序解析

    基于循环神经网络(RNN)的多输入单输出预测模型(适用于时间序列预测与回归分析,需Matlab 2021及以上版本),基于循环神经网络(RNN)的多输入单输出预测模型(matlab版本2021+),真

    基于循环神经网络(RNN)的多输入单输出预测模型(适用于时间序列预测与回归分析,需Matlab 2021及以上版本),基于循环神经网络(RNN)的多输入单输出预测模型(matlab版本2021+),真实值与预测值对比,多种评价指标与线性拟合展示。,RNN预测模型做多输入单输出预测模型,直接替数据就可以用。 程序语言是matlab,需求最低版本为2021及以上。 程序可以出真实值和预测值对比图,线性拟合图,可打印多种评价指标。 PS:以下效果图为测试数据的效果图,主要目的是为了显示程序运行可以出的结果图,具体预测效果以个人的具体数据为准。 2.由于每个人的数据都是独一无二的,因此无法做到可以任何人的数据直接替就可以得到自己满意的效果。 这段程序主要是一个基于循环神经网络(RNN)的预测模型。它的应用领域可以是时间序列预测、回归分析等。下面我将对程序的运行过程进行详细解释和分析。 首先,程序开始时清空环境变量、关闭图窗、清空变量和命令行。然后,通过xlsread函数导入数据,其中'数据的输入'和'数据的输出'是两个Excel文件的文件名。 接下来,程序对数据进行归一化处理。首先使用ma

    【图像识别】手写文字识别研究 附Matlab代码+运行结果.rar

    1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。

    旅游管理系统(基于springboot,mysql,java).zip

    旅游管理系统中的功能模块主要是实现管理员;首页、个人中心、用户管理、旅游方案管理、旅游购买管理、系统管理,用户;首页、个人中心、旅游方案管理、旅游购买管理、我的收藏管理。前台首页;首页、旅游方案、旅游资讯、个人中心、后台管理等功能。经过认真细致的研究,精心准备和规划,最后测试成功,系统可以正常使用。分析功能调整与旅游管理系统实现的实际需求相结合,讨论了Java开发旅游管理系统的使用。 从上面的描述中可以基本可以实现软件的功能: 1、开发实现旅游管理系统的整个系统程序;  2、管理员;首页、个人中心、用户管理、旅游方案管理、旅游购买管理、系统管理等。 3、用户:首页、个人中心、旅游方案管理、旅游购买管理、我的收藏管理。 4、前台首页:首页、旅游方案、旅游资讯、个人中心、后台管理等相应操作; 5、基础数据管理:实现系统基本信息的添加、修改及删除等操作,并且根据需求进行交流查看及回复相应操作。

    Boost二级升压光伏并网结构的Simulink建模与MPPT最大功率点追踪:基于功率反馈的扰动观察法调整电压方向研究,Boost二级升压光伏并网结构的Simulink建模与MPPT最大功率点追踪:基

    Boost二级升压光伏并网结构的Simulink建模与MPPT最大功率点追踪:基于功率反馈的扰动观察法调整电压方向研究,Boost二级升压光伏并网结构的Simulink建模与MPPT最大功率点追踪:基于功率反馈的扰动观察法调整电压方向研究,Boost二级升压光伏并网结构,Simulink建模,MPPT最大功率点追踪,扰动观察法采用功率反馈方式,若ΔP>0,说明电压调整的方向正确,可以继续按原方向进行“干扰”;若ΔP<0,说明电压调整的方向错误,需要对“干扰”的方向进行改变。 ,Boost升压;光伏并网结构;Simulink建模;MPPT最大功率点追踪;扰动观察法;功率反馈;电压调整方向。,光伏并网结构中Boost升压MPPT控制策略的Simulink建模与功率反馈扰动观察法

    基于matlab平台的图像去雾设计.zip

    运行GUI版本,可二开

    Deepseek相关参考资源文档

    Deepseek相关主题资源及行业影响

    WP Smush Pro3.16.12 一款专为 WordPress 网站设计的图像优化插件开心版.zip

    WP Smush Pro 是一款专为 WordPress 网站设计的图像优化插件。 一、主要作用 图像压缩 它能够在不影响图像质量的前提下,大幅度减小图像文件的大小。例如,对于一些高分辨率的产品图片或者风景照片,它可以通过先进的压缩算法,去除图像中多余的数据。通常 JPEG 格式的图像经过压缩后,文件大小可以减少 40% – 70% 左右。这对于网站性能优化非常关键,因为较小的图像文件可以加快网站的加载速度。 该插件支持多种图像格式的压缩,包括 JPEG、PNG 和 GIF。对于 PNG 图像,它可以在保留透明度等关键特性的同时,有效地减小文件尺寸。对于 GIF 图像,也能在一定程度上优化文件大小,减少动画 GIF 的加载时间。 懒加载 WP Smush Pro 实现了图像懒加载功能。懒加载是一种延迟加载图像的技术,当用户滚动页面到包含图像的位置时,图像才会加载。这样可以避免一次性加载大量图像,尤其是在页面内容较多且包含许多图像的情况下。例如,在一个新闻网站的长文章页面,带有大量配图,懒加载可以让用户在浏览文章开头部分时,不需要等待所有图片加载,从而提高页面的初始加载速度,同时也能

    1. Download this file: https://cdn-media.huggingface.co/frpc-gradio-0.3/frpc-windows-amd64.exe

    Could not create share link. Missing file: C:\Users\xx\.conda\envs\omni\Lib\site-packages\gradio\frpc_windows_amd64_v0.3 1. Download this file: https://cdn-media.huggingface.co/frpc-gradio-0.3/frpc_windows_amd64.exe 2. Rename the downloaded file to: frpc_windows_amd64_v0.3 3. Move the file to this location: C:\Users\xx\.conda\envs\omni\Lib\site-packages\gradio

Global site tag (gtag.js) - Google Analytics