SpringBoot

BaseTimeEntity JPA에서 자동으로 생성일자 , 수정일자를 만들어 주는 추상 클래스 @MappedSuperclass @EntityListeners 자동으로 생성일자 / 수정일자 컬럼을 sql문에 추가시키는 어노테이션 @Getter // TODO : 자동을 생성일자 / 수정일자 컬럼을 sql 문에 추가시키는 어노테이션 2개 @MappedSuperclass @EntityListeners(AuditingEntityListener.class) public abstract class BaseTimeEntity { // TODO : 단점 // TODO: 공통속성 : yyyy-MM-dd HH:mm:ss 이 패턴이 아닌 기본 패턴으로 보임 private String insertTime; private Str..
JPA 란? ORM (Object - Relational Mapping) 프레임 워크 build.gradle 사용 // logback , log4jdbc 설정 implementation 'org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4.1:1.16' implementation 'ch.qos.logback:logback-classic:1.2.11' implementation 'org.slf4j:slf4j-api:1.7.36' implementation 'org.slf4j:jcl-over-slf4j:1.7.36' //TODO: Jpa 라이브러리 implementation 'org.springframework.boot:spring-boot-starter-data-jpa' a..
· SpringBoot
common 패키지 https://tinylittlelife.tistory.com/219 vo 패키지 Emp (EmpVo) @Getter @Setter @ToString @NoArgsConstructor @AllArgsConstructor public class Emp extends BaseTimeEntity { private Long eno; private String ename; private String job; private Long manager; private String hiredate; private Long salary; private Long commission; private Long dno; } EmpDao @Mapper ..
다이나믹 SQL 상황에 따라서 조건을 다르게 주고싶을때 사용한다. ♠ \ 참조 / ♠ ( 1 ) xml 파일에서 if 문 활용 가능 ( 2 ) 롬복 , 로그백 사용 https://tinylittlelife.tistory.com/209 HTML에서 검색창 SELECT BOX를 열어서 이름 또는 부서위치로 검색을 하고 싶을때 한번에 하는 법 basetime https://tinylittlelife.tistory.com/212 페이징 처리 vo https://tinylittlelife.tistory.com/220 Dept vo @Getter @Setter @ToString @NoArgsConstructor @AllArgsConstructor public class D..
MyBatis ( 1 ) 편리하다 옛날 코딩 sql = "select * + ... "from table" + ... ( 2 ) 약간 내 생각인데.. view → Controller → Service → Dao → resources/mappers/.xml(변환) → DB MyBatis 설정 https://tinylittlelife.tistory.com/217 resources/mappers/table명(소문자).xml 폴더명 특징 common 공통 xml 파일 넣는곳 xml파일 정의 ( 이것은 MyBatis여! ) 조회 (get 방식) 예시 ( Like 검색 )..
페이징 처리 JSP 와 같은 SSR 에서의 페이징처리는 조금 까다로운데요. React 와 같은 CSR 에서의 페이징처리는 라이브러리를 사용하면 됩니다만.. JSP에선 그럴 수 없죠.. 결과화면은 밑과 같습니다. PageReq @Getter @Setter @ToString @NoArgsConstructor //@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) public class PageReq { /** 현재 페이지 번호 : page == number */ private int page; /** 페이지당 출력할 데이터 개수 */ private int size; //offset 개수 : 1st 데이터로 부터 얼마나 떨어져 있는지 개수 //privat..
model / common 패키지 ( 공통 클래스 ) ( 등록일 , 수정일 같은 공통 클래스를 만드는 곳 ) 등록일 수정일 저장 https://tinylittlelife.tistory.com/212 페이징 처리 ( React 상관 x ) https://tinylittlelife.tistory.com/220
Optional Null 값 방지 용도 자바 클래스 https://tinylittlelife.tistory.com/153 선택 조회시 ( 1건 조회 ) Service Optional.ofNullable() /** * id(기본키)로 조회 : 상세조회(1건 조회) * 기능 업그레이드 null 방지 * @param dno * @return */ public Optional findById(long 기본키) { 객체 객체변수 = deptDao.selectById(기본키); Optional optionalDept = Optional.ofNullable(객체변수); return optionalDept; } Controller get() @GetMapping("/경로/{기본키}") public Resp..
Form 태그 정의 get(select) , post(insert) , put(update) , delete(delete) 다만 JSP - put , delete 방식은 HTML 에서 지원을 안함 따라서 application.properties # PUT , DELETE 방식도 form 에서 사용할 수 있게 만들어줌 spring.mvc.hiddenmethod.filter.enabled=true HTML HTML Delete Submit 태그 기본기능 - 해당 url 이동됨 ( Submit 버튼은 페이지 이동이 일어남 )
RedirectView view 페이지 강제 이동 ( 페이지를 Redirect 시킴 ) ( jsp 같은 얘들이 사용 ) 정의 return new RedirectView("페이지경로"); JSP 예제 ( 데이터 저장 후 페이지 강제 이동시키기 ) Controller // TODO: 저장 클릭시 db 저장하기 함수 @PostMapping("경로") public RedirectView create(@ModelAttribute 객체 객체변수) { // TODO : 서비스의 저장함수 객체Service.save(객체변수); return new RedirectView("페이지경로"); } view ( form 입력양식 ) ( BootStrap 사용 ) 부서 이름 부서 위치 Submit
@ResponseBody 정의 함수의 결과로 json 데이터를 리턴하고자 할때 사용하는 어노테이션 ( 함수의 위에 붙이기 ) ( RestController가 붙어 있으면 @ResponseBody가 따라오기 때문에 않붙여도 됨 ) @PostMapping("경로") @ResponseBody public List 함수명(@RequestBody 객체 변수) { return ; }
model / common 패키지 ( 공통 클래스 ) ( 등록일 , 수정일 같은 공통 클래스를 만드는 곳 ) 예제 코드 (수정 필요) @Getter @Setter @ToString public class BaseTimeEntity { /** 등록일 */ private String insertTime; /** 수정일 */ private String updateTime; // 초기값 저장 public BaseTimeEntity() { this.insertTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));; this.updateTime = LocalDateTime.now().format(DateTimeFor..
별이춤추는밤
'SpringBoot' 카테고리의 글 목록 (4 Page)