mybatis重复扫描package的问题

    今天修改了一些东西后,发现web项目启动不了了。日志中出现504组如下的日志,都是mybatis打印的,扫描jar,解析dao,mapping文件等信息。费了半天劲,也没有找到问题。因为这些全是debug级别的,我就没有在意。后来发现每组的最后一条信息"Ignoring bean creation exception...",有错误信息,才发现问题的根源是mybatis的mapping.xml文件中,语句的id重复了。

   可问题是
          1.为什么会打印这么多重复的日志呢?

          2.为什么只有debug级别的日志呢?

 

问题1:

    通过对日志 和源码的学习,终于把第一问题解答了。

    1). dao类是需要注入一个SqlSessionFactory的。mybatis与spring整合,对应的是SqlSessionFactoryBean类。

    2). SqlSessionFactoryBean在创建的时候,会加载所有的mapping文件。

    3). 当加载失败的时候,不会抛出异常,只是打印了一个debug级别的日志。刚才提到的"Ignoring bean creation exception..."信息。

        所以程序会继续进行。

   

    4). 然后,当每次需要注入“依赖 [此SqlSessionFactoryBean类] 的Dao类”的时候,就会打印一组 3)中的错误信息。

        so,当有很多类依赖这些Dao的时候,就有了这504组错误信息。。

 

问题2:

      查看了所有的日志,发现只有这一行信息能够清楚的说明问题的原因。这一行信息是由spring记录的。( org.springframework.beans.factory.support.AbstractBeanFactory#getTypeForFactoryBean )

      估计他并不想直接吞掉这个异常,因为把这个Exception放入了suppressedExceptions属性里,可能会在必要的时候统一抛出。

      可是,在这种情况下,他并没有抛出正确的异常。不知算不算mybatis-spring的bug。总之,这种编程问题,在测试环境下,就可以发现,不会影响生产环境,所以问题也不大。不过这种处理方式,错信息混杂在debug级别的信息中,确实不太好定位问题。

 

 

 

附两组日志:

DEBUG DefaultListableBeanFactory - Creating shared instance of singleton bean 'tradeShareDao'
DEBUG DefaultListableBeanFactory - Creating instance of bean 'tradeShareDao'
DEBUG DefaultListableBeanFactory - Eagerly caching bean 'tradeShareDao' to allow for resolving potential circular references
DEBUG DefaultListableBeanFactory - Creating shared instance of singleton bean 'settlementSqlSessionFactory'
DEBUG DefaultListableBeanFactory - Creating instance of bean 'settlementSqlSessionFactory'
DEBUG DefaultListableBeanFactory - Eagerly caching bean 'settlementSqlSessionFactory' to allow for resolving potential circular references
DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'settlementDataSource'
DEBUG PathMatchingResourcePatternResolver - Looking for matching resources in jar file [file:/xxxx/webapps/management/WEB-INF/lib/xxx-settlement-orm-1.0-SNAPSHOT.jar]
DEBUG PathMatchingResourcePatternResolver - Resolved location pattern [classpath:settlement_mapper/*Mapper.xml] to resources [class path resource [settlement_mapper/PaymentTypeMapper.xml], class path resource [settlement_mapper/TradeShareMapper.xml]]
DEBUG DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'settlementSqlSessionFactory'
DEBUG ResolverUtil - Find JAR URL: jar:file:/xxxx/webapps/management/WEB-INF/lib/xxx-settlement-orm-1.0-SNAPSHOT.jar!/com/test/settlement/orm/
DEBUG ResolverUtil - Inner URL: file:/xxxx/webapps/management/WEB-INF/lib/xxx-settlement-orm-1.0-SNAPSHOT.jar!/com/test/settlement/orm/
DEBUG ResolverUtil - Extracted JAR URL: file:/xxxx/webapps/management/WEB-INF/lib/xxx-settlement-orm-1.0-SNAPSHOT.jar
DEBUG ResolverUtil - Found JAR: file:/xxxx/webapps/management/WEB-INF/lib/xxx-settlement-orm-1.0-SNAPSHOT.jar
DEBUG ResolverUtil - Listing jar:file:/xxxx/webapps/management/WEB-INF/lib/xxx-settlement-orm-1.0-SNAPSHOT.jar!/com/test/settlement/orm/
DEBUG ResolverUtil - Found resource: /com/test/settlement/orm/dao/TradeShareDao.class
DEBUG ResolverUtil - Found resource: /com/test/settlement/orm/dao/PaymentTypeDao.class
DEBUG ResolverUtil - Checking to see if class com.test.settlement.orm.dao.TradeShareDao matches criteria [is assignable to Object]
DEBUG ResolverUtil - Checking to see if class com.test.settlement.orm.dao.PaymentTypeDao matches criteria [is assignable to Object]
DEBUG DefaultListableBeanFactory - Ignoring bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tradeShareDao' defined in URL [jar:file:/xxxx/webapps/management/WEB-INF/lib/xxx-settlement-orm-1.0-SNAPSHOT.jar!/com/test/settlement/orm/dao/TradeShareDao.class]: Cannot resolve reference to bean 'settlementSqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'settlementSqlSessionFactory' defined in class path resource [applicationContext-db-settlement.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'class path resource [settlement_mapper/manual-SettleItemMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: XML fragments parsed from previous mappers already contains value for com.test.settlement.orm.dao.SettleItemDao.SettleItem_columns


DEBUG DefaultListableBeanFactory - Creating shared instance of singleton bean 'paymentTypeDao'
DEBUG DefaultListableBeanFactory - Creating instance of bean 'paymentTypeDao'
DEBUG DefaultListableBeanFactory - Eagerly caching bean 'paymentTypeDao' to allow for resolving potential circular references
DEBUG DefaultListableBeanFactory - Creating shared instance of singleton bean 'settlementSqlSessionFactory'
DEBUG DefaultListableBeanFactory - Creating instance of bean 'settlementSqlSessionFactory'
DEBUG DefaultListableBeanFactory - Eagerly caching bean 'settlementSqlSessionFactory' to allow for resolving potential circular references
DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'settlementDataSource'
DEBUG PathMatchingResourcePatternResolver - Looking for matching resources in jar file [file:/xxxx/webapps/management/WEB-INF/lib/xxx-settlement-orm-1.0-SNAPSHOT.jar]
DEBUG PathMatchingResourcePatternResolver - Resolved location pattern [classpath:settlement_mapper/*Mapper.xml] to resources [class path resource [settlement_mapper/PaymentTypeMapper.xml], class path resource [settlement_mapper/TradeShareMapper.xml]]
DEBUG DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'settlementSqlSessionFactory'
DEBUG ResolverUtil - Find JAR URL: jar:file:/xxxx/webapps/management/WEB-INF/lib/xxx-settlement-orm-1.0-SNAPSHOT.jar!/com/test/settlement/orm/
DEBUG ResolverUtil - Inner URL: file:/xxxx/webapps/management/WEB-INF/lib/xxx-settlement-orm-1.0-SNAPSHOT.jar!/com/test/settlement/orm/
DEBUG ResolverUtil - Extracted JAR URL: file:/xxxx/webapps/management/WEB-INF/lib/xxx-settlement-orm-1.0-SNAPSHOT.jar
DEBUG ResolverUtil - Found JAR: file:/xxxx/webapps/management/WEB-INF/lib/xxx-settlement-orm-1.0-SNAPSHOT.jar
DEBUG ResolverUtil - Listing jar:file:/xxxx/webapps/management/WEB-INF/lib/xxx-settlement-orm-1.0-SNAPSHOT.jar!/com/test/settlement/orm/
DEBUG ResolverUtil - Found resource: /com/test/settlement/orm/dao/TradeShareDao.class
DEBUG ResolverUtil - Found resource: /com/test/settlement/orm/dao/PaymentTypeDao.class
DEBUG ResolverUtil - Checking to see if class com.test.settlement.orm.dao.TradeShareDao matches criteria [is assignable to Object]
DEBUG ResolverUtil - Checking to see if class com.test.settlement.orm.dao.PaymentTypeDao matches criteria [is assignable to Object]
DEBUG DefaultListableBeanFactory - Ignoring bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'paymentTypeDao' defined in URL [jar:file:/xxxx/webapps/management/WEB-INF/lib/xxx-settlement-orm-1.0-SNAPSHOT.jar!/com/test/settlement/orm/dao/PaymentTypeDao.class]: Cannot resolve reference to bean 'settlementSqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'settlementSqlSessionFactory' defined in class path resource [applicationContext-db-settlement.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'class path resource [settlement_mapper/manual-SettleItemMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: XML fragments parsed from previous mappers already contains value for com.test.settlement.orm.dao.SettleItemDao.SettleItem_columns

 

TKMyBatis实战指南:告别重复CRUD,提升MyBatis开发效率 在Java持久层开发中,ORM框架通过对象关系映射技术,将数据库操作抽象为面向对象的方法调用,从而简化数据访问层的开发。其核心原理是利用反射和动态代理机制,在运行时生成并执行SQL语句,实现数据与对象的自动转换。这项技术显著提升了开发效率,减少了样板代码,尤其适用于需要快速迭代的业务系统。在实际工程实践中,通过约定优于配置的原则,开发者可以更专注于业务逻辑而非底层SQL编写。例如,在构建后台管理系统或微服务架构时,单表的基础增删改查操作往往占据大量开发时间。TKMyBatis(通用Mapper)作为MyBa 阅读详情

相关推荐

TkMyBatis实战:告别MyBatis重复SQL,实现单表CRUD自动化

在Java企业级应用开发中,ORM框架是连接对象模型与关系数据库的核心组件,其核心原理是通过元数据映射与动态SQL生成,将面向对象的操作转换为高效的数据库指令。MyBatis作为一款半自动化的持久层框架,以其对SQL的精细控制能力而广受欢迎,但在处理大量单表操作时,开发者仍需编写大量重复的XML映射文件,影响了开发效率。TkMyBatis作为MyBatis的增强工具包,通过引入通用Mapper和基于反射的动态SQL生成机制,实现了单表CRUD操作的自动化。其技术价值在于,它巧妙地在保留MyBatis原生灵活

weixin_34007906的博客 371

MyBatis 原理:扫描 Mapper 接口

Mapper 扫描需要依赖 Maybtis/Spring 这个项目。无论是 @Mapper 还是 @MapeprScan 注解,底层都是需要去注册一个 MapperScannerConfigurer 的 Bean , 然后通过该 Bean 来实现 Mapper 的主动注入。

Java技术攻略的博客 4100

MyBatis Invalid bound statement 错误排查:从原理到实战解决

在Java持久层框架中,ORM(对象关系映射)技术通过将数据库操作映射为Java方法调用,简化了数据访问层的开发。其核心原理在于建立接口方法与SQL语句之间的绑定关系,通过动态代理和XML解析实现方法调用到SQL执行的转换。这一机制的技术价值在于实现了数据访问逻辑与业务逻辑的解耦,提升了代码的可维护性和可测试性。在实际应用场景中,开发者常使用MyBatis或MyBatis-Plus进行数据库操作,但配置不当容易引发绑定异常。本文聚焦于常见的Invalid bound statement错误,深入分析其背后的

weixin_30443731的博客 435

org.mybatis.spring.mapper.ClassPathMapperScanner和tk.mybatis.spring.annotation.MapperScan

org.mybatis.spring.mapper.ClassPathMapperScanner - No MyBatis mapper was found in '[com.xxx.xxx.xxx]' package. Please check your configuration.

qq_42553504的博客 1625

springboot sessionFactory 方式 配置 mybaits 扫描多个 mapper xml

static final String MAPPER_LOCATION1 = "classpath:mybatis/dsno1/*/*.xml"; //扫描 目录1 static final String MAPPER_LOCATION2 = "classpath:mybatis/dsno2/*/*.xml"; //扫描 目录2 @Bean(name = "masterSqlSessionFactory") @Primary //www.1b23.com public...

1703

【异常】ClassPathMapperScanner - No MyBatis mapper was found in ‘[com.xxx.mapper]‘ package.

下没有扫描到任何 Mapper 接口,可能是配置或代码结构问题导致的。通过以下步骤,通常能定位到“未找到 Mapper 接口”的原因(多数是包路径错误或注解缺失)。根据实际情况调整后,警告会消失。这个警告信息表明 MyBatis 在指定的包路径。

奶爸的编程之路,也就一周冷个三天 234

Mybatis通用Mapper(tk.mybatis)的使用

一、前言 使用Mybatis的开发者,大多数都会遇到一个问题,就是要写大量的SQL在xml文件中,除了特殊的业务逻辑SQL之外,还有大量结构类似的增删改查SQL。而且,当数据库表结构改动时,对应的所有SQL以及实体类都需要更改。这工作量和效率的影响或许就是区别增删改查程序员和真正程序员的屏障。这时,通用Mapper便应运而生…… 二、什么是通用Mapper 通用Mapper就是为了解决单表增删改查...

不见其长,日有所长 3万+

保姆级教程:用Python和PyTorch复现PTB-XL心电信号分类论文(附完整代码)

本文提供了一份详细的PTB-XL心电信号分类教程,涵盖从数据预处理到模型优化的完整流程。通过PyTorch实现三种深度学习架构(Conv1D、SincNet和熵特征融合网络),并针对医疗AI特有的类别不平衡问题提供解决方案。教程包含可运行的代码示例,帮助开发者快速复现论文结果并应用于实际心电信号分析场景。

weixin_30555125的博客 405

springboot引入tk.mybatis却老是导到org.mybatis.spring.annotation.MapperScan扫描包

是这样的,在配置mapper扫描包的时候,我本来是想导入tk.mybatis.spring.annotation.MapperScan包的,但一直找不到,只有org.mybatis.spring.annotation.MapperScan的包。经过几次查询发现,是tk.mybatis版本的问题,之前用的是1.1.1的版本。后面用2.0.3的版本,重新clean,install之后。导报就发现有tk...

chen1992xin的博客 1万+

java结合Ai

Spring AI 是 AI 工程的应用框架。其目标是将Spring生态系统的设计原则(如可移植性和模块化设计)应用于AI领域,并促进使用POJO作为应用程序的构建块到AI领域。特征跨 AI 提供商的可移植 API 支持,适用于聊天、文本到图像和嵌入模型。支持同步 API 和流 API 选项。还支持下拉以访问特定于模型的功能。聊天模型亚马逊基岩人类学Cohere的命令AI21 Labs的侏罗纪-2Meta 的 LLama亚马逊的泰坦人类学克劳德Azure 开放式 AI。

qq_67832732的博客 2848

Matlab实战:水声信号DEMON谱分析从入门到精通(附完整源码)

本文详细介绍了使用Matlab进行水声信号DEMON谱分析的完整流程,从基础理论到实战应用,涵盖信号预处理、包络提取、频谱分析等关键步骤,并附完整源码。特别针对水声通信中的低信噪比环境,提供了多种优化方案和性能提升技巧,帮助读者快速掌握这一水下目标检测的核心技术。

gamma的博客 296

springboot整合mybatis,对于mapper文件扫描,和xml扫描详解

springboot整合mybatis,对于mapper文件扫描,和xml扫描详解 使用idea创建springboot项目(这里不做主要讲解) 1.准备连接数据库(用自己的配置:192.168.10.* 3306 xl root 123456 2.导数据库相关包: <dependency> <groupId>org.myba...

qq_30633867的博客 5564

EB配置输入捕获ICU模块----基于S32K3

基于S32K311芯片,EB配置ICU输入捕获(Emios 和Siul)

weixin_43586400的博客 1772

No MyBatis mapper was found in ‘[xx.mapper]‘ package. Please check your configuration.特殊处理

启动告警spring boot+mybatis+mybatis-plus

阿文的专栏 2万+

从Chimera到ChimeraX:科研绘图升级指南,让你的论文配图更专业

本文详细介绍了从UCSF Chimera升级到ChimeraX的科研绘图指南,帮助研究者提升论文配图质量。ChimeraX在渲染引擎、大分子处理能力和动画功能上具有显著优势,特别适合生命科学和结构生物学领域。文章涵盖材质设置、专业配色、工作流程和期刊适配等核心技巧,助力产出出版级分子可视化图像。

weixin_33670786的博客 934

【智能制造】- APS系列|05 APS 排产的五大底层算法逻辑

很多人误以为APS只是给生产工单排先后顺序,实则整套系统依托成熟算法体系,完成多维度约束下的最优生产决策在制造业数字化排产普及的当下,依旧有不少制造管理者对APS存在认知误区,将其等同于简易工单排序工具。事实上,专业级高级计划与排程系统,早已脱离单纯按时间排序的基础功能,而是依托一整套成熟完善的底层算法逻辑,整合现场各类生产限制条件,在海量变量中自动推演、筛选、输出最贴合企业经营目标的生产方案。

qq_40821260的博客 435

mybatis-plus 常见的绑定错误解决方案

mybatis-plus 常见的绑定错误解决方案 比较长见到的几个绑定错误: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) Result Maps collection already contains value for xxx org.apache.ibatis.bindi...

_WanG 1万+

分布式协作方案:OpenClaw多节点部署与设备互联

主从架构或对等架构服务发现与注册机制负载均衡策略选择分布式任务队列优先级调度失败重试机制WebSocket实时通信数据同步引擎冲突解决策略健康检查机制故障自动转移数据复制与恢复通过分布式部署,OpenClaw可以支撑更大规模的业务场景,提供更稳定可靠的AI助手服务。在下一篇文章中,我们将深入探讨安全与权限管理的精细化策略。

gaoxiang_120的专栏 371

SpringBoot整合MyBatis常见问题与解决方案

在Java企业级开发中,ORM框架MyBatis与SpringBoot的整合是常见技术组合。其核心原理是通过SqlSessionFactoryBean创建数据库会话工厂,依赖数据源(DataSource)实现持久层操作。当出现'SqlSessionFactoryBean未找到'错误时,通常涉及依赖管理、自动配置或数据源连接等基础问题。开发者需要掌握依赖树分析、@MapperScan注解配置等工程实践技巧,特别是在多模块项目或自定义配置场景下。通过合理配置mybatis.mapper-locations等参数

weixin_30345577的博客 421

推荐系统[九]项目技术细节讲解z2:搜索Query理解[Term Weight、Query 改写、同义词扩写]和语义召回技术

在 pooling 方法上,我们也尝试过不同层 pooling,或者在多层上增加 attention 聚合 BERT 多层结果,效果和最后一层所有 token 做 average pooling 相当。损失函数方面,在排序阶段使用pairwise比 pointwise 损失函数的效果会更好。

丨汀、的博客 1109

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

Spring Boot项目MyBatis依赖配置与核心配置详解

在Java企业级应用开发中,ORM框架是连接应用与数据库的关键技术层,它通过对象关系映射原理,将数据库操作抽象为面向对象的方法调用,从而提升开发效率并降低SQL维护成本。MyBatis作为一款半自动化的持久层框架,因其灵活的SQL编写能力和与Spring生态的无缝集成,在工程实践中被广泛采用。其技术价值在于平衡了开发便捷性与SQL可控性,尤其适用于需要复杂查询优化的场景。在Spring Boot项目中,通过引入mybatis-spring-boot-starter依赖,开发者可以快速完成数据源配置、Mapp

weixin_30216561的博客 353

深度学习工具包 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")

mybatis基础学习

1:typeAliases别名 当我们在mapper的xml文件中编写statement的时候,会通过resultType指定返回类型,通过parameterType指定参数的类型,正常的都是需要些类的全限定类名称,但是一般的类的全限定名称都是比较长的,这样就会造成文件的过渡冗余配置,比如下面的配置: <select id="queryByXxx" resultType="foo.bar.MyObj"> select ... from ... where ... </select>

wang0907的博客 898

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

JB3-1-MyBatis

配通,增删改查,动态SQL,SQL片段,一级缓存,二级缓存,多表联查,注解开发等。

周航宇的博客 2666

初期使用MyBatis配置映射器mappers的两个异常

配置mappers映射器后报org.apache.ibatis.binding.BindingException和org.apache.ibatis.binding.BindingException

douju的博客 1235

myBatis +myBatis Plus

第一步:创建maven工程第二部:创建实体类和dao的接口user.java文件:实现Serializable接口?定义属性生成get、set、toStringIuserDao.java 接口实现方法 List serlect();第三步:创建Mybatis的主配置文件SqlMapConifg.xml文件</</</</</</</第四步:创建映射配置文件IUserDao.xml文件</</环境搭建的注意事项:实现自动提交事务(不好)

sjdjh19920910的博客 201
上一篇: javap分析一行简单的运算符代码
fly0wings
博客等级 码龄18年 0粉丝 6原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值