반응형

프로젝트 코드 : https://github.com/svkim/springboot_example/tree/main/01_login_register/demo

 

단계 1. 프로젝트 설정

1. Spring initializr 접속한다.

https://start.spring.io/

 

2. Dependencies를 추가한다.

아래의 Dependencies를 추가하여 생성

 

Spring Data JPA
Spring Web
MySQL Driver
Thymeleaf
Lombok

 

(Spring Security는 나중에 원할 때, 추가하면 된다.)

 

이후 GENERATE를 눌러 생성한다.

3. Intellij로 해당 프로젝트 파일을 연 후, 테스트 페이지 출력

Open을 클릭 후 \demo\build.gradle을 선택한다.

 

테스트 페이지 출력을 위해,

이후 src/main/java/com.example.demo 패키지로 가서 DemoApplication을 아래로 수정한 후, Run을 돌려본다

 

 

DemoApplication.java

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class DemoApplication {

	@RequestMapping("/")
	String home() {
		return "Hello World!";
	}

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}
}

 

이후 웹브라우저를 켜서 localhost:8080를 입력했을 때, 아래와 같이 뜬다면 정상이다.

여기까지 왔다면 프로젝트 설정은 다 한 셈이다.

 

단계 2. 

1. Project Structure

src/
├── main/
│   ├── java/com/example/demo/
│   │   ├── controller/
│   │   │   ├── AuthController.java
│   │   │   └── HomeController.java
│   │   ├── model/
│   │   │   └── Member.java
│   │   ├── repository/
│   │   │   └── MemberRepository.java
│   │   ├── service/
│   │   │   └── AuthService.java
│   │   └── DemoApplication.java
│   └── resources/
│       ├── static/
│       ├── templates/
│       │   ├── home.html
│       │   ├── login.html
│       │   └── register.html
│       └── application.properties

 

반응형