Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

<packaging>war</packaging>
    <properties>
        <spring.version>4.3.0.RELEASE</spring.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
    </dependencies>

Yet when I built it ends up complaining package org.springframework.web.bind.annotation does not exist

Why? I already added spring web as a dependency. What am I doing wrong?

like image 405
MassiveParty24 Avatar asked Sep 07 '17 04:09

MassiveParty24


1 Answers

I had a similar issue, I fixed it by going into my pom.xml file and changing the artifactID for the spring boot dependency from:

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

to

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
</dependency>
like image 70
Cory Bergquist Avatar answered Sep 22 '22 02:09

Cory Bergquist