JUnit은 하나의 클래스 안에 여러 개의 테스트 메소드가 들어가는 것을 허용한다. @Test가 붙어있고 public 접근자가 있으며 리턴 값이 void 형이고 파라미터가 없다는 조건을 지키기만 하면된다. | 스프링부트 테스트 ( @Spring Boot Test ) -@SpringBootTest 어노테이션을 통해 스프링부트 어플리케이션 테스트에 필요한 거의 모든 의존성을 제공해 줍니다. -@SpringBootTest 어노테이션 내에 어떠한 테스트 환경으로 테스트를 실행할 것인지를 따로 지정할 수 있습니다. 스프링부트 테스트를 진행하기 위해서는 먼저 다음과 같이 의존성을 추가해야 합니다. org.springframework.boot spring-boot-starter-test test 테스트를 실행하기 위..
| 스프링 부트 외부 설정 스프링 부트는 외부 설정을 통해 스프링 부트 어플리케이션의 환경설정 혹은 설정값을 정할 수 있습니다. 스프링 부트에서 사용할 수 있는 외부 설정은 크게 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:..
아래의 오류의 경우 해결 방법은 1월 20, 2020 2:53:09 오전 org.apache.catalina.core.StandardService startInternal 정보: Starting service [Tomcat] 1월 20, 2020 2:53:09 오전 org.apache.catalina.core.StandardEngine startInternal 정보: Starting Servlet engine: [Apache Tomcat/9.0.30] 1월 20, 2020 2:53:09 오전 org.apache.catalina.core.ContainerBase startInternal 심각: A child container failed during start java.util.concurrent.Exec..
스프링 부트 자동 설정 이해 스프링 부트는 스프링 프레임워크에서 어플리케이션을 만들 때 주로 사용하는 설정들을 자동으로 설정합니다. 이 기능은 자바의 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..
*************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class Action: Consider the following: If you want an embedded database (H2, HSQL or Derby), please put it on the classpath. If you have data..
| 스프링 부트 의존성 관리 (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 다음과 같이 의존성을 추가하면 스프링 부트가 자체적..