The key to spring and hibernate integration is that Hibernate's sessionfactory is created by the spring IOC container, and Hibernate's transactions are managed by spring's AOP. Note: Because of the integration, the configuration in Hibernate configuration file (Hibernate.cfg.xml) can be written to the
Over the past few days, I have made Hibernate and spring look good. I think about some of struts's things and decided to integrate the three things. The presentation layer uses STRUTS + freemarker and the business layer uses spring, hibernate processes the persistent layer. In struts, authorization is used to delegate
level Cach E provider, Hibernate-infinispan, for example, are available in the classpath).The Hibernate.cfg.xml configuration needs to be added:Org.springframework.beans.factory.BeanCreationException:Error creating Bean with Name ' sessionfactory ' defined in Class path resource [Resource/applicationcontext.xml]: Invocation of Init method failed; Nested exception is Java.lang.noclassdeffounderror:org/slf4j/loggerfactoryLack of Slf4j-api-1.6.1.jarOrg.
toString method to output information.
}
}
Then
Add bean-related configuration in the configuration file AppliccationContext. xml (this is a value injection, interface and construction injection)
Test code
Public class testPerson {Public static void main (String [] args ){XmlBeanFactory beansfactory = new XmlBeanFactory (new FileSystemResource ("src/ApplicationContext. xml "));System. out. println (beansfactory );Person nike = (Person) beansfactory. getBean ("nike ");System. out. println (
long ago, I heard of SSH, at first thought is a thing, the specific content is unknown, always feel high-end atmosphere on the grade, after learning to find, not only on the tall, but also low-key luxury has connotation, after a period of research and study of the basic principles of SSH framework and ideas, finally grounded gas. As a beginner, a little bit of harvest, want to through the form of Bowen and everyone to share, common progress, in the process of updating the blog will inevitably ha
Over the past few days, I have made Hibernate and spring look good. I think about some of struts's things and decided to integrate the three things. The presentation layer uses STRUTS + freemarker and the business layer uses spring, hibernate processes the persistent layer. In struts, authorization is used to delegate
Spring + springmvc + hibernate integrated instance, springmvchib.pdf
In the previous blog, I wrote about the integration of spring and springmvc, and added hibernate to this article.
Like the previous one, this time is still a pilot jar package. This time, you need to add the jar package in
1, SSH three framework integration principle
The integration of spring and Struts2 is to give the Action object to the Spring container for creation.
The integration of spring and Hibernate is to give the sessionfactory to the spring container for maintenance, a
It's actually very simple.
The first method is to use hiberante. cfg. xml:
The configuration of hiberante. cfg. XML is as follows:
"-// Hibernate/hibernate configuration DTD 3.0 // en"Http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">Org. hibernate. dialect. mysqldialectThen configure applicationContext
SpringMVC + Spring + Hibernate, springmvchib.pdf
Although Strusts2 + Spring + Hibernate is the mainstream WEB development framework, SpringMVC is widely used by more and more people!
Here is a small example of SpringMVC + Spring + Hibern
SPRINGMVC:The Spring framework is highly configurable and includes a variety of view technologies, such as JavaServer Pages (JSP) technology, Velocity, Tiles, IText, and POI. The Spring MVC framework does not know which view to use, so you can choose the view autonomously. Spring MVC separates the roles of controllers, model objects, dispatchers, and handler obje
struts+hibernate+spring Implement User Login functionThrough the login case to achieve the integration between the three frameworks, the login function is a necessary module for any system and software, but through this module to understand these complex framework technology, understanding the data flow and the whole design idea is quite easy. Only after mastering the application of these small modules, it
Struts, Hibernate, and spring are common keys in our Java development, and they provide the most appropriate solution for different scenarios. But do you know how these well-known frameworks were originally created?We know that traditional Java Web applications are implemented using Jsp+servlet+javabean, which implements the most basic MVC layering, which divides the program structure into several layers, t
));
Auditmanager. log () occurs in the new TX context, if auditmanager. log () itself is successful (that is, there is no exception), it will be submitted.
Create a sample Environment
In order to establish the sample environment, I followed the steps of the reference spring live:
1. download and install the following components. During the operation, pay attention to the accurate version number. Otherwise, the version mismatch may occur.
·
First, the framework of the download 1, struts2:http://struts.apache.org/download 2, Spring:http://www.springsource.org/download/community3, hibernate:http://sourceforge.net/projects/hibernate/files/hibernate4/. Create a project, add a JAR package 1, create a Java Web Project testssh.2, Add a struts package: Aopalliance-1.0.jar, freemarker-2.3.19.jar,ognl-3.0.5.jar,struts2-core-2.3.4.jar,struts2-spring-plug
This article belongs to reprint, from Baidu question Http://zhidao.baidu.com/question/213823575.html?qbl=relate_question_0word=beans%20publicSsh:Struts (presentation layer) +spring (business layer) +hibernate (persistence layer)Struts:Struts is a presentation-layer framework that mainly functions as interface display, receiving requests, and distributing requests.In the MVC framework, struts belongs to the
Struts: Responsible for the display layer, is a perfect MVC implementation, it calls the business layer to complete the operational logic, the business layer calls the persistence layer to complete the database read and write.Hibernate: Creates a series of persisted classes that correspond to the properties of each class to the database table's property one by one.Spring: relies on injection and control inversion. As soon as you get a class that implements this interface, you can easily inject t
Learn extjs5 with me (27 -- adding the Server web, spring, and hibernate configuration files ),Learn extjs5 with me (27 -- adding the Server web, spring, and hibernate configuration files)
We created a java web project before. Now we need to add the jar packages connected by spr
On spring transaction management Let's think about how we do data manipulation in hibernate when we don't use spring. In Hibernate we do one operation at a time we have to open the transaction, then the data operation, and then commit the transaction, close the transaction, we do this because
A few days ago, I introduced a method for generating data tables using the tool class. However, the previous method requires a tool class that has little to do with the project. It is a bit redundant, so I will introduce a method to you today. That is, Hibernate and Spring work together to generate the table structure.
First, configure the web. xml configured for Sprin
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.