错误一:
Invalid bound statement (not found)
在网上找了很多方法都没有解决:后面遇到的解决方法是:
mybatis会进行识别,比如mapper里面对应的resource下面文件名要一样(就是这个问题导致一直出错)
示例代码:
@Resource
private UserSystemMapper userSystemMapper;
采用这种方式进行service层进行mapper的引用 会出现文件名不一致而出现的导入错误,所以在使用的时候要注意文件命名问题;
具体其他解决方案:
参考:
参考地址一
参考地址二
记录时间:21-03-01
记录二:关于mybatis里面和数据库驼峰命名匹配问题
<resultMap id="BaseResultMap" type="org.linlinjava.litemall.db.domain.TsendInfo">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="admin_id" jdbcType="BIGINT" property="adminId" />
<result column="send_name" jdbcType="VARCHAR" property="sendName" />
<result column="send_phone" jdbcType="VARCHAR" property="sendPhone" />
<result column="send_address" jdbcType="VARCHAR" property="sendAddress" />
<result column="is_select" jdbcType="INTEGER" property="isSelect" />
<result column="create_time" jdbcType="VARCHAR" javaType="Date" property="createTime" />
<result column="update_time" jdbcType="VARCHAR" javaType="Date" property="updateTime" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
<foreach collection="criteria.galleryCriteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value,typeHandler=org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value,typeHandler=org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler} and #{criterion.secondValue,typeHandler=org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem,typeHandler=org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
<foreach collection="criteria.galleryCriteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value,typeHandler=org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value,typeHandler=org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler} and #{criterion.secondValue,typeHandler=org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem,typeHandler=org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id,admin_id,send_name,send_phone,send_address,is_select,create_time,update_time
</sql>
<sql id="Blob_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
detail
</sql>
只有配置完这些在mybatis里面才可以进行驼峰命名才可以使用
记录三:利用vue+element进行上传文件(这边是上传excel后端使用easyexcel进行处理)
//这边是上传excel
// 组件编写
<el-upload
class="upload-demo"
:action="uploadPath"
:on-preview="handlePreview"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:limit="1"
accept=".xls,.xlsx"
:on-change="upload_excel"
:on-exceed="handleExceed"
:file-list="fileList"
>
// 关键在于这一步的处理,把文件发送给后端,之前因为文件格式的错误导致一直报错
upload_excel(fileList) {
this.loading = false
const formData = new FormData()
formData.append('file', fileList.raw)
upload_excel(formData).then(responese => {
this.$message.success('上传成功!')
}).catch(responese => {
this.$message.error(responese.data.data.errmsg)
})
}
// 接口编写:
export function upload_excel(data) {
return request({
url: '/excelSystem/upload_excel',
method: 'post',
data
})
}
// 这边接收的一定要是data的数据而且不加参数 如果加了:params:data这边会对数据进行解析就会导致错误,所以一定要避免
//后端的接受
@PostMapping("/upload_excel")
public Object uploadExcel(@RequestParam("file") MultipartFile file){
System.out.println(file);
excelHandleService.handleExcel(file,excelHandleService);
return ResponseUtil.ok();
}
// 最后使用easyexcel进行数据流的处理即可,图片上传也是 后面会加上oss直接上传到oos然后返回链接才是正确的操作
对了element中操作也不建议用on-success进行操作因为我们实际是操作数据流不做其他处理 所以会传一个undefine给后台会报错,使用on-change会上传两次 开始-结束,所以这边使用
:http-request="upload_excel_btn"
使用这个方法然后,传文件上去即可
upload_excel_btn(file, fileList) {
this.loading = false
const formData = new FormData()
formData.append('file', file.file)
upload_excel(formData).then(responese => {
this.$message.success('上传成功!')
}).catch(responese => {
this.$message.error(responese.data.data.errmsg)
})
}
记录问题三: discard long time none received connection. jdbcUrl : xxxx 使用阿里的druid出现
在大概的网上看了一下 有回答问题说回退版本。。。。。额,,这个治标不治本的回答。。
if (valid && isMySql) { // unexcepted branch
long lastPacketReceivedTimeMs = MySqlUtils.getLastPacketReceivedTimeMs(conn);
if (lastPacketReceivedTimeMs > 0) {
long mysqlIdleMillis = currentTimeMillis - lastPacketReceivedTimeMs;
if (lastPacketReceivedTimeMs > 0 //
&& mysqlIdleMillis >= timeBetweenEvictionRunsMillis) {
discardConnection(holder);
String errorMsg = "discard long time none received connection. "
+ ", jdbcUrl : " + jdbcUrl
+ ", version : " + VERSION.getVersionNumber()
+ ", lastPacketReceivedIdleMillis : " + mysqlIdleMillis;
LOG.warn(errorMsg);
return false;
}
}
}
查看源码可以知道:这段代码大致意思就是如果一个连接空闲超过60s,就丢弃之(holder)并且打印一条warn日志。
所以我们就有了初步的解决方法,就是关掉ping方法 不让其过期
有具体做法:
1.运行时配置
即在运行参数中增加 : 在运行参数中增加:
-Ddruid.mysql.usePingMethod=false
类文件配置
在项目的DruidConfig类中新增加:
/*
* 解决druid 日志报错:discard long time none received connection:xxx
* */
public class DruidConfig {
@PostConstruct
public void setProperties(){
System.setProperty("druid.mysql.usePingMethod","false");
}
}
关于出现配置问题:Spring Session without Spring Security leads to NoClassDefFoundError: org/springframework/security/web/authentication/RememberMeServices #16871
为了解决跨域问题导致的sessionId不一致的问题,引入了
spring-session-core会出现配置丢失的问题:
在百度怎么找都找不到解决方法,最后没办法上谷歌找到了解决方法
https://github.com/spring-projects/spring-boot/issues/16871
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</exclusion>
</exclusions>
</dependency>
增加安全管理,排除安全验证 这样就可以了
关于redis中一些问题的解决:
关于redis的安装:
https://blog.youkuaiyun.com/w893932747/article/details/85549460
springboot注入不了redisTemplate<Long,Object>提示bean not foud
解决方法:@Autowrite 改为 @Resource
关于ssm项目的启动问题
- Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cann
这种问题一般要去看一下数据库配置问题:
我出现的问题是后面的配置忘记加上导致配置出现错误;
还有一个问题搞了一晚上在开发前一定要对spring版本是否匹配jdk版本,这个问题导致出来的是配置一直出错