반응형

 

STEP 1. 스프링부트 프로젝트 만들기

 

STEP 2. application.properties 채우기

demoProject\src\main\resources\application.properties

 

※ 이 때, mysql이 3306 포트를 사용중이어야하고,  tdb라는 데이터베이스가 있어야한다.

spring.application.name=demoProject
debug=true

spring.datasource.url=jdbc:mysql://localhost:3306/tdb
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

 

 

 

 

STEP 3. build.gradle에 아래로 채우기

demoProject\build.gradle

...
dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
	implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	compileOnly 'org.projectlombok:lombok'
	annotationProcessor 'org.projectlombok:lombok'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	testRuntimeOnly 'org.junit.platform:junit-platform-launcher'


	implementation 'mysql:mysql-connector-java:8.0.26'
}
...

 

 

 

STEP 4. DemoProjectApplication 구현

package com.example.demoProject;

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

@RestController
@SpringBootApplication
public class DemoProjectApplication {

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

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

}

 

 

STEP 5. DemoProjectApplication를 실행 후  localhost:8080 로 접속하기

반응형