Troubleshoot Spring Boot missing package Error

package org.springframework.web.bind.annotation does not exist

Troubleshoot Spring Boot missing package Error
GBFinance - GODBELL DEV LOUNGE
프로젝트 GB Finance 관련 포스트

Gradle 사용 시

build.gradle 파일의 dependencies 항목을 봅시다. start.spring.io 기본제공 파일 기준 다음과 같이 되어 있을 겁니다.

dependencies {
        implementation 'org.springframework.boot:spring-boot-starter'
        testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

이를 다음과 같이 수정합니다. 뒤에 -web만 붙였습니다.

dependencies {
        implementation 'org.springframework.boot:spring-boot-starter-web'
        testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

Maven 사용 시

pom.xml 파일의 dependency 항목을 살펴 봅시다. start.spring.io 기본제공 파일 기준 다음과 같이 되어 있을 겁니다.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
</dependency>

이를 다음과 같이 수정하면 됩니다. artifactId 값 끝에 -web만 붙였습니다.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

참고 문서

package org.springframework.web.bind.annotation does not exist even though it’s defined in POM
So I have this code import org.springframework.web.bind.annotation.GetMapping; And I already have the following in my POM file &lt;packaging&gt;war&lt;/packaging&gt; &lt;properties&gt; ...