Paul Sanwald
Paul Sanwald

Reputation: 11329

Intellij: recognize a spring configuration file in jar

I have a project that includes a jar, that ships with a spring configuration file. IntelliJ Idea Ultimate version 11.1 gives me a red error/warning when I reference this file in a unit test:

@ContextConfiguration(locations={"/application_context.xml"})

I get a red warning from IntelliJ for /application_context.xml, which it highlights in red. However, the file is referenced correctly and my test runs fine. So, this would appear to be just some IntelliJ configuration issue, and not an actual problem with how I am referring to the class. The only difference between this file, and others that IntelliJ does recognize, is that this file lives in a JAR.

What's the correct way to configure IntelliJ, or refer to this file in the ContextConfiguration annotation, so that it recognizes my XML configuration file?

The answer: Crazy Coder is correct, this looks like a bug. Specifying classpath explicitly fixes the problem:

@ContextConfiguration(locations={"classpath:/application_context.xml"})

Upvotes: 2

Views: 1074

Answers (1)

CrazyCoder
CrazyCoder

Reputation: 401897

Looks like IDEA-84470. Please check if you have the same problem in IDEA 12 Preview.

Upvotes: 1

Related Questions