Announcement Announcement Module
Collapse
No announcement yet.
Beginner questions about Spring MVC Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Beginner questions about Spring MVC

    Ok this is long and has many stupid questions, because I am a dumb beginner. If you can help with any of it, ton of thanks!

    Im a single developer working on a project (Java Web App) and I am relatively new to Java. I am even newer to the Spring framework. I have managed to write a small project that uses one servlet and some jsp's to authenticate users against a database and route them to either a welcome page or an error page based on login credentials. I have gotten to this point but it is only the beginning of what this application will do ofcourse. Most importantly, I am not using any Spring.

    I understand that it is in my interest to learn the spring framework if I am to design Java EE enterprise applications because it makes many things easier. So, in that quest, I headed over to the tutorials on this website:

    http://spring.io/guides/gs/serving-web-content/

    in order to do some learning. I relized quickly that all of their examples include a Maven or Gradle script for dependencies and for build. So, I thought oh no now I have to learn about one of these build tools if I need to use Spring framework? So, with my limited knowledge and reading around, I picked Gradle when I started understanding that it is the latest generation build tool in the line of Ant->Maven->Gradle. So, I thought Gradle is what I should invest my time in.

    Anyway, when I started to work on the Spring tutorial above, I quickly realized that they are doing this at the command line and not on an IDE. That confused me even further because I thought why would anyone used command line in todays world full of capable IDEs. I had Eclipse (plain vanilla + Spring Tool Suite) installed already so I thought I will do this on Eclipse instead. That's where my confusion skyrocketed.

    For starters, I couldn't figure out what kind of project template to start with. Should it be a "Dynamic Web Project?" No wait it has to be some kind of a Spring template right? Otherwise why would I go through the trouble of adding the Spring Tool Suite and get all these new templates? Ok, so I picked a Spring template. I quickly realized that I also have the option to import the Spring MVC tutorial that I was doing into Eclipse. So, I did that. More confusion, now I realized that if I right click on the imported example project, there is no longer a "Run on server" option in the "Run as" menu. I thought why is that gone? I must have picked the wrong project template. But wait, I couldn't have picked the wrong template because I imported the whole project from the Spring website. Oh man my head hurts. After some thinking I remembered.....oh yes they talked about Gradle and I already downloaded it and set my Path environment variable for it so I'll use Gradle to build and run this project. Ok now how do I invoke Gradle from within Elipse? More reading told me I must have Eclipse Gradle Integration. So I downloaded that plugin into eclipse. Now, in my right click menu I have a "Gradle" and "Gradle..." option but still no "Run on server". Man, why is this so complicated I am a beginner simply trying to run a tutorial Spring MVC project. Anyway, I chose "Gradle" from the "run as" option and I saw that Gradle prints out a bunch of a stuff in the Eclipse console like when its starting the embedded servlet container and other good stuff. But I see nothing else happening. I expected the Eclipse embedded web browser to show me "Hello world". But wait this isn't a web project because there is no Web-Inf folder in its hierarchy, so why would I see a browser...okay but I also don't see "hello world" in the console? Where is the project running? Ahaha..finally I launched my own Chrome browser and pointed it to localhost URL and glory, I saw "hello world".

    It took me two and a half days of playing around to figure all out up to this point. As you can see, my understanding is in its infancy on these things and I need some questions answered. If am looking to build a Java web application and I am the only developer:

    1. Do I need a build tool? I thought this was for teams.
    2. If so, is Gradle ok?
    3. Which Eclipse template to start with?
    4. Some other Spring MVC tutorials I saw online like the one from tutorialspoint do include jsp's and are web based(and not simply command line). Those tutorials ask you to import some jars(Spring and related jars like commons-logging) into the project at some point. How do these guys know which of the spring jars they need? Is it from experience or is there another source for this knowledge? I thought this dependency management is where the whole need for the build tool comes in and that's what Gradle will handle for me, nevermind I don't know how to ask Gradle to do that yet.
    5. Once I start a project and start using Spring incrementally, how do I know what additional jars I need at certain points?

    Thanks for reading until this line and thanks for your help.

  • #2
    IDE is a matter of taste, but yes, Java developers do generally use IDEs - like all tools, it takes some time to feel productive with it and really understand how things work together.

    Dependency management is a must have (not only in Java land). In my opinion, tutorials and blogs that suggest "adding jars to your classpath" is a smell (i.e. close your browser tab and go somewhere else). Maven and Gradle are the most popular, and they take care of all the boilerplate for you. You don't have to add JARs in your application, but rather declare a dependency in your build file (just tell your build tool which dependency+version you want).

    Try to start with small projects and learn about those tools (IDE, Spring, build management) as you go; asking clear, concise questions on StackOverflow.com and SuperUser.com should help you. Actually, those questions have often already been asked and answered for you.

    Anyway, the forums are moving to stackoverflow, a page explaining all this will be available there in a few days: http://spring.io/questions

    Comment

    Working...
    X