1

I'm a beginner at Spring boot trying to get a simple web application up and running. The problem I'm experiencing is that the IntellIJ IDE is not recognizing the spring framework imports, so some parts of my code are outlined in red(as in a Syntax Error). I can still run my application using gradlew, building the project through my terminal.

buildscript {
    repositories{
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE")
    }
}


apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

bootJar {
    baseName = 'gs-spring-boot'
    version = '0.1.0'
}

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    testCompile("junit:junit")

}

This is the build.gradle file I'm using.

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

These are the imports I am using which are not recognized by my IDE. I was wondering if I should download the spring library? Although I've seen that with Maven an XML file is enough make use of the spring libraries.

Moo
  • 48
  • 2
  • 9
  • Try to reimport in intellij idea. – Sambit Aug 29 '19 at 14:25
  • You need the spring-boot-starter-parent dependency. All else flows from that. Sounds like you've got a lot of new things to worry about all at once: IntelliJ, Spring Boot, Gradle. I would recommend simplifying things - start with Maven. Why an Eclipse plug in if you're using IntelliJ? – duffymo Aug 29 '19 at 14:27
  • I've fixed the problem by re-importing as mentioned by Sambit. Since Intellij doesn't have an option itself to reimport Gradle projects, I've used the terminal command gradle idea. You can read more about it in this post: https://stackoverflow.com/questions/19596567/intellij-re-import-gradle-project – Moo Aug 29 '19 at 14:35

0 Answers0