小BUG合集

BUG1

在简单程序写好以后运行,报错。找不到这个类型
解决方案,在启动类上面,加上一个注解@ComponentScan(basePackages = { “cn.josion.mapper.CdpUserMapper”})
就能的到解决

BUG2

修改mapper.xml文件时,获取数据库数据报错
在这里插入图片描述

将int 修改成long就行了

BUG3

jQuery中的.model无法呈现窗口

目录如此。

解决方案
在主界面添加引入页面标签与自定义js

其中::add_josion,是add_josion.html中的标签

BUG4

当请求post是,参数
id=1&name=张三&taskId=3&callMonth=2019.6&authority=2&phone=18786869365一直报错

解决方法:写成json串的形式就行了

BUG5

一个js文件想使用另一个js中的函数

在文档就绪外面设置全局变量,其他文件就越能查询

BUG6
在mybatis中写入的sql语句,根据where条件查询无数据,将控制台打印的sql复制到在PLSQL中执行有数据。

解决,多表联查时,不要再数据库中直接修改数据,而是在业务前端添加,否则查询不出数据

BUG7

Bootstrap validator使用的时候一直不起作用
Html脚本语言,表单验证参数要放到前面先加载

项目引用本地文件时,报错
放到static包下

BUG8

$().data赋值一直赋值不上
页面中
在这里插入图片描述

Js中
在这里插入图片描述

List.html中
在这里插入图片描述

解决:将audit.2修改为audit2就行

BUG9

控制台启动时出现这种情况,控制台打印的启动信息出现问题,但不影响正常代码运行。
在这里插入图片描述

解决:发现在在切换控制台的时候不小心点了“ Ansi Console ”,点击右上角搞定
在这里插入图片描述

BUG10

在将别的电脑上的eclipse项目压缩后,在另外一台电脑上解压并用STS使用时,项目不能使用报错。

The project description file (.project) for is missing. This file contains important information about the project. The project will not function properly until this file is restored. The project description file (.project) for 'hyst

解决:
删除不能使用得项目,不要打勾(磁盘上不能删)
在这里插入图片描述

重新导入整个项目

BUG11

mybatis报错:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exception
原因一:

 /**
     * 获取当前登录用户数据权限
     * @param userId
     * @return
     */
    public List<?> selectDeptMap(Long userId);

mapper.xml配置

<select id="selectDeptMap" parameterType="Long" resultType="List">
	 	SELECT seed_dept_id FROM sys_dept_map WHERE dept_id = #{value} 
	 	
	</select>

將resultType="List"改為resultType="Long "
原因二:
查詢時,參數沒有帶註解@Param()

//@Mapper
public interface UserMapper {

	List<User> userList(@Param("qo") UserQO qo);

}

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.josion.seckill.mapper.UserMapper">
    <resultMap id="User" type="com.josion.seckill.pojo.User">
        <result property="id" column="ID" />
        <result property="userName" column="USER_NAME" />
        <result property="taskId" column="TASK_ID" />
        <result property="callMonth" column="CALLMONTH" />
        <result property="phone" column="PHONE" />
        <result property="status" column="STATUS" />
        <result property="email" column="EMAIL" />
      	<result property="accountType" column="ACCOUNT_TYPE" />
      	<result property="password" column="PASSWORD" />
    </resultMap>
   
  <sql id="baseFields">
       	 TU.ID,
         TU.USER_NAME,
         TU.TASK_ID,
         TU.CALLMONTH,
         TU.PHONE,
         TU.STATUS,
         TU.EMAIL,
         TU.ACCOUNT_TYPE,
         TU.PASSWORD
    </sql>
    
   
    
    <sql id="queryCondition">
        <where>
            <if test="qo != null and qo.id != null and qo.id > 0 ">
                
                AND TU.ID = #{qo.id, jdbcType=NUMERIC}
            </if>
            <if test="qo != null and qo.userName != null and qo.userName != '' ">
                AND TU.USER_NAME = #{qo.userName, jdbcType=VARCHAR}
            </if>
            <if test="qo != null and qo.password != null and qo.password != '' ">
                AND TU.PASSWORD = #{qo.password, jdbcType=VARCHAR}
            </if>
        </where>
    </sql>
  



    <select id="userList"  resultMap="User">
        <![CDATA[ 
            SELECT
        ]]>
            <include refid="baseFields" />
        <![CDATA[
            FROM T_USER TU
		]]>
            <include refid="queryCondition" />
    </select>
  
</mapper>

BUG12

java.sql.SQLSyntaxErrorException: ORA-00933: SQL 命令的結束有問題

<!-- update -->
	<update id="update">
		UPDATE FA_DEPT FD
		SET
            <if test="name != null and name != '' ">
            FD.NAME = #{name, jdbcType=VARCHAR}
            </if>
            <if test="preCheckIn != null and preCheckIn &gt;= 0 and preCheckIn &lt;= 1 ">
            FD.PRE_CHECK_IN = #{preCheckIn, jdbcType=NUMERIC}
            </if>
            <if test="order != null and order != '' ">
            FD.ORDER_ = #{order, jdbcType=NUMERIC}
            </if>
            <if test="statement != null">
            FD.STATEMENT = #{statement, jdbcType=VARCHAR}
            </if>
            <if test="parentId != null and parentId > 0 ">
            FD.PARENT_ID = #{parentId, jdbcType=NUMERIC}
            </if>
			WHERE FD.ID_ = #{id, jdbcType=NUMERIC}
	</update>

解決:

<!-- update -->
	<update id="update">
		<![CDATA[
		UPDATE FA_DEPT FD
		SET
		]]>
	            <if test="name != null and name != '' ">
	            NAME = #{name, jdbcType=VARCHAR},
	            </if>
	            <if test="preCheckIn != null and preCheckIn &gt;= 0 and preCheckIn &lt;= 1 ">
	            PRE_CHECK_IN = #{preCheckIn, jdbcType=NUMERIC},
	            </if>
	            <if test="order != null and order != '' ">
	            ORDER_ = #{order, jdbcType=NUMERIC},
	            </if>
	            <if test="statement != null">
	            STATEMENT = #{statement, jdbcType=VARCHAR},
	            </if>
	            <if test="parentId != null and parentId > 0 ">
	            PARENT_ID = #{parentId, jdbcType=NUMERIC}
	            </if>
           <![CDATA[
			WHERE FD.ID_ = #{id, jdbcType=NUMERIC}
			]]>
	</update>
BUG13

承接bug12
當parentId為null時,報錯
java.sql.SQLSyntaxErrorException: ORA-01747: user.table.column, table.column 或資料欄的設定無效

UPDATE FA_DEPT SET NAME = ?, PRE_CHECK_IN = ?, ORDER_ = ?, STATEMENT = ?, WHERE ID_ = ?

Parameters: 多福多壽(String), 0(Integer), 333(Integer), 0(String), 9(Integer)

解決:

			<![CDATA[
			UPDATE FA_DEPT
					SET
					]]>
	            <if test="name != null and name != '' ">
	            NAME = #{name, jdbcType=VARCHAR}
	            </if>
	            <if test="preCheckIn != null and preCheckIn &gt;= 0 and preCheckIn &lt;= 1 ">
	            ,PRE_CHECK_IN = #{preCheckIn, jdbcType=NUMERIC},
	            </if>
	            <if test="order != null and order != '' ">
	            ,ORDER_ = #{order, jdbcType=NUMERIC},
	            </if>
	            <if test="statement != null">
	            ,STATEMENT = #{statement, jdbcType=VARCHAR}
	            </if>
	            <if test="parentId != null and parentId > 0 ">
	            ,PARENT_ID = #{parentId, jdbcType=NUMERIC}
	            </if>
           <![CDATA[
			WHERE ID_ = #{id, jdbcType=NUMERIC}
			]]>

但是此方法中,若NAME 為null同樣會報錯

解決2:

UPDATE     TABLE
       <trim prefix="set" suffixOverrides=",">  <!-- 意思是在前面加上set  去掉最后的逗号!! -->
       <if test="id!=null">
        id= #{id,jdbcType=INTEGER},
       </if>
      <if test"name!=null">
        name = #{name,jdbcType=VARCHAR},
     </if>
     </trim>
where id = #{id,jdbcType=INTEGER}

节点标签:

trim主要功能是可以在Trim包含的内容前加上某些前缀(prefix),也可以在Trim包含的内容之后加上某些后缀(suffix),还可以把Trim包含内容的首部的某些内容忽略掉(prefixOverrides) ,也可以把Trim包含的内容的尾部的某些内容忽略掉(suffixOverrides)

解決2

<!-- 使用 <set></set>可以智能去掉最后一个逗号-->
<update id="update" parameterType="map">
        update t_role
        <set> 
        <if test="name != null and name !=''">
            name=#{name},
        </if>
        <if test="msg != null and msg !=''">
            msg=#{msg},
        </if>
        <if test="type != null and type !=''">
            type=#{type},
        </if>
        <if test="creator_id != null and creator_id !=''">
            creator_id=#{creator_id},
        </if>
        <if test="level != null and level !=''">
            level=#{level}
        </if></set>
     where id=#{id}
</update>
BUG14

java 后端使用post方式map类型进行接受数据,但是使用JSON格式无法传值

let data= {
                queryParameter: `{"name": "${nameQ}"}`
            }
JSON.stringify(data)
 import _axios from '../api/request.js'
			_axios({
                  method: 'post',
                  url: '/dept/list/page',
                  data: qs.stringify(query)
              }).then(result=>{
@PostMapping("/list/page")
    public Page<List<FADeptResponseDTO>> ListForPage(@RequestParam Map<String, Object> map) {
    		
    	 JQueryDtParameterBaseConvert qpConvert = new JQueryDtParameterBaseConvert(map);

解决:
安装一个axios的qs
命令:

npm install qs
import qs from 'qs'
let data= {
                queryParameter: `{"name": "${nameQ}"}`
            }
qs.stringify(data)
BUG15

Could not resolve type alias
在这里插入图片描述
解决:
在这里插入图片描述
在这里插入图片描述resultMap写成了resultType,修改过来

BUG16

在做vue多页面时,
在这里插入图片描述
报错。如图

[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the “name” option.

[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the “name” option.

[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the “name” option.
在这里插入图片描述
解决:
vue使用最新版font-awesome字体图标库.
安装基础依赖:

npm i --save @fortawesome/fontawesome-svg-core
npm i --save @fortawesome/vue-fontawesome

进入 Vue 项目文件夹,执行如下命令安装基础依赖库。

安装样式依赖

Font Awosome 为我们提供了 Solid、Regular、Brands 这三种免费样式(日常使用完全足够)

npm i --save @fortawesome/free-solid-svg-icons
npm i --save @fortawesome/free-regular-svg-icons
npm i --save @fortawesome/free-brands-svg-icons

在项目的main.js中加入以下配置;

import { library } from '@fortawesome/fontawesome-svg-core'
import { fas } from '@fortawesome/free-solid-svg-icons'
import { far } from '@fortawesome/free-regular-svg-icons'
import { fab } from '@fortawesome/free-brands-svg-icons'
import { FontAwesomeIcon, FontAwesomeLayers, FontAwesomeLayersText }
 from '@fortawesome/vue-fontawesome'
 
library.add(fas, far, fab)
 
Vue.component('font-awesome-icon', FontAwesomeIcon)
Vue.component('font-awesome-layers', FontAwesomeLayers)
Vue.component('font-awesome-layers-text', FontAwesomeLayersText)

成功解决

BUG17

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [/sta/templates/model/views/vue.html], template might not exist or might not be accessible by any of the configured Template Resolvers
在以下配置时报错
在这里插入图片描述在这里插入图片描述

@Controller
@RequestMapping("/view")
public class IndexView {
	
//	@GetMapping("/index1")
//	public ModelAndView login1() {
//		return new ModelAndView("/views/vue");  //路径只需要填写html名字,不需要填写index.html,只需要填写index
//	}
	
	@GetMapping("/index2")
	public String login2() {
		return "/sta/templates/model/views/vue.html";
	}
	
}

BUG18

bug:error Component name “xxx“ should always be multi-word vue/multi-word-component-names
在这里插入图片描述
在这里插入图片描述
解决一:
修改配置项,关闭语法检查,vue.config.js加上一句:lintOnSave:false,再次运行就可以
在这里插入图片描述

module.exports = defineConfig( {
    // transpileDependencies: true,
    filenameHashing: false,
    lintOnSave:false,
...
})

解决二:
更改组件名,使其符合命名规范如:驼峰命名法

BUG19

报错:Property or method “xxx“ is not defined on the instance but referenced during render.
在这里插入图片描述翻译:

属性或方法“tableData”不是在实例上定义的,而是在呈现期间被引用的。通过初始化该属性,确保该属性是响应性的,无论是在data选项中,还是在基于类的组件中。

找了好久,一直以为时父页面没能传参过来,最后在子页面使用了watch监听才发现值早就传过来了。

watch: {
            tabledata(){
            console.log(this.tabledata)
            }
        },

解决:
一定要注意data中、props中和字母有没有写错
在这里插入图片描述

BUG20

Can not import project from an existing workspace folder

BUG21

[vue-router] uncaught error during route navigation
在这里插入图片描述解决:
原因是vue进行了try catch,会捕获到代码执行过程中的错误。
在这里插入图片描述

BUG22

在数据库中,关于 select * 的错误用法
在这里插入图片描述在这里插入图片描述以为select执行后得到所有字段,结果不是。下次注意还是写具体字段名

BUG22

在输出流之后存在return, return失效

 //ServletOutputStream outputStream = response.getOutputStream();
 //ImageIO.write(image,"png",outputStream);
 return "行不行";

显示
在这里插入图片描述

 ServletOutputStream outputStream = response.getOutputStream();
 ImageIO.write(image,"png",outputStream);
 return "行不行";

在这里插入图片描述

BUG23

异常:Error resolving template “xxx”, template might not exist or might not be accessible…解决办法
Error resolving template “index”, template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:870)
at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072)

原因:我想使用thymeleaf框架,找到今天页面,结果易制爆这个错

依赖添加了

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

yml配置了

spring:
	thymeleaf: 
    suffix: .html # 过滤所有非html结尾的文件
    classpath: /templates/model/** #则不指定suffix: .html --> 扫描/templates/model/下所有文件
    prefix: classpath:/templates/model/  # 扫描/templates/model/下所有文件
    cache: false # 关闭缓存 开发模式下设置为false,避免改了模板还要重启服务器,线上设置为true,可以提高性能。
    encoding: UTF-8
    check-template-location: true  #check-tempate-location: 检查模板路径是否存在
  

页面写了
在这里插入图片描述
controller_view也写了

@RestController
@RequestMapping("/view")
public class IndexView {
	
	@GetMapping("/index1")
	public ModelAndView login1() {
		return new ModelAndView("/views/vue");  //路径只需要填写html名字,不需要填写index.html,只需要填写index
	}
}

一致报这个错
网上的解决方案大致分为两个:
1.查看你的@ResponseBody、@RestController用了没。
2.关于返回路径前面的"/“。这个很明显,带”/"的是绝对路径,不带的是相对路径。
我的原因是:将templates包放到了static包下面去了,导致找不到文件
解决:将templates包与static包同级即可

BUG24

前端报错415
后端报错:

.w.s.m.s.DefaultHandlerExceptionResolver[0;39m [2m:[0;39m Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'multipart/form-data;boundary=----WebKitFormBoundaryZDb9yIzjUBnuwTJc;charset=UTF-8' not supported]

原因:

<Upload
                        elememt-id="id-select-file"
                        ref="uploadFile"
                        :before-upload="fileBeforeUpload"
                        :action="actionUrl"
                        :on-success="uploadSuccess"
                        :on-error="uploadError"
                        :show-upload-list="false"
                        :max-size="maxSize"
                        :format="format"
                        :accept="accept"
                        :data="parameter"
                        type="drag"
                        :on-format-error="fileFormatError"
                        :on-exceeded-size="fileSizeError"
                    >
                        <Button icon="ios-cloud-upload-outline">选择文件</Button>
                    </Upload>

其中、:data= 和 action=

this.$refs.uploadFile.post( this.file )上传文件的同时,携带data参数上传

后端:

@PostMapping("/upload-file")
	public R<Boolean> uploadFile(@RequestPart("file") MultipartFile file,@RequestBody InfoVO iVO){

解决:
去掉@RequestBody

BUG25

报错:

Error querying database. Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.ArrayList and java.lang.String

Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.ArrayList and java.lang.String] with root cause

原因:
在mybatis中,存在这样的语句

<if test="configPage != null and configPage != ''">
					AND MVCM.CONFIG IN
			        <trim prefix="(" suffix=")" suffixOverrides=",">
				           	<foreach collection="configPage" item="obj" index="index">
				           		 #{obj, jdbcType=VARCHAR},
				           	</foreach>
			        </trim>
			</if>

传入的时数组或者集合,但是用去与String比较
解决:
将and configPage != ''删掉

BUG26

eclipse ,正常模式可以运行,DEBUG模式被卡住的解决方案
找到
在这里插入图片描述
把项目的断点全部清除掉(我这里因为已经全部清空了,所以显示空白),就OK

BUG27

报错:元素類型 “resultMap” 的內容必須配對 “(constructor?,id*,result*,association*,collection*,discriminator?)”。

在mybatis中,

 <resultMap id="materialDctionaryMap"
		type="com.foxconn.cdp.cofa.material.pojo.dto.response.MaterialDctionaryDTO">		
		<id property="id" column="ID"/>
        <result property="projectId" column="PROJECT_ID"/>
        <result property="milestoneId" column="MILESTONE_ID"/>
        <!-- info -->
        <collection property="childrenMaterial" javaType="ArrayList" ofType="com.foxconn.cdp.cofa.material.pojo.po.Material" columnPrefix="MM_">
			<id property="id" column="ID"/>
	        <result property="projectId" column="PROJECT_ID"/>
		</collection>
        <result property="lastEditorEmpNo" column="LAST_EDITOR_EMPNO"/>
	</resultMap>

解决:< id>、< result>、< assoation>都是有顺序的,把一个assocation元素放在了result中间导致这一个异常。association 必须在 collection 前面。

BUG28 required a bean of type ‘XXX’ that could not be found

在未编译情况下,有飘红报错,检查一下包是不是同级。

在启动时,未飘红报错,则出现的原因是spring在注入对象的时候,没能够找到该类型,是因为spring管理对象是在运行的时候就必须获取,才能将其放到容器中。

解决:
如果是maper(dao)层,一般@MapperScan(“com.xxx.xxx.xx.mapper”)或者在interface上加@mapper
其他情况,通常在启动类添加@ComponentScan(basePackages = {“com.xxx.xxx.xxx”}将其扫描

BUG29 EasyExcel导入时,导入文件中有数据但导入的对象中没数据

一定时导入对象的问题(都是我遇到的问题)
问题一:属性需要严格按照小驼峰命名
问题二:方法只能存在属性的get和set

BUG30 用try-catch后@Transactional失效?

当一个service方法中做先删除,后新增操作时,确保删除后新增失败的情况,需要做一个删除回滚操作。

SpringBoot项目会自动配置一个 DataSourceTransactionManager,所以我们只需在方法(或者类)加上 @Transactional 注解,就自动纳入 Spring 的事务管理了。

默认spring事务只在发生未被捕获的 RuntimeException 时才回滚。

如果使用try-catch捕获异常,则该事务不会回滚。

解决1:

去掉try-catch捕获异常,只是用注解

解决2

获得运行时异常,又抛出运行时异常,让aop捕获异常再去回滚

try {
}catch(Exception e) {
		throw new RuntimeException();
}
解决3

语句中增加:TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();语句,手动回滚,这样上层就无需去处理异常。

catch (Exception e)
{
    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//手动回滚
    return null;
}
BUG31 STS打包遇到,Child module of\pom.xml does not exis

第一步:在父项目pom文件中,存在

<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
		          <fork>true</fork>
		          <addResources>true</addResources>
		        </configuration>
			</plugin>
		</plugins>
	</build>

第二步:配置JDK在这里插入图片描述第三步:
打 jar 包 选中项目右键>Run As >Maven bulid… 在 Goals 框中输入 clean package ,点击 Run
在这里插入图片描述报错:
[[1;34mINFO[m] Scanning for projects…
[[1;31mERROR[m] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Child module E:\workspaces\store\my-store\cloud-gateway of E:\workspaces\store\my-store\pom.xml does not exist @
[ERROR] Child module E:\workspaces\store\my-store\wares of E:\workspaces\store\my-store\pom.xml does not exist @
@
[[1;31mERROR[m] The build could not read 1 project -> [1m[Help 1][m
[[1;31mERROR[m]
[[1;31mERROR[m] The project com.josion:my-store:0.0.1-SNAPSHOT (E:\workspaces\store\my-store\pom.xml) has 2 errors
[[1;31mERROR[m] Child module E:\workspaces\store\my-store\cloud-gateway of E:\workspaces\store\my-store\pom.xml does not exist
[[1;31mERROR[m] Child module E:\workspaces\store\my-store\wares of E:\workspaces\store\my-store\pom.xml does not exist
[[1;31mERROR[m]
[[1;31mERROR[m] To see the full stack trace of the errors, re-run Maven with the [1m-e[m switch.
[[1;31mERROR[m] Re-run Maven using the [1m-X[m switch to enable full debug logging.
[[1;31mERROR[m]
在这里插入图片描述解决:
在这里插入图片描述

在父项目中修改为

<profiles>
    <profile>
		 <modules>
		   <module>seckill</module>
		   <module>erueka</module>
		   <module>cloud-gateway</module>
		   <module>gateway</module>
		   <module>wares</module>
		   <module>hystrix-dashboard</module>
		 </modules>
		 </profile>
  </profiles>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值