How to solve the problem that Junit starts containers with spring-boot-starter-data-jpa dependencies to report errors?

after adding spring-boot-starter-data-jpa to your springboot project, when you unit test your repository with junit. There will be a lot of

when starting the container through junit test case. The error of

[Xlint:cantFindType]
[AppClassLoader@xxxx] error can"t determine implemented interfaces of missing type xxxx is in the console (see the screenshot for detailed stack information). And will cause my Springboot Data repository Scanning to become very slow.
[main] .s.d.r.c.RepositoryConfigurationDelegate: Finished Spring Data repository scanning in 41625ms.

strangely, the error report does not affect the container startup and does not fail my case. What is even more strange is that when I directly run my SpringApplication class to start the container, there is no error message and the Springboot Data repository Scanning is very fast and does not slow down.

the background of these two problems occurred after I added spring-boot-starter-data-jpa dependencies to the project. The version of Springboot tried 2.0.3 and then upgraded to the latest version of release. Is there something missing in my junit case?

has also tried to switch to TestNg, and the problem repeats itself.

related codes

App:

@ SpringBootApplication
/ / @ EnableDubboConfiguration
public class DubboCallerApplication {

public static void main(String[] args) {
    SpringApplication app = new SpringApplication(DubboCallerApplication.class);
    app.setBannerMode(Banner.Mode.OFF);
    app.run(args);
}

}

Test class:

@ RunWith (SpringJUnit4ClassRunner.class)
@ SpringBootTest (classes = DubboCallerApplication.class)
public class JpaTest {

@Autowired
DeviceRepository deviceRepository;

@Test
public void test(){
    Device device = deviceRepository.findDevice("xxxxx");
    System.out.println(device);
}

}

Repository class:

@ Repository
public interface DeviceRepository extends JpaRepository < Device, Integer > {

@Query("select d from Device d where device_id = ?1")
public Device findDevice(String device_id);

@Query("update Device set create_time = ?2 where device_id = ?1")
public Device findDevice(String device_id, long create_time);

}

data source configuration:

@ Configuration
@ EnableTransactionManagement
@ EnableJpaRepositories (

)
    entityManagerFactoryRef = "entityManagerFactoryMember",
    transactionManagerRef = "transactionManagerMember",
    basePackages = {"com.xxx.apicaller.dao.member"}

)
public class MemberDataSourceConfig {

//
@Autowired
@Qualifier("memberDataSource")
private DataSource memberDataSource;

//EntityManager
@Primary
@Bean(name="entityManagerMember")
public EntityManager entityManager(EntityManagerFactoryBuilder builder){
    return entityManagerFactoryMember(builder).getObject().createEntityManager();
}

//EntityManager
@Primary
@Bean(name="entityManagerFactoryMember")
public LocalContainerEntityManagerFactoryBean entityManagerFactoryMember(EntityManagerFactoryBuilder builder){
    return builder
            .dataSource(memberDataSource)
            .properties(getVendorProperties())
            .packages("com.xxx.apicaller.domain.member")
            .persistenceUnit("memberPersistenceUnit")
            .build();
}

//Jpa
@Autowired
private  JpaProperties jpaProperties;

//Jpa
private Map<String, String> getVendorProperties(){
    return jpaProperties.getProperties();
}

//
@Primary
@Bean(name="transactionManagerMember")
public PlatformTransactionManager transactionManagerMember(EntityManagerFactoryBuilder builder){
    return new JpaTransactionManager(entityManagerFactoryMember(builder).getObject());
}

}

although the error report will not fail case, nor will it fail to start the container, it is difficult to see these error message thieves, and the scanning time of repository is even more painful. Is there anything you can do to help.


you can consider whether it is a package conflict. The exception shows that the inherited interface cannot be determined due to the missing xxx class

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37fa2-2b624.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37fa2-2b624.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?