[공부] 영상(40)
-
스프링 부트 강의 정리 (16~18 : 템플릿 엔진, 에러 핸들링, 데이터 바인딩)
스프링 부트 MVC는 다음과 같은 템플릿 엔진을 기본적으로 지원한다. FreeMarker (업데이트가 느려서 권장 x) Groovy Thymleaf Mustache JSP (사용을 권하지 않음) 위의 템플릿 엔진을 사용할 때 파일을 불러오는 기본 경로는 src/main/resources/templates 이다. Thymeleef 사용 예시 Thymeleef dependency 추가 org.springframework.boot spring-boot-starter-thymeleaf src/main/resources/templates/helloView.html src/main/com/testcompany/testproject/controller/HelloController.java @Controller pub..
2019.04.27 -
스프링 부트 강의 정리 (15 : WebJar)
WebJar : 프론트엔드 라이브러리를 jar 형태로 패키징해놓은 형태. JQuery 같은 것을 메이븐을 통해서 다운 받을 수 있다. 메이븐으로 설치한 JQuery를 프론트엔드에서 라이브러리를 사용할 수 있다. 추가한 라이브러리는 webjars/ 이하 경로를 통해서 가져올수있다. org.webjars jquery 3.4.0 HTML JQuery 선언 스프링 부트에서 캐시에 자유롭게 변경된 내용을 계속 반영해주는 방법 방법 1. 버전 agnostirng URL : org.webjars webjars-locator-core 방법 2. 캐시 버스팅 : 캐시될 파일 이름의 뒤에다 해쉬코드값을 붙여서 캐시에 독립적으로 동작하도록 한다. # Cache busting properties spring.resources..
2019.04.24 -
스프링 부트 강의 정리 (13~14 : HttpMessageConverter, Static content)
스프링 부트는 Tomcat, jetty, undertow, netty등을 내장하고 있어서 Web 개발에 유용하다. spring-boot-web 를 이용하면 빠르게 웹개발을 빠르게 시작해볼 수 있다. spring-boot-starter-webflux 를 이용하면 reactive web 어플리케이션을 개발 할 수 도 있다. spring mvc : controller, restcontroller 로 http request를 핸들링한다. spring boot 는 spring web mvc를 위한 auto configuration을 제공한다. Spring Web Auto-configuration의 특징 controller의 return string -> ViewResolver -> View -> ContentNe..
2019.04.21 -
스프링 부트 강의 정리 (11~12 : Profile, Log)
profile으로 local 환경 dev 환경 분리하기 https://kok202.tistory.com/114?category=782902 스프링 부트 개발환경 로컬환경 분리 application.yml 에 profile을 dev와 local 로 분할 spring: profiles: development ... --- spring: profiles: local ... 로컬환경으로 돌리고 싶을 경우 Run - Edit configurations -> Configuration ->VM optio.. kok202.tistory.com @Profile을 이용하면 profile 값에 따라서 주입받을 클래스를 바꿀 수 있다. public interface Parent { public String getMessage..
2019.04.21 -
스프링 부트 강의 정리 (8~10 : Properties 읽어들이기)
스프링 부트는 설정파일을 밖으로 빼낼 수 있게 해져있다. properties, yml, Environment, command line 등을 사용하여 정의할 수 있다. 정의된 설정 값은 @Value로 주입받거나 스프링이 제공하는 Environment interface로 접근할 수 있다. 값을 주입 받는 방법은 @Value("${name}") 이다. 설정값 우선순위 1. spring-boot-devtools를 사용할 경우 ~/.spring-boot-devtools.properties 2. @TestPropertySource 3. @SpringBootTest 여기서부터 실질적으로 사용하는 값들이다. 4. Command line argument 5. Command line argument 를 SPRING_APP..
2019.04.21 -
스프링 부트 강의 정리 (6~7 : SpringApplication)
SpringApplication 클래스 public static void main(String[] args) { SpringApplication.run(MySpringConfiguration.class, args); } 스프링은 MainApplication 클래스 안의 main 메소드에서 SpringApplication.run() 을 이용하여 실행된다. info level 에서 logging 할 수 있도록 해준다. (application.properties 또는 application.yml를 이용하여 logging level을 바꿀 수도 있긴하다.) 참조 : https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-feature..
2019.04.20