shubham singla
shubham singla

Reputation: 21

@SpringBootApplication cannot be resolved to a type. I have tried everything but only this error remains

package org.example;

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

/**
 * Spring boot main Application
 *
 */
@SpringBootApplication
public class Application 
{
    public static void main( String[] args ) throws Exception
    {
        SpringApplication.run(Application.class, args);
    }
}

Upvotes: 0

Views: 12434

Answers (5)

Kiran
Kiran

Reputation: 1

When I set the sourceCompatibility to the correct version in build.gradle, it fixed my error.

Also, gradle version should be compatible to the Java version.

Upvotes: 0

ssomu
ssomu

Reputation: 89

This may be due to "spring-boot-starter-parent" version issue.

i have changed the version it resolved the errors.

Upvotes: -1

Mohammad Saif
Mohammad Saif

Reputation: 21

If you are doing it with gradle. Make sure you have "org.springframework.boot:spring-boot-gradle-plugin:1.5.6.RELEASE" at classpath and apply plugin :'org.springframework.boot' included in your bulid.gradle file.

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

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

Upvotes: 2

active92
active92

Reputation: 654

I faced the same issue and manage to solve it by

deleting all maven local repo and update it back using maven -> update project

Upvotes: 0

vivek sharma
vivek sharma

Reputation: 11

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
</parent>

add above dependency

Upvotes: 1

Related Questions