1
votes

I am trying to run the spring boot project in IntelliJ, I am facing issues when compiling the code. Detailed explanation below.

**bold**Error below **bold**

` javac StudentApplication.java

StudentApplication.java:6: error: package org.springframework.boot does not exist import org.springframework.boot.SpringApplication; ^ StudentApplication.java:7: error: package org.springframework.boot.autoconfigure does not exist import org.springframework.boot.autoconfigure.SpringBootApplication; ^ StudentApplication.java:9: error: cannot find symbol @SpringBootApplication ^ symbol: class SpringBootApplication StudentApplication.java:14: error: cannot find symbol SpringApplication.run( ^ symbol: variable SpringApplication location: class StudentApplication 4 errors `

Below is my StudentApplication.java ' I am getting the error in the SpringApplication.run '

//import org.springframework.context.ApplicationContext;


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

@SpringBootApplication
public class StudentApplication {

  public static void main(String[] args) {
    //ApplicationContext ctx =
        SpringApplication.run(
        StudentApplication.class, args);
    //System.out.println(ctx);
  }
}

Below is my porm.xml ' With the list ' ' '

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>info.inet</groupId>
    <artifactId>coursestudent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>coursestudent</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>11</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

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

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

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

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>

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

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-rest-hal-browser</artifactId>
            <version> 3.3.6.RELEASE </version>
        </dependency>

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

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.2.5.RELEASE</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

I am unable to solve it. Even after adding the dependency in the porm.xml file. Anyone able to help me. If required, I will push git to see the complete code. But please don't close it unnecessarily.`

1

1 Answers

0
votes

is your remote maven repo updated? check

Settings -> Build, Execution, Deployment -> Build tools -> Maven -> Repositories