Spring Boot Web 프로젝트에서 JSP 적용하기
·
Spring
1. Gradle 의존성 추가build.gradle에 JSP를 사용하기 위한 의존성을 추가dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' // Spring Web 기본 의존성 implementation 'org.apache.tomcat.embed:tomcat-embed-jasper' // JSP 렌더링을 위한 Tomcat Jasper implementation 'javax.servlet:jstl:1.2' // JSTL 지원}tomcat-embed-jasper:JSP를 처리하기 위한 Jasper JSP 엔진.jstl:JSP에서 JSTL 태그를 사용할 수 있도록 지원.2. 디렉터리 구조 설정Spr..
Spring Web - Controller와 RestController
·
Spring
어노테이션 간단 비교:@Controller = 웹 페이지 반환용 컨트롤러.@RestController = 데이터(JSON/XML) 반환용 컨트롤러 (@Controller + @ResponseBody).1. @Controller역할: 웹 애플리케이션에서 뷰(View)를 반환하기 위한 컨트롤러로 사용됨주요 특징:메서드의 반환값은 뷰의 이름(String)이 되며, 뷰 리졸버(View Resolver)를 통해 실제 뷰(예: JSP, Thymeleaf 템플릿)가 렌더링됩니다.모델(Model) 객체를 사용하여 뷰에 데이터를 전달할 수 있습니다.사용 예시: import org.springframework.stereotype.Controller;import org.springframework.ui.Model;impor..
Spring Boot - Spring Web
·
Spring
1. Spring Web이란?Spring Web은 웹 애플리케이션 개발을 위한 모듈, HTTP 요청과 응답을 처리하는 기능을 제공주요 컴포넌트 :Spring MVC(Model-View-Controller) :웹 애플리케이션의 구조적 설계 지원REST API 개발 :JSON, XML과 같은 데이터 형식으로 클라이언트와 서버 간 통신을 간소화Handler와 Controller :URL 요청을 처리하고 응답 데이터를 생성2. Spring Boot와 Spring WebSpring Boot는 Spring Web 모듈을 내장하여 설정 작업을 자동화한다.⇒ 최소한의 설정으로 HTTP 서버, REST API, HTML 렌더링 등을 쉽게 구현 가능내장 서버 :tomcat, jetty같은 웹 서버가 내장되어 별도의 설치 ..
MyBatis - SqlSession
·
Spring
https://mybatis.org/mybatis-3/ko/getting-started.html 마이바티스 3 | 시작하기 – mybatis mybatis.org 1. SqlSession이란?SqlSession은 MyBatis의 핵심 객체, 데이터베이스 작업(SQL 실행, 트랜잭셩 관리 등)을 담당역할 :SQL 실행 : select, insert, update, delete 쿼리를 실행트랜잭션 관리 : 데이터베이스 작업의 시작과 종료를 관리함.매핑 작업 : SQL 결과를 자바 객체로 매핑함.2. SqlSession 사용 흐름graph TD A[SqlSessionFactory 생성] --> B[SqlSession 생성] B --> C[SQL 실행] C --> D[결과 매핑] D -->..
MyBatis - Mapper XML
·
Spring
https://mybatis.org/mybatis-3/ko/sqlmap-xml.html 마이바티스 3 | 매퍼 XML 파일 – mybatisMapper XML 파일 마이바티스의 가장 큰 장점은 매핑구문이다. 이건 간혹 마법을 부리는 것처럼 보일 수 있다. SQL Map XML 파일은 상대적으로 간단하다. 더군다나 동일한 기능의 JDBC 코드와 비교하면mybatis.org MyBatis의 Mapper XML은 SQL 쿼리를 작성하고, 데이터베이스 결과를 자바 객체로 매핑하는 중요한 역할을 합니다. 처음 시작하는 사람이 Mapper XML을 이해하고 멘탈 모델을 형성하기 위해서는 구조, 기본 구성 요소, 매핑 원리, 그리고 실제 데이터 흐름을 명확히 파악해야 합니다.1. Mapper XML의 주요 개념1.1..
MyBatis 개요
·
Spring
mybatis – 마이바티스 3 | 소개 마이바티스 3 | 소개 – mybatis마이바티스는 무엇인가? 마이바티스는 개발자가 지정한 SQL, 저장프로시저 그리고 몇가지 고급 매핑을 지원하는 퍼시스턴스 프레임워크이다. 마이바티스는 JDBC로 처리하는 상당부분의 코드와mybatis.org mybatis – 마이바티스 3 | 매퍼 XML 파일 마이바티스 3 | 매퍼 XML 파일 – mybatisMapper XML 파일 마이바티스의 가장 큰 장점은 매핑구문이다. 이건 간혹 마법을 부리는 것처럼 보일 수 있다. SQL Map XML 파일은 상대적으로 간단하다. 더군다나 동일한 기능의 JDBC 코드와 비교하면mybatis.org https://github.com/mybatis/spring-boot-starter/w..
RowMapper와 BeanPropertyRowMapper
·
Spring
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/jdbc/core/RowMapper.htmlhttps://docs.spring.io/spring-framework/docs/current/javadoc- BeanPropertyRowMapper (Spring Framework 6.2.1 API)Determine the mapped names for the given property. Subclasses may override this method to customize the mapped names, adding to or removing from the set determined by this base ..
JDBC API - JDBC Template
·
Spring
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/jdbc/core/JdbcTemplate.html JdbcTemplate (Spring Framework 6.2.1 API)Execute a query for a result object, given static SQL. Uses a JDBC Statement, not a PreparedStatement. If you want to execute a static query with a PreparedStatement, use the overloaded JdbcOperations.queryForObject(String, Class, Object...) me..
Spring Boot - JDBC 연결과 DataSource(MariaDB)
·
Spring
https://docs.spring.io/spring-boot/reference/data/sql.html SQL Databases :: Spring BootThe Reactive Relational Database Connectivity (R2DBC) project brings reactive programming APIs to relational databases. R2DBC’s Connection provides a standard method of working with non-blocking database connections. Connections are provided by using a Cdocs.spring.io 1. 프로젝트 설정1-1. 의존성 추가Sprign Boot 프로젝트의 bui..
[Spring] Java Bean vs POJO vs Spring Bean
·
Spring
Java Bean : Classes adhering to 3 constraints : 1 : Have public default (no argument) constructors2 : Allow access to their properties using getter and setter methods3 : Implement java.io.Serializable(Java Bean의 개념은 더 이상 중요하지 않다. EJB을 사용하는 사람이 많지 않기 때문.) POJO : Plain Old Java Object 즉, 자바로 생성하는 순수한 객체( = 모든 Java 객체는 POJO) Spring Bean : Spring이 관리하는 모든 Java 객체- Spring uses IOC Container (Bean Fac..