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.
Related
I downloaded the latest version of Struts 2 to upgrade our current set of jars, and looking at the huge list of jars that come with Struts 2, I want to only include the ones that are truly required.
I had a look at the Struts 2 dependency tree and the Struts 2 compile dependencies, but I'm having trouble understanding what they mean for my application. I don't think we use anything in org.springframework (doing a workspace-wide search), but is that enough to know whether we can exclude those jars?
Is it as simple as looking at the "optional" column of the compile dependencies table from the 2nd link above? Of the optional ones, how do you know when you need them and when you don't? There are so many....
The Struts2 project has a compile dependency on Spring framework. But this doesn't mean that you need a spring framework jars to your project. As you mentioned these dependencies are optional. It means they are required if you use some features of Struts2 that depend directly on Spring. You can use Maven to resolve dependencies for your project's pom.xml. If you want to view/analize a dependency tree you can use eclipse m2eclipse plugin. Analogous visualization tools available in other IDEs. The same as invoking manually mvn dependency:tree.
It doesn't depend on spring framework.
Check here
Step 3 - Add Struts 2 Jar Files To Class Path
to see the minimum required libs for a strtus2 project.
Struts2 is using the spring framework only for the tests and compiling during build.
Beside this only the Struts2 Spring plugin has a dependency to the spring framework.
If you are not using this plugin you should not have any spring dependencies in your project.
struts2 has a dependency on spring framework because of some decent core features.
Dependency injection and AOP are the widely used features of spring framework with struts2.
while struts2 framework is rich in UI and MVC view but these are the components that makes struts2 dependent on spring.
Spring framework's security feature,JDBC,transaction management are the other module that can be used with struts2.
thanks,
Amit Kumar
Struts2 does not have any dependency on Spring. However, when you take a look at struts 2 library, it contains Spring related jar. This is done to add additional support to integrate Struts and Spring and to use nice to have features/modules of Spring like DI, AOP, transaction etc. It is completely optional to exclude those jars and to go ahead with conventional Struts framework. Also as there is no incremental development for struts like bringing struts 3 in market. Way to go forward is to integrate struts with Spring.
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.
I'm fairly new to Java/Spring and am trying to put together a simple app which will include some basic CRUD operations and I'd like to use Hibernate for data access.
I'm using Maven as my build tool. My question is: how can I find out which dependencies are required to use Hibernate? For example, I'm using Spring 3.0.6, but how would I know what version of Hibernate to use with that version of Spring? More over, if there are multiple possible Hibernate dependencies, how would I know which ones to include for the functionality I need? So far this seems to be partially reading documentation and partially trial and error.
Is there a definitive way of knowing which Maven dependencies to use with certain version of other dependencies? Any which dependencies to use for particular bits of functionality?
Thanks,
James.
I follow these steps when starting to use a new framework:
Go to framework's web site. In your case hibernate web site and try to find latest (or a specific) version. For hibernate it is 3.6.8-Final at the time of writing.
Search for a maven dependency definition on the framework web site. If you can not find any dependency definition, them simply google for "frameworkname _version_ maven dependency" and you'll most probably find necessary definition, as well as the necessary repository information. For example you can find the dependency definition for hibernate on mvnrepository.com and necessary artifact repository information on Hibernate 3.6.8 release page:
The artifacts have all been published to the JBoss Nexus repository under the org.hibernate groupId at http://repository.jboss.org/nexus/content/groups/public-jboss/
The question of which dependencies are necessary and which are optional depends entirely on the framework to be used. So for example in order to use hibernate, as stated on Hibernate Quick Start Guide:
hibernate-core: The main artifact, which contains all the Hibernate classes, in packageorg.hibernate. You need these to build applications using the native Hibernate APIs. It includes capabilities for using native Hibernate mapping in hbm.xml files, as well as annotations.
About compatibility issues (which version of hibernate is compatible with spring 3.0.6), all I can say is you have to read about integration manuals for those frameworks. Since Spring and Hibernate are two exclusively distinct frameworks, I don't think you can find a constant location to look for version compatibility matrix or something like that.
The purpose of Maven is to avoid handling dependencies by hand. Just choose which version of Hibernate to use and include it in your pom; Spring supports many different versions.
If you know what parts of Spring you want to use, just include those parts in your pom; they'll include their own requirements.
Is there a specific module and/or version combination you're having an issue with?
The only way to know for sure that you've got all dependencies is by running your app.
Maven resolves for you transitive dependencies so you can quickly detect missing ones by compiling the java code.
However, in a web app there are many dependencies that are required in runtime only, so they are not detected at compilation time.
you can find out the dependencies by running mvn dependency:tree and analyze if they are required or not by running mvn dependency:analyze.
Taking the newest ones usally works as long as they are stable.
Start with hibernate and spring core, context, tx.
After you added some could you will probably recognize that something else is missing.
Try and error doesn't sound good, but its working pretty well for spring dependencies.
we are trying to develop a web application framework and build implementatins on top of it. This framwork will be versioned in SVN, live its own life in parallel to those implementations. It will have lots of spring config files, security config and so on. We would like to use those in those implementations.
What structure should such an project have? Keep everything together? Link particular folers (implementations) in "svn: externals"? We would like to use Maven, and create an archetype for those implementations, but is it possible to update the archetype after it has been changed in implementation applications?
Regards,
This is a good example :
http://www.sonatype.com/books/mvnex-book/reference/web.html
Also this book is very useful resource when starting with maven
I found this also :
http://www.avajava.com/tutorials/lessons/how-do-i-create-a-web-application-project-using-maven.html
I'd suggest you create your framework project as a simple jar project to include in your implementation, which would be war projects. For the Spring config files you have three options then:
Package them into your framework jar. This would make it hard for the implementations to customize it. I would not recommend it, unless your configuration is definitively fixed.
Use svn: externals. I have not much experience with that, but I think dependencies between svn repositories would be hard to manage.
Maintain these configuration files per implementation. So, an archetype would help to get started with an initial configuration. Then maintain these configuration files as your framework evolves. This is what we do most of the time. The good thing about Spring configuration is that it often rarely needs to be touched once you are confident with it.
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.