반응형 Programing/Springboot39 Gradle 파일 변수 설정 및 활용 Gradle 파일의 변수를 설정하는 방법을 알아보겠습니다. 변수 선언은 buildscript의 ext 를 활용합니다. buildscript { ext { springBootVersion = "3.1.4" } } 여러개의 변수를 사용하는 경우는 ',' 없이 아래로 붙여서 사용하시면 됩니다. buildscript { ext { springBootVersion = "3.1.4" queryDslVersion = "5.0.0" } } 선언 된 변수는 "${}" 를 써서 사용할 수 있습니다. plugins { id 'java' id 'org.springframework.boot' version "${springBootVersion}" } single quotation (') 을 사용하면 제대로 동작하지 않으니 do.. Programing/Springboot 2023. 12. 6. spring boot + JPA + Tibero 연동 설정 spring boot 2.x와 JPA 설정은 다른 데이터베이스와 같습니다. 이번 포스팅에서는 살짝 차이가 있는 Tibero 연동을 주로 보도록 하겠습니다. (6.x 버전 기준) Tibero의 경우 JDBC는 Tibero 설치 경로의 /client/lib/jar 에 있는 tibero6-jdbc.jar 파일이 필요합니다. 해당 파일을 복사하여 프로젝트의 최상위 libs 폴더에 붙여넣고 gradle 에 jar 파일을 읽을 수 있도록 설정합니다. implementation fileTree(dir: 'libs', include: ['*.jar']) 그리고 spring-boot-starter-data-jdbc 의존성이 추가 되어 있다면 제거를 해줍니다. implementation 'org.springframewor.. Programing/Springboot 2023. 10. 5. Spring boot 실행 시 경고 문구 해결 방법 You are asking Spring Security to ignore Ant [pattern='/favicon.ico']. This is not recommended -- please use permitAll via HttpSecurity#authorizeHttpRequests instead. [발생 원인] web.ignoring()을 사용할 경우 spring security의 보호를 받을 수 없기 때문에 authorizeHttpRequests().permitAll 에 추가하여 설정하는 방식으로 변경 [경고 발생 코드] @Bean public WebSecurityCustomizer webSecurityCustomizer() { return (web) -> web.ignoring() .antMatche.. Programing/Springboot 2023. 8. 18. [API documentation 자동화] spring boot swagger UI 적용 방법 API의 Document를 자동으로 제공해주는 swagger UI 설정방법을 알아보겠습니다. springboot 2.7.7 springsecurity gradle 1. dependencies 를 추가 /*swagger*/ implementation group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0' /*security*/ implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '2.7.5' 2.WebMvcConfig.java 생성 import org.springframework.context.annotation... Programing/Springboot 2023. 1. 26. SpringBoot + JWT + Security + JPA 인증 구현, JWT란? 해당 포스팅은 인프런의 무료강의를 참고하여 작성되었습니다. Link: https://www.inflearn.com/course/%EC%8A%A4%ED%94%84%EB%A7%81%EB%B6%80%ED%8A%B8-jwt/dashboard 이해하기 쉽게 설명되어 있으니 참고하시면 좋을 것 같습니다. Link: https://jwt.io/ JWT.IO JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. jwt.io 1. JWT (Json Web Tokens) 란? JWT는 RFC 7519 웹 표준으로 지정된 JSON 객체를 사용해서 토큰 자체에 정보를 저장.. Programing/Springboot 2022. 11. 14. SpringBoot RestAPI 404 Not Found message Custom, @ControllerAdvice @ExceptionHandler SpringBoot 로 API를 개발할 때 RequestMapping 되어있지 않은 주소로 요청하면 아래와 같은 에러 메시지를 전송합니다. { "timestamp": "2022-11-09T09:35:14.441+00:00", "status": 404, "error": "Not Found", "message": "No message available", "path": "/api/" } 기존에 API 에서 전송하던 구조와 다르면 제공받는 입장에서도 처리하기 껄끄럽기 때문에 기존 응답 구조에 맞게 설정을 해주는 것이 좋습니다. 그럼 응답 구조에 맞게 처리하는 방법을 알아보겠습니다. 우선 application.yml 파일에 설정을 추가해 주어야 합니다. 1. spring boot properties 설정 [ap.. Programing/Springboot 2022. 11. 9. Spring Boot Banner 변경하기, 배너 변경하기 Spring Boot 프로젝트가 실행이 되면 위와 같은 베너가 출력되는 것을 보신적이 있으실꺼에요. 이번 포스팅에서는 요 베너를 변경하는 방법을 알아보겠습니다. 1.banner.txt 생성 Spring Boot 프로젝트에서 배너는 resources 하위에 banner.txt 파일의 텍스트를 읽어 출력합니다. 해당 경로에 파일을 추가해 줍니다. 2.banner 텍스트 복사 Link : http://patorjk.com/software/taag/ Text to ASCII Art Generator (TAAG) patorjk.com 위 사이트로 이동하여 텍스트를 입력하고 Test All 버튼을 클릭합니다. 그럼 아래와 같이 모든 텍스트가 출력됩니다. 마음에 드는 것을 골라 Select & Copy 버튼을 클릭하.. Programing/Springboot 2022. 11. 8. gradle project 배포 시 compiler error 해결 방법 gradle project 배포 시 compiler error 해결 방법 gradle 프로젝트 배포 시 Gradle tasks에서 compile 에러가 발생하는 경우가 있습니다. 에러 코드 전체 에러 코드는 아래의 '더보기'를 클릭하세요! 더보기 org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileJava'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:147) at org.gradle.internal.Try$Failure.ifSucce.. Programing/Springboot 2022. 9. 26. Spring lombok @RequiredArgsConstructor Spring lombok @RequiredArgsConstructor @RequiredArgsConstructor 은 lombok 에서 제공하는 annotation입니다. 이 annotation을 추가하게 되면 클래스의 final 이나 @NonNull인 필드값을 파라미터로 받는 생성자를 자동으로 만들어 줍니다. 예를들어 아래와 같이 User 라는 클래스가 있을 때 클래스 변수를 초기화하지 않고 final로 설정하면 반드시 생성자가 필요하게됩니다. (Spring 에서는 getter/setter 보다는 생성자 주입 방식을 권장합니다.) public class User { private final String userId; private final String userName; @NonNull private .. Programing/Springboot 2022. 6. 28. ajax formData file upload 시 MultipartFile 로 못받는 이유 ajax formData file upload 시 MultipartFile 로 못받는 이유 보통 프론트엔드에서 ajax를 활용해 파일을 서버로 보낼 때는 FormData를 활용합니다. formData 에 파일을 append 하거나 해당 form을 그대로 POST Method로 전송하죠. const formData = new FormData(); const files = document.querySelector("#files").files; for(let file of files){ formData.append("files", file); } 서버에서는 다양한 방식으로 MultipartFile을 받게됩니다. @PostMapping("/upload.do") public String uploadFile(@Re.. Programing/Springboot 2022. 5. 30. 이클립스 Springboot Junit 사용 방법 이클립스 Springboot Junit 사용 방법 JUnit 이란? JUnit은 Java의 단위테스트(Unit Test) 프레임워크 입니다. 어플리케이션 실행과 별도로 동작하기 때문에 매번 메소드의 결과를 디버깅 하지 않아도 되는 편리함을 제공합니다. Springboot project 생성 spring initiallizr 에서 프로젝트를 다운로드하여 이클립스에 추가해줍니다. 프로젝트 추가방법을 아래의 Link를 참고하세요! Link : https://aljjabaegi.tistory.com/480 Eclipse Spring boot Gradle 프로젝트 간단 생성 방법 Eclipse Spring boot Gradle 프로젝트 간단 생성 방법 원래는 간단 합니다. 이클립스 좌측 Project Explor.. Programing/Springboot 2022. 5. 26. springboot properties to yml, yml 파일로 변경, profiles 설정 springboot properties to yml, yml 파일로 변경, profiles 설정 springboot의 설정파일인 application.properties 파일을 application.yml 로 변경하는 방법을 알아보겠습니다. properties, yml 차이 properties 파일은 key=value 의 구조를 갖고 yml 파일은 properties 파일에서 반복되는 접두사를 줄인 계층적 구성을 가지고 있습니다. 두 파일 데이터의 차이를 보시죠. List 구조 방식에서도 차이를 보입니다. proflie 설정에서도 차이를 보입니다. properties의 경우 파일을 분리하여 proflie 설정을 해야 했지만, yml은 한 파일 내에서 profile 분기가 가능합니다. --- 구분자를 사용.. Programing/Springboot 2022. 5. 18. WebServerException: Unable to create tempDir 해결방법 WebServerException: Unable to create tempDir 해결방법 가상화 서버 재부팅 후 발생한 에러입니다. 잘 부팅되던 Springboot API 서버가 OS 재부팅 후 아래와 같은 에러 메시지를 출력했습니다. org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to create tempDir. java.io.tmpdir is set to C:\Users\ADMINI~1\AppData\Local\Temp\2\ Caused by: org.. Programing/Springboot 2022. 3. 31. Spring Boot Embeded Tomcat 내장 톰캣 application.properties 설정 Spring Boot Embeded Tomcat 내장 톰캣 application.properties 설정 이번 포스팅에서는 Spring Boot 2.x 의 application.properties 에서 설정가능한 내장 톰캣 옵션에 대해서 알아보도록 하겠습니다. Connection 관련 설정 설명 기본값 server.tomcat.connection-timeout 커넥션 타임아웃 설정 server.tomcat.keep-alive-timeout 커넥션 종료 전 다른 HTTP 요청을 기다리는 시간 설정 설정하지 않으면 connection-timeout 이 사용, -1이면 무한 100 server.tomcat.max-connections 서버가 주어진 시간에 처리할 수 있는 최대 커넥션 설정 8192 Thread.. Programing/Springboot 2022. 2. 3. SpringBoot AOP 활용 / 모든 응답 데이터에 접근 SpringBoot AOP 활용 / 모든 응답 데이터에 접근 이번 포스팅에서는 서버의 응답 데이터 접근하는 방법을 알아보겠습니다. AOP 기능을 활용할건데요, AOP에 대한 설명은 아래의 링크를 확인하세요. Link : https://aljjabaegi.tistory.com/278 AOP 설정을 활용한 세션체크 AOP Session Check AOP 설정을 활용한 세션체크 AOP Session Check /****20170331 update ********/ 세션체크는 AOP를 활용한 방식보다는 Interceptor를 활용하는 방식을 추천합니다. Link : Spring Interceptor 활용 세션 설정 ajax.. aljjabaegi.tistory.com 간단하게 AOP는 Aspect-Oriente.. Programing/Springboot 2021. 12. 15. 이전 1 2 3 다음 💲 추천 글 반응형