Failed to load ApplicationContext from Unit Test: FileNotFound

前端 未结 9 1044
夕颜
夕颜 2021-02-01 14:44

I am creating a Maven Spring project, which includes MVC, Data and Security. My Spring applicationContext-*.xml files are located at \\src\\main\\resources\\spring\\

My

相关标签:
9条回答
  • 2021-02-01 14:53

    The problem is insufficient memory to load context.

    Try to set VM options:

    -da -Xmx2048m -Xms1024m -XX:MaxPermSize=2048m
    
    0 讨论(0)
  • 2021-02-01 14:56

    Add in in pom.xml give the following plugin:

    <plugin>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.10</version>
      <configuration>
        <useFile>false</useFile>
      </configuration>
    </plugin>
    
    0 讨论(0)
  • 2021-02-01 14:58

    try as below

    @ContextConfiguration (locations = "classpath*:/spring/applicationContext*.xml")
    

    this will load all 3 of your application context xml file.

    0 讨论(0)
  • 2021-02-01 15:00

    I faced the same error and realized that pom.xml had java 1.7 and STS compiler pointed to Java 1.8. Upon changing compiler to 1.7 and rebuild fixed the issue.

    PS: This answer is not related to actual question posted but applies to similar error for app Context not loading

    0 讨论(0)
  • 2021-02-01 15:11

    For me, I was missing @ActiveProfile at my test class

    @ActiveProfiles("sandbox")
    class MyTestClass...
    
    0 讨论(0)
  • 2021-02-01 15:11

    If you are using intellij, then try restarting intellij cache

    1. File-> Invalidate cache/restart
    2. clean and build project

    See if it works, it worked for me.

    0 讨论(0)
提交回复
热议问题