본문 바로가기

분류 전체보기

(124)
[Spring Boot] Auto Configuration 만들기 1. Spring-Boot-AutoConfigure vs Spring-Boot-Starter XXX-Spring-Boot-Autoconfigure 모듈 : 자동 설정 XXX-Spring-Boot-Starter 모듈 : 필요한 의존성 정의(pom.xml이 중요) 하나로 만들고 싶으면 Starter로 만들면 됨 2. pom.xml에 의존성 추가 (Project A) org.springframework.boot spring-boot-autoconfigure org.springframework.boot spring-boot-autoconfigure-processor true org.springframework.boot spring-boot-configuration-processor true 3. Human cl..
[Spring Boot] 자동 설정 (Auto Configuration) 1. @EnableAutoConfiguration @SpringBootApplication만 적어도 Application 실행 시 여러 설정들이 읽히면서 웹 Application이 뜨게 되는 이유는 EnableAutoConfiguration 때문 2. @SpringBootApplication @SpringBootApplication은 다음 세 개의 어노테이션으로 바꿀 수 있음 @SpringBootConfiguration : @Configuration과 동일(명칭만 다르다고 봐도 무방) @ComponentScan @EnableAutoConfiguration 으로 바꿀 수 있음 3. Spring Boot의 빈을 등록하는 2단계 @ComponentScan 으로 등록 @EnableAutoConfiguration..
[maven] 의존성 찾기 1. mvnrepository 접속 https://mvnrepository.com/ 2. 의존성 검색 3. 버전 선택 4. 복사해서 pom.xml에 붙여넣기
[Spring Boot] 의존성 관리 1. 의존성 관리 pom.xml내에 dependency는 버전 정보를 적지 않아도 Spring Boot가 제공하는 의존성 관리에 의해 알아서 가져옴 Spring Boot가 제공하지 않거나 특정 버전을 사용하고 싶은 경우 직접 명시해야 함 프로젝트의 구조 때문에 parent POM을 사용할 수 없는 경우에는 dependencyManagement를 사용하면 되지만 spring-boot-starter-parent 사용을 권장 # pom.xml에서 parent를 타고 들어가게 되면 # 최상단에 위치한 파일에 tomcat, thymeleaf 등의 dependency 확인 가능 2. 의존성 추가 추가해야 할 의존성을 내에 지정 좌측에 화살표 위쪽 방향이 표시된 경우 자동으로 버전관리를 해주기 때문에 버전을 명시하지..
[Spring Boot] Spring Boot 시작하기 1. Spring Boot 소개 독립적이고, 제품 수준인 Spring 기반 application을 만들 때, 빠르고 쉽게 만들 수 있음 유저가 최소한의 설정만 할 수 있도록 자주 사용되는 설정 값을 기본적으로 제공함 ex) 톰캣 Java 8 이상에서 사용 가능 2. Spring Boot 목적 Spring application 개발을 더 빠르고, 폭넓게 할 수 있음 기본적으로 자주 사용하는 설정 값을 제공하지만, 요구사항에 맞게 얼마든지 변경할 수 있음 non-functional 기능도 제공함 ex) embedded servers, security, metrics, health checks, externalized configuration 코드 제너레이션과 XML 설정을 하지 않음 3. maven Java..
[Spring] 정적 컨텐츠 # 웹 개발 방식 정적 컨텐츠 : 서버에서 뭔가를 하지 않고 파일을 웹 브라우저에 그대로 전달 mvc와 템플릿 엔진 : jsp, php가 템플릿 엔진 html을 그냥 전달하지 않고 서버에서 프로그래밍을 해서 html을 동적으로 바꿔서 전달 mvc : model, view, controller api # 동작방식 1. http://localhost:8080/hello-static.html 2. controller쪽에서 hello-static 찾음 (controller가 우선순위를 가짐) 3. resources/static에서 hello-static.html 찾음 4. hello-static.html 반환 # controller가 있는 경우 동작 방식 2021.10.19 - [Java/Spring] - [S..
[IntelliJ] Git Bash 연동 1. File - Settings - Tools - Terminal (단축키 Ctrl + Alt + s) : Application Settings 밑에 Shell path에 git bash 경로 적어줌 "C:\Program Files\Git\bin\bash.exe" -login -i 2. IntelliJ 재구동 https://violetboralee.medium.com/intellij-idea%EC%99%80-git-bash-%EC%97%B0%EB%8F%99%ED%95%98%EA%B8%B0-63e8216aa7de IntelliJ IDEA와 Git Bash 연동하기 JetBrains 계열의 IDEA와 Git Bash를 연동하는 방법을 소개합니다. violetboralee.medium.com https://..
[Spring] 빌드하고 실행하기(Git Bash, CMD) : Git Bash, Windows CMD에서 gradle 빌드하고 실행하기 1. 프로젝트 디렉터리로 이동 (Git Bash, CMD 동일) C:\Users\hhlin>cd hello-spring 2. gradle 실행 # Windows C:\Users\hhlin\hello-spring>./gradlew # Git Bash C:\Users\hhlin\hello-spring>gradlew # CMD # Mac C:\Users\hhlin\hello-spring>./gradlew build # 잘 안되는 경우 # ./gradlew clean 하면 build 폴더가 없어짐 # ./gradlew clean build 하면 지우고 다시 생성 C:\Users\hhlin\hello-spring>./gradlew cle..
[Spring] View 환경설정 1. Welcome Page : spring boot는 static/index.html을 올려두면 Welcome page 기능을 제공 2. 정적 페이지 : 파일을 웹서버가 웹브라우저에 그냥 던짐 Hello hello 3. Thymeleaf 템플릿 엔진 : 템플릿 엔진을 이용해 루프를 넣는 등 원하는 대로 바꿀 수 있음 스프링 부트는 FreeMarker, Groovy, Thymeleaf, Mustache 제공 안녕하세요. 손님 를 선언해줘야 thymeleaf 문법을 쓸 수 있음 th : thymeleaf 4. Controller @Controller 붙여줘야 함 @GetMapping("hello") : 웹 어플리케이션에서 /hello로 들어오면 해당 메소드 호출 package hello.hellosprin..
[IntelliJ] html 서버 재시작 없이 변경 파일 실행 : spring-boot-devtools 라이브러리 추가하면 html 파일을 컴파일만 해주면 서버 재시작 없이 View 파일 변경 가능 # build.gradle dependencies에 spring-boot-devtools 추가 서버 재시작 없이 Build - Recompile 만으로도 변경된 파일 확인 가능 dependencies { implementation 'org.springframework.boot:spring-boot-devtools' }