标签:nsx img get pyse font 体系 set www service
Spring 开篇
Data access结构体系图
Spring的第一个案例
1.引依赖 jar包
beans自动引入core
<!-- beans -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
Context 自动引入AOP和expression
<!--context-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.2.RELEASE</version>
</dependency>
public class HappyService {
private String info;
public void work(){
System.out.println("happy"+info);
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
}
3.applicationContext配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beansxmlns="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">
<bean id="happyService" class="cn.happy.Service.HappyService">
//id可以是任何值 class: 全路径
<property name="info" value="Spring"></property>
//如何获取到spring容器
编译结果:
标签:nsx img get pyse font 体系 set www service
原文地址:http://www.cnblogs.com/wangdan123/p/7398806.html