java - Spring ContextConfiguraion failed to load Application Context -


this question has answer here:

i have simple test, so:

@runwith(springjunit4classrunner.class) @contextconfiguration(classes = testing.class) public class test {      @autowired     public string str;      @test     public void works(){         assertnotnull(str);     } } 

the configuration class is:

@configuration public class testing {      @bean     public string getstring(){         return "hi";     } } 

but error:

    2015-10-02 14:18:23,761 error [main] [test.context.testcontextmanager.preparetestinstance()] - caught exception while allowing testexecutionlistener [org.springframework.test.context.support.dependencyinjectiontestexecutionlistener@4df828d7] prepare test instance [com.glassdoor.search.jobs.spring.test@b59d31] java.lang.illegalstateexception: failed load applicationcontext     @ org.springframework.test.context.testcontext.getapplicationcontext(testcontext.java:157)     @ org.springframework.test.context.support.dependencyinjectiontestexecutionlistener.injectdependencies(dependencyinjectiontestexecutionlistener.java:109)     @ org.springframework.test.context.support.dependencyinjectiontestexecutionlistener.preparetestinstance(dependencyinjectiontestexecutionlistener.java:75)     @ org.springframework.test.context.testcontextmanager.preparetestinstance(testcontextmanager.java:313)     @ org.springframework.test.context.junit4.springjunit4classrunner.createtest(springjunit4classrunner.java:211)     @ org.springframework.test.context.junit4.springjunit4classrunner$1.runreflectivecall(springjunit4classrunner.java:288)     @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:12)     @ org.springframework.test.context.junit4.springjunit4classrunner.methodblock(springjunit4classrunner.java:284)     @ org.springframework.test.context.junit4.springjunit4classrunner.runchild(springjunit4classrunner.java:231)     @ org.springframework.test.context.junit4.springjunit4classrunner.runchild(springjunit4classrunner.java:88)     @ org.junit.runners.parentrunner$3.run(parentrunner.java:238)     @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:63)     @ org.junit.runners.parentrunner.runchildren(parentrunner.java:236)     @ org.junit.runners.parentrunner.access$000(parentrunner.java:53)     @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:229)     @ org.springframework.test.context.junit4.statements.runbeforetestclasscallbacks.evaluate(runbeforetestclasscallbacks.java:61)     @ org.springframework.test.context.junit4.statements.runaftertestclasscallbacks.evaluate(runaftertestclasscallbacks.java:71)     @ org.junit.runners.parentrunner.run(parentrunner.java:309)     @ org.springframework.test.context.junit4.springjunit4classrunner.run(springjunit4classrunner.java:174)     @ org.junit.runner.junitcore.run(junitcore.java:160)     @ com.intellij.junit4.junit4ideatestrunner.startrunnerwithargs(junit4ideatestrunner.java:78)     @ com.intellij.rt.execution.junit.junitstarter.preparestreamsandstart(junitstarter.java:212)     @ com.intellij.rt.execution.junit.junitstarter.main(junitstarter.java:68)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:497)     @ com.intellij.rt.execution.application.appmain.main(appmain.java:140) caused by: java.lang.illegalargumentexception     @ org.springframework.asm.classreader.<init>(unknown source)     @ org.springframework.asm.classreader.<init>(unknown source)     @ org.springframework.asm.classreader.<init>(unknown source)     @ org.springframework.core.type.classreading.simplemetadatareader. 

i'm using maven, , code fails on command line , ide (intelli-j). can illuminate me going wrong?

i tested code pom.xml worked fine, we'd need see pom.xml

<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0"      xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"      xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion>  <groupid>com.xenoterracide</groupid> <artifactid>so1</artifactid> <version>1.0-snapshot</version>  <parent> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-parent</artifactid> <version>1.2.5.release</version> </parent>  <dependencies> <dependency>   <groupid>org.springframework.boot</groupid>   <artifactid>spring-boot-starter-web</artifactid> </dependency> <dependency>   <groupid>org.springframework.boot</groupid>   <artifactid>spring-boot-starter-test</artifactid>   <scope>test</scope> </dependency> </dependencies>  </project> 

i've tested on spring 3

<?xml version="1.0" encoding="utf-8"?>   <project xmlns="http://maven.apache.org/pom/4.0.0"         xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"         xsi:schemalocation="http://maven.apache.org/pom/4.0.0  http://maven.apache.org/xsd/maven-4.0.0.xsd">   <modelversion>4.0.0</modelversion>  <groupid>com.xenoterracide</groupid> <artifactid>so1</artifactid> <version>1.0-snapshot</version>  <dependencies>   <dependency>     <groupid>org.springframework</groupid>     <artifactid>spring-core</artifactid>     <version>3.2.14.release</version>   </dependency>   <dependency>     <groupid>org.springframework</groupid>     <artifactid>spring-test</artifactid>     <version>3.2.14.release</version>     <scope>test</scope>   </dependency>   <dependency>     <groupid>org.springframework</groupid>     <artifactid>spring-beans</artifactid>     <version>3.2.14.release</version>   </dependency>   <dependency>     <groupid>org.springframework</groupid>     <artifactid>spring-context</artifactid>     <version>3.2.14.release</version>   </dependency>   <dependency>     <groupid>junit</groupid>     <artifactid>junit</artifactid>     <version>4.12</version>     <scope>test</scope>   </dependency> </dependencies> 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -