Examples on the official website
JSON-lib is a Java class package used to convert beans, maps, and XML into JSON and convert JSON back to bean and dynabean.: Http://json-lib.sourceforge.net/The third-party package is also required:Org. Apache. commons (version 3.2 or later)Org. Apache. oroNet. SF. ezmorph (ezmorph-1.0.4.jar)Nu. XOM1. ListJava code
Boolean[] Boolarray =NewBoolean[] {True,False,True};
Jsonarray jsonarray1 = jsonarray. fromobject (boo
Spring -- configure bean through annotation, spring -- bean
Spring configures bean through AnnotationBean configuration based on AnnotationConfigure bean Attributes Based on AnnotationsScan components in classpathComponent scan: Spring can automatically scan from classpath to detect and instantiate components with spec
Common annotations for Spring beans@Component: usually annotations, available for any bean@Repository: Typically used to annotate the DAO layer, which is the persistence layer@Service: Typically used to annotate service tiers, or services tiers@Controller: Typically used to annotate the controller layer, which is the control layerAutomatic detection of classes and the registration of beansDefining beansThe bean
. Annotationconfigapplicationcontext preparerefresh Info: refreshing org. springframework. Context. Annotation. Annotationconfigapplicationcontext@203e25d3:startup Date [Thu : Each CST 2016] ; root of context hierarchyspring container start initialization ... 2. The @Bean is labeled on the method (the method that returns an instance), equivalent to the spring XML configuration file , which functions as: registering the
Spring bean dependency injection, bean assembly and related annotations, springbeanDependency Injection
Spring provides the following two methods for dependency injection:
Property-based Setter method Injection
Constructor Injection
Setter method Injection
Example:
public class Communication { private Messaging messaging; /* * DI via Setter */ public void setMessaging(Messaging m
Bean of Spring Core Components and spring core beanBeanBean class hierarchy of Spring Core Components
BeanFactory is the top-level interface of Bean, where the source code is
/spring-framework/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactory.java
DefaultListableBeanFactory implements all interfaces. But why do we need to define so many interfaces? To differentiate the restrictions o
Diagram of the spring container, bean configuration information, bean implementation class, and application four:Bean configuration information defines the implementation and dependencies of the bean, and the spring container establishes the Bean definition registry within the container based on various forms of
Reference: http://hi.baidu.com/victorlin23/blog/item/45ba7d1b2ccbced8ad6e7595.html
The bean defaults to Singleton.
If you do not want a singleton, the following configuration:
Singleton is the configuration of this bean is a singleton, if not write, is the default value of True.
Annotations:
Spring Bean life cycle
The scope of the 1.
Original: http://selppay-gmail-com.iteye.com/blog/7632631. Spring Bean definationIn general, we define and apply beans using bean IDs, but today I have this definitionXML code
bean id = "writeservice" class = "Aserviceimp, Bserviceimp, cserviceimp"
name = "Aservice, bservice, cservice" Init-method = "init">
property name = "InterfaceName">
In addition to creating a bean by configuring a full-class name using reflection, you can also use the factory method to create the bean. This will be used when the framework is integrated.1. Static Factory methodCalling the static factory method to create the bean is the process of encapsulating the object creation into a static method . When a client needs an o
Today, I pulled out "Popular Science". Four or five years ago, cainiao did not laugh ......Of course, at that time, it was still very delicious. Now we don't need to use such an "overflow" technique. As long as we know some batch processing commands, it's easy to bypass it ......Also, I used to name HackerRose, HackRose, hacker ......It was originally published in three independent articles and is now merged into one article, saving time and starting
1. Instantiating the [default class constructor] using the Class Builder2. Instantiating using a static factory methodclass= "Cn.itcast.service.OrderFactory" factory-method= "Createorder"/>publicclass orderfactory { // Note This method here is static! public static Orderservicebean Createorder () { return New Orderservicebean (); }}3. Instantiate using the instance factory method:class= "Cn.itcast.service.OrderFactory"/>Publicclass orderfactory { Public Orderserviceb
There are two types of beans in Spring, one is a normal bean and the other is a factory bean, or Factorybean.A factory bean differs from a normal bean in that it returns an object that is not an instance of the specified class, and returns the object returned by the factory Bean's GetObject method. 1.1 Creating a
Spring4.0.6 latest stable version new feature learning, annotation automatic scan bean, automatic injection bean (2)
The new features of Spring4.0 have been introduced in the previous chapter. Including jdk8 support, Groovy Bean Definition DSL support, core container function improvement, Web development improvement, testing framework improvement, and so on. This
@Required comment The setter method applied to the Bean property, which indicates that the affected bean properties must be placed in the XML configuration file at configuration time, or the container throws a Beaninitializationexception exception.Java Public classStudent {PrivateInteger age; PrivateString name; @Required Public voidsetage (Integer age) { This. Age =Age ; } PublicInteger getage () {retur
Stateful Session Bean: each user has its own unique instance,Bean maintains user information, that is, "stateful"The bean life cycle ends once the user dies (the call ends or the instance ends.That is, each user will initially get an initial Bean.Stateless Session Bean: Once instantiated, the
Spring learning notes -- 02 Bean naming and instantiation, learning notes bean
I. Bean naming
In the previous article, IoC is a container for Bean management. In most cases, beans are configured through XML files. The Bean naming methods are as follows.
1. No id is specified
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.