Don't know which project to create inside Spring Tool Suite - java

I am new with developing web application with Java Spring Framework inside Spring Tool Suite IDE. When start a new project there are so many kinds of project such as Spring Project, Simple Spring Utility Project, Spring VMC Template Project, Spring Roo Project, Static Web Project, Dynamic Web Project and Maven Project. I do not know which project I should select? Can someone explain me, please?

I would choose none of the above.
If you have a recent version of STS (since 3.4 I think) there is also an "Import Spring Getting Started Content" (clue in the name: if you are getting started this is a good place to look, and all the guides are online at https://spring.io/guides). If you are studying the guides then this is the best place to start.
You also get a "Spring Starter Project" option directly in the "New" menu. If you want a minimal project with enough code to run but no actual business logic, then this is the best place to start. It's what you would use to create the code in the guides mostly.
The other options (including all those listed in the original post) are unofficially deprecated, and not particularly well maintained or modern.

As an absolute beginner, I would read up on Spring Roo and then pick either Spring MVC or Spring Roo project depending on whether I liked Roo or not.

Related

Dummy Project Structure for Java Spring Project

There are certain conventions for having a decent project structure while working with Java Spring Framework. Different packages, different properties file, beans.xml files and other packages and classes for a maintainable and readable project. Can anyone please provide me with the same. Also some dummy package names and class names would be really helpful for me to start with.
Thanks!
You should use Maven archetypes to create standard conventions of Project Structures in any framework.
You can use STS (Spring Tool Suite) or Spring Initializer for creating Spring Project skeletons with different modules of Spring tied up (optional).
Moreover, Spring is a very well supported community. You'll find many well-documented open source projects on Git for reference.

Have I to put spring-mvc.jar in my classpath to create a Spring MVC project?

I am pretty new in Spring. If I want to implement a Spring MVC project have I to explicitly put the spring-mvc.jar file into my classpath? From what I know the Spring MVC project is not part of the Spring Core.
Is it right?
You can go many ways but I'll suggest you to learn a build automation tool like maven or gradle. It will take care of everything related to dependency management. Here's a good resource to get started https://spring.io/guides/gs/gradle/

Should I use the Spring Framework jar files or Spring Batch jar files while creating a java email batch program?

I am trying to create a java email batch program that sends an email with an attachment each day to a specific email address, and I have to use Spring as the framework for this program. It is not going to be a web application, but since I'm implementing Spring into this, how would I go about this? I am totally new to Spring (and Java for that matter), but am unsure of which direction I need to go. Which jar files do I need? Spring Batch or Spring Framework? Also, where can I download the jar files for Spring Framework? The spring.io site won't let me download those jar files.
I very strongly suggest you use a build tool that handles dependency management. Such tools are Ant+Ivy, Maven and Gradle. They will take care of downloading the appropriate jars based on your declaration of what dependencies you need and will take care of all the transitive dependencies.
One good way of getting started with Spring Batch is to follow this tutorial using either Maven or Gradle (the latter would probably be easier since you don't need to install it - the tutorial's code has a wrapper).
The tutorial uses Spring Boot which vastly simplifies Spring configuration (which is a serious benefit especially for someone who is new to Spring)
As others already told you, I personally would not start any spring based project (means: any project) without maven! You have so much benefits from it, not only depencency management.
To start a spring app outside an application context:
#Configuration
public class AppConfig {
//any bean configurations here
}
//your entry class
static void main(String args[]) {
//get a reference to the spring context. use this context throughout your app!
ApplicationContext ctx = new AnnotationConfigApplicationContext(CacheConfig.class).get();
//optain any beans from the context. inside these beans, you can use any spring feature you like, eg #Autowired
ctx.getBean(YourBean.class).executeMethod();
}
I'd recommend starting with Spring Boot which will handle all of that for you. As others have mentioned, pick a build tool (Maven or Gradle) and follow the guide we provide on building a batch application here: http://spring.io/guides/gs/batch-processing/.

I am confused with Hibernate Spring

I am rookie into Java and I am directly thrown into Hibernate and Spring. I have attended some training classes and I am following documents online from random forums and trying to run a test project. I have some set of questions to be answered.
What is the latest version of Hibernate that has come and where do I download all the dependent jars in one place?
What is the latest version of Spring that is out there?
Any links/blogs that shows me to configure a hello world or a similar implementation would be of great help with the latest versions of Spring and Hiberante!!
Thanks.
The project web page says it is Spring 3.0.5 Release
The project web page says it is Hibernate 3.6.1 Release
Hibernate and Spring tutorial
Rest you will find using some web search like google.com or bing.com or altavista.com
I highly recommend you check out Spring Roo. There is a super duper quickstart.
Although its touted for doing Code and JSP scaffolding I find its biggest benefit is setting up your project in a very canonical and java/spring best practice setup.
It will setup maven and all the dependencies you will need. The default Maven Pom file alone is a big time saver.
If you don't want to use Roo you can easily just strip it out of your Maven pom file after your done doing the initial scaffolding.
The other option is using a Maven Archetype like AppFuse but I haven't used this in quite some time and I find Roo easier.
What I don't recommend is wasting your time writing an Ant script and then trying to cobble together all the dependencies.

Ready configurations for Spring + Hibernate

Sometimes, it's very tediously to make own configuration, find all libraries, check it ...
So, is there any ready typical (template) config for appropriative task?
AppFuse can be used for generating project templates for your given choice and combination of technologies.
Spring Roo is designed for this. It's on RC2 for their 1.0 release now.
It has a command shell environment that allows you to pick and setup the parts of the Spring application you'd like to use. It generates the Spring config files, Maven setup, and templates the Java classes for you.
Besides being great for templating, it's also a good way to get yourself introduced to other parts of the Spring application stack (Web Flow, Security).
Maybe you'll find what you're looking for here: http://code.google.com/p/project-template/.
There is no ready made runtime config for your application but you can use things like Maven or Ivy to manage all the JARs you need automatically.
You could start from one of the examples as provided in the Spring download package and modify it to suits your need.

Categories

Resources