我有一个资源服务,我正在尝试在此测试类中自动布线。它在应用程序xml中注册,并带有运行器和所有其他好东西。安装完全相同的Java版本不会失败。
@RunWith(classOf[SpringJUnit4ClassRunner])
@ContextConfiguration(Array("classpath*:/applicationContext.xml"))
class RequestSuite extends JUnitSuite
with TableDrivenPropertyChecks with Matchers with BeforeAndAfterAll {
...
var myServiceResource = new MyServiceResource
@Autowired
var beanFactory: AutowireCapableBeanFactory = null
beanFactory.autowireBean(myServiceResource)
...
}
另一方面,上面的代码在我调用beanFactory时会抛出一个空指针,因为它从未被初始化。