我是 Spring Boot 的新手。我正在尝试为 Spring Boot Repository 配置 Junit 测试。下面是代码片段和配置。
@RunWith(SpringRunner.class)
@DataJpaTest
@AutoConfigureTestDatabase(replace=Replace.NONE)
@ContextConfiguration(classes= ObjectAddressDaoImpl.class, loader=AnnotationConfigContextLoader.class)
@EnableAutoConfiguration(exclude=AutoConfigureTestDatabase.class)
@TestPropertySource("/application.properties")
public class AddressTest{
@Autowired
private AddressDao daoAddress;
@Test
public void testGetAddresses() {
List<AddressEntity> addresses = daoAddress.getAddresses(99L);
System.out.println("Addresses : " + addresses.size());
}
}
application.properties
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@IP:Port:schema
spring.datasource.username=abcs
spring.datasource.password=abcs
spring.profiles.active=oracle
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
spring.jpa.hibernate.ddl-auto=validate
当我运行测试时,它打印 0。
如果我的配置正确,请告诉我。任何及时的帮助表示赞赏!
哔哔one
皈依舞
相关分类