Spring vs SpringBoot

wheezy·2022년 5월 2일
0

Spring

Spring 프레임워크를 통해서 개발자들의 겨울이 끝났다.

The fact that Spring represented a fresh start after the "winter" of traditional J2EE

하지만!!! 설정의 어려움이 크다!

Spring을 봄이라고 하면 SpringBoot는 조금 더 봄 이라는 표현이 좋았다.

SpringBoot

SpringBoot는 간단함을 강조하는 아래의 말을 공식 홈페이지에서 한다.

SpringBoot makes it easy // 쉽게 만든다
to create stand-alone, // 단독적인
produciont-grade // 상용화 수준의
Spring based Applications // 스프링 기반 애플리케이션
that you can "just run". 당신은 실행만 시키면 된다.

Spring vs SpringBoot

dependency

SpringSpringBoot
- 너무 길음
- 모든 dependency를 버전까지 정확하게 작성해야 됨
- 길이가 짧아짐
- 버전관리도 권장버전으로 자동설정이 됨
- starter 시리즈를 통해 알아서 의존성이 있는 곳에서 쓰여짐
- Gradle을 쓰면 길이가 더 짧아짐

Spring dependency 예시

<dependency>
  <groupId>org.thymeleaf</groupId>
  <artifactId>thymeleaf-spring4</artifactId>
  <version>2.1.4.REALEASE</version>
</dependency>

SpringBoot starter 시리즈 예시

spring-boot-starter-data-jpa
spring-boot-starter-security
spring-boot-starter-test
spring-boot-starter-thymeleaf

configuration (환경 설정)

SpringSpringBoot
- 엄청 길음
- 많은 어노테이션과 어떤 처리를 할지에 대한 bean도 기본적으로 설정 해주어야 함
- 다른 설정 없이 application.properties만 적용을 해주면 됨

application.properties vs application.yml

application.yml(야믈)이 중복제거도 되어 간단하고 depth로 표현하고 때문에 인간이 쉽게 읽을 수 있게(human-readable) 해준다.
💡 참고
.yml은 YAML(YAML Ain't Markup Language)의 확장자이다.

application.properties

spring.h2.console.enabled=true
spring.h2.console.path=/h2-console

application.yml

spring:
	h2:
		console:
			enabled:true
			path:/h2-console

embedded server (내장 서버)

  • 내장 서버인 Tomcat을 통해서 서버 구동 시간이 절반 가까이 단축
  • tomcat이 싫으면 간단하게 jetty로 변경할 수 있음
...
configuration {
	compile.exclude module:'spring-boot-starter-tomcat'
}

dependencies {
...
	implementation('org.springframework.boot:spring-boot-starter-web')
	implementation('org.springframework.boot:spring-boot-starter-jetty')
...
}
  • 내장 서블릿 컨테이너 덕분에 jar 파일로 간단하게 배포할 수 있음

마무리 정리 (SpringBoot 장점)

  • 간편한 설정
  • 편리한 의존성 관리 & 자동 권장 버전 관리
  • 내장 서버로 인한 간단한 배포 서버 구축
  • 스프링 Security, Data JPA 등의 다른 스프링 프레임워크 요소를 쉽게 사용

참고

profile
🧀 개발을 하면서 도움이 되었던 부분을 기록하는 공간입니다 🧀

0개의 댓글