我坚持这个,让我们说,在PMTest中,testConfig方法, 注入时,geoService将GeoRep属性设置为null,但PMTest类的GeoRep属性不为null。为什么会这样?
这是我的课程
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {PersistenceConfig.class})
public class PMTest {
@Autowired
private GeoRep geoRep;
@Autowired
private GeoService geoService;
@Test
public void testConfig() {
geoServive.findAll();
geoRep.findAll();
}
}
@Service
public class GeoService {
@Autowired
private GeoRep geoRep;
.
.
.
}
@Transactional
public interface GeoRep extends JpaRepository<GeoRegion, Long> {
}
任何帮助,谢谢。
简而言之,
PMTest
-
- - - - - - GeoService
- -
- -
- - - - - - - GeoRep (is null)
-
-
-
- - - - - - - GeoRep (is not null)