자바 프로젝트 노트(1)

4813 단어 springbootJava
1.springboot 콘 솔 에서 sql 로 그 를 인쇄 합 니 다.
logging.level.---------.mapper = debug

2.프론트 엔 드 에서 백 엔 드 로 전 달 된 json 을 자바 대상 json 으로 변환 합 니 다.프론트 엔 드 에서 정 의 된 json 문자열 의 변수 이름 ProductRecord.class:변환 하고 싶 은 대상.class 에 대응 합 니 다.
 
        com.alibaba
        fastjson
        1.2.47
    


ProductRecord productRecord = JSON.parseObject(json, ProductRecord.class);

전단 전송 대상 배경 이 string 형식 으로 수신 되면 해결 방법:
public  ResponseState createOrder(Orders orders,
	@RequestParam(value = "listOrderProduct",required = true) String listOrderProduct){
    JSONArray arrayList= JSONArray.parseArray(listOrderProduct);   //  string  JSONArray  。
    List list = JSONObject.parseArray(arrayList.toJSONString(),OrderProduct.class); //         list,OrderProduct     。
    return orderService.createOrder(orders,list);
}

3.전단 전송 대상 과 json 을 해결 하고 배경 수신 은 null 입 니 다.
@RequestMapping    produces="application/json; utf-8"

4.배경 에서 집합 을 받 아 이상 한 java.lang.NoSuchMethodException:java.util.List.()해결 방법 추가@RequestParam(value="list",required=true)List list list
5.for,foreach,Iterator 서로 다른 데이터 구조 스 트 리밍 시간 테스트
         ,       ,for            
LinkedList linkedList = new LinkedList();
    for (int i =0;i<10000;i++){
        linkedList.add(i);
    }
    
         ,        ,            
 ArrayList linkedList = new ArrayList();
    for (int i =0;i<1000000;i++){
        linkedList.add(i);
    }
    
foreach Iterator  ,               

6.springboot 전역 날짜 포맷 설정
#jackson    
spring.jackson.date-format = yyyy-MM-dd HH:mm:ss
#       
spring.jackson.time-zone= GMT+8
#ALWAYS         null,        key,  yml          
spring.jackson.default-property-inclusion=ALWAYS

7.인터페이스 테스트 에서 한 가지 문 제 를 발 견 했 는데 두 개의 실체 류 는 계승 관계 가 있 고 그 중의 한 실체 류 는 list 집합 이 있다.이 때 인 터 페 이 스 는 list 집합 을 전송 해 야 합 니 다.만약 에 이 두 list 집합 변수 이름 이 바 뀌 면 이 매개 변수 list 집합 을 옮 겨 다 닐 때 집합 에 몇 개의 데이터 가 있 든 list.size 는 항상 2 와 같 습 니 다.이때 list 의 데 이 터 는 하나의 데이터 로 데이터베이스 에 저장 되 고 두 번 순환 합 니 다!해결 방법 은 변수 이름 을 바 꾸 어 이름 을 바 꾸 는 것 을 방지 하 는 것 이다.
8.Swagger 를 집합 할 때:오류 스 택 이 넘 쳤 습 니 다.코드 와 swagger 가 충돌 하여 무한 재 귀(1)를 초래 했 을 수 있 습 니 다.인터페이스 에 있 는 매개 변수 에서 실체 류 를 인용 하지 말고 가능 한 한 json 을 사용 하 십시오.(2)코드 논리 에 서 는 다 중 집합 을 하지 않도록 한다.해결 방법:시작 클래스 의@Enable Swagger 2 를 설명 하고 코드 논 리 를 바 꾸 겠 습 니 다.그만 두 겠 습 니 다.
org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is com.google.common.util.concurrent.ExecutionError: java.lang.StackOverflowError

java.lang.Stack Overflow Error 가 이 이상 한 이 유 를 던 졌 습 니 다.Jvm 스 레 드 가 요청 한 스 택 깊이 는 가상 컴퓨터 가 허용 하 는 깊이 보다 큽 니 다.
9.포획 이상
package rongheng.member.controller;

import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import rongheng.member.entity.ResponseState;

import javax.servlet.http.HttpServletRequest;

@ControllerAdvice
public class GlobalDefaultExceptionHandler{
	/**
	 * @RequiresPermissions("user:updateSysUser")        
	 * @param req
	 * @param e
	 * @return
	 */
	 @ExceptionHandler(UnauthorizedException.class)
     @ResponseBody
     public Object defaultExceptionHandler(HttpServletRequest req,Exception e){
		 ResponseState responseState = new ResponseState();
		 responseState.setState("403");
		 responseState.setMsg("   ,    !");
		return responseState;
     }
}

10.springboot 열 배치
#       
spring.devtools.restart.enabled=true
#       ,      
spring.freemarker.cache=false


    
        org.springframework.boot
        spring-boot-devtools
        true
        true
    
    
 
        vip
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
            
                
                org.springframework.boot
                spring-boot-maven-plugin
                
                    
                    true
                
            
        
    

좋은 웹페이지 즐겨찾기