1.(Initializing ProtocolHandler) 端口被佔用異常。tomcat重複啓動所致。*
信息: Initializing ProtocolHandler [“http-bio-9001”]
三月 20, 2019 9:01:47 上午 org.apache.coyote.AbstractProtocol init
嚴重: Failed to initialize end point associated with ProtocolHandler [“http-bio-9001”]
java.net.BindException: Address already in use: JVM_Bind :9001
**2.在註冊中心找不到對應的服務
java.lang.IllegalStateException: Failed to check the status of the service**
com.pinyougou.sellergoods.service.BrandService. No provider available for the service com.pinyougou.sellergoods.service.BrandService from the url
zookeeper://192.168.25.129:2181/com.alibaba.dubbo.registry.RegistryService?application=pinyo ugou-manager
web&dubbo=2.8.4&interface=com.pinyougou.sellergoods.service.BrandService&methods=updat e,get,delete,selectOptionList,add,getListByPage&pid=3980&revision=0.0.1
SNAPSHOT&side=consumer×tamp=1501146823396 to the consumer 172.16.17.14 use dubbo version 2.8.4
這種錯誤是服務層代碼沒有成功註冊到註冊中心導致,請檢查一下你的服務層代碼是否添加 了@service 註解,並且該註解的包一定是 com.alibaba.dubbo.config.annotation 包,不是 org.springframework.stereotype.Service,這個地方極容易出錯。另外還有一個原因就是你的 服務層工程由於某些原因沒有正常啓動,也無法註冊到註冊中心裏。
3.無法連接到註冊中心
timeout: 5000
org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within
timeout: 5000 org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:876) org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:98)
org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:92) org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:80)
com.alibaba.dubbo.remoting.zookeeper.zkclient.ZkclientZookeeperClient.<init>(ZkclientZook eeperClient.java:26)
請檢查 IP 與端口是否填寫正確,檢查註冊中心是否正常啓動
4.子項目中pom文件圖標不正確,無法正常創建webapp目錄 。
<modules>
<module>../pinyougou_pojo</module>
<module>../pinyougou_dao</module>
<module>../pinyougou_common</module>
<module>../pinyougou_sellergoods_interface</module>
<module>../pinyougou_sellergoods_service</module>
<module>../pinyougou_manager_web</module>
<module>../pinyougou_shop_web</module>
</modules>
請檢查父工程中是否有導入子工程。而後在maven中選中項目,點擊刷新即可。
5.在做增加和修改方法時,主鍵id增加但是沒有輸入的值。
/**
* 添加方法
* @param tbBrand
*/
@RequestMapping("/add.do")
public SuccessMessage testAdd(@RequestBody TbBrand tbBrand){
//判斷名稱是否重複 開始 -↓-
String name = tbBrand.getName();
List<TbBrand> all = brandService.findAll();
for (TbBrand brand : all) {
String brandName = brand.getName();
if(name.equals(brandName)){
return new SuccessMessage(false,"重複名稱!");
}
}
//判斷名稱是否重複 結束 -↑-
//添加方法 開始 -↓-
try {
brandService.add(tbBrand);
return new SuccessMessage(true,"");
} catch (Exception e) {
e.printStackTrace();
return new SuccessMessage(false,"保存失敗");
}
//添加方法 結束 -↑-
}
請檢查傳入的參數中是否有@RequestBody註解。
6.在做刪除方法時,遇到java NullPointerException(空指針異常)
請檢查前端參數與後臺參數的名稱是否一致。
7.在前端js代碼分層時,遇到無法讀取未定義的“success”
//前臺報錯信息
angular.min.js:80 TypeError:
Cannot read property 'success' of undefined
at a.$scope.search (brandController.js:75)
at a.$scope.reloadList (baseController.js:6)
at Object.onChange (baseController.js:15)
未在方法前加return 返回。則會報無法定義success。
//搜索
this.search=function (page,size,searchEntity) {
return $http.post("../brand/search.do?page=" +
page + "&size=" + size, searchEntity);
};
調用JS的service層 沒有return返回值
8.、在前端js代碼分成時,遇到前臺報$scope未定義
//代碼示例
app.service("brandService",function ($http) {
//讀取列表數據綁定到表單中
this.findAll=function () {
//.get獲取後端控制器層的方法
return $http.get("../brand/findAll.do");
};
在服務處js頁面,方法的調取應該使用 this. 而非$scope.
9.在做新增規格選項時,定義方法後,按鈕無法使用。控制檯報錯。
angular.min.js:80 TypeError:
Cannot read property 'specificationOptionList' of undefined
at h.$scope.addTableRow (specificationController.js:82)
at angular.min.js:158
at angular.min.js:175
at h.$eval (angular.min.js:98)
at h.$apply (angular.min.js:99)
at HTMLButtonElement.<anonymous> (angular.min.js:175)
at HTMLButtonElement.dispatch (jquery-2.2.3.min.js:3)
at HTMLButtonElement.r.handle (jquery-2.2.3.min.js:3)
查看specificationController.js第82行,
$scope.entity.specificationOptionList.push({});爲null值,需要定義後方可使用。
//修改後代碼
$scope.entity={specificationOptionList:[]};
$scope.addTableRow=function(){
$scope.entity.specificationOptionList.push({});
}
10、在登陸後臺時,報錯 “創建名爲…的bean時出錯”。
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#6':
重啓虛擬機,重啓idea即可。
11、在做solr添加索引時遇到Document is missing mandatory uniqueKey field: id(文檔缺少必需的uniquekey字段:id)
public void importItemData(){
TbItemExample example=new TbItemExample();
TbItemExample.Criteria criteria = example.createCriteria();
criteria.andStatusEqualTo("1");//審覈通過
List<TbItem> itemList = itemMapper.selectByExample(example);
System.out.println("---商品列表---");
for (TbItem tbItem : itemList) {
System.out.println(tbItem.getId()+"---"+tbItem.getTitle()+"---"+tbItem.getPrice());
}
solrTemplate.saveBeans(itemList);
solrTemplate.commit();
}
問題就出在solrTemplate.saveBean(selectByExample);這段代碼上導致了Document is missing mandatory uniqueKey field: id這個錯誤信息,正確的是solrTemplate.saveBeans(selectByExample);這個錯誤很尷尬,由於兩個方法很相似,調用的時候要看仔細。