打开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