maven structure

Hi,

I was going through below maven example

http://www.srccodes.com/p/article/24/spring-3-mvc-framework-based-hello-world-web-application-example-using-maven-eclipse-ide-and-tomcat-server


as given in the picture of the project in the link the maven structure seems very connfusing to me compared to conventional web application structure.

why there
SpringSecurityHelloWorld/src/main/resources
which has again packages to contain .java files

Again why there is other src under which main--->web-app --->web-ing--->pages---.jsp  files


can you advise on advantages, disadvanges, practical uses of this structure.

Please advise. Any ideas, resources, sample code highly appreciated. thanks in advance
LVL 7
gudii9Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mccarlIT Business Systems Analyst / Software DeveloperCommented:
That's just how Eclipse shows the structure, the actual structure on disk is more like this...


src
 ->   main
         ->      java
                   ->        (all *.java files)
         ->     resources
                   ->        (all non *.java files needed by the app that AREN'T web related)
         ->     webapp
                   ->        (all web related app files, such as jsp's, dispatcher servlet .xml files, etc)
0
gudii9Author Commented:
>>>That's just how Eclipse shows the structure, the actual structure on disk is more like this..


that make more sense, why does eclipse change the structure. please advise
0
mccarlIT Business Systems Analyst / Software DeveloperCommented:
why does eclipse change the structure
It's not really that it *changes* the structure, just that it represents it in a different way. As for why, well it's probably just a matter of preference, but I guess it allows you to easily see from a top level, ie. without first having to drill into subfolders, where the different parts are, as in Java source code, resource files, and files required for a web application.

This representation actually changes depending on what type of project Eclipse believes it to be. In the case of the screenshot in that link, it looks like the project isn't even fully configured as a webapp, as otherwise it would have given a whole different set of top level folders that make navigating a webapp project a little simpler.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

gudii9Author Commented:
src
 ->   main
         ->      java
                   ->        (all *.java files)
         ->     resources
                   ->        (all non *.java files needed by the app that AREN'T web related)
         ->     webapp
                   ->        (all web related app files, such as jsp's, dispatcher servlet .xml files, etc)




Does above structure applies to maven web projects also. I always see maven web project structure bit weird, different compared to regular web projects. please advise
0
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Does above structure applies to maven web projects also.
Why do you say "also"? This IS the structure of a maven web project.

If it was NOT a maven web project, ie. just a standard maven project, there would be no webapp directory, just "java" and "resources".



And yes maven, in general, has a different structure to most anything else, ie. a maven web project will be different to a regular web project, and a maven java project will be different to a regular java project. It is just how maven does things!
0
gudii9Author Commented:
>>>If it was NOT a maven web project, ie. just a standard maven project, there would be no webapp directory, just "java" and "resources".



I have attached both non maven and maven projects.

I see no webapp directory.

I do not see 'resources' there. is it is same as ' Java Resources'


Also in maven project

' Java Resources' has--->src/main/resources



At bottom there is again
src--main---resources.

I also see one 'deployment descriptor at the top and ther web.xml' at bottom for maven project. i wonder why things are repeating for maven projects

Please advise
MavenStr1.jpg
0
gudii9Author Commented:
please advise
0
mccarlIT Business Systems Analyst / Software DeveloperCommented:
I see no webapp directory.
I do, it is the 5th item "up from the bottom" in your screenshot. It is only in the maven project (and not the regular project) because as I said in the previous post, maven/non-maven projects have different structures. The equivalent in the regular project is the "WebContent" directory that you can see in the screenshot.

I do not see 'resources' there. is it is same as ' Java Resources'
Again, I do see it, it is the 6th item "up from the bottom" in your screenshot. And again, it is only in the maven project because they have different structures. There is no real equivalent to the resources folder in a regular, non-maven project.



Also in maven project
' Java Resources' has--->src/main/resources

At bottom there is again
src--main---resources.
I also see one 'deployment descriptor at the top and ther web.xml' at bottom for maven project. i wonder why things are repeating for maven projects
These two issues (the fact that things are repeated in the project view) is a feature of Eclipse (nothing to do with maven). You will notice the in both projects, Eclipse has placed a "Deployment Descriptor" item at the top of each project, as well as you can see the actual source file for this, web.xml, near the bottom of each project. Note though that these AREN'T two separate things, the "Deployment Descriptor" item is just like a "view" of the web.xml file, ie. if you were to go into web.xml and modify some settings in there, those changes would be reflected in the entries under "Deployment Descriptor" and vice versa.

Same for the src/main/resources, there is only ONE of these folders, Eclipse is just presenting a "view" of the folder under "Java Resources". Again if you were to add a file under the "Java Resource" -> "src/main/resources" folder, you would also see the new file at the bottom of the project under "src/main/resources".



All this is just Eclipse's way of attempting to make life easier, by taking the "filesystem layout" view of the project and trying to make a more meaningful "developer centric" view of the project, ie. web.xml is a fairly common file that needs to be edited,modified, etc so rather than just have it buried in a few levels of filesystem folders, such as "src/main/webapp/WEB-INF/web.xml" in the cade of a maven web project, it provides the "Deployment Descriptor" view of that right at the top of the project to make it easier to access.
0
gudii9Author Commented:
In my project

src
 ->   main
         ->      java
                   ->        (all *.java files)
         ->     resources
                   ->        (all non *.java files needed by the app that AREN'T web related)
         ->     webapp
                   ->        (all web related app files, such as jsp's, dispatcher servlet .xml files, etc)







I see one more web-resource apart from ,java, resources, webapp.



src
 ->   main
         ->      java
                   ->        (all *.java files)
         ->     resources
                   ->        (all non *.java files needed by the app that AREN'T web related)
         ->     webapp
                   ->        (all web related app files, such as jsp's, dispatcher servlet .xml files, etc)
         ->     web-resources





 what does web-resource is used for. please advise
0
gudii9Author Commented:
Please advise
0
mccarlIT Business Systems Analyst / Software DeveloperCommented:
"web-resources" (if you were to have a look in there yourself) just contains some ancillary Maven stuff. You don't need to be concerned with anything in there, it won't affect your project in any way.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.