Confused by Folder Colors and Associated Actions

I created a Maven project, and the src folder is orange and I can't create a package beneath it -- even if I remove the folders underneath.

Another developer who created a similar project has a package beneath src with no problems (his src folder is blue). Huh?

I'm really confused what's going on. I've spent two full days trying to debug a "simple" Spring-ws deployment.

If you look at the folder below, the Web Service Endpoing class is underneath "resources".

I'm therefore having trouble configuring Spring what directory should be for its scan.

So, my question is what's the deal with the folders in IDEA. This is probably a simple thing to understand, but no matter what I do, I can't create a package beneath "src" (again, even if I remove the directiores underneath it).

How can I create a package beneath "src"???

Very confused.

Thanks in advance.

- m



Attachment(s):
folders.png
4 comments

Hi Mork,

Here 'src' is a content root and resources is a source root. Feel free to check corresponding reference section about that.

Denis

0

Hi Denis,

Thanks for your reply.

Here's the situation. I'm getting a 404 error that seems to possibly be related to the Spring-ws mapping. I think it may be due to how I'm mapping the

    <context:component-scan base-package="resources"/>

element.

Leading me to a: "org.springframework.ws.client.WebServiceTransportException: Not Found [404]" Exception when I run the client code.

If you look at my directory structure above in the screenshot, does "resources" make sense for the base package for Spring?

If I put in com.ws.test as the base package, then I get JDOM errors.

This is extremely frustrating as I'm basically in configuration hell. It seems my code is identical to the test code I'm "mimicing" except for the project name, which I've consistently refactored throughout.

I've now been working on this for three days... just trying to get a simple JDOM Spring-WS example to, gulp, work.

The major difference I see between my code and the author's code is the way things are grouped under "SRC".

I could send you the Intellij project if you want, but I'm really just trying to understand why this keeps failing.

Any suggestions would be welcomed.

Thanks,

- m

0

Well, 'resources' is not a package name at your example, it's a source root. All packages are located under a source root.

Consider the following example - let's have a class at 'org' package. File system view for it is as below:

denis@unit-311:~/Downloads/test$ find .
.
./src
./src/org
./src/org/StartClass.java



When we compile it and put the result into 'classes' dir, the project looks like below:

denis@unit-311:~/Downloads/test$ find .
.
./classes
./classes/org
./classes/org/StartClass.class
./src
./src/org
./src/org/StartClass.java



Now, when we need to run this class, we need to setup the classpath correctly. There is a number of ways to do that like below:
  • denis@unit-311:~/Downloads/test$ java -cp classes org.StartClass
  • denis@unit-311:~/Downloads/test/classes$ java -cp . org.StartClass

The main idea is that you put not a package directory but it's parent directory into classpath.

Let's map that example into IJ domain:

  • ~/Downloads/test - module's content root;
  • ~/Downloads/test/src - module's source root (obliged to be located at or under content root);
  • ~/Downloads/test/classes - module's compile output;

I.e. you can organise your project in any way (keep the sources directly at 'src' folder and mark it as a content root and a source root; keep the sources inside src/main/java and have 'src' be a content root and 'src/main/java' a content root) etc.

Hope that helps.

Denis

0

Please sign in to leave a comment.