Eclipse - java.lang.ClassNotFoundException
Eclipse dışında JUnit-benim Test başlatmak için çalışırken, bir"". ClassNotFoundException "" Konsol - her şey gayet iyi çalışıyor. mvn test çalıştırırken Ayrıca, sorunları Eclipse rapor yok.
Proje benim yapısı aşağıdaki gibidir:
- ana proje (pom-paketleme)
- Proje (savaş-ambalaj - JUnit test benim burada) Web
- Flex projesi
- Yapılandırma projesi
edit: sınıfın Nasıl bulunabilir? Özel kütüphaneler ile Hello world Uygulaması basit.
İşte benim JUnit Çalıştır yapılandırma:
Testclass (ama dediğim gibi; basit bir Hello world ile de işlemiyor...):
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import biz.prognoserechnung.domain.User;
import biz.prognoserechnung.domain.UserRepository;
import biz.prognoserechnung.domain.hibernate.UserHibernateDao;
public class UserDaoTest {
/**
* the applicationcontext.
*/
private ApplicationContext ctx = null;
/**
* the user itself.
*/
private User record = null;
/**
* Interface for the user.
*/
private UserRepository dao = null;
@Before
public void setUp() throws Exception {
String[] paths = { "WEB-INF/applicationContext.xml" };
ctx = new ClassPathXmlApplicationContext(paths);
dao = (UserHibernateDao) ctx.getBean("userRepository");
}
@After
public void tearDown() throws Exception {
dao = null;
}
@Test
public final void testIsUser() throws Exception {
Assert.assertTrue(dao.isUser("John", "Doe"));
}
@Test
public final void testIsNoUser() throws Exception {
Assert.assertFalse(dao.isUser("not", "existing"));
Assert.assertFalse(dao.isUser(null, null));
Assert.assertFalse(dao.isUser("", ""));
}
}
CEVAP
Bu durum karşısında birkaç kez geldim ve girişimleri bir sürü sonra, ben çözümü buldum.
Projenizi build-path ve her klasör için özel çıkış klasörleri etkinleştir onay.Projenizin kaynak klasör, her halde tek tek git ve maven kullanmak istiyorsunuz klasör çıktı ayarlayın.
Örneğin, web proje src/main/java
test sınıfları target/test-classes
web proje altında olmalıdır ve web projesi kapsamında target/classes
var.
Bu yapılandırmayı kullanarak eclipse birim testleri çalıştırmak için izin verir.
Sadece bir tavsiye, Eğer web proje testleri gerektiren bazı yapılandırma dosyaları altında kaynaklarını, emin olun içeren klasörü olarak bir kaynak klasör ve uygun yapı-yol yapılandırma.
Umarım yardımcı olur.
java.lang.ClassNotFoundException: org....
Eclipse Java proje: türü java.lang.Nes...
Java alıyorum.lang.ClassNotFoundExcept...
İle " uğraşan;java.lang.OutOfMemor...
Eclipse/Java kod tamamlama çalışmıyor...