0

I've created a new Spring Boot project with the Spring Initializr and implemented a REST API with the Spring Boot RestController annotation. Errors occurred regarding the import and usage of the ResponseEntity class after adding a React Frontend into the application.

I don't know why the React app would interfere with anything on the Spring Boot backend, because the only connections they have are the endpoints that get called via axios from React. It's also very weird that this problem occurs globally in all of my Spring Boot projects all of a sudden.

Edit: Not a single Spring Boot annotation works anymore, it's not just about ResponseEntity

Screenshot of the rest controller (REST API): enter image description here

This is the pom.xml:

<?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.6.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.anything.examy</groupId>
    <artifactId>examy</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>examy</name>
    <description>examy</description>
    <properties>
        <java.version>11</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.1.0</version>
            </plugin>
        </plugins>
    </build>

</project>

The error: cannot resolve symbol 'responseentity'

lu_lu
  • 133
  • 12
  • Do you have `import org.springframework.http.ResponseEntity;` statement? – João Dias Jan 19 '22 at 14:16
  • yes, but I've seen that none of the Spring Boot annotations work anymore, it's not a responseentity problem apparently. Non of the annotations can be found anymore in any of my Spring Boot Projects, even if I set up a new project with https://start.spring.io/ – lu_lu Jan 19 '22 at 14:26
  • I would suggest you clear your `.m2` folder and rebuild the project again. – João Dias Jan 19 '22 at 14:40

0 Answers0