들어가기 전에
Spring Boot를 이용하면 간편하게 웹 애플리케이션을 작성할 수 있습니다. 부스트 코스 웹 과정에서는 Spring Boot를 사용하지 않고 스프링 프레임워크를 사용하여 웹을 개발하고 있는데요. 부스트 코스에서 배운 내용을 Spring Boot를 이용한 방법으로 개발하려면 어떻게 해야할지 배워보도록 하겠습니다.
특강 개요
- 특강 날짜 : 2018.08.22
- 교수자 : 웹 프로그래밍 백엔드 설계자 강경미님
- 주제 : 기존 스프링 프로젝트를 스프링 부트로 바꾸기
영상
comment
시간이 흘러서 비교적 최신 버전으로 spring boot를 만들어 실습한다면 아래 요소 확인하고 실행해보세요!
1. pom.xml 에서 java version 이 현재 설치된 java와 일치하는지 확인
(보통 기본값이 11인데, 저는 8로 수정하니까 오류가 수정되었습니다)
2. (@RunWith not found 이라면) Junit 5 버전이 적용된건지 확인하기
- Junit 5 에서는 @RunWith 지정 안해주고 @SpringBootTest 하나만 하면 됩니다
- Assertions.assertThat 사용
@SpringBootTest
class RoleappApplicationTests {
@Autowired
DataSource dataSource;
@Test
void connectionTest() throws Exception {
Connection conn = dataSource.getConnection();
Assertions.assertThat(conn).isNotNull();
conn.close();
}
}
정말 좋은 강의 감사드립니다!! Spring Boot 정말 쉽게 설명해주셨서용 ㅎㅎㅎ 기존MVC랑 뭐가 달라졌는지, 더 편해진건 뭔지 차근차근 다시 정리해서 프로젝트 변환 해봐야겠습니다 ㅎㅎ
role.html 코드입니다!! 편하게 복사 붙여넣기 하세요 ㅎㅎㅎ
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>roles</title>
<meta contenㅅ="text/html; charset=UTF-8" http-equiv="Content-Type"/>
</head>
<body>
<h1>Roles</h1>
<div id="roles">
<div class = "role" th:each="role:${list}">
<div class = "roleId" th:text="${role.roleId}"></div>
<div class = "roleId" th:text="${role.description}"></div>
</div>
</div>
</body>
</html>
좋은 강의 감사합니다! 정말 스프링 부트 별거 없네 (?) 란 생각을 할 수 있었습니다 ㅋㅋ
다만 현장에선 제공된 것 같은데 여기엔 data.sql 이나 schema.sql 파일의 별도 링크가 없는 것 같아서 내부의 내용 (정확한지 모르겠지만 ) 제가 실습하면서 만들어 쓴 것들 아래에 남겨놓겠습니다. 검색하면 나오지만 pom.xml에 추가해야 하는 thymeleaf dependency도 같이 남겨 놓을게요~ 모두 열공하세요~
data.sql
INSERT INTO ROLE VALUES (100, 'Developer');
INSERT INTO ROLE VALUES (101, 'Researcher');
INSERT INTO ROLE VALUES (102, 'Project manager');
schema.sql
DROP TABLE ROLE;
CREATE TABLE ROLE(
role_id INTEGER NOT NULL,
description VARCHAR(100)
);
thymeleaf
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>