spring5.02 Quick Start

spring5.02 Quick Start divided into the following four steps,

1. dependence introduction

2. Create a profile beans.xml

3 creates a corresponding interface class (only quickly create, classes do not give any method to achieve)

4. Create a container object, according to obtain the object id

Detail steps are as follows:

1. introducing dependent
<! - dependent spring incorporated in the core ->
<dependency>
<the groupId> org.springframework </ the groupId>
<the artifactId> spring-context </ the artifactId>
<Version> 5.0.2.RELEASE </ Version>
</ dependency>
2. create a profile beans.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">

</beans>

3 creates a corresponding interface class (only quickly create, classes do not give any method to achieve)

4. Create a container object, according to obtain the object ID
the ApplicationContext the ClassPathXmlApplicationContext new new AC = ( "the beans.xml");
Object userDao = ac.getBean ( "userDao");
System.out.println (userDao);
`` `

Guess you like

Origin www.cnblogs.com/lijun6/p/11117902.html