[6-5] @Entity无法导入(已Google,仍不得要领)

来源:6-5 -后台编码

ming2281_0001

2017-11-12

# 实际现象

已按照老师的教程来做, 但是 @Entity 等无法正确导入( IDE 提示没有这个类 )

报错的导入为

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;


#  相关代码


# 上下文环境

* Gradle配置

buildscript {
   ext {
      springBootVersion = '1.5.8.RELEASE'
   }

    // 自定义  Thymeleaf 和 Thymeleaf Layout Dialect 的版本
    ext['thymeleaf.version'] = '3.0.3.RELEASE'
    ext['thymeleaf-layout-dialect.version'] = '2.2.0'

    /* 6 */
    // 自定义  Hibernate 的版本
    ext['hibernate.version'] = '5.2.8.Final'

   repositories {
      //mavenCentral()
      maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
   }
   dependencies {
      classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
   }
}

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

group = 'com.hezhiming.springboot'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
   // mavenCentral()
   maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
}


dependencies {
   compile('org.springframework.boot:spring-boot-starter-web')
    // template engine
    compile('org.springframework.boot:spring-boot-starter-thymeleaf')

    /* 6 */
    // 添加 Spring Data JPA 的依赖
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    // 添加 MySQL连接驱动 的依赖
    compile('mysql:mysql-connector-java:6.0.5')
    // 添加h2的依赖
    runtime('com.h2database:h2:1.4.193')

   testCompile('org.springframework.boot:spring-boot-starter-test')
}

# 尝试解决 & 我的理解

* 我的搜索: https://www.google.com/search?q=import+javax.persistence.Entity%3B&oq=import+javax.persistence.Entity%3B&aqs=chrome..69i57.251j0j7&sourceid=chrome&ie=UTF-8

* 我的理解: 是不是哪个包没安装? 


写回答

1回答

老卫

2017-11-12

jpa 就是那些包的,包的设置没有问题,你重新刷新下  Gradle。

0
0

基于Spring Boot技术栈博客系统企业级前后端实战

毕设 Elasticsearch搜索+Thymeleaf模板+JPA+Security+BootStrap

1296 学习 · 738 问题

查看课程