JPA面临的春季启动问题

时间:2018-07-14 04:14:16

标签: spring-boot jpa

在春季启动中,我试图访问存储库并进入休眠状态,但无法解决。

Repository code : package com.demo.repository;
import org.springframework.data.repository.CrudRepository;

import com.demo.entity.NewEmployee;

// This will be AUTO IMPLEMENTED by Spring into a Bean called userRepository
// CRUD refers Create, Read, Update, Delete

public interface UserRepository extends CrudRepository<NewEmployee, Long> {

}

获取异常:CrudRepository cannot be resolved to a type

在Gradle依赖项中:

apply plugin: 'java'
apply plugin: 'eclipse'

ext{

    springDataVersion       = '1.10.5.RELEASE'
    hibernateVersion        ='4.3.11.Final'
    hibernateValidatorVersion='4.3.0.Final'
    hibernateJPAApiVersion  ='1.0.0.Final'

}

archivesBaseName = 'Spring4'
version = '1' 
repositories {
    maven { url "https://repo.spring.io/libs-release" }
    mavenLocal()
    mavenCentral()
}
dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    compile 'org.springframework.boot:spring-boot-starter:1.2.3.RELEASE'
     compile 'org.springframework.boot:spring-boot-starter-data-jpa'

    compile 'org.springframework:spring-context-support:4.1.6.RELEASE'
    compile 'org.springframework:spring-tx:4.1.6.RELEASE'
    compile 'org.quartz-scheduler:quartz:2.2.1'

    compile 'mysql:mysql-connector-java'

    // compile "org.hibernate:hibernate-entitymanager:${hibernateVersion}"
    // compile "org.hibernate:hibernate-core:${hibernateVersion}"
    // compile "org.hibernate:hibernate-validator:${hibernateValidatorVersion}"
   // compile "org.hibernate.javax.persistence:hibernate-jpa-2.1-api:${hibernateJPAApiVersion}"




} 
jar {
    manifest {
        attributes 'Main-Class': 'com.concretepage.Main'
    }
}

我是春季靴的新手

1 个答案:

答案 0 :(得分:0)

不确定问题是否存在,但无法在输出中看到,因此想问-是CrudRepository注释为@ Repository,POJO注释为@Entity,例如,根据本帖子https://dzone.com/articles/building-a-data-repository-with-spring-data