SpringBoot 2.x Security security.basic.enabled=false 失效问题解决

本文介绍了Spring Security在SpringBoot 2.x中`security.basic.enabled=false`配置失效的问题。在升级到2.x后,该配置不再有效,需要通过自定义Security配置类并继承`WebSecurityConfigurerAdapter`,重写`configure(HttpSecurity http)`方法来关闭验证。通过这种方式,可以避免在项目中使用Security默认的账号密码登录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Spring Security 是一个功能强大且高度可定制的身份验证和访问控制框架。它是用于保护基于 Spring 的应用程序的实际标准。

Spring Security 致力于为 Java 应用程序提供身份验证和授权。与所有 Spring 项目一样,Spring Security 的真正强大之处在于可以轻松扩展以满足自定义要求。

特性:

  • 全面和可扩展的身份验证和授权支持

  • 防止会话固定、点击劫持、跨网站请求伪造等攻击

  • Servlet API 集成

  • 与 Spring Web MVC 的可选集成

简介SpringBoot 2.x Security security.basic.enabled=false 失效问题解决

在将一个 SpringBoot 1.x 的项目升级到 2.x 的过程中,测试时发现之前在 1.x 项目中,关闭 Security 验证的配置不可用了

security:
  basic:
    enabled: false

查看文档发现,这样的配置在 2.0+ 之后就无法使用了,在 SpringBoot 2.x 的项目中,需要通过代码去配置

也就是继承 WebSecurityConfigurerAdapter 类,并重写其中的 confi

### VSCode 代码跳转功能失效解决方案 对于VSCode中`Ctrl + Click`无法实现代码跳转的问题,存在几种有效的处理方法[^2]。 #### 修改配置文件 一种方式涉及调整用户的全局或工作区级别的设置。确保在settings.json中有如下配置项: ```json { "editor.mouseWheelZoom": true, "editor.multiCursorModifier": "altKey", "breadcrumbs.enabled": true, "python.analysis.completeFunctionParens": true, "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "editor.formatOnSave": true, "files.autoSave": "afterDelay", "explorer.confirmDelete": false, "workbench.colorTheme": "Visual Studio Dark", "window.zoomLevel": 0, "git.enableSmartCommit": true, "diffEditor.ignoreTrimWhitespace": false, "terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe", "search.followSymlinks": true, "security.workspace.trust.untrustedFiles": "open", "cSpell.userWords": [ "xxx" ], "go.useLanguageServer": true, "java.configuration.updateBuildConfiguration": "automatic", "redhat.telemetry.enabled": false, "liveServer.settings.donotShowInfoMsg": true, "emmet.triggerExpansionOnTab": true, "php.suggest.basic": false, "telemetry.enableTelemetry": false, "telemetry.enableCrashReporter": false, "http.proxyStrictSSL": false, "debug.onTaskErrors": "showDebugAdapterTerminal", "remote.SSH.showLoginTerminal": true, "remote.SSH.connectTimeout": 30, "remote.SSH.useLocalServer": true, "remote.SSH.remotePlatform": {}, "remote.SSH.configFile": "~/.ssh/config", "extensions.autoUpdate": true, "update.mode": "default", "typescript.tsserver.log": "off", "typescript.disableAutomaticTypeAcquisition": true, "npm.packageManager": "yarn", "eslint.alwaysShowStatus": true, "prettier.requireConfig": true, "vetur.experimental.templateInterpolationService": true, "rust-analyzer.cargo.loadOutDirsFromCheck": true, "rust-analyzer.procMacro.enable": true, "yaml.customTags": [], "docker.composeV2": true, "kubernetes.kubectl.context": "", "githubPullRequests.gitHubToken": "", "jupyter.askForKernelRestart": false, "notebook.cellToolbarLocation": { "default": "right", "jupyternotebook": "left" }, "powershell.codeFormatting.whitespaceBeforeOpenBrace": true, "powershell.codeFormatting.whitespaceAfterComma": true, "powershell.codeFormatting.alignAssignmentStatements": true, "powershell.codeFormatting.preserveSingleLineStatements": true, "powershell.codeFormatting.newLineAtEndOfFile": true, "powershell.codeFormatting.ignoreExistingLineWrapping": true, "powershell.codeFormatting.whitespaceAroundOperators": true, "powershell.codeFormatting.openBracesOnSameLine": true, "powershell.codeFormatting.closeBracesOnSameLine": true, "powershell.codeFormatting.pipelineIndentationStyle": "sameLine", "powershell.codeFormatting.labelIndentation": "oneLessThanCurrent", "powershell.codeFormatting.functionDefinitionKeywordWrap": "nextLine", "powershell.codeFormatting.parameterListAlignment": "forceWithParentheses", "powershell.codeFormatting.arrayAndHashIndentation": "indentByOne", "powershell.codeFormatting.trimWhiteSpaceAroundPipe": true, "powershell.codeFormatting.newlineBetweenPipelineSegments": true, "powershell.codeFormatting.insertSpaceAfterOpeningContainer": true, "powershell.codeFormatting.insertSpaceBeforeClosingContainer": true, "powershell.codeFormatting.expandAliasToFullyQualifiedCommandName": true, "powershell.codeFormatting.convertControlCharactersToFullWidth": true, "powershell.codeFormatting.escapeSpecialCharactersInStrings": true, "powershell.codeFormatting.removeRedundantQuotes": true, "powershell.codeFormatting.replaceCurlyBracesWithSquareBracketsWhenPossible": true, "powershell.codeFormatting.addSemicolonAtEndOfStatement": true, "powershell.codeFormatting.wrapCommentsUsingRegionDirectives": true, "powershell.codeFormatting.indentHereStringContent": true, "powershell.codeFormatting.rewriteScriptBlockExpressionsAsSubexpressions": true, "powershell.codeFormatting.optimizeVariableNames": true, "powershell.codeFormatting.optimizeParameterValues": true, "powershell.codeFormatting.optimizePropertyAccessors": true, "powershell.codeFormatting.optimizeArrayLiterals": true, "powershell.codeFormatting.optimizeHashtableLiterals": true, "powershell.codeFormatting.optimizeSwitchStatements": true, "powershell.codeFormatting.optimizeIfElseConstructs": true, "powershell.codeFormatting.optimizeForEachLoops": true, "powershell.codeFormatting.optimizeDoWhileLoops": true, "powershell.codeFormatting.optimizeTryCatchFinallyBlocks": true, "powershell.codeFormatting.optimizeFunctionDefinitions": true, "powershell.codeFormatting.optimizeClassDefinitions": true, "powershell.codeFormatting.optimizeEnumDefinitions": true, "powershell.codeFormatting.optimizeDataSections": true, "powershell.codeFormatting.optimizeWorkflowActivities": true, "powershell.codeFormatting.optimizeXmlDocuments": true, "powershell.codeFormatting.optimizeJsonObjects": true, "powershell.codeFormatting.optimizeYamlDocuments": true, "powershell.codeFormatting.optimizeMarkdownDocuments": true, "powershell.codeFormatting.optimizeHtmlDocuments": true, "powershell.codeFormatting.optimizeCssStylesheets": true, "powershell.codeFormatting.optimizeJavaScriptSnippets": true, "powershell.codeFormatting.optimizePythonScripts": true
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

智能体格

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

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

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

打赏作者

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

抵扣说明:

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

余额充值