IntelliJ์์ Springboot ์คํํ๊ธฐ
1. ๊ธฐ๋ณธ์ค์ ํ์ธ ํ Next
2. GroupId์ ArtifactId ์ค์ . ํนํ ArtifactId๋ ํ๋ก์ ํธ์ ์ด๋ฆ์ด ๋๊ธฐ ๋๋ฌธ์ ์ํ๋ ์ด๋ฆ์ผ๋ก ์์ฑ ํ Finish
3. ํ๋ก์ ํธ ์์ฑ์ด ๋ค์๊ณผ ๊ฐ์ด ๋์๋์ง ํ์ธ
4. build.gradle ํ์ผ์ ์ด์ด ์๋์ ์ฝ๋๋ฅผ ์์ฑ ํ ์ฐ์ธก ํ๋จ์ Enable Auto-Import ํด๋ฆญ
buildscript {
ext {
springBootVersion = '2.1.7.RELEASE'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group 'com.tistory.mincoding'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
5. gradle ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์ ์์ ์ผ๋ก ๋ฑ๋ก์ด ๋์๋์ง ์๋์ ๊ฐ์ด ํ์ธ
6. Application.java ์์ฑ
package com.tistory.mincoding.springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
7. TestController.java ์์ฑ
package com.tistory.mincoding.springboot.web;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TestController {
@GetMapping("test")
public String test() {
return "test";
}
}
8. ์๋์ ๊ฐ์ด ์คํ(ํน์ Ctrl + Shift + F10) ํ ์น ๋ธ๋ผ์ฐ์ ๋ฅผ ์ด์ด localhost:8080/test๋ก ์ ์ ๋ฐ ํ์ธ
9. ๊ฒฐ๊ณผ ํ๋ฉด
์ถ๊ฐ) ํฌํธ๊ฐ ์ค๋ณต์ด ๋์์ ๋๋ application.properties์ ํฌํธ๋ฒํธ๋ฅผ ์ถ๊ฐํด ์ฃผ๋ฉด ๋ฉ๋๋ค.
'Back-End > Spring' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[SpringBoot] ์คํ ๋ฐฐ๋ ๋ณ๊ฒฝ ๋ฐฉ๋ฒ (0) | 2023.02.06 |
---|---|
[Spring] ์ค์จ๊ฑฐ(Swagger) ์ค์ (0) | 2023.02.06 |
[SpringBoot] ์๋ฐ ํ์ผ์ด ์ธ์๋์ง ์์ ๋ (0) | 2023.02.04 |
[Spring] @Controller, @RestController ์ฐจ์ด์ (0) | 2023.02.04 |
[Spring] ์คํ๋ง์ด๋ ? (0) | 2023.02.04 |