品优购商城项目常见BUG解析
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-managerweb&dubbo=2.8.4&interface=com.pinyougou.sellergoods.service.BrandService&methods=updat e,get,delete,selectOptionList,add,getListByPage&pid=3980&revision=0.0.1SNAPSHOT&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 undefinedat 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:
查看specificationController.js第82行,
$scope.entity.specificationOptionList.push({});為null值,需要定義后方可使用。
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);這個錯誤很尷尬,由于兩個方法很相似,調用的時候要看仔細。
總結
以上是生活随笔為你收集整理的品优购商城项目常见BUG解析的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Springboot+vue项目体用用品
- 下一篇: Verilog实现移位寄存器