---
title: "Sprint JPA Test"
author: "zerostar88"
date: "2015-02-14T13:45:45Z"
tags: []
categories: ["数据库"]
slug: "sprint-jpa-test"
draft: false
lastmod: "2015-02-14T13:45:45Z"
id: 2185932
url: "https://jeffyding.iteye.com/blog/2185932"
---

```
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class TestUserService {
	@Configuration
	@ComponentScan(basePackages = { "com.yxt" })
	static class ContextConfiguration {
	}

	@Autowired
	UserService userService;

	@Test
	public void testFindAll() throws ApiException {
		List<User> list = userService.findAll();
		Assert.assertTrue(list.size() > 0);
		for (User user : list) {
			System.out.println(user.getEmail());
		}
	}

}
```