1.常見(jiàn)報(bào)錯(cuò)
1.1idea中使用mybatis遇到Could not autowire. No beans of 'xxxx' type found
解決方案:安裝mybatis插件
1.2Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
解決方案:1.mapper.xml文件得與相應(yīng)的java文件在同一個(gè)目錄下。
1.3java.lang.AbstractMethodError: org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()Ljava/lang/Integer;
解決方案:mybatis-spring版本過(guò)低導(dǎo)致哭懈,添加版本更高的jar包
1.4編譯文件中就沒(méi)有編譯mybatis的xml文件
解決方案:在pom.xml中添加如下代碼
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.tld</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.tld</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
1.5java.lang.NoClassDefFoundError: javax/servlet/SessionCookieConfig
Spring4測(cè)試的時(shí)候需要servlet3.0的支持
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.0</version>
<scope>provided</scope>
</dependency>
1.6 Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 5' at line 1
SQL語(yǔ)句在單元測(cè)試中可以通過(guò),但是在Spring測(cè)試模塊中不能通過(guò)藕筋,得把后面的;號(hào)去掉
SELECT * from tb1_emp;
改為:
SELECT * from tb1_emp
1.7web路徑的問(wèn)題
不以“/”開(kāi)始的相對(duì)路徑,以當(dāng)前資源的路徑為基準(zhǔn)恋沃,經(jīng)常出現(xiàn)問(wèn)題
以“/”開(kāi)始的相對(duì)路徑,以服務(wù)器的路徑為標(biāo)準(zhǔn)(http://localhost:3309),需要加上項(xiàng)目名稱
如/SSM_CRUD/static/js/jquery-3.2.1.min.js
1.8由于外鍵而不能truncate
SET FOREIGN_KEY_CHECKS=0;
來(lái)禁用外鍵約束.
之后再用
SET FOREIGN_KEY_CHECKS=1;
來(lái)啟動(dòng)外鍵約束.
truncate TABLE address;
truncate TABLE car;
truncate TABLE goods;
truncate TABLE login;
truncate TABLE money;
truncate TABLE `order`;
truncate TABLE orderitem;
truncate TABLE shop;
truncate TABLE `user`;
1.9使用jquery的load方法加載頁(yè)面的時(shí)候被加載頁(yè)面js不能使用的問(wèn)題
$.ajax({
url : 'userInformation.html',
cache : true,
async:false,
success : function(html) {
$(".body_center_right").html(html);
}
});
引自:https://blog.csdn.net/u013644839/article/details/72528788
2.0 radio使用checked獲取不到被選radio的值的問(wèn)題
<lable id="user_genger">
<input type="radio" value="男" checked="checked" name="user_genger">男
<input type="radio" value="女" name="user_genger">女
</lable>
if($("#user_genger input:eq(0)").prop("checked")){
userGender = $("#user_genger input:eq(0)").val();
}
else
userGender = $("#user_genger input:eq(1)").val();
2.1直接使用base64加密后的圖片必指,base64位的數(shù)據(jù)前得加上囊咏,“,”也必須有
data:image/jpg;base64,
2.2 mybatis傳參String時(shí)報(bào)錯(cuò)的解決方法
There is no getter for property named '*' in 'class java.lang.String
https://blog.csdn.net/zcl_love_wx/article/details/78601481
2.3Required String parameter is not present
發(fā)現(xiàn)是前端傳的參數(shù)名與后端代碼定義的參數(shù)名不一致導(dǎo)致的
2.4關(guān)于window.location.href 傳中文參數(shù) 亂碼問(wèn)題
將window.location.href = "goodsList.html?goodsName=" +goodsName + "&pn=1";
改成
window.location.href = "goodsList.html?goodsName=" + encodeURI(encodeURI(goodsName)) + "&pn=1";
2.5一個(gè)特別奇葩的bug塔橡,在使用mybatis中的pagehelper插件進(jìn)行分頁(yè)的時(shí)候發(fā)現(xiàn)有時(shí)候分頁(yè)成功梅割,有時(shí)候分頁(yè)失敗。
PageHelper.startPage(pn,10);
List<Money> moneyList = iMoneyService.selectByUserId(userId);
PageInfo pageInfo = new PageInfo(moneyList,5);
PageHelper.startPage 方法調(diào)用后葛家,后面必須有一個(gè)Mapper的查詢方法户辞,必須被消費(fèi)掉。 否則會(huì)由于ThreadLocal的原因癞谒,當(dāng)該線程被其他方法調(diào)用時(shí)被分頁(yè)