Programming/SpringBoot
-
[Spring] dataSource or dataSourceClassName or jdbcUrl is required.Programming/SpringBoot 2024. 5. 11. 13:56
java.lang.IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required. DB연결을 하기 위해 DatabaseConfig파일을 만들고 Bean으로 만들려고 하는데 발생한 에러! 찾아본 결과 스프링 커넥션 풀의 차이에서 나타났는데SrpingBoot 2.0이전에는 tomcat-jdbc 를 사용하다, 2.0이후에는 HikariCP를 기본옵션으로 채택하고 있다. 그렇기 때문에 설정 방식에 조금 차이가 있다. 1. application.properties 파일url을 jdbc-url로 수정spring.datasource.url -> spring.datasource.jdbc-urlHikariCP의 Database URL설..
-
[Spring] bean 라이프 사이클Programming/SpringBoot 2024. 5. 9. 11:29
Bean자바 어플리케이션의 객체들은 독립적으로 동작하는 것 보다 서로 상화작용하여 동작하는 경우가 많은데 이를 "객체의 의존성"이라고 표현한다.스프링에서는 스프링 컨테이너에 객체들을 생성하면 객체끼리 의존성을 주입(Dependency Injection)하는 역할을 한다.스프링 컨테이너에 등록한 객체들을 "빈"이라고 한다. 스프링 컨테이너에 Bean을 등록하는 2가지 방법1. 컴포넌트 스캔과 자동 의존관계 설정2. 자바 코드로 직접 스프링 빈 등록 1. 컴포넌트 스캔과 자동 의존관계 설정스프링 부트에서 사용자 클래스를 스프링 빈으로 등록하는 가장 쉬운 방법클래스 선언부 위에 @Component 어노테이션을 사용하는 것이다.@Controller, @Service, @Repository 모두 @Componen..
-
[Network] Proxy, Reverse ProxyProgramming/SpringBoot 2024. 4. 3. 16:35
proxy란? "대리"라는 의미로 내부 네트워크에서 인터넷 접속을 할 때 빠른 액세스나 안전한 통신 등을 확보하기 위한 중계 서버를 "프록시 서버"라고 한다. proxy server 서버와 클라이언트 사이에 중계기로, 대리로 통신을 수행하는 것 클라이언트와 웹 서버간의 중개자 역할을 하는 서버이다. 프록시 서버는 크게 포워드 프록시, 리버스 프록시로 나뉜다. - 포워드 프록시는 클라이언트 - 리버스 프록시는 서버쪽의 설정을 한다. Forward Proxy 우리가 흔히 말하는 '프록시 서버'란 포워드 프록시 서버를 의미한다. 프록시 서버는 클라이언트 앞에 놓여 있다. 클라이언트가 웹 서버에 요청을 보내면 중간에서 그 요청을 프록시 서버가 가로챈다. 프록시 서버는 해당 요청을 웹 서버에게 다시 보내고, 웹 ..
-
[CS] 웹 서비스 구조Programming/SpringBoot 2024. 3. 27. 18:30
정적 페이지 (Static Pages) 데이터베이스에서 정보를 가져오거나 등 별도의 서버에서의 처리가 없어도, 사용자들에게 보여줄 수 있는 페이지. 어떠한 사용자가 오던간에 동일한 페이지를 보여준다. Ex) image, html, css, javascript 파일과 같이 컴퓨터에 저장되어 있는 파일들 동적 페이지 (Dynamic Pages) 서버의 데이터베이스에서 정보를 가져와서 처리하는 것처럼, 어떠한 요청에 의하여 서버가 일을 수행하고 해당 결과가 포함된 파일을 보여주는 페이지. 사용자들마다 다른 페이지가 보여질 수 있다. Web Server 클라이언트의 요청에 따라 정적 파일을 응답하여 제공하는 소프트웨어 nginx WAS (Web Application Server) 클라이언트의 요청에 대해 동적인..
-
-
[SpringBoot] Lombok 롬복Programming/SpringBoot 2023. 12. 7. 16:07
Lombok이란 코드를 간소화해 주는 라이브러리입니다. 자바의 라이브러리로 반복되는 메소드를 Annotation을 사용해서 자동으로 작성해주는 라이브러리입니다. Lombok을 이용해서 작성한 코드는 컴파일 과정에서 Annotataion을 이용해서 코드를 생성하고 .class에 자동 컴파일 됩니다. Lombok 설치 프로젝트 탐색기에서 firstproject > src >build.gradle 파일에서 설정 코드를 작성합니다. dependencies { compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' } 편집기에 코끼리 모양의 새로고침 아이콘을 클릭합니다. 롬복 라이브러리가 다운로드 되는지 확인합니다...
-
[SpringBoot] JPAProgramming/SpringBoot 2023. 12. 7. 15:12
JPA Java Persisitence API는 자바 진영의 ORM기술 표준입니다. - ORM (Object Relational Mapping) : 객체와 테이블을 매핑해서 패러다임의 불일치를 개발자 대신 해결 DB에 데이터를 기록해야 할때, 자바 언어로 저장할 수 없습니다. DB는 SQL언어를 사용하기 때문입니다. JPA는 자바 언어로 DB에 명령을 내리는 도구입니다. 데이터를 객체 지향적으로 관리할 수 있게 해줍니다. JPA의 핵심 도구로는 엔티티와 리파지터리가 있습니다. Entity 자바 객체를 DB가 이해할 수 있게 만든 것으로, 이를 기반으로 테이블이 만들어집니다. Repository 엔티티가 DB속 테이블에 저장 및 관리될 수 있게 하는 인터페이스 1. DTO를 엔티티로 변환하기 2. 리파지터..
-
[SpringBoot] MVC패턴 + REST API + JPA 프로젝트 설계Programming/SpringBoot 2023. 12. 7. 14:09
MVC + JPA 프로젝트 설계 Form을 사용한 웹 설계는 아래와 같습니다. REST API를 사용하지 않는다면 응답을 뷰 템플릿으로 하게 됩니다. MVC + REST API + JPA 프로젝트 설계 REST API를 사용하면 요청과 응답 데이터가 대표적으로 JSON을 사용하여 통신하게 됩니다. 클라이언트와 서버 간 처리 흐름은 크게 4가지로 나눌 수 있습니다. - MVC (Model-View-Controller) : 서버 역할을 분담해 처리하는 기법 - JPA (Java Persisitence API) : 서버와 DB간 소통에 관여하는 기술 - SQL (Structured Query Language) : DB데이터를 관리하는 언어 - HTTP (HpyterText Transfer Protocol) :..