(To change the project series) Spring Study notes (1)

Source: Internet
Author: User

1.P Namespaces

Attribute Injection Reference

<property name= "CD" ref= "CD"/>

<p:cd-ref= "CD"/>

Attribute injection literal

<property name= " property " value= " literal " />

<property name ""/>

<list>

<value>123</value>

</list>

</property>

<bean id= "123" class= "XXX"

P. Property = "XX"

2.util- Namespaces

<util-list> elements Create a list bean

<util-list id = "Ulist" >

<value>1</value>

<value>2</value>

<value>3</value>

</util-list>

The list Bean can now be injected into the property

<bean id= "123" class= "XXX"

P.tracks-ref = "Ulist"

</bean>

Besides, there are elements such as Util-map Util-set

2.5.1 referencing XML configuration in Javaconfig

Split Javaconfig class

1) use @Import annotations in the original javaconfig to import the cdconfig

@Import (Cdconfig.class)

2) take a better approach to creating a higher -level soundsystemconfigthat is used in this class @Import Annotations combine two configuration classes together.

@Import {cdconfig.class,Cdplayerconfig.class}

simultaneous loading based on configuration of XML and JAVA

1) using @ImportResource annotations

@Configuration

@import (Cdplayerconfig)

@import ("Classpath:cd-config.xml")

public class soundsystemconfig{}

two beans will be loaded into the spring container.

2.5.2 referencing Javaconfig in XML

Split XML Configuration

1) Use the <import> element to reference the XML file

2) use <bean> tags to import JAVA configuration

<beans

<bean class = "Soundsystem.cdconfig"/>// import java configuration

<bean id= "CDPlayer"//xml configuration

class = "Soundsystem.cdplayer"

c:cd-ref= "CD"

/>

</beans>

3) The same method, you can create a higher level of the configuration file, this file does not declare any beans, is only responsible for multiple configurations together

usually regardless of the use XML configuration or javaconfig configuration, we typically create a root configuration , which enables component scanning in the root configuration.

by <Context:conponent-scan> or @ConponentScan

(To change the project series) Spring Study notes (1)

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.