使用JpaRepository o.h.i.SessionFactoryImpl时:HHH000031:关闭

时间:2018-08-02 17:09:32

标签: spring-boot jpa spring-data-jpa

使用Using JpaRepository开始spring-boot appication时出现问题。 更多详细信息,删除ReviewRepository中的findReviewByUser_num效果很好。 我的代码没有控制器,服务,我正在创建存储库,只是进行测试。

Review.Java

package org.soma.tripper.review.entity;

import lombok.*;

import javax.persistence.*;
import java.util.List;

@Getter
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Review {
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    private int review_num;

    @Column(name = "user_num")
    private int user_num;

    @Column(name = "schedule_num")
    private String schedule_num;

    @Column(name = "content",length = 1000)
    private String content;

    @Column(name="rating")
    private double rating;

    @Column(name="ml_rating")
    private double ml_rating;

    @Builder Review(int user_num, int schedule_num, String content, double rating){
        this.user_num=user_num;
        this.user_num = schedule_num;
        this.content=content;
        this.rating = rating;


    }

}

ReviewRepository.java

package org.soma.tripper.review.repository;

import org.soma.tripper.review.entity.Review;
import org.springframework.data.jpa.repository.JpaRepository;


public interface ReviewRepository extends JpaRepository<Review,Integer> {
    Review findReviewByUser_num(int user_num);
}

build.gradle

buildscript {
    ext {
        springBootVersion = '2.0.3.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

jar {
    manifest {
        attributes 'Main-Class': 'org.soma.tripper.TripperApplication'
    }
    from {
        configurations.compile.collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }
}

group = 'org.soma'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
//swagger
    compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.5.0'
    compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.5.0'
//jpa
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compileOnly('org.projectlombok:lombok')
//logback
    compile('ch.qos.logback:logback-classic:1.2.3')
    compile('ch.qos.logback:logback-core:1.2.3')
    compile 'log4j:log4j:1.2.17'
    compile 'org.slf4j:slf4j-api:1.7.5'
    compile 'org.slf4j:slf4j-log4j12:1.7.5'
// S3
    // https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk
    compile group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.371'

// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.6'


    compile('mysql:mysql-connector-java')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

控制台

enter image description here

0 个答案:

没有答案