@DataJpaTest нужен класс вне теста
В приложении SpringBoot я хотел бы провести некоторый тест на уровне хранилища.
@RunWith(SpringRunner.class)
@DataJpaTest
public class VisitRepositoryTest {
@Autowired
private TestEntityManager entityManager;
@Autowired
private VisitRepository visitRepository;
...
}
Когда я пытаюсь запустить тест изVisitRepositoryTest
Я получаю сообщение об ошибкеDefaultConfigService
Для поля defaultConfigService в com.norc.Application требуется компонент типа com.norc.service.DefaultConfigService, который не может быть найден.
Так что это нужно запуститьApplication
?
Я пытался положить бобDefaultConfigService
вVisitRepositoryTest
, но это не разрешено.
Этот класс используется в моем приложении
@EntityScan(basePackageClasses = {Application.class, Jsr310JpaConverters.class})
@SpringBootApplication
@EnableScheduling
public class Application implements SchedulingConfigurer {
@Autowired
private DefaultConfigService defaultConfigService;
...
}
Как это сделать?
редактироватьВ моем приложении я использую этот класс вхрон вкладка:
@Service
public class DefaultConfigServiceImpl implements DefaultConfigService {
private final DefaultConfigRepository defaultConfigRepository;
@Autowired
public DefaultConfigServiceImpl(final DefaultConfigRepository defaultConfigRepository) {
this.defaultConfigRepository = defaultConfigRepository;
}
}