:::: 개발 :::: 452

JAVA 트리(tree) 이해하기 1

public class Node { // 맴버 변수 선언 private Node left; private Node right; private Object data; //생성자 public Node(Object data){ this.data = data; } // 노드 왼쪽 자식노드와 연결해주는 메소드 public void makeLeftSubTree(Node sub){ if(this.left != null){ this.left = null; } this.left = sub; } // 노드 오른쪽 자식 노드와 연결해주느 메소드 public void makeRightSubTree(Node sub){ if(this.right != null){ this.right = null; } this.right = sub..

spring boot 로딩된 bean 목록 출력 소스...

이클립스에서 분명 사용하는 bean 리스트를 본것 같은데.. 아무리 찾아도 안나옴.. 그래서 로딩된 bean 목록 출력하는것 소스 import org.springframework.beans.factory.support.DefaultListableBeanFactory; public class RestController { @Autowired private DefaultListableBeanFactory dfBean; @GetMapping("/webportalif/getbean") public void getBean () { for(String name : dfBean.getBeanDefinitionNames()) { log.info(" INFO BEAN NAME === "+name); } } } 출력.. ..

spring boot rest api 애러 처리

기본 설계가 없는 플젝 빠르게 만들고 있는데 개발만 빨리 해달라더니.. 빠르게 하니 이것저것 요구하고 있음요 기분좋게 해야 되는데 왜케 구찮을까요~~ㅎㅎ 인터셉터 사용 HandlerInterceptorAdapter 상속받은 클래스에서 preHandle 인터셉터 에서 애러가 발생 return false; 해주면 그 상태에서 모든게 끝난다 @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if(토큰이 없다면) { log.debug(" AuthKey empty"); response.sendError(HttpStatus.UNAUTHOR..

@ResponseBody response 처리 혹은 예외 처리

여러 디비 거쳐서 합친 리스트 데이터라 개 귀찮아서 Dto 안만든고 그대로 뿌린다고 @ResponseBody 로 뿌렸다 근데 특정 애러면 바로 404 로 http 응답해주라는 요청.. HttpServletResponse response 파라미터 받아서 response.sendError 애러 처리 하려고 했는데 리턴값 어쩌고 ..애러 발생... 폭풍검새 해결코드 !!! ㅎㅎㅎㅎㅎ @ResponseBody public Map 메서드() throws NotFoundException { if(1){ return map; }else{ throw new NotFoundException(); } } @ResponseStatus(code = HttpStatus.NOT_FOUND, reason = "Not Found")..

spring @RequestBody Map<String, Object> Json 핸들링

{ "id":"test", "status": { "location":"E1", "mode":"2", "starttime":"2020/09/30 12:20:00", "endtime":"2020/09/30 13:50:00" }, "time":"2020/09/01 11:14:12" } 위 json 넘어온 데이터 스프링 컨트롤러에서 받아서. public test (@RequestBody Map param) { } 넘어온 값을 아래처럼 json 다시 만들고 싶을때 { "id":"test", "status": { "location":"E1", "mode":"2", "starttime":"2020/09/30 12:20:00", "endtime":"2020/09/30 13:50:00" }, "reg":{ "id": "..

스프링 부트(Spring Boot) - 인터셉터(Interceptor)

뭔가 인증할때 구현하면 개 편함 api 요청전 키 검증용으로 진행 @Bean public RestApiInterceptor restApiInterceptor() { return new RestApiInterceptor(); } 빈 생성 // Interceptor 등록 @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(restApiInterceptor()).addPathPatterns("/api/v1/**"); } public class RestApiInterceptor extends HandlerInterceptorAdapter { private static final Logger log..

spring boot Quartz @service 에 적용하기..

스프링부트( Quartz ) 서비스 스케쥴 기능 적용 시키기.. 스프링 부트 시작하는 Class 에서 @EnableScheduling @EnableScheduling public class Application{ .... } 실제 스케쥴이 실행 되어야 할 서비스에 @Scheduled(cron = "0 * * * * MON-FRI") 적용 @Service public class MyService{ ... @Scheduled(cron = "0 * * * * MON-FRI") public void myScheduledMethod(){ .... } 매우~ ~ 심플 ㅎㅎ