首页 > 解决方案 > 即使测试成功,数据也不会添加到表中

问题描述

我有两个实体,我测试我的 crud 应用程序。我的测试成功,但数据没有出现在表格中。

当我们使用Hibernate的测试类时,不是数据添加到表中了吗?

测试类:

@RunWith(SpringRunner.class)
@DataJpaTest
@AutoConfigureTestDatabase(replace=Replace.NONE)
public class UniversitiesAndStudentEntityTest {

@Autowired
TestEntityManager entityManager;

@Autowired
private UniversityRepo universityRepo;

@Autowired
private StudentRepo studentRepo;



// write test cases here

@Test
public void whenFindByName_thenReturnEmployee() {
    // given
    Students alex = new Students("ali",new Date());
    Universities kbuuniversity=new Universities("KArabuk uni",     "karabuk", "kbu.com", UniversityType.DEVLET, new Date());
    kbuuniversity.setApi_id(2);


    alex.setUniversity(kbuuniversity);
    kbuuniversity.add(alex);

    universityRepo.save(kbuuniversity);
    studentRepo.save(alex);



    // when
    List<Students> students = studentRepo.findAll();


    // then
    assertThat(students.size())
      .isEqualTo(1);

}

}

实体:

/*
 * Students entity sınıfı.
 */
@Entity
@Table(name="students")
@JsonIgnoreProperties(value= {"created_at","updated_at"},
allowGetters=true)
public class Students{

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;

private String name;

private Date started_at;

//
@CreationTimestamp
private Date created_at;

@UpdateTimestamp
private Date updated_at;

//Üniversitenin tutulduğu değişken. Tablodaki university_id ile eşleşir.
@ManyToOne
@JoinColumn(name="university_id")
private Universities university;

//setters,getters,constructors...

}






/*
 * Universities entity sınıfı.
 * 
 */
@Entity
@Table(name="universitiess")
@JsonIgnoreProperties(value= {"created_at","updated_at"},
    allowGetters=true)
public class Universities{

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;

private int api_id;

private String name;
private String city;
private String web_page;

//devlet ve vakıf üniversitesi şeklinde iki tip barındaran enum.
private UniversityType type;

private Date founded_at;

@CreationTimestamp
private Date created_at;


@UpdateTimestamp
private Date updated_at;


//university parametresi Students sınıfındaki university adlı değişkeni işaret eder.
@OneToMany(mappedBy="university")
private List<Students> students;

//setters,getters,constructors...
}

存储库类:

@Repository
public interface StudentRepo extends JpaRepository<Students, Integer>{

}


@Repository
public interface UniversitiesRepo extends JpaRepository<Universities, Integer>{

}

MariaDB [kodia-project]> SELECT * FROM universitys; 空集(0.00 秒)

MariaDB [kodia-project]> 从学生中选择 *;空集(0.00 秒)

日志:

    20:17:50.603 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]
    20:17:50.632 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
    20:17:50.659 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
    20:17:50.718 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest] from class [org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper]
    20:17:50.765 [main] INFO org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest], using SpringBootContextLoader
    20:17:50.777 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]: class path resource [com/emr/kodi/KodiaSoftProject/EntityTest/UniversitiesAndStudentEntityTest-context.xml] does not exist
    20:17:50.778 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]: class path resource [com/emr/kodi/KodiaSoftProject/EntityTest/UniversitiesAndStudentEntityTestContext.groovy] does not exist
    20:17:50.778 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]: no resource found for suffixes {-context.xml, Context.groovy}.
    20:17:50.780 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]: UniversitiesAndStudentEntityTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
    20:17:50.981 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]
    20:17:51.249 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [/home/emrullah/Masaüstü/proje/KodiaSoftProject/target/classes/com/emr/kodi/KodiaSoftProject/KodiaSoftProjectApplication.class]
    20:17:51.251 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.emr.kodi.KodiaSoftProject.KodiaSoftProjectApplication for test class com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest
    20:17:51.254 [main] DEBUG org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper - @TestExecutionListeners is not present for class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]: using defaults.
    20:17:51.255 [main] INFO org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
    20:17:51.322 [main] INFO org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@4d826d77, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@61009542, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@77e9807f, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@448ff1a8, org.springframework.test.context.support.DirtiesContextTestExecutionListener@1a38c59b, org.springframework.test.context.transaction.TransactionalTestExecutionListener@7f77e91b, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@44a664f2, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@7f9fcf7f, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@2357d90a, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@6328d34a, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@145eaa29, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@15bb6bea]
    20:17:51.328 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]
    20:17:51.329 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]
    20:17:51.387 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]
    20:17:51.388 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]
    20:17:51.390 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]
    20:17:51.390 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]
    20:17:51.391 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]
    20:17:51.391 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]
    20:17:51.398 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@2c34f934 testClass = UniversitiesAndStudentEntityTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@12d3a4e9 testClass = UniversitiesAndStudentEntityTest, locations = '{}', classes = '{class com.emr.kodi.KodiaSoftProject.KodiaSoftProjectApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper=true}', contextCustomizers = set[[ImportsContextCustomizer@240237d2 key = [org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration, org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration, org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration, org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration, org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@6b57696f, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@38bc8ab5, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory$DisableAutoConfigurationContextCustomizer@13c27452, org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer@351584c0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@5fda11dd, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@37374a5e], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map[[empty]]], class annotated with @DirtiesContext [false] with mode [null].
    20:17:51.399 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]
    20:17:51.400 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest]
    20:17:51.409 [main] DEBUG org.springframework.test.context.support.DependencyInjectionTestExecutionListener - Performing dependency injection for test context [[DefaultTestContext@2c34f934 testClass = UniversitiesAndStudentEntityTest, testInstance = com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest@23282c25, testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@12d3a4e9 testClass = UniversitiesAndStudentEntityTest, locations = '{}', classes = '{class com.emr.kodi.KodiaSoftProject.KodiaSoftProjectApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper=true}', contextCustomizers = set[[ImportsContextCustomizer@240237d2 key = [org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration, org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration, org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration, org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration, org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@6b57696f, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@38bc8ab5, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory$DisableAutoConfigurationContextCustomizer@13c27452, org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer@351584c0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@5fda11dd, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@37374a5e], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map[[empty]]]].
    20:17:51.769 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper=true, server.port=-1}

      .   ____          _            __ _ _
     /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
    ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
     \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
      '  |____| .__|_| |_|_| |_\__, | / / / /
     =========|_|==============|___/=/_/_/_/
     :: Spring Boot ::        (v2.1.2.RELEASE)

    2019-06-08 20:17:52.856  INFO 13814 --- [           main] e.k.K.E.UniversitiesAndStudentEntityTest : Starting UniversitiesAndStudentEntityTest on emrozk with PID 13814 (started by emrullah in /home/emrullah/Masaüstü/proje/KodiaSoftProject)
    2019-06-08 20:17:52.864  INFO 13814 --- [           main] e.k.K.E.UniversitiesAndStudentEntityTest : No active profile set, falling back to default profiles: default
    2019-06-08 20:17:54.354  INFO 13814 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
    2019-06-08 20:17:54.652  INFO 13814 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 250ms. Found 2 repository interfaces.
    2019-06-08 20:17:55.834  INFO 13814 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
    2019-06-08 20:17:56.196  INFO 13814 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
    2019-06-08 20:17:56.390  INFO 13814 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
        name: default
        ...]
    2019-06-08 20:17:56.523  INFO 13814 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.3.7.Final}
    2019-06-08 20:17:56.525  INFO 13814 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
    2019-06-08 20:17:56.884  INFO 13814 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
    2019-06-08 20:17:57.183  INFO 13814 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
    2019-06-08 20:17:58.443  INFO 13814 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
    2019-06-08 20:17:59.322  INFO 13814 --- [           main] e.k.K.E.UniversitiesAndStudentEntityTest : Started UniversitiesAndStudentEntityTest in 7.551 seconds (JVM running for 10.581)
    2019-06-08 20:17:59.371  INFO 13814 --- [           main] o.s.t.c.transaction.TransactionContext   : Began transaction (1) for test context [DefaultTestContext@2c34f934 testClass = UniversitiesAndStudentEntityTest, testInstance = com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest@23282c25, testMethod = whenFindByName_thenReturnEmployee@UniversitiesAndStudentEntityTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@12d3a4e9 testClass = UniversitiesAndStudentEntityTest, locations = '{}', classes = '{class com.emr.kodi.KodiaSoftProject.KodiaSoftProjectApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper=true}', contextCustomizers = set[[ImportsContextCustomizer@240237d2 key = [org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration, org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration, org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration, org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration, org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@6b57696f, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@38bc8ab5, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory$DisableAutoConfigurationContextCustomizer@13c27452, org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer@351584c0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@5fda11dd, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@37374a5e], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map[[empty]]]; transaction manager [org.springframework.orm.jpa.JpaTransactionManager@ca8ef3a]; rollback [true]
    Hibernate: insert into universitiess (api_id, city, created_at, founded_at, name, type, updated_at, web_page) values (?, ?, ?, ?, ?, ?, ?, ?)
    Hibernate: insert into students (created_at, name, started_at, university_id, updated_at) values (?, ?, ?, ?, ?)
    2019-06-08 20:17:59.752  INFO 13814 --- [           main] o.h.h.i.QueryTranslatorFactoryInitiator  : HHH000397: Using ASTQueryTranslatorFactory
    Hibernate: select students0_.id as id1_0_, students0_.created_at as created_2_0_, students0_.name as name3_0_, students0_.started_at as started_4_0_, students0_.university_id as universi6_0_, students0_.updated_at as updated_5_0_ from students students0_
    2019-06-08 20:18:00.054  INFO 13814 --- [           main] o.s.t.c.transaction.TransactionContext   : Rolled back transaction for test: [DefaultTestContext@2c34f934 testClass = UniversitiesAndStudentEntityTest, testInstance = com.emr.kodi.KodiaSoftProject.EntityTest.UniversitiesAndStudentEntityTest@23282c25, testMethod = whenFindByName_thenReturnEmployee@UniversitiesAndStudentEntityTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@12d3a4e9 testClass = UniversitiesAndStudentEntityTest, locations = '{}', classes = '{class com.emr.kodi.KodiaSoftProject.KodiaSoftProjectApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper=true}', contextCustomizers = set[[ImportsContextCustomizer@240237d2 key = [org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration, org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration, org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration, org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration, org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@6b57696f, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@38bc8ab5, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory$DisableAutoConfigurationContextCustomizer@13c27452, org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer@351584c0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@5fda11dd, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@37374a5e], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map[[empty]]]
    2019-06-08 20:18:00.068  INFO 13814 --- [       Thread-3] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
    2019-06-08 20:18:00.078  INFO 13814 --- [       Thread-3] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
    2019-06-08 20:18:00.138  INFO 13814 --- [       Thread-3] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

标签: javahibernatespring-bootspring-data-jpaspring-data

解决方案


推荐阅读