我是 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.propertiesspring.datasource.driver-class-name=oracle.jdbc.OracleDriverspring.datasource.url=jdbc:oracle:thin:@IP:Port:schemaspring.datasource.username=abcsspring.datasource.password=abcsspring.profiles.active=oraclespring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialectspring.jpa.hibernate.ddl-auto=validate当我运行测试时,它打印 0。如果我的配置正确,请告诉我。任何及时的帮助表示赞赏!
添加回答
举报
0/150
提交
取消