카테고리 없음
[Spring] 프로젝트 생성하기
happyst
2024. 8. 29. 23:49
프로젝트 환경설정 및 생성
다음 사이트에서 스프링 프로젝트 생성 https://start.spring.io
- build.gradle 파일이 아래처럼 생성됨
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.3'
id 'io.spring.dependency-management' version '1.1.6'
}
group = 'hello'
version = '0.0.1-SNAPSHOT'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
tasks.named('test') {
useJUnitPlatform()
}
- 아무것도 안했는데 다음과 같이 오류가 남
Dependency requires at least JVM runtime version 17. This build uses a Java 11 JVM.
- 이 프로젝트는 Java 17을 요구하는데, 내 Java 버전이 11이어서 오류가 나는 듯 함
- IntelliJ 설정에서 Gradle 버전을 변경하여 오류 해결
- File > Settings > Build, Execution, Deployment > Build Tools > Gradle
- Gradle build 성공
- HelloSpringApplication 실행
- localhost:8080 접속하여 어플리케이션 실행 확인
빠른 실행을 위해 IntelliJ 빌드 설정을 아래와 같이 변경
-
- File > Settings > Build, Execution, Deployment > Build Tools > Gradle