| 스프링 부트 외부 설정 스프링 부트는 외부 설정을 통해 스프링 부트 어플리케이션의 환경설정 혹은 설정값을 정할 수 있습니다. 스프링 부트에서 사용할 수 있는 외부 설정은 크게 properties, YAML, 환경변수, 커맨드 라인 인수 등이 있습니다. | properties 파일을 통한 설정 properties 파일을 통해서 다음과 같이 스프링 부트 어플리케이션의 외부 설정을 할 수 있습니다. properties의 값은 @Value 어노테이션을 통해 읽어올 수 있습니다. # application.properties # 스프링부트가 구동될 때 자동적으로 로딩하는 프로퍼티 파일 # 스프링부트의 규약 hi.name=hong hi.age=${random.int} //random값을 이용하여 값 랜덤 생성 #..
SpringApplication.run(SpringName.class,args); ->이렇게하면 스프링 애플리케이션에 제공하는 다양한 커스터마이징 기능을 사용하기 어렵다 따라서 인스턴스를 만들고 run하는 방법을 사용하면 위 코드와 결과는 같지만 커스터마이징 기능을 사용할 수 있다. SpringApplication app = new SpringApplication(SpringintitApplication.class); app.run(args); ->기본적으로 info level이 low레벨이다 | 이벤트 리스너( Event Listener ) 스프링 부트를 실행할 시 구동되는 단계마다 여러 이벤트들이 발생하게 됩니다. 스프링부트에서는 프로그래머가 이 이벤트들을 나타내는 객체를 인자로 받아 각 단계마다 원..
| 스프링부트(Spring Boot) HTTPS 구축 스프링부트에서 HTTPS 설정법은 다음과 같습니다. Terminal 창에 다음과 같이 커맨드를 입력하여 keystore 파일을 하나 생성합니다. keytool -genkey -alias spring -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 4000 application.properties에 위에서 설정한 정보를 입력합니다. 위 https로 설정된 스프링 부트 어플리케이션에 http://localhost:8080/ 로 요청했을 경우에는 요청을 받지 않는다는 브라우져 메세지가 뜨게 됩니다. 그렇다면 https 프로토콜로 위와 같은 요청을 했을 경우(https:..
| 사용자(Custom) Autoconfigure 클래스 선언의 문제점 @Configuration 어노테이션을 등록하여 Autoconfigure 스프링 부트 자동 설정을 만들었지만 여기에 문제점이 있습니다. @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication application = new SpringApplication(Application.class); application.setWebApplicationType(WebApplicationType.NONE); application.run(args); } @Bean public Saelobi saelobi(){ ..
스프링 부트 자동 설정 이해 스프링 부트는 스프링 프레임워크에서 어플리케이션을 만들 때 주로 사용하는 설정들을 자동으로 설정합니다. 이 기능은 자바의 main 진입점에 @SpringBootApplication을 붙임으로서 사용할 수 있습니다. @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication application = new SpringApplication(Application.class); application.run(args); } } @Configuration @ComponentScan @EnableAutoConfiguration public class Ap..
| 스프링 부트 의존성 관리 (Spring Boot Dependency Management) 스프링 부트는 Maven, Gradle 같은 빌드 관리 툴을 통해 의존성을 관리합니다. 여기서는 Maven 기준으로 스프링 부트가 의존성을 어떻게 관리하는 지 살펴보도록 하겠습니다. pom.xml 에 스프링 부트에 대한 기본적인 의존성을 추가하면 다음과 같습니다. org.springframework.boot spring-boot-starter-parent 2.1.1.RELEASE org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test 다음과 같이 의존성을 추가하면 스프링 부트가 자체적..