sonraki testini çalıştırıyorum: klasörün /APP/src/main/resources/META-INF/spring/
Bahar @ContextConfiguration
altında dosyanın applicationContext.xml
ile
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/META-INF/spring/applicationContext.xml" })
public class FloorServiceTest {
@Autowired
private FloorService floorService;
@Test
public void testFloorService() {
floorService.findById((long)1);
}
}
Ama doğru fasulye autowire görünmemektedir:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.confloorapp.services.FloorServiceTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.confloorapp.services.FloorService com.confloorapp.services.FloorServiceTest.floorService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.confloorapp.services.FloorService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Bu uygulama içeriğini gönder? – chrylis
ApplicationContext dosyanızı gönderebilir misiniz? deneyin 'ApplicationContext bağlam = new ClassPathXmlApplicationContext ("sınıf yolu: /META-INF/spring/applicationContext.xml"); sınıfınızın içinde' , yani sen deneyebilir miyiz –
işe yarayabilecek: @ContextConfiguration (konumları = { "sınıf yolunda: /applicationContext.xml "}) – Arpit