exception with no transaction and cannot be inserted into the database.Analysis: What is the reason for this: I used the spring MVC framework, when the MVC configuration file scanned the entire package, (including the package in the service), will naturally use @trancetion as a normal bean, so there is no transaction management.For example, the MVC configuration file uses theWorkaround:The settings for the
"); Hello.sayhello ();}}Hello.xmlPom.xmlOutput resultsHere, we have successfully used the spring framework, so what exactly does spring do? In short, it is used to help us to manage the Java class, before we use the Java class, we need to manually go to the new object, and then call the constructor or method to assign the value, Now that spring has taken the plac
Simply record a sample of spring AOPBased on two configuration methods:Based on XML configurationAnnotation-based configurationThis example is to simulate a change to the database to add thingsActually did not add, just a simple output of the recordFirst look at the entire example of the directory map All the code is not posted, the number is a bit more, but ver
First, create an XML file that describes the message, named Messages.xmlThis bean's ID is dead and can only be "Messagesource". The class here needs to fill in the implementation of the Messagesource interface. Among them, in the book I read only mentioned two classes, one is: Resourcebundlemessagesource, the other is Reloadableresourcebundlemessagesource. The latter provides features that can reload the new configuration without rebooting.The body value "Org/rjstudio/
When learning a new content, I will look for some examples. However, some examples seem incomplete, some SQL table creation statements do not exist, and sometimes there is no jar package. I feel like, there are a lot of obstacles for beginners, So I first put the directory structure of the project out, then put the SQL tabulation statement, and finally put the source code:
Directory structure:
2. Table creation statement:
MySQL database, test database:
create table 'users'(id int(10) unsigned
Build a Web development environment using IntelliJ IDEA and Maven Management (taking Spring MVC as an example)
I used MyEclipse all the time. After I changed my job, the new company used IDEA. I first got to know IDEA and found that wow, there are so many shortcut keys, but I think it is very useful all the way, especially with Maven management, it's a breeze. Of course, I have encountered many problems in
/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd ">class>org.springframework.web.context.contextloaderlistenerclass> class>org.apache.cxf.transport.servlet.cxfservletclass> /*All projects have been configured and can be published to Tomcat, entered in the browser: HTTP://LOCALHOST:8080/CXFDEMO/WS, returnFrom which we can see our external WebService interface, click on the Blue hyperlink and returnThis proves that our web service has been successfully published and can be tested for call
Strusts2+spring+hibernate Although is the mainstream web development framework, but SPRINGMVC more and more people use, it is also very useful, very cool!A small example of springmvc+spring+hibernate is implemented here. The comments are all in the code.The structure of each package of the project is as follows:1, first of all, Pom.xml.2, Web. XML configuration G
Last said, the Spring component annotation scope has Singleton, prototype, request, session, global session such a few common scenarios . Here is a special note, according to the source code to show that the scope annotation is divided into configurablebeanfactory and webapplicationcontext two large classes, Configurablebeanfactory contains ( Singleton, prototype) there are two types of scope,webapplicationcontext below (Root_web_application_context_
Spring DAO's jdbc Spring-provided DAO (data Access object) support the main purpose is to make it easier to use different data access technologies, such as JDBC, in a standard way, Hibernate, or JDO. Not only does it allow you to easily switch between these persistent technologies, but it allows you to encode without having to deal with specific exceptions in various technologies. to facilitate the use
After this period of study and use of spring, slowly realize the excellent spring, is deeply absorbing the essence of spring, hehe. This is just a simple AOP example, including a pre-notification, a post-notification, a surround notification, and a target object. The main goal of this
instance name HelloWorld - Beanname= "HelloWorld"class= "Com.wangcf.HelloWorld"> Propertyname= "Name"> value>Xiao mingvalue> Property> Bean>Beans>3. Create a test class PackageCOM.WANGCF;Importorg.junit.Test;ImportOrg.springframework.context.ApplicationContext;ImportOrg.springframework.context.support.ClassPathXmlApplicationContext; Public classhellotest {@Test Public voidTestsayhello () {//Create a spring containerAp
()); */}}Execution Result:Entry Method ---Surround notifications>>>>>>>> ready to search users ..........---------------" FindAll ": {smith=smith00, tom=tom00, xiaoming = Xiao Ming xx, lucy=lucy00,hello=hello00}------------------Exit Method ---Surround notifications>>>>>>>> Search User Complete ..........Note: @Before is to execute a piece of logic before the intercepted method executes. @After is to execute a piece of logic after the intercepted method executes. @Around is a logic that can be
In order to comb the previous study of "Spring integration MyBatis (maven+mysql) One" and "Spring Integration MyBatis (maven+mysql) II" in the content, Get ready to do a complete example of a simple book management function, with the main technologies used include spring, MyBatis, maven, and MySQL. The final performan
configuration to [email protected] started 6 plugins.
Copy CodeOpen the browser and access: http://localhost:15672/, and use the default user guest login, the password is also guest. We can see the administration page as follows:, we can see some of the basic concepts mentioned in the previous chapters, such as Connections, Channels, exchanges, queue, and so on. The first use of the reader, can be opened to see what the content, familiar with the RABBITMQ Server service side.Click the
To learn more about starting a transaction with spring, let's take a look at this simple example:1. entity class user. Java
Package Org. lab24.entity;
2. Abstract DAO class. Here it is set as an abstract class mainly to prevent it from directly instantiating objects (this design seems a bit redundant here. This should be a design pattern ):
Package Org. lab24.dao;
3 DAO implementation class:
Package Org
The Mapfactorybean class provides developers with a way to create a specific Map collection class (HashMap and TreeMap) in the Spring bean configuration file. Here is a mapfactorybean. For example, at run time it instantiates a hashmap and injects it into a bean property.Package Com.yiibai.common;import Java.util.map;public class Customer {private Map maps;//...}Spring's bean configuration file.In addition,
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.