spring security使用总结

Spring Security介绍 文章主要分三部分 1、Spring Security的架构及核心组件:(1)认证;(2)权限拦截;(3)数据库管理;(4)权限缓存;(5)自定义决策; 2、环境搭建与使用,使用当前热门的Spring Boot来搭建环境,结合项目中实际的例子来做几个Case; 3、Spring Security的优缺点总结,结合第二部分中几个Case的实现来总结Spring Security的优点和缺点。 1、Spring Security介绍 ​ 整体介绍,Spring Security为基于J2EE开发的企业应用软件 阅读详情

spring security 使用总结

两大核心:1、认证 2授权

认证:就是常见的用户名密码校验 通过实现UserDetailsService 中 loadUserByUsername 方法 完成用户认证
授权:通过继承BasicAuthenticationFilter实现doFilterInternal 方法实现授权 (暂时还未用到,个人理解,期待指导)

spring security 里面封装的内容很多 里面都是通过filter使用责任链的模式来实现的

暂时只用到了认证
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class TokenWebSecurityConfig extends WebSecurityConfigurerAdapter {
private UserDetailsService userDetailsService;
private TokenManager tokenManager;
private IndustryPasswordEncoder industryPasswordEncoder;
private RedisTemplate redisTemplate;

@Reference
private UserInfoService userInfoService;

@Autowired
public TokenWebSecurityConfig(UserDetailsService userDetailsService, IndustryPasswordEncoder industryPasswordEncoder,
                              TokenManager tokenManager, RedisTemplate redisTemplate) {
    this.userDetailsService = userDetailsService;
    this.industryPasswordEncoder = industryPasswordEncoder;
    this.tokenManager = tokenManager;
    this.redisTemplate = redisTemplate;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
    http.sessionManagement().invalidSessionStrategy(new MyInvalidSessionStrategy())
            .and().exceptionHandling()
            .authenticationEntryPoint(new CustomAuthenticationEntryPoint()) //屏蔽密码错误弹框
            .and().csrf().disable()
            .authorizeRequests()
            .anyRequest().authenticated()
            .and().logout().logoutUrl("/logout")
            .addLogoutHandler(new TokenLogoutHandler(tokenManager, redisTemplate))
            .and()
            .rememberMe().key("xxx").alwaysRemember(true)
            .rememberMeServices(new RememberMeServiceImpl(userInfoService, authenticationManager()))              
            //.addFilter(new TokenLoginFilter(authenticationManager(), tokenManager, redisTemplate)) //登录认证过滤器     
            //.addFilter(new TokenAuthenticationFilter(authenticationManager(), tokenManager, redisTemplate))//授权filter暂时不需要
            .and()
            .httpBasic();
}
//屏蔽密码错误弹框
class CustomAuthenticationEntryPoint extends BasicAuthenticationEntryPoint {
    CustomAuthenticationEntryPoint() {
        this.setRealmName("xxx");
    }

    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException)
            throws IOException {
        // 能屏蔽掉浏览器弹出登录框
        response.setHeader("WWW-Authenticate", "FormBased");
        response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
        // 自定义401处理
        response.getWriter().write(JSONObject.toJSONString(ApiResponse.error(401, "用户名或者密码错误")));
    }
}
//配置不要拦截的请求
@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers("/test1", "/test/test2");
}

}

记住我过滤器:用于业务场景小程序登陆 前端会将openid放入header中 重写autoLogin方法
public class RememberMeServiceImpl implements RememberMeServices {

private UserInfoService userInfoService;
private AuthenticationManager authenticationManager;

private AuthenticationDetailsSource<HttpServletRequest, ?> authenticationDetailsSource = new WebAuthenticationDetailsSource();


public RememberMeServiceImpl(UserInfoService userInfoService, AuthenticationManager authenticationManager) {
    this.userInfoService = userInfoService;
    this.authenticationManager = authenticationManager;
}

@Override
public Authentication autoLogin(HttpServletRequest request, HttpServletResponse response) {

    String openid = request.getHeader("user-source");
    log.info("autoLogin:{}", openid);
    //只有小程序 走rememberme
    if (StringUtils.isBlank(openid)) {
        return null;
    }
    UserBean userBean = userInfoService.getUserMsgByOpenid(openid);
    if (userBean == null) {
        return null;
    }
    SimpleGrantedAuthority grantedAuthority = new SimpleGrantedAuthority("USER");
    IndustrySessionInfo info = new IndustrySessionInfo(userBean.getId().longValue()
            , userBean.getUsername(), userBean.getPassword(), Collections.singletonList(grantedAuthority));
    RememberMeAuthenticationToken auth = new RememberMeAuthenticationToken("qianlima", info, new ArrayList<>());
    auth.setDetails(this.authenticationDetailsSource.buildDetails(request));
    return auth;
}

@Override
public void loginFail(HttpServletRequest httpServletRequest, HttpServletResponse response) {

}

@Override
public void loginSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) {

}

}

到这暂时就结束了,只是security认证的简单使用,后续会继续扩展更新,技术道路永无止路,继续成长

Spring Security 这个类中没有多余的逻辑,都是HttpSecurity内部配置类中重写的方法执行,HttypSecurit的内部配置类就是我们通过HttpSecurity点出来的属性配置,比如:CsrfConfigurer,构建的时候,传入的就是上层配置类的HttpSecurity。,保存了各个SecurtiyConfigure初始化构建的HttpSecurity,httpSecurity经过build后返回的DefaultSecurityFilterChain对象,这个对象中包含的匹配路径,对应的过滤器集合。 阅读详情

相关推荐

spring security详解

1.概要 Spring是非常流行和成功的Java应用开发框架,SpringSecurity正是Spring家族中的成员。SpringSecurity基于Spring框架,提供了一套Web应用安全性的完整解决方案。正如你可能知道的关于安全方面的两个主要区域是“认证”和“授权”(或者访问控制),一般来说,Web应用的安全性包括用户认证(Authentication)和用户授权(Authorization)两个部分,这两点也是SpringSecurity重要核心功能。 (1)用户认证指的是:验证某个用户是否为系统

wumingdu1234的博客 7768

Spring Security系列教程14--基于自定义的认证提供器实现图形验证码

前言 在上一个章节中,一一哥 带大家实现了如何在Spring Security中添加执行自定义的过滤器,进而实现验证码校验功能。这种实现方式,只是实现验证码功能的方式之一,接下来我们再学习另一种实现方式,就是利用AuthenticationProvider来实现验证码功能,通过这个案例,我们学习如何进行自定义AuthenticationProvider。 一. 认证提供器简介 在上一章节中,我带各位利用自定义的过滤器实现了图形验证码效果,接下来我们利用另一种方式,基于自定义的认证提供器来实现图形验证码

一一哥 1655

Spring Boot中集成Spring Security 专题

当然,Spring Security明确的设计可以处理这种常见需求,但是作为替代你应该使用项目的域对象的安全能力来实现这个目标。例如在默认的安全配置中authorizeRequests(),formLogin()、httpBasic()这三个方法返回的分别是ExpressionUrlAuthorizationConfigurer、FormLoginConfigurer、HttpBasicConfigurer,他们都是SecurityConfigurer接口的实现类,分别代表的是不同类型的安全配置器。

2401_86940371的博客 2231

爆破专栏丨Spring Security系列教程之基于自定义的认证提供器实现图形验证码_webauthenticationdetailssource

了解完上面的这些必要的API,我们就可以实现今天的需求了。

2401_84424937的博客 894

Spring Security 4 原理详解

场景: 用户通过提交username和password请求登陆 服务器验证身份信息是否正确 获取用户信息(包括角色集合) 利用3中的信息构建Security Context 在此之后,该用户的所有请求,Spring Security的访问控制机制将根据Security Context中的信息判断用户是否具有权限 以上,前3点即为认证,构建Security Context,为之后5的授权(访

lbqssss的博客 8455

【Spring Security系列】Spring Security 简介

Spring Security简介 官网:https://spring.io/projects/spring-security 中文文档:https://www.springcloud.cc/spring-security.html Spring Security 的前身是 Acegi Security,在被收纳为Spring子项目后正式更名为Spring Security。 在笔者成书时,Spring Security已经升级到5.1.3.RELEASE版...

qq_28248897的博客 1845

Springboot+SpringSecurity实现图片验证码功能

https://blog.csdn.net/qq_41076797/article/details/86506732 到目前,我学会了两种方法,在这里分享给大家。 第一种 在使用Spring Security框架过程中,经常会有这样的需求,即在登录验证时,附带增加额外的数据,如验证码、用户类型等。下面将介绍如何实现。 第一步:实现自定义的WebAuthenticationDetails ...

竹林幽深 1060

Spring Security使用

上面登录认证流程实现了用户会话访问接口,但是SessionId存储在cookie中,这样会导致csrf攻击,所以前端还需要把SessionId存储到其他位置,比如localStorage,在请求时,把它放到Header中,避免csrf攻击,或者直接生成一个新的csrf token,在每次请求时把它放到header或parameter中,在后端服务进行验证。一般来说,filterChain是我们需要重写的,我们的应用是无法直接使用默认filter的配置。数据库查询到的用户对应的密码。请求中的用户名/密码。

CASER_HDMI的博客 1156

spring security 5 (5)-自定义认证

第3篇讲过,用户登录时,系统会读取用户的UserDetails对其认证,认证过程是由系统自动完成的,主要是检查用户密码。而在现实中,登录方式并不一定是检查密码,也可能是验证码或其他,此时就需要自定义认证。 AuthenticationProvider 自定义认证逻辑在AuthenticationProvider的authenticate方法中完成,第4篇讲过,认证的入参是一个未认证Authen...

JAVA博客 5902

Spring Security学习——基于Java注解的Spring Security配置

基于Java注解的Spring Security配置           Spring在早期版本的时候,全是基于xml配置文件,导致配置极其繁杂。后期的版本中,Spring提供了对基于Java注解的支持。Java注解的Spring使每个Bean类有了自配置的特性,通过在每个类中添加相应的Java注解,就可以标注这些类在系统中的功能,可以大大减少配置文件的管理。当然,Java注解的Spring也

Benson的博客 1412

别再问“这游戏啥引擎做的”了,手把手教你用SteamDB一键查询(附实战案例)

本文详细介绍了如何使用SteamDB一键查询游戏引擎信息,包括Unity 3D、Unreal Engine等热门引擎的识别方法。通过实战案例和高级查询技巧,帮助玩家快速获取游戏技术底细,优化游戏体验和兼容性分析。

weixin_31412781的博客 866

SpringBoot+SpringSecurity前后端分离+Jwt的权限认证(改造记录)

一般来说,我们用SpringSecurity默认的话是前后端整在一起的,比如thymeleaf或者Freemarker,SpringSecurity还自带login登录页,还让你配置登出页,错误页。但是现在前后端分离才是正道,前后端分离的话,那就需要将返回的页面换成Json格式交给前端处理了。

z_ssyy的博客 1747

算法设计与分析 0-1背包问题 动态规划解法【超详细】

0-1背包问题 问题描述 给定i个物品和一个容量为的背包,物品的重量是Wi,其价值为Vi 物品个数为i,背包容量为C。 如何选择装入背包内的物品,使得装入背包中的物品的总价值最大? 其中,每种物品只有全部装入背包或不装入背包两种选择。 物品不能分割,不能重复使用。 动态规划算法思路 首先建立一个数组B[i][c],最上面一行表示背包容量,最左边一列表示物品编号,中间填充的数值表示当当前背包容量为C...

寒泉 4万+

Spring Security 详解

​ Spring Security 是 Spring家族中的一个安全管理框架。相比与另外一个安全框架Shiro,它提供了更丰富的功能,社区资源也比Shiro丰富。一般来说中大型的项目都是使用SpringSecurity来做安全框架。小项目有Shiro的比较多,因为相比与SpringSecurity,Shiro的上手更加的简单。​ 一般Web应用的需要进行认证和授权。​ 而认证和授权也是SpringSecurity作为安全框架的核心功能。视频地址:​ 我们先要搭建一个简单的SpringBoot工程① 设置父工

qq_22075913的博客 12万+

高光谱盲超分DBSR复现全记录:从退化估计到双域耦合的工程实践

高光谱图像超分辨率旨在从低分辨率观测中恢复高分辨率光谱立方体,其核心挑战在于退化过程未知,即盲超分问题。盲超分需同时估计模糊核、噪声水平与下采样方式,本质上是病态逆问题,依赖空间与光谱先验约束。双域耦合方法通过联合空间域与光谱域信息,显著提升退化核估计精度与光谱保真度,技术价值在于更贴近真实成像场景。该技术广泛应用于遥感、医学影像与材料检测等领域。本文围绕DBSR(双域盲超分)的复现,深入剖析退化估计子网调试、双域主干训练策略及显存优化等工程细节,为高光谱盲超分实践提供可复现的参考。

weixin_29031057的博客 205

30分钟上手TI DRV89xx-Q1EVM:多通道电机驱动器评估板实战指南

多通道H桥电机驱动器是机器人、工业自动化及汽车电子中实现多轴运动控制的核心器件,其核心原理是通过集成多个半桥电路,利用SPI通信与PWM调制技术,实现对多个直流电机或负载的独立、精确驱动。这类技术方案能显著减少外围元件数量与PCB面积,提升系统集成度与可靠性,在关节机器人、精密座椅调节及多轴控制单元等场景中价值突出。本文以德州仪器DRV89xx-Q1系列评估板为例,深入解析其硬件架构、安全操作规范及图形化软件配置流程,重点涵盖**过流保护**与**PWM频率**等关键参数的设置与调试,帮助工程师快速完成从硬

weixin_29192141的博客 342

Spring Security 登陆成功后的处理

       Spring Security 完成登陆后一般需要一些自定义的处理,例如,记录登陆日志,初始化用户菜单等等 这里就需要自定义的 登陆成功处理了,Spring  提供了 AuthenticationSuccessHandler 接口,完成这个接口就可以了。 但是,修改到这里处理后,原先系统的自动转向处理就没有了,接口中应该怎么写,才可以保持原来的功能呢?   代码如下:   ...

guanry的博客 5913

多目标跟踪中使用trackeval评估dancetrack运行结果

trackeval使用

qq_46144849的博客 1786

Spring Security配置详细

Spring Security 是一个功能强大且高度可定制的身份验证和访问控制框架,专为基于Spring的应用程序设计。本教程将指导你如何在一个简单的Spring Boot应用程序中集成Spring Security,以实现基本的用户认证和授权功能。

2401_83447580的博客 2540

零基础玩转IndexTTS2:5分钟搭建个人语音克隆工具(支持B站同款情感语音)

本文详细介绍了如何零基础使用IndexTTS2快速搭建个人语音克隆工具,支持B站同款情感语音。IndexTTS2作为自回归零样本TTS系统,突破传统技术限制,实现精准时长控制和丰富情感表达。通过HuggingFace在线演示,用户可轻松克隆音色并调节情感参数,适用于自媒体配音、有声书朗读等场景。

purple的博客 924

【雷达】基于matlab合成孔径雷达干涉测量(InSAR)时序分析【含Matlab源码 9037期】

合成孔径雷达干涉测量(InSAR)时序分析 完整代码,包运行;可提供运行操作视频!适合小白!

订阅付费专栏Matlab(奶茶价版),可赠送奶茶价版付费专栏指定代码1份; 161

Spring Security团队正式宣布Spring Security OAuth终止维护

Spring Security团队正式宣布Spring Security OAuth终止维护。spring 官宣终止维护spring security oauth目前官网的主页已经高亮提醒大家彻底停止维护。官网已经通知EOL旧的Spring Security OAuth项目终止到2.5.2.RELEASE版本,该项目将不会再进行任何的迭代,包括Bug修复,之前胖哥已经提醒该项目即将停止维护,有心的同学已经进行了迁移。2020年就已经宣布了EOL时间表项目文档和代码仓库被移除目前该项目的官方文档已经正式从sp

资料免费分享,点击名片 1601

Python 爬虫高级实战:HTTPS 证书忽略与代理抓包配置

本文深入解析了HTTPS加密与SSL证书校验机制在爬虫开发中的核心问题及解决方案。文章首先剖析了HTTPS协议架构和证书校验流程,指出爬虫开发中常见的证书异常场景及其负面影响。随后详细介绍了Python主流请求库(requests、httpx、aiohttp)的证书忽略配置方法,包括同步/异步模式下的实现方案。针对代理环境,文章系统比较了HTTP、HTTPS、SOCKS5等代理类型的特性差异,并提供了完整的代理配置示例。特别对中间人抓包场景,阐述了Mitmproxy的工作原理和配置要点。最后提出了工程级爬虫

2503_91057718的博客 89

Spring Security的基本使用

本文详细介绍了Spring Security在基于JWT(JSON Web Token)的认证和授权中的基本使用方法,结合Mybatis、Redis等技术实现了一个完整的用户认证和授权流程。通过自定义用户详情类、全局异常处理、JWT工具类以及安全配置类,实现了用户登录、登出、权限校验等功能,并提供了跨域问题的解决方案

2302_79603114的博客 1883

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

VB摄像头监控

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

Spring Security快速入门

目录1 Spring Security介绍2 创建工程2.1 创建maven工程2.2 Spring容器配置2.3 Servlet Context配置2.4 加载 Spring容器3 认证3.1 认证页面3.2.安全配置3.2.Spring Security初始化2.3.默认根路径请求2.4.认证成功页面2.5 测试4 授权5 小结 1 Spring Security介绍 Spring Security是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架。由于它是Sprin

赵广陆 1万+

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Spring Security 基本使用

一、Spring Security是什么? Spring Security is a powerful and highly customizable authentication and access-control framework. It is the de-facto standard for securing Spring-based applications. Spring Security是一个功能强大且高度可定制的身份验证和访问控制框架。它是用于保护基于Spring的应用程序的实际标准。

qq_36700462的博客 2809
上一篇: Dubbo服务治理规范
下一篇: redis缓存数据清理
chen's blog
博客等级 码龄8年 1粉丝 13原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址