Answer the question
In order to leave comments, you need to log in
The class for testing in Spring Boot loads only its automatic configuration, how to load your own?
Help me to understand. I use Spring Boot 2.0 with Spring Data JPA
There is a main class
@SpringBootApplication
public class PhoneBookApplication {
public static void main(String[] args) {
SpringApplication.run(PhoneBookApplication.class, args);
}
}
public interface UserRepository extends JpaRepository<User, Integer>{}
@ActiveProfiles("test")
@RunWith(SpringRunner.class)
@SpringBootTest(classes=PhoneBookApplication.class)
@DataJpaTest
public class UserRepositoryTest {
@Autowired
public UserRepository userRepository;
@Test
public void createUser(){
User u = new User();
u.setFullName("FullName");
u.setPassword("123456");
u.setUserName("Name");
userRepository.save(u);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question