'전체 글'에 해당되는 글 384건
- 2023.06.14 [Docker] 기초 정리 1
- 2023.06.13 Servlet & Servlet Container
- 2023.06.13 [Spring] Tomcat + Spring Framework 구동 흐름 정리 1
- 2023.06.02 [Spring] 스프링의 4가지 concept 정리
- 2023.06.02 [Oracle] NVL과 COALESCE 의 차이
- 2023.05.08 tomcat 관련
- 2023.04.27 MYSQL DEFINER
- 2023.04.27 개발표준
- 2023.04.12 SQL 네이밍 규칙
- 2023.04.05 MyBatis #{} ${} 차이
## 도커 설치
1. virtual box 설치 - 네트워크 구성 - vm 만들기
- virtualbox 다운로드 후 설치(virtualbox.org)
- 환경설정(네트워크 구성)
- 가상머신 만들기
2. vm에 ubuntu 20.04 설치하고 기본 환경 구성하기
- ubuntu 20.04 설치(ubuntu.com) : LTS(Long Term Support version)
키보드 설정 그대로 - 디스크를 지우고 우분투 설치 - 타임존 서울
- 여기까지 하면 설치가 되고 재시작을 물어봄
- 재시작 후 우측 상단에서 설정 버튼을 통해 [디스플레이] tab에 진입하여 화면 해상도를 변경해준다. 1280 * 960(4:3)
- 네트워크 구성
- 바탕화면에서 우측버튼 클릭하면 `터미널 열기` 로 들어감(cmd)
- ip addr, hostn90me 클릭하면 정보 확인 가능
- 호스트 네임 변경: sudo vi /etc/hostname 입력 후 docker-ubuntu.example.com 으로 수정(putty 명령어 활용)
- 호스트 정보 추가 : sudo vi /etc/hosts 입력 후
- ping -c 3 8.8.8.8 을 입력하여 통신이 잘되는지 확인(8.8.8.8 은 google의 dns)
- root password 설정 : 비밀번호(password)
- 여기까지 하면 ubuntu 환경 구성은 완료
- exit 2번 입력 후 reboot 입력
- putty로 접속정보 입력 후 접속
3. vm에 centos 설치하고 환경구성하기
4. ubuntu/centos server에 docker 설치하기
- https://docs.docker.com/engine/install/ubuntu/
* 다운로드 방법
- repository를 이용해서 설치 (외부 네트워크 O)
- download 후 직접설치 (외부 네트워크 X)
- script를 이용한 설치
// Install using the apt repository
// 설치 전 이전버전 삭제
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
// 요구프로그램 설치
guru@docker-ubuntu:~$ sudo apt-get update
guru@docker-ubuntu:~$ sudo apt-get install ca-certificates curl gnupg
// 인증서 저장
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
// url 등록
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
// docker engine 등록
sudo apt-get update
// 설치 가능 버전 확인
apt-cache madison docker-ce | awk '{ print $3 }'
// 특정 버전 설치
VERSION_STRING=5:20.10.24~3-0~ubuntu-jammy
sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io -y
// 설치 정상적으로 되었는지 확인
guru@docker-ubuntu:~$ sudo docker version
Client: Docker Engine - Community
Version: 20.10.24
API version: 1.41
Go version: go1.19.7
Git commit: 297e128
Built: Tue Apr 4 18:21:03 2023
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.24
API version: 1.41 (minimum version 1.12)
Go version: go1.19.7
Git commit: 5d6db84
Built: Tue Apr 4 18:18:48 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.21
GitCommit: 3dce8eb055cbb6872793272b4f20ed16117344f8
runc:
Version: 1.1.7
GitCommit: v1.1.7-0-g860f061
docker-init:
Version: 0.19.0
GitCommit: de40ad0
guru@docker-ubuntu:~$
- 계정 추가 및 관리자 권한 부여
guru@docker-ubuntu:~$ su - // root 로 접속
암호:
root@docker-ubuntu:~# usermod -a -G docker guru // guru 관리자 권한 부여
root@docker-ubuntu:~# su - guru
guru@docker-ubuntu:~$ docker ps // 권한 잘 부여되었는지 확인
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
guru@docker-ubuntu:~$
5. windows 10에 dockerDesktop 설치하기
# cat app.js
const http = require('http');
const os = require('os');
console.log("test server is running...");
var handler = function(req, res) {
res.writeHead(200);
res.end("Container Hostname: " + os.hostname() + "\n");
};
var www = http.createServer(handler);
www.listen(8080);
# cat Dockerfile
FROM node:12 // node환경을 설치하고
COPY app.js /app.js // ??
ENTRYPOINT ["node", "app.js"] // 만들어놓은 app.js를 저장하고 실행할 수 있는 환경을 만듬
'IT Infra' 카테고리의 다른 글
[Ubuntu] SELinux 설치 (0) | 2023.06.16 |
---|---|
리눅스(Linux), 커널(Kernel), 우분투(Ubuntu) (0) | 2023.06.15 |
PUTTY (0) | 2023.03.31 |
JWT(JSON Web Token) (0) | 2023.03.29 |
개발 환경 구성 (0) | 2023.03.29 |
Servlet이란?
- WebProgramming에서 Client의 요청을 처리(request)
- 그 결과를 다시 Client에게 전송하는 자바 프로그래밍 기술(response)
- Servlet 클래스의 구현 규칙을 따름
- javax.servlet package에 정의된 인터페이스
- 서블릿의 라이프 사이클을 위한 세가지 필수 메소드 정의
- init : 초기화 (최초의 요청인 경우만 실행; 1회 실행)
- service: 초기화 이후 각각의 요청들이 들어오면 호출 (계속 실행)
- destroy : 서블릿 객체가 파괴되어야 할 때 호출
Servlet의 특징
- Java Thread를 이용해 동작
- HTML 변경 시 재컴파일 필요
- Java 코드에 HTML이 들어가있음
- HTML을 사용해서 요청에 응답
Servlet 생성방법
- @WebServlet
해당 서블릿과 매핑될 url 지정
- HttpServlet 클래스 상속
Servlet 동작방식
- 사용자(클라이언트)가 URL을 클릭하면 HTTP Request를 Servlet Container로 전송
- HTTP Request를 전송받은 Servlet Container는 HttpServletRequest, HttpServletResponse 두 객체를 생성
- web.xml은 사용자가 요청한 URL을 분석하여 어느 서블릿에 대해 요청을 한 것인지 찾음
- 해당 서블릿에서 service메소드를 호출한 후 클리아언트의 POST, GET여부에 따라 doGet() 또는 doPost()를 호출
- doGet() or doPost() 메소드는 동적 페이지를 생성한 후 HttpServletResponse객체에 응답을 보냄
- 응답이 끝나면 HttpServletRequest, HttpServletResponse 두 객체를 소멸
Servlet Container 란?
- 서블릿들의 LifeCycle(생성, 실행, 소멸) 을 담당 (서블릿 관리)
- 요청이 들어올때 마다 자바 스레드를 만듬(Multi Thread 지원)
- 대표적으로 무료 서비스가 바로 Tomcat
- Tomcat은 웹서버와 소켓을 만들어 통신하며 JSP와 Servlet이 작동할 수 있는 환경을 제공
* GenericServlet
- GenericServlet은 Servlet 인터페이스를 상속하여 클라이언트-서버 환경에서 서버단의 애플리케이션으로서 필요한 기능을 구현한 추상클래스
- service() 메서드를 제외한 모든 메서드를 재정의하여 적절한 기능으로 구현
- GenericServlet 클래스를 상속하면 애플리케이션의 프로토콜에 따라 메서드 재정의 구문을 적용해야 함.
* HttpServlet
- 일반적으로 서블릿이라하면 거의 대부분 HttpServlet을 상속받은 서블릿을 의미
- HttpServlet은 GenericServlet을 상속받았으며, GenericServlet의 유일한 추상 메서드인 service를 HTTP 프로토콜 요청 메서드에 적합하게 재구현해놓음.
- 이미 DELETE, GET, HEAD, OPTIONS, POST, PUT, TRACE를 처리하는 메소드가 모두 정의되어 있음
'Java' 카테고리의 다른 글
int 형 숫자의 자릿수 구하는 방법 (0) | 2023.10.18 |
---|---|
jar, war 파일 관련 (0) | 2023.08.01 |
HttpSession (0) | 2023.04.04 |
Server 1대에 Multi version 의 JDK 사용 (0) | 2022.12.06 |
DAO, DTO, VO (0) | 2022.03.21 |
1. Tomcat에 의해 web.xml 로드하고, web.xml의 ContextLoaderListener 생성
* ContextLoaderListener
- ServletContextListener 인터페이스를 구현하고 있으며, ApplicationContext를 생성하는 역할을 수행한다.
- Servlet의 생명주기를 관리해준다.
- Servlet을 사용하는 시점에 서블릿 컨텍스트에 ApplicationContext 등록, Servlet이 종료되는 시점에 ApplicationContext 삭제
- `contextConfigLocation` 파라미터를 사용하여 load할 수 있는 설정파일을 지정
* ApplicationContext
- IoC엔진, bean의 생명주기 담당
- 최상위 컨텍스트
- root-context에 등록되는 빈들은 모든 컨텍스트에서 사용 할 수 있다. (공유가능)
- Service, DAO를 포함한 웹환경에서 독립적인 Bean들을 담아둔다. (@Service, @Repository)
- 서로 다른 servlet-context에서 공유해야 하는 빈들을 등록해놓고 사용할 수 있다.
- servlet-context내 Bean들은 이용이 불가능하다.
// web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>ㅇㅇㅇㅇ</display-name>
<description></description>
<context-param>
<param-name>package.version</param-name>
<param-value>5.3.5.0-SNAPSHOT</param-value>
</context-param>
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>*.do</url-pattern>
<url-pattern>*.json</url-pattern>
</filter-mapping>
<filter>
<filter-name>HTMLTagFilter</filter-name>
<filter-class>softin.sams.framework.filter.HTMLTagFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HTMLTagFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter>
<filter-name>FServiceLogFilter</filter-name>
<filter-class>softin.sams.framework.filter.FServiceLogFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>FServiceLogFilter</filter-name>
<url-pattern>*.do</url-pattern>
<url-pattern>*.json</url-pattern>
</filter-mapping>
<filter>
<filter-name>WebResourceAuthorizedFilter</filter-name>
<filter-class>softin.sams.framework.filter.WebResourceAuthorizedFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>WebResourceAuthorizedFilter</filter-name>
<url-pattern>/docs/*</url-pattern>
</filter-mapping>
<!-- <filter>
<filter-name>CustomWebSecurityFilter</filter-name>
<filter-class>softin.sams.framework.filter.CustomWebSecurityFilter</filter-class>
<init-param>
<param-name>content.security.policy</param-name>
<param-value>default-src 'self'; connect-src 'self' *.kakao.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.kakao.com *.daumcdn.net; style-src 'self' 'unsafe-inline'; img-src 'self' data: *.kakao.com *.daumcdn.net;</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CustomWebSecurityFilter</filter-name>
<url-pattern>*.do</url-pattern>
<url-pattern>*.json</url-pattern>
</filter-mapping> -->
<!-- ② contextConfigLocation 파라미터를 사용하여 load할 수 있는 설정파일을 지정 ★★★ -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:inframework/spring/context-*.xml,
classpath*:inframework/spring/custom/context-*.xml
</param-value>
</context-param>
<!-- ① ContextLoaderListener ★★★ -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 서블릿 컨텍스트 파일 경로 지정 ★★★ -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/inframework/springmvc/dispatcher-*.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
<url-pattern>*.json</url-pattern>
<url-pattern>*.in</url-pattern>
</servlet-mapping>
<!-- <servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.html</url-pattern>
<url-pattern>*.css</url-pattern>
<url-pattern>*.js</url-pattern>
<url-pattern>*.jpg</url-pattern>
<url-pattern>*.png</url-pattern>
<url-pattern>*.gif</url-pattern>
</servlet-mapping> -->
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
<session-config>
<cookie-config>
<name>Softin-ORGN_SID</name>
</cookie-config>
<session-timeout>60</session-timeout>
<tracking-mode>COOKIE</tracking-mode>
</session-config>
<welcome-file-list>
<welcome-file>index.do</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<error-page>
<error-code>403</error-code>
<location>/html/errorView.html</location>
</error-page>
<error-page>
<location>/error/errorView.do</location>
</error-page>
<!-- JNDI 설정 -->
<resource-ref>
<description>JNDI DATASOURCE</description>
<res-ref-name>JNDI-softin-orgn</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<!-- Security -->
<security-constraint>
<web-resource-collection>
<web-resource-name>Allowed methods</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method-omission>GET</http-method-omission>
<http-method-omission>POST</http-method-omission>
</web-resource-collection>
<auth-constraint />
<!-- HTTPS Redirect -->
<!-- <user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint> -->
</security-constraint>
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<trim-directive-whitespaces>true</trim-directive-whitespaces>
</jsp-property-group>
</jsp-config>
</web-app>
2. contextConfigLocation에 mapping된 xml 파일을 기준으로 Spring Container(ROOT: 첫번째 spring container)가 구동
- 여기서 대상이 되는 xml파일은 case가 여러가지가 될수 있다. ( ex. root-context.xml, applicationContext.xml)
- 아래 예시의 경우 (context-common.xml) 전자정부 프레임워크의 context-*.xml 파일들에서 설정한 내용들을 모두 합쳐놓은 부분
- 여기서 대상이 되는 xml파일은 주로 view 지원을 제외한 공통 bean을 설정한다.(web과 관련된 bean들은 등록하지 않음)
// context-common.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<!-- Component scan -->
<context:component-scan base-package="inframework,softin.sams">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- Spring XML 설정파일에서 Properties 정보 읽어 올수 있도록 추가 -->
<bean id="propertyConfigurer" class="softin.sams.framework.properties.configurer.EncryptablePropertyConfigurer">
<!-- SamsProperties 에서 properties 설정 파일 로드 처리함 -->
<property name="samsProperties" ref="samsProperties" />
</bean>
<!-- MessageSource -->
<bean id="localMessageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>classpath:/inframework/message/message-common</value>
<value>classpath:/inframework/message/message-code</value>
</list>
</property>
<property name="defaultEncoding" value="UTF-8"/>
<property name="cacheSeconds">
<value>60</value>
</property>
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"/>
<!-- 로컬 리소스 -->
<bean id="samsMessage" class="softin.sams.framework.properties.SamsMessage">
<property name="messageSource" ref="localMessageSource" />
</bean>
<bean id="samsProperties" class="softin.sams.framework.properties.SamsProperties" init-method="loadProperties">
<property name="samsMessage" ref="samsMessage" />
</bean>
<!-- DB 리소스 -->
<bean id="messageSource" class="softin.sams.framework.properties.DBMessageSource">
</bean>
<bean id="samsDBMessage" class="softin.sams.framework.properties.SamsDBMessage">
<property name="messageSource" ref="messageSource" />
</bean>
<!-- MultiPart File Upload -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="${Globals.upload.maxUploadSize:10485760}"/>
<property name="maxInMemorySize" value="${Globals.upload.maxInMemorySize:10240}"/>
</bean>
</beans>
3. Client로부터 웹 어플리케이션 요청이 옴.
- 최초의 클라이언트 요청에 의해 DispatcherServlet 생성
- DispatcherServlet 객체는 WEB-INF/config 폴더에 존재하는 대상이 되는 xml파일 (ex. servlet-context.xml) 파일을 로딩하여 두번째 스프링 컨테이너를 구동
- 이 두 번째 스프링 컨테이너가 Controller 객체를 메모리에 생성한다.
- DispatcherServlet은 FrontController의 역할을 수행한다.(클라이언트로부터 요청 온 메시지를 분석하여 알맞은 PageController에게 전달하고 응답을 받아 요청에 따른 응답을 어떻게 할지 결정한다.)
- 이때 첫번째 Spring Container(ROOT) 가 구동되면서 생성된 DAO, VO, ServiceImpl 클래스들과 협업하여 알맞은 작업을 처리하게 된다.
* DispatcherServlet 클래스에 의해 만들어지는 것이 WebApplicationContext
* WebApplicationContext
- servlet-context에 등록되는 빈들은 해당 컨텍스트에서만 사용할 수 있다.
- DispatcherServlet이 직접 사용하는 Controller를 포함한 웹 관련 빈을 등록하는 데 사용 (@Controller)
- 독자적인 컨텍스트들을 가지며, root-context 내 빈 사용이 가능
// dispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd" >
<!-- <context:component-scan base-package="inframework,softin">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
</context:component-scan> -->
<!-- 패키지 내 Controller, Service, Repository 클래스의 auto detect를 위한 mvc 설정 -->
<context:component-scan base-package="inframework,softin.sams,softin.test" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!--
<mvc:annotation-driven />
<context:annotation-config />
<aop:aspectj-autoproxy />
-->
<!-- <mvc:annotation-driven /> -->
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<!-- JSON HTML Tag escape 처리 -->
<!-- ★★★ HttpMessageConverter: 자바객체와 Http 요청/응답 몸체 사이의 변환 처리-->
<bean class="softin.sams.framework.common.gson.CustomGsonHttpMessageConverter" />
</mvc:message-converters>
</mvc:annotation-driven>
<aop:aspectj-autoproxy />
<!-- 인증 인터 셉터 -->
<mvc:interceptors>
<!-- 사용자 인증 사용하는 경우 아래 path 추가 필수 -->
<mvc:interceptor>
<mvc:mapping path="/cmm/**" />
<mvc:mapping path="/web/**" />
<mvc:mapping path="/api/**" />
<mvc:mapping path="/inorg/**" />
<!-- exclude -->
<mvc:exclude-mapping path="/api/msagw/**"/>
<mvc:exclude-mapping path="/msagw/api/**"/>
<bean class="softin.sams.framework.interceptor.DefaultAuthInterceptor" />
</mvc:interceptor>
<!-- 로그인 접근 인증 -->
<mvc:interceptor>
<mvc:mapping path="/login/**" />
<!-- exclude -->
<mvc:exclude-mapping path="/login/logout.do"/>
<bean class="softin.sams.framework.interceptor.LoginAccessInterceptor" />
</mvc:interceptor>
<!-- 서버 -->
<mvc:interceptor>
<mvc:mapping path="/server/**" />
<!-- health check -->
<mvc:exclude-mapping path="/server/health/**"/>
<bean class="softin.sams.framework.server.interceptor.ServerAuthenticInterceptor" />
</mvc:interceptor>
<!-- MSA GW -->
<mvc:interceptor>
<mvc:mapping path="/api/msagw/**" />
<mvc:mapping path="/msagw/api/**" />
<bean class="softin.sams.framework.msagw.interceptor.MsaGwAuthenticInterceptor" />
</mvc:interceptor>
<!-- Open API -->
<mvc:interceptor>
<mvc:mapping path="/openapi/**" />
<bean class="softin.sams.framework.openapi.interceptor.OpenApiServerInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
<!-- Tiles3 적용 -->
<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver" p:order="1">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView" />
</bean>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/config/inframework/tiles/default-layout.xml</value>
</list>
</property>
</bean>
</beans>
4. 클라이언트 요청으로부터 DispatcherServlet의 전체 흐름
- 클라이언트가 해당 어플리케이션에 접근하면 접근한 URL 요청을 DispatcherServlet이 가로챔
- RequestMappingHandlerMapping이 해당 요청을 처리할 컨트롤러를 찾음
- DefaultListableBeanFactory 가 mainContoller 를 쓰면 된다고 알려줌
- RequestResponseBodyMethodProcessor가 servlet-context.xml 에 선언해놓은 MessageConverter을 이용하여 요청 바디(파라미터)를 읽음
- DataSourceTransactionManager 로 DB 접속
- 컨트롤러에서 view를 리턴하면 ViewResolver가 먼저 받아 해당 view가 존재하는지 검색
- DispatcherServlet은 ViewResolver를 통해 접두사와 접미사가 붙은 JSP 파일의 이름과 경로를 리턴받아 최종적으로 JSP를 실행. view에 결과를 보낸 후 DispatcherServlet은 최종 결과를 클라이언트에 전송
'Framework' 카테고리의 다른 글
[Spring] 스프링의 4가지 concept 정리 (0) | 2023.06.02 |
---|---|
개발표준 (0) | 2023.04.27 |
[Spring] PostConstruct (0) | 2023.04.04 |
Front-End Framework 정리 (0) | 2021.06.13 |
스프링(Spring) AOP : AspectJ Pointcut 표현식 (Feat. 프로젝트에서 꼭 활용할 내용들) (0) | 2020.03.31 |
1. IoC (Inversion of Control)
- 제어의 역전
- 객체의 생성과 관리를 개발자가 아닌 framework가 하는 것
- 스프링 애플리케이션에서는 오브젝트(빈)의 생성과 의존 관계 설정, 사용, 제거 등의 작업을 애플리케이션 코드 대신 스프링 컨테이너가 담당
- 스프링 컨테이너 = IoC 컨테이너 (= 빈 팩토리, DI 컨테이너, `[애플리케이션 컨텍스트]` )
- 애플리케이션 컨텍스트 : IoC와 DI 그 이상의 기능을 가짐. (메세지 소스, 환경변수, 어플리케이션 이벤트, 리소스 조회)
* BeanFactory
- 스프링 설정파일에 등록된 <bean> 객체를 생성하고 관리
- 컨테이너가 구동될 때 객체를 생성하는 것이 아니라 클라이언트로부터의 요청에 의해서만 객체를 생성 (Lazy Loading 방식) -> 일반적인 스프링 프로젝트에서 사용할 일이 없음
* ApplicationContext
- BeanFactory가 제공하는 <bean> 객체 관리 기능 외에도 트랜잭션 관리나 메시지 기반의 다국어 처리 기능 지원
- 컨테이너가 구동되는 시점에 <bean>에 등록되어 있는 클래스들을 객체화 하는 즉시로딩(Pre-Loading 방식)
- <bean> option에 lazy-init="true"를 써서 클라이언트가 요청하는 시점에 구동할 수도 있음
- ApplicationContext의 구현 클래스는 매우 다양하지만, 두 개만 알고 있으면 됨
- GenericXmlApplicationContext : 대표적으로 ApplicationContext를 구현한 클래스, 파일 시스템이나 클래스 경로에 있는 xml 설정 파일을 로딩하여 구동하는 컨테이너
- XmlWebApplicationContext : 웹 기반의 스프링 애플리케이션을 개발할 때 사용하는 컨테이너 (직접 개발 안하는 컨테이너)
- 정리 : 스프링 컨테이너는 bean 저장소에 해당하는 xml 설정파일을 참조하여 bean 생명주기 관리
2. DI (Dependency Injection)
- 의존성 주입
- 외부에서 객체를 주입받아 사용하는 것
- 어떤 클래스가 다른 클래스에 의존하는 것
public class A {
// A에서 B를 주입받음
@Autowired
B b;
}
@Component // 클래스 A를 빈으로 등록
public class A {
...
}
3. AOP (Aspect Oriented Programming)
- 관점 지향 프로그래밍
- 프로그래밍을 할 때 핵심관점 과 부가관점 을 나누어서 개발하는 것
- 부가관점 코드를 핵심 관점 코드에서 분리
4. PSA (Portable Service Abstraction)
- 이식 가능한 서비스 추상화
- 어느 기술을 사용하던 일관된 방식으로 처리하도록 하는 것
- 예를 들어, spring에서 database에 접근할 때 JPA, MyBatis, JDBC 등을 사용할 수 있지만, 일관된 방식으로 데이터베이스에 접근하도록 인터페이스를 지원하는 것
'Framework' 카테고리의 다른 글
[Spring] Tomcat + Spring Framework 구동 흐름 정리 (1) | 2023.06.13 |
---|---|
개발표준 (0) | 2023.04.27 |
[Spring] PostConstruct (0) | 2023.04.04 |
Front-End Framework 정리 (0) | 2021.06.13 |
스프링(Spring) AOP : AspectJ Pointcut 표현식 (Feat. 프로젝트에서 꼭 활용할 내용들) (0) | 2020.03.31 |
NVL('aa', 'bb') // 2가지 값만 처리 가능
COALESCE('aa', 'bb', 'cc', 'dd'... ) // 2가지 이상 값까지 처리 가능
'DATABASE(SQL)' 카테고리의 다른 글
[MS-SQL] Begin Tran (0) | 2023.08.10 |
---|---|
[Oracle] Archive (Log) Mode (0) | 2023.08.01 |
MYSQL DEFINER (0) | 2023.04.27 |
SQL 네이밍 규칙 (0) | 2023.04.12 |
MyBatis #{} ${} 차이 (0) | 2023.04.05 |
1. 톰캣 폴더내 lib 폴더로 이동
`java -cp catalina.jar org.apache.catalina.util.ServerInfo`
2. catalina.out 로그 생성 안되도록 설정
bin/catalina.sh 에서
아래
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out // ---------> CATALINA_OUT=/dev/null 로 수정한다.
fi
3. 배포 방법에는 2가지가 있다.
- war파일을 이용한 배포(webapps)
- 디렉토리 수동 배포(web/{#프로젝트명})
'DevTools' 카테고리의 다른 글
[VS Code] .properties 파일에서 한글 깨지는 경우 (0) | 2023.08.01 |
---|---|
SourceTree (0) | 2023.07.05 |
VS Code 에서 명령어 실행이 안될때 (0) | 2022.05.12 |
Eslint (0) | 2021.09.28 |
Markdown 쓰는 방법 (0) | 2021.03.15 |
1. VIEW DEFINER 수정
ALTER DEFINER = '계정'@'localhost' VIEW 뷰 이름 AS 뷰 생성 쿼리
ALTER DEFINER = 'testtest'@'localhost' VIEW 뷰 이름 AS SELECT * FROM ~~~~~
예시)
ALTER DEFINER = 'root' view VI_ORGN_EMP_SESSION AS
SELECT ...
FROM ...
2. 함수1개 Definer 수정
status; // 계정 접속상태 확인
show function status where db='DB명';
show procedure status where db='DB명';
select * from mysql.proc where definer='계정명@%' and type='function';
select * from mysql.proc where definer='계정명@%' and type='procedure';
UPDATE MYSQL.PROC SET DEFINER = 'newuser@%' WHERE DEFINER='olduser@%' and type = 'FUNCTION';
'DATABASE(SQL)' 카테고리의 다른 글
[Oracle] Archive (Log) Mode (0) | 2023.08.01 |
---|---|
[Oracle] NVL과 COALESCE 의 차이 (0) | 2023.06.02 |
SQL 네이밍 규칙 (0) | 2023.04.12 |
MyBatis #{} ${} 차이 (0) | 2023.04.05 |
DML DDL DCL (0) | 2022.12.20 |
• servlet-context.xml: Controller, 애노테이션, ViewResolver, Interceptor
• root-context.xml: Service, Repository => View와 관련없는 Bean
'Framework' 카테고리의 다른 글
[Spring] Tomcat + Spring Framework 구동 흐름 정리 (1) | 2023.06.13 |
---|---|
[Spring] 스프링의 4가지 concept 정리 (0) | 2023.06.02 |
[Spring] PostConstruct (0) | 2023.04.04 |
Front-End Framework 정리 (0) | 2021.06.13 |
스프링(Spring) AOP : AspectJ Pointcut 표현식 (Feat. 프로젝트에서 꼭 활용할 내용들) (0) | 2020.03.31 |
'DATABASE(SQL)' 카테고리의 다른 글
[Oracle] NVL과 COALESCE 의 차이 (0) | 2023.06.02 |
---|---|
MYSQL DEFINER (0) | 2023.04.27 |
MyBatis #{} ${} 차이 (0) | 2023.04.05 |
DML DDL DCL (0) | 2022.12.20 |
Oracle Tablespace (0) | 2022.12.20 |
SELECT PROFILES_ACTIVE
, USER_ID
, SESSION_ID
, INSTANCE_ID
, IN_DATE
FROM SFI_LOGIN_SESSION
WHERE PROFILES_ACTIVE = '${profilesActive}'
${}
- 파라미터가 바로 출력됨 (Statement)
- 해당 컬럼의 자료형에 맞추어 파라미터의 자료형이 변경됨
- 쿼리 주입(SQL Injection)을 예방할 수 없어 보안에서 불리. (사용자 입력을 전달할때는 사용x)
- 테이블이나 컬럼명을 파라미터로 전달하고 싶을 때 사용 ( #{} 은 ' ' 가 자동으로 붙음 )
SELECT PROFILES_ACTIVE
, USER_ID
, SESSION_ID
, INSTANCE_ID
, IN_DATE
FROM SFI_LOGIN_SESSION
WHERE PROFILES_ACTIVE = #{profilesActive}
#{}
- 파라미터가 string 형태로 들어옴
- 쿼리 주입을 예방할 수 있어 보안 측면에서 유리 (PreparedStatement)
SELECT * FROM MEMBER WHERE ID = ''or 1=1--' and PW = '아무거나입력'
SQL Injection
- WHERE 절을 강제로 참으로 만들어 SQL을 조작
- `'or 1=1` 입력을 통해 참이 됨
'DATABASE(SQL)' 카테고리의 다른 글
MYSQL DEFINER (0) | 2023.04.27 |
---|---|
SQL 네이밍 규칙 (0) | 2023.04.12 |
DML DDL DCL (0) | 2022.12.20 |
Oracle Tablespace (0) | 2022.12.20 |
Oracle Synonym (0) | 2022.12.20 |