Read about spring configuration file example, The latest news, videos, and discussion topics about spring configuration file example from alibabacloud.com
toString () {return tostringbuilder.reflectiontostring (this);}}
2. Create spring.xml files
Use ${NAME},${PROPX} in the configuration file to indicate that you need to replace the content in the properties file
3. Create spring.properties file where variables can recursively refer to other variables defined in the
Spring environment: Importing jar packages, configuration file names, and placement locationsNow the project development in the Spring Framework application is still more, their use is not very skilled, each time with the total configuration of half a day, always some
of proxy. Why write it as an internal class? In order to let the proxy impersonate it to let the Controller autowire. (For details, see the following example)
1.3. Loose configuration, to XML or not to XMLIt is said that spring is much looser than struts configuration, which gives people the opportunity to recall thin
, the context namespace for the label of the component)Code Explanation:1, xmlns= "Http://www.springframework.org/schema/beans"Declares the default namespace for the XML file, which represents the default namespace for all labels that do not use other namespaces.2, xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"Declares an XML Schema instance that can be declared to use the SchemaLocation property.3, xmlns:aop= "HTTP://WWW.SPRINGFRAMEWORK.ORG/S
Spring + SpringMVC + Mybaties integration-configuration file configuration and content explanation-can be directly copied for use-occasionally changed, springmvcmybaties
The following configurations can be used directly. You only need to change the package name.
The description and usage of internal labels are describe
-apiArtifactid>version>1.1version>Dependency>(Java Learning Communication ③ Group: 256909960, Welcome to join)2. Configuration ClassIn this case, the spring annotations are configured directly, and the XML configuration method is subsequently written @Component // 1 @PropertySource (" Classpath:aaa.properties ") // 2 public class valueproperties {@Value ( "$
This article summarizes the basic configuration of spring MVC by first pasting a screenshot of my project's catalog, with some extra files that you don't have to care about:
Some of the jar bags used in this:
Next is the configuration of Web. XML:
Next is Springmvc-servlet.xml:
These are the most basic configurations of
" management of the container to the component--masterDynamic lookup and Control inversion (ix), we use control inversion to remove the component's dependency on the container.simple configuration, ReflectionWhen the container was initialized in the previous post, use new to power the object, this blog post we use the configuration file + reflect the strength of
order to let the proxy impersonate it to let the Controller autowire. (For details, see the following example)
1.3. Loose configuration, to XML or not to XMLIt is said that spring is much looser than struts configuration, which gives people the opportunity to recall things from the
Although simple user login, but a little bit, based on the MVC principle of implementation, divided into DAO layer, service layer, action layer and Web layer, where DAO and service layer have their own interface.
Today the main explanation of the configuration file code, I learn examples, like from the control layer, and then use what class or JSP, and then one by one pull "egg" pulled out.
Of course, look
To refer to attributes defined in the properties file in spring XML requires special loading, first using the PropertyplaceholderconfigurerThe typical configuration is as follows:class= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >This is the list assignment of the called locations, or it can be a singleProperties in the configuration
property. 1.3. Let @autowired work to enable @autowired to work, and add the following code to the configuration file 1Beanclass= "Org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />1.4. @Qualifier the @autowired is automatically assembled according to the type. In the example above, if there is more than one Userdao type of bea
Spring Boot Dry series: (ii) configuration file parsing2017-02-28 toot md du ye Java Super Theological hall ObjectiveThe previous article introduced spring boot, knowing that spring boot uses "habit better than Configuration" (the
First, the XML configuration form1. Add a facet-oriented configuration in the spring configuration fileThe method in the slice class is executed when any method of the Com.activemq.service.impl.ConsumerServiceImpl interface implementation class is called.2. Write Slice classAttention:1) can not do the Web layer (for
ready.SummarySteps to resolve if you encounter a SPRINGMVC transaction that cannot be rolled back:1. Check that the configuration file has not joined the transaction management configuration and driver;2. Check whether the database supports transactions (such as MySql4.0 support transactions, ENGINE:INNODB);3. Checks whether the code block throws an exception, a
The simplest XML file header explain the namespace header parsing mode content
While the XML configuration of spring is rather cumbersome, it is not as easy to recommend the annotated approach, but it is important to be able to read XML configuration files, especially for the maintenance of some old systems, almost in
}") private String title; // omit getter and setter }By convention, the unit tests are passed to verify that the properties in the Blogproperties have been loaded according to the configuration file.@RunWith (Springjunit4classrunner. Class) @SpringApplicationConfiguration (application. class )publicclass applicationtests { @Autowired private Blogproperties blogproperties; @Test public
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.