본문 바로가기
728x90

Spring Boot38

Spring boot 내장 Servlet Container 소스코드 public static void main(String[] args) throws LifecycleException { Tomcat tomcat = new Tomcat();//톰캣 객체 생성 tomcat.setPort(8080);//포트 설정 Context context= tomcat.addContext("/", "/"); HttpServlet servlet = new HttpServlet() {//서블릿 만들기 @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { PrintWriter printWriter = resp.getWriter.. 2022. 1. 29.
Starter & AutoConfigure 구현방법 1. 의존성 추가 4.0.0 org.example.study1 cheolju-spring-boot-starter 1.0-SNAPSHOT 8 8 org.springframework.boot spring-boot-autoconfigure org.springframework.boot spring-boot-autoconfigure-processor true org.projectlombok lombok org.springframework.boot spring-boot-dependencies 2.0.3.RELEASE pom import 2. @Configuration 파일 작성 @Bean public Man holoMan(){ return Man.builder() .name("cheolju") .age(5.. 2022. 1. 29.
@SpringBootApplication @SpringBootApplication의 구성 @SpringBootConfiguration > 해당 클래스에서 1개 이상의 bean을 생성하고 있음을 명시 (bean을 등록하는 설정파일) @ComponentScan > 해당 패키지 하위의 @Component를 찾아 bean을 등록 > @Configuration, @Repository, @Service, @Controller, @RestController 도 bean으로 등록 @EnableAutoConfiguration - spring-boot-autoconfigure > META-INF > spring-factories 에 Auto Configure를 키-값으로 등록되어있음 > 키값을 등록되어있는 클래스들을 Auto Configuration > @Con.. 2022. 1. 29.
Spring boot 원리 Spring boot 구조 메이븐 기본 프로젝트 구조와 동일 소스 코드 (src\main\java) 소스 리소스 (src\main\resource) 테스트 코드 (src\test\java) 테스트 리소스 (src\test\resource) Spring boot 의존성 관리 최상위 parent(spring-boot-dependencies)에 dependency가 정의되어있음 > 호환을 위한 각각의 의존성을 따로 설정해줄 필요가 없음 * parent가 고정되어 변경이 불가능한 경우 dependencyManagement를 사용하여 의존성 설정을 할 수 있음 org.springframework.data spring-data-releasetrain Fowler-SR2 pom import org.springfram.. 2022. 1. 1.
728x90