Spring之路(六)Spring——Spring谷粒教程改编实战1helloworld

打开spring.io :https://spring.io/projects/spring-framework#learn

Over time, the role of Java EE in application development has evolved. In the early days of Java EE and Spring, applications were created to be deployed to an application server. Today, with the help of Spring Boot, applications are created in a devops- and cloud-friendly way, with the Servlet container embedded and trivial to change. As of Spring Framework 5, a WebFlux application does not even use the Servlet API directly and can run on servers (such as Netty) that are not Servlet containers.

意思是,从spring5开始,springBoot来提供运行。从Spring Framework 5开始,WebFlux应用程序甚至不直接使用Servlet API,并且可以在非Servlet容器的服务器(例如Netty)上运行。

我这里看的视频是Spring4.主要还是要学习Spring基础知识,要下载相关Jar包地址:https://repo.spring.io/release/org/springframework/spring/

https://mvnrepository.com/artifact/commons-logging/commons-logging

 

package com.dongyu;

public class Hello {

	private String name;

	public void setName(String name) {
		this.name = name;
	}

	public void hello() {
		System.out.println("hello: " + name);

	}

}
package com.dongyu;

public class Test {
 public static void main(String[] args) {
	 Hello hello = new Hello();
	 hello.setName("abc");
	 hello.hello();
 }
}

好了,又一个javahello ,但这跟spring有什么关系呢

下一步复制spring4.0的jar包。

//	 Hello hello = new Hello();
//	 hello.setName("abc");
	ApplicationContext ctx = new  ClassPathXmlApplicationContext("applicationContext.xml");
	Hello   hello =(Hello) ctx.getBean("hello"); 
	 hello.hello();
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:context="http://www.springframework.org/schema/context" 
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
			http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
		 http://www.springframework.org/schema/context 
			http://www.springframework.org/schema/context/spring-context-4.0.xsd 
			  ">


<bean id="hello" class="com.dongyu.Hello">
<property name="name" value="cdef"></property>
</bean>

</beans>

由于创建了这个配置文件。applicationContext.xml

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

东宇科技

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值