본문 바로가기

BACK-END5

Spring Boot : application.properties 대신 application.yml 사용하기 application.properties는 Spring Boot사용시 여러 설정값을 정의할 수 있는 파일입니다. 일반적으로 서버포트,DB 연결정보,로그설정등을 작성해서 사용합니다. 저도 기존에는 application.properties를 사용했었는데 이번에 application.yml을 사용해보았습니다. 둘은 작성 형식만 다를뿐 같은 기능을 한다고 생각하면 됩니다. application.properties #JSP (ViewResolver) spring.mvc.view.prefix= /WEB-INF/views/ spring.mvc.view.suffix: .jsp #DB spring.datasource.url: jdbc:postgresql://localhost:5432/postgres spring.data.. 2022. 12. 19.
STS : lombok(롬복) 설치 후 사용하기 lombok(롬복)은 코드 경량화에 유용한 라이브러리 중 하나입니다. 자바 개발시 필수적인 getter/setter의 사용을 아주 편리하게 만들어줍니다. 추가적으로 로깅(logging)도 편리하게 사용할 수있습니다. Project Lombok is a java library that automatically plugs into your editor and build tools, spicing up your java. Never write another getter or equals method again, with one annotation your class has a fully featured builder, Automate your logging variables, and much more. 롬복(.. 2022. 12. 15.
Spring Boot : jdbcTemplate을 이용한 PostgreSQL DB연동법 지난번 글에서 로컬에 PostgreSQL을 설치하고 DBeaver를 이용해 사용해봤으니 이번에는 PostgreSQL을 JAVA와 연결해보겠습니다. 2022.12.05 - [DATABASE] - PostgreSQL 15.1 설치 (Windows) PostgreSQL 15.1 설치 (Windows) PostgreSQL은 오픈소스 DBMS입니다. Oracle DB, MySQL, Microsoft SQL에 이어 많이 사용되는 DBMS로 알려져 있습니다. PostgreSQL is a powerful, open source object-relational database system with over 35 years of active development that ha devnam.tistory.com 2022.1.. 2022. 12. 9.
Spring Boot Appliction이 구동 될 때 실행되는 코드 추가하기 Spring Boot에서 SpringApplication이 구동 될 때 특정 코드를 실행하고 싶으면 ApplicationRunner, CommandLineRunner를 사용하면됩니다. 둘다 run 매서드 내부에 구현한 코드를 SpringApplication 구동시 실행하지만 차이점은 arguments를 받는 Parameter에 있습니다. ApplicationRunner : ApplicationArguments CommandLineRunner : String... (String 배열) ApplicationRunner 구현 package devnam.tistory.com; import org.springframework.boot.ApplicationArguments; import org.springframe.. 2022. 12. 7.
Java list 동일한 크기로 분할 나누기 (Guava) 자바 리스트(list)에 담겨있는 내용을 일정크기로 분할해서 리스트에 담고싶을때 사용하면 편리한 library가 있습니다. 바로 구글 Guava 입니다. guava의 partition 함수를 이용하면 편리하게 list를 분할할 수 있습니다. 설정 //pom.xml com.google.guava guava 31.1-jre //build.gradle dependencies { // Pick one: // 1. Use Guava in your implementation only: implementation("com.google.guava:guava:31.1-jre") // 2. Use Guava types in your public API: api("com.google.guava:guava:31.1-jre").. 2022. 12. 5.