반응형

상단 메뉴바 File > New > Project

 

Gradle, Java 선택, Next

 

프로젝트 이름이랑 경로 지정

프로젝트에서 

build.gradle에서 의존성 설정

plugins {
    id 'org.springframework.boot' version '2.5.0'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {

    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}

test {
    useJUnitPlatform()
}

 

java 디렉토리 밑에 패키지랑 controller 등 이것저것 뚝딱뚝딱

 

RunApplication 내용

package com.export;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

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

 

기본적인 실행을 위한 Controller 내용

package com.export.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class MainController {
    @RequestMapping(value = "/home")
    public String main() throws Exception {
        return "index";

    }
}

 


참고

 

Building an Application with Spring Boot

this guide is designed to get you productive as quickly as possible and using the latest Spring project releases and techniques as recommended by the Spring team

spring.io

 

반응형

+ Recent posts