springspring-bootspring-boot-maven-plugin

In springboot error sayingThe declared package "com.example.demo" does not match the expected package ""


package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootEdurekaTrialApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootEdurekaTrialApplication.class, args);
    }

}


  [1]: https://i.sstatic.net/78XDP.png

I have shared the screenshot of project package in above image. I have created the class under same package but I don't know why I am getting error. please guide.


Solution

  • Check your directory structure once in the file system. It should contain these three folders com/example/demo and under demo the file should be present. Sometimes folder structure is created as a single folder com.example.demo instead of the com/example/demo(3 folders). This should be the root cause of the issue.