1.首先檢查pom.xml配置中有沒有添加相關(guān)依賴(如果沒有復(fù)制粘貼以下依賴到pom.xml文件中)

<dependency>
          <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
2.如果添加依賴后,還是@Entity還是報(bào)紅,光標(biāo)放在@Entity后面,按ctrl+1,選擇要導(dǎo)的包

截圖

截圖