使用IDEA极简整合SSM框架

【SpringMVC 】什么是SpringMVC(二)?如何整合ssm框架以及使用mybatisPlus? MybatisPlus的基础操作封装了常见的增删改查操作,使得开发者可以更容易地使用MybatisPlus进行数据库操作。这些基础操作是通过Mapper接口和实现类来完成的,开发者只需要继承BaseMapper接口即可。以下是MybatisPlus支持的基础操作: 插入:insert、insertBatch、insertOrUpdate 等方法。 更新:updateById、update、updateBatchById 等方法。 删除:deleteById、deleteByMap、delete 等方法。 阅读详情
网页左边,向下滑有目录索引,可以根据标题跳转到你想看的内容

1、整合介绍

  • springMVC框架主要用于实现MVC设计模式,MyBatis负责持久层业务操作数据库,而spring负责管理springMVC和MyBatis
  • 但是springMVC是spring的一个子模块,所以spring和springMVC本身不用整合,我们需要考虑的仅仅是如何整合spring和MyBatis
  • 而myBatis官方以经为我们提供了整合使用的jar包mybatis-spring

2、环境搭建(Maven)

  • 使用Maven导入相关jar包
<dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <!--  SpringMvc  -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>5.2.3.RELEASE</version>
    </dependency>
    <!--Spring JDBC-->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>5.2.3.RELEASE</version>
    </dependency>
    <!--Spring AOP和Spring aspects-->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aop</artifactId>
      <version>5.2.3.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aspects</artifactId>
      <version>5.2.3.RELEASE</version>
    </dependency>
    <!-- Mabatis -->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.5.4</version>
    </dependency>
    <!--Spring & MyBatis-->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>2.0.3</version>
    </dependency>
    <!-- MySql -->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.2</version>
    </dependency>
    <!--C3P0-->
    <dependency>
      <groupId>com.mchange</groupId>
      <artifactId>c3p0</artifactId>
      <version>0.9.1.2</version>
    </dependency>
    <!--jstl-->
    <dependency>
      <groupId>jstl</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
    <!--Servlet-->
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>4.0.1</version>
    </dependency>

 </dependencies>

在这里插入图片描述

3、配置web.xml

  • web.xml文件配置信息
<web-app>
  <display-name>Archetype Created Web Application</display-name>

  <!--配置spring-->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <!--springMvc的DispatchServlet 前端控制器-->
  <servlet>
    <servlet-name>dispatchServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:dispatchServlet.xml</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>dispatchServlet</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  <!--字符编码过滤器-->
  <filter>
    <filter-name>characterEncodingFilter</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>
  </filter>
  <filter-mapping>
    <filter-name>characterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <!--加载静态资源-->
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.js</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.css</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.jpg</url-pattern>
  </servlet-mapping>
</web-app>
  • 配置spring在这里插入图片描述
  • 配置SpringMvc的dispatchServlet前端控制器在这里插入图片描述
  • 配置characterEncodingFilter字符编码过滤器在这里插入图片描述
  • 配置静态资源在这里插入图片描述

4、整合spring和MyBatis

  • 整合spring和mybatis就是将mybatis交给spring管理,而mybatis提供的整合包mybatis-spring,可以帮我们轻松完成整合在这里插入图片描述
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    <!--spring整合myBatis-->
        <!--配置数据源,这里用连接池c3p0-->
        <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
            <property name="user" value="root" />
            <property name="jdbcUrl" value="jdbc:mysql//localhost:3306/mywebsite?userUnicode=true&amp;characterEncoding=UTF-8" />
            <property name="password" value="123456" />
            <property name="driverClass" value="com.mysql.jdbc.Driver" />
            <property name="initialPoolSize" value="5" />
            <property name="maxPoolSize" value="10" />
        </bean>
    <!--获取SqlSession-->
        <!--1、获取SqlSessionFactory 通过整合包mybatis-spring下的SqlSessionFactoryBean类-->
        <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <property name="configLocation" value="classpath:config.xml"/>
            <property name="mapperLocations" value="classpath:com/yzpnb/dao/*.xml" />
        </bean>
        <!--2、将接口扫描到spring-->
        <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <property name="basePackage" value="com.yzpnb.dao" />
        </bean>
</beans>
  • 配置mybatis的核心配置文件,可以不配,因为主要内容全部配置给spring管理了,而mybatis的核心配置文件只需要配置一些辅助信息即可在这里插入图片描述

5、配置前端控制器

在这里插入图片描述

6、idea配置pom.xml

<!--使idea的maven可以扫描到xml-->
<resources>
  <resource>
    <directory>src/main/java</directory>
    <includes>
      <include>**/*.xml</include>
    </includes>
  </resource>
  <resource>
    <directory>src/main/resources</directory>
    <includes>
      <include>**/*.xml</include>
      <include>*.xml</include>
    </includes>
  </resource>
</resources>

在这里插入图片描述

7、测试查询方法

  • 根据数据库建立三层模型在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述

8、常见错误

  • 1、SSM框架遇到异常Error creating bean with name 'org.springframework.cache.interceptor.CacheInterceptor#0’意思是找不到cache
  • 这是因为idea在配置前端控制器时,标签 < !–开启注解驱动–>< mvc:annotation-driven></mvc:annotation-driven>自动导入了错误信息,将此标签删除,并重新导入即可在这里插入图片描述
  • 2、com/mchange/v2/c3p0/impl/NewProxyResultSet.isClosed()Z is abstract4
  • 表示c3p0依赖出错,重新配置pom.xml在这里插入图片描述
  • 3、所有数据源信息都正确,但还是连接不上数据库
  • 如果确定不是你的信息有问题,可以检测下你的数据库版本,是否和你所配置的jar包匹配,比如5.0版本数据库,使用了和我一样的8.0的jar包,就会无法连接
  • 4、Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid b,找不着接口
  • 意思就是no find ,没有发现你的mapper映射文件,一般会说你的dao层接口怎么这么没找到,比如no find com.XXX.dao.SsmDao.selAll()这样的
  • 这是因为你的xml配置文件放在了pom.xml找不到的地方,idea必须配置xml文件的位置在这里插入图片描述
基于IDEA很详细的SSM整合全过程 禁止转载,谢谢 在网上看到很多关于SSM整合的框架,满怀信心的取跟着做,发现老是做着做着就报错飘红的很多,就很容易没有信心做下去,自己也是在网上找了好多,发现能用的比较少,自己就跟着教材做了一个用IDEA做的项目,也是跟着磨了好久,总算是做了出来,整理了一下就发了出来,风华在这里就分享给大家,希望能够给大家带来帮助。有帮助的话,你的支持就是我最大的动力。 都说“万事开头难”,第一步,要做的就是先要... 阅读详情

相关推荐

ssm框架之ssm整合实现登录功能

ssm框架分别是 spring springmvc 和mybatis的简称。是现在开发javaweb项目的一种常见的技术组合方式。 下面就开始ssm框架的整合通过idea创建一个maven的web项目: 打开pom.xml文件,添加如下依赖,最终效果如下: 依赖添加完后,刷新maven依赖,让所有依赖都加载进来,如果刷新不过来,执行clean install首先整体看一下项目结构: 第一步,先修改web.xml文件,最终内容如下: 第二部,在同级目录下,创建spring-servlet.xml文件,内容

卿着飞翔 1253

使用IDEA搭建SSM项目

文章目录1 创建一个webapp模板的maven项目1.1 选择模板并创建项目1.2 设定项目名称并设置工作坐标1.3 设置maven路径与配置文件,之后点击finish就配置好了2 导入jar包依赖2.1 删除用不到的坐标依赖,我们删除掉原有的properties标签、dependencies标签和build标签中的所有内容2.2 导入相应的坐标依赖 1 创建一个webapp模板的maven项目 首先我们在IDEA中创建一个webapp模板的maven项目,名字随意,设定好工作坐标以及我们自己的maven

lijiaxuan_的博客 1万+

IntelliJ IDEA中SSM框架整合实战指南

本文还有配套的精品资源,点击获取 简介:本文将介绍如何在IntelliJ IDEA开发环境中整合SSM框架,即SpringMVC、Spring和Mybatis。SSM框架是Java Web开发中广泛使用的框架组合,能够高效地构建企业级Web应用。文章将按照详细的步骤讲解从创建项目、添加依赖、配置各框架至编写和测试代码的整个整合过程。同时,还会介绍IDEA中实用的插件辅助工具...

weixin_35749545的博客 1669

IDEA搭建SSM框架

这里有时候会发现没有该插件,这时是pom.xml中mybatis-generator-maven-plugin 插件的plugins标签要与pluginManagement标签并列)-----> mybatis-generator:generate -----> 右击 选择 Run Maven Build。将 mysql-connector-java-8.0.16.jar包移动到自己配置系统环境变量的jdk文件下的jre文件中。缺少CGLIB,添加依赖到工程中,打开Pom文件,添加依赖。

weixin_62013325的博客 9555

使用IDEA和Maven整合SSM框架的全教程

随着互联网技术的发展,企业级应用开发需求越来越复杂,SSM框架应运而生,它由Spring、Spring MVC和MyBatis三个框架整合而成,简化了Java EE的应用开发。本章节旨在为读者介绍SSM框架的基本概念,为理解后续章节中框架的详细配置和开发流程打下坚实基础。在Spring框架中,Bean的定义和依赖注入是核心功能之一,它们允许开发者以声明式的方式配置对象及其依赖关系。Bean定义通常在XML配置文件或注解中完成,而依赖注入则通过Setter方法注入或构造函数注入等方式实现。

weixin_32747681的博客 1163

《小白入门:无人机电调 ESC 的 PWM 接口特性、主流协议与使用指南》

电调是无人机的 “动力中枢”,其 PWM 接口是入门的基础,而 SBUS、DroneCAN 等协议则代表了更高阶的控制方式。小白学习时,需先掌握 PWM 的基本特性和连接方法,再根据场景选择合适的协议,同时严格遵守使用注意事项(如电源匹配、校准步骤、安全操作)。随着实践深入,逐步理解 “协议差异” 和 “系统协同”,才能让无人机更稳定、安全地飞行。

bother3000的博客 3783

IDEA快速搭建SSM框架(新手必备)

第一步:新建MAVEN项目 第二步:搭建项目整体架构 项目结构分析:(和三层架构类似) .controller层:控制层,处理页面请求 interceptor:拦截器 mapper:后台持久层(相当于三层架构中的Dao层) pojo:实体类 service:业务访问层 resource:存放SSM中的配置文件,方便管理 webapp-static:存放静态文件,js,css,images等 WEB-INF-page:存放jsp页面 test-java:junit单元测试 第三步

qq_35254085的博客 1145

Silvaco Atlas(五)——物理模型总结

物理模型总结

qsz1425AWD2121的博客 2156

【使用IDEA创建SSM项目】

本文详细的介绍了在IDEA中使用SSM框架开发JavaWeb项目。

一位在代码世界摸爬滚打的全栈开发工程师,在0和1的世界里,持续迭代自我! 6168

Camera 基础知识

Raw Sensor输出的Data格式为Raw,图像的效果处理使用BB端的ISP,BB端接收Raw data后进行一系列的图像处理(OB,Shading,AWB,Gamma,EE,ANR等),效果方面由BB端控制,需要针对不同的模组进行效果调试,Raw sensor是目前的主流,数据量比YUV Sensor小(RAW10 格式的sensor 1个pixel 10个bit)使用平台ISP处理,能支持较大的size。不过,相位对焦并不是那么完美,它对光线的要求就比较高,在弱光拍摄环境下,相位对焦就无能威力了。

手机-手表蓝牙开发工程师的博客 3070

Windows 10下Carla 0.9.15安装避坑指南:从下载到运行的全流程解析

本文详细解析了在Windows 10系统上安装和运行Carla 0.9.15自动驾驶仿真平台的全流程。内容涵盖从系统环境准备、资源下载、Python依赖安装,到首次启动验证及常见错误(如DLL缺失、显卡驱动问题)的深度解决方案,旨在帮助用户快速搭建稳定的开发环境,并运行第一个自动驾驶Python脚本。

alice7model的博客 550

【ssm框架】从0开始搭建ssm框架(idea版本)

SSM(Spring+SpringMVC+MyBatis)框架集由Spring、MyBatis两个开源框架整合而(SpringMVC是Spring中的部分内容),常作为数据源较简单的web项目的框架。

我有满天星辰的博客 9135

Roboguide与TIA V16通讯

Roboguide与TIA V16通讯

haier123888的博客 2678

史上最详细的IDEA优雅整合Maven+SSM框架(详细思路+附带源码)

网上很多整合SSM博客文章并不能让初探ssm的同学思路完全的清晰,可以试着关掉整合教程,摇两下头骨,哈一大口气,就在万事具备的时候,开整,这个时候你可能思路全无 ~中招了咩~ ,还有一些同学依旧在使用eclipse或者Myeclipse开发,我想对这些朋友说IDEA 的编译速度很快,人生苦短,来不及解释了,直接上手idea吧。这篇文章每一步搭建过程都测试过了,应该不会有什么差错。本文章还有个比较优秀的特点,就是idea的使用,基本上关于idea的操作都算是比较详细的,所以不用太担心不会撸idea!最后,本文

宜春 24万+

基于深度学习的图像识别技术在农业领域中的应用

是识别"病害种类"还是"病害严重度分级"?前者是分类,后者常需分割或分级回归。是叶片级(离体叶片图像)、植株级(田间单株)、地块级(无人机俯拍)?视角不同,模型差异巨大。实时无人机巡检可能要求 < 50 ms/帧(Jetson Orin),而离线测报可接受秒级推理。类别标签、结构化 JSON、GIS 图斑、报警事件?

AI天才研究院 2182

Agentic AI应用架构师如何提升AI应用的灵活性

可扩展性(Scalability):快速添加新功能或扩展任务范围(如Agent从“客服”扩展到“供应链管理”);可修改性(Modifiability):调整Agent的决策逻辑或动作策略,无需重构整个系统;鲁棒性(Robustness):在环境异常或数据噪声下保持性能稳定;自适应(Self-Adaptation):自主学习新场景,无需人工干预。状态空间(S):Agent能感知的所有内部/外部状态(如用户需求、环境数据);动作空间(A):Agent能执行的所有动作(如调用工具、发送消息);

项目管理的博客 612

2022新版图文详解IDEA整合SSM框架(附源码)

本教程以图文形式详细讲解IDEA整合SSM框架的流程以及具体步骤及其注意事项。总体而言,利用IDEA搭建Maven工程并整合SSM框架的技术难度不大;但是需要注意的细节之处较多。所以,在整合过程中务必细致周到,考虑周全,富有耐心。

谷哥的小弟 1万+

华为OD新系统机试真题 - 配置操作失败数量统计

华为OD机试新系统 4月8号【配置操作失败数量统计】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题【配置操作失败数量统计】。

qq_45776114的博客 1178

SSM框架整合+案例

SSM框架整合1、环境要求2、数据库环境3、基本环境搭建3.1 创建项目3.2 Maven项目添加web支持3.3 配置pom.xml文件3.4 建立框架的基本结构和配置文件3.4.1 创建包3.4.2 添加配置文件3.4.3 database.properties文件3.4.4 mybatis-config.xml 文件3.4.5 applicationContext.xml 文件3.4.6 spring-dao.xml 文件3.4.7 spring-service.xml文件3.4.8 sprin

诗琪芮的博客 6595

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

SSM框架整合【图文详解】

ssm框架入门,手把手教学,从环境配置到增删改查的实现!

Czh的博客 4308

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

IDEA下的SSM框架整合

根据上课的内容进行整合发现jdk1.8和spring3的不兼容,索性换成idea+maven 环境搭建 通过上面的连接搭好的环境具备了所有的jar包,下一步把目录建好,然后进行整合 下面的内容建立在jar包齐全的基础上,并且设置java目录为source root,resources为resources文件 1、整合Dao 1.1、 创建SqlMapConfig.xml配置文件 &amp;lt;?xm...

林鸿清的blog 484

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

idea下ssm框架整合步骤(较全)

最近在学习idea,作为一名小白,找了很多资料,浪费了不少时间,因为idea对新手真的实在太不友好了。。。 所以我把我查过的资料,和整合过程中碰到的问题都总结了一下,分享给大家,希望少踩点坑~~~ ============================================================================ 1.这是我找到的比较全的ssm整合文章: ...

ZLZQ_Yuan 1095

关于IDEA使用maven整合ssm框架

工作到现在一直在用分布式,spring boot来搭建项目是非常方便而且快捷的。但是现在很多公司都很少使用分布式去进行开发,所以复习了一下ssm的搭建。废话不多说,下面进入正题。   1.创建maven项目 点击next 填写包名以及项目名,之后会生成maven项目。 2.搭建基本项目架构 然后点击src,在src下创建test文件夹(用于存放单元测试类),然后在m...

qq_23665305的博客 3757

IDEA实现SSM框架整合并在网页上显示数据

IDEA实现SSM框架整合并在网页上显示数据 关注公众号,每天更新优质好文! 接下来我们来整合SSM框架。 第一步、 创建一个maven工程。配置Tomcat,并测试是否正常访问HelloWorld. 这一步就省略了。 不懂得看这个博客: idea创建maven项目 创建出来是这样的: 我们从这里开始整合ssm。 第二步、 在pom.xml导入依赖,以下依赖是ssm常用的一些依赖,都导进去,没有坏处。 <properties> <project.build.sourceEn

weixin_46295656的博客 3156

IDEA 整合 SSM 框架学习

认识 Spring 框架 更多详情请点击这里:这里 Spring 框架是 Java 应用最广的框架,它的成功来源于理念,而不是技术本身,它的理念包括 IoC (Inversion of Control,控制反转) 和 AOP(Aspect Oriented Programming,面向切面编程)。 什么是 Spring: Spring 是一个轻量级的 DI / IoC 和...

我没有三颗心脏的博客 1656

ssm框架整合全记录(idea版)

文章目录ssm框架整合全记录(idea版)整合思路环境搭建新建maven工程新建数据库在pom.xml中添加坐标依赖创建文件目录配置tomcat搭建Spring框架编写User类新建applicationContext.xml配置文件编写UserDao接口编写UserService接口编写UserServiceImpl实现类编写测试类SpringTestSpring框架搭建完成搭建SpringMV...

Xin的博客 885
上一篇: 用windows系统简单介绍SVN
下一篇: Spring Boot详细笔记
ydenergy_殷志鹏
博客等级 码龄7年 5895粉丝 543原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ydenergy_殷志鹏

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值
⌂ 换网址