报错JDBC Connection [com.mysql.jdbc.JDBC4Connection@184c65da] will not be managed by Spring

本文记录了一次因密码错误导致的登录失败问题及其解决过程。通过排查发现直接使用明文密码进行数据库验证是问题根源,建议采用加密方式存储并验证密码。
折腾了一个下午,报了这个错,现在找出原因了,就是密码错误,不要避开md5(不要直接在数据库加入个可见的密码用来登录)

先注册,记住注册的密码,在用这个密码,登录


不要用这种密码登录

2018-04-21 21:09:11,766 [http-bio-8084-exec-7] [org.springframework.web.servlet.DispatcherServlet]-[DEBUG] DispatcherServlet with name 'taotao-sso' processing POST request for [/user/selectlogin]
2018-04-21 21:09:11,767 [http-bio-8084-exec-7] [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]-[DEBUG] Looking up handler method for path /user/selectlogin
2018-04-21 21:09:11,767 [http-bio-8084-exec-7] [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]-[DEBUG] Returning handler method [public com.taotao.common.pojo.TaotaoResult com.taotao.sso.controller.UserController.userLogin(java.lang.String,java.lang.String)]
2018-04-21 21:09:11,767 [http-bio-8084-exec-7] [org.springframework.beans.factory.support.DefaultListableBeanFactory]-[DEBUG] Returning cached instance of singleton bean 'userController'
2018-04-21 21:09:11,768 [http-bio-8084-exec-7] [org.mybatis.spring.SqlSessionUtils]-[DEBUG] Creating a new SqlSession
2018-04-21 21:09:11,768 [http-bio-8084-exec-7] [org.mybatis.spring.SqlSessionUtils]-[DEBUG] SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6438ec85] was not registered for synchronization because synchronization is not active
2018-04-21 21:09:11,769 [http-bio-8084-exec-7] [org.springframework.jdbc.datasource.DataSourceUtils]-[DEBUG] Fetching JDBC Connection from DataSource
2018-04-21 21:09:11,769 [http-bio-8084-exec-7] [org.mybatis.spring.transaction.SpringManagedTransaction]-[DEBUG] JDBC Connection [com.mysql.jdbc.JDBC4Connection@184c65da] will not be managed by Spring
2018-04-21 21:09:11,769 [http-bio-8084-exec-7] [com.taotao.mapper.TbUserMapper.selectByExample]-[DEBUG] ==>  Preparing: select id, username, password, phone, email, created, updated from tb_user WHERE ( username = ? ) 
2018-04-21 21:09:11,770 [http-bio-8084-exec-7] [com.taotao.mapper.TbUserMapper.selectByExample]-[DEBUG] ==> Parameters: ww(String)
2018-04-21 21:09:11,772 [http-bio-8084-exec-7] [com.taotao.mapper.TbUserMapper.selectByExample]-[DEBUG] <==      Total: 1
2018-04-21 21:09:11,772 [http-bio-8084-exec-7] [org.mybatis.spring.SqlSessionUtils]-[DEBUG] Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6438ec85]
2018-04-21 21:09:11,773 [http-bio-8084-exec-7] [org.springframework.jdbc.datasource.DataSourceUtils]-[DEBUG] Returning JDBC Connection to DataSource
2018-04-21 21:09:11,773 [http-bio-8084-exec-7] [org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdviceChain]-[DEBUG] Invoking ResponseBodyAdvice chain for body=com.taotao.common.pojo.TaotaoResult@64d559aa
2018-04-21 21:09:11,773 [http-bio-8084-exec-7] [org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdviceChain]-[DEBUG] After ResponseBodyAdvice chain body=com.taotao.common.pojo.TaotaoResult@64d559aa
2018-04-21 21:09:11,774 [http-bio-8084-exec-7] [org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor]-[DEBUG] Written [com.taotao.common.pojo.TaotaoResult@64d559aa] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@25272bc4]
2018-04-21 21:09:11,774 [http-bio-8084-exec-7] [org.springframework.web.servlet.DispatcherServlet]-[DEBUG] Null ModelAndView returned to DispatcherServlet with name 'taotao-sso': assuming HandlerAdapter completed request handling
2018-04-21 21:09:11,774 [http-bio-8084-exec-7] [org.springframework.web.servlet.DispatcherServlet]-[DEBUG] Successfully completed request

在 Node.js 中使用 `crypto` 模块时,如果遇到 `crypto.hash is not a function` 的错误,通常是因为调用方式不正确或误用了模块的方法。Node.js 的 `crypto` 模块并未直接提供 `hash` 方法作为顶层函数,而是通过 `createHash` 方法来创建哈希实例。 ### 正确使用 `createHash` 创建哈希对象 以下是一个使用 `crypto.createHash()` 生成数据哈希值的示例: ```javascript const crypto = require('crypto'); // 创建一个 SHA-256 哈希实例 const hash = crypto.createHash('sha256'); // 添加数据到哈希流中 hash.update('Hello, world!'); // 计算并输出十六进制格式的哈希值 console.log(hash.digest('hex')); // 输出类似:a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e ``` ### 错误原因分析 1. **直接调用 `crypto.hash()`** 如果尝试使用 `crypto.hash('sha256')` 这样的方式,将导致报错,因为 `hash` 并不是 `crypto` 模块暴露的 API [^4]。 2. **混淆了其他库的 API(如 bcrypt)** 某些第三方加密库(例如 `bcrypt`)提供了 `.hash()` 方法,但原生 `crypto` 模块并不支持这种调用方式 [^5]。 ### 解决方案 确保使用正确的语法结构: ```javascript const crypto = require('crypto'); const hash = crypto.createHash('算法名称'); hash.update(数据); const digest = hash.digest(编码格式); ``` ### 示例:使用 MD5 算法生成哈希值 ```javascript const crypto = require('crypto'); const md5hash = crypto.createHash('md5').update('hello').digest('hex'); console.log(md5hash); // 输出:5d41402abc4b2a76b9719d911017c592 ``` ### 示例:分块更新哈希内容 ```javascript const crypto = require('crypto'); const hash = crypto.createHash('md5'); hash.update('Hello, '); hash.update('world!'); console.log(hash.digest('hex')); // 输出:fc5e038d3ea686f7a373a21a5078fd06 ``` ---
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值