eclipse安裝Spring的具體步驟

一、下載spring 官網下載須要jar包放在lib中java

本人分享百度雲jarspring

連接:https://pan.baidu.com/s/1iEMwBbTTCxuCNOEdprlGhg
提取碼:e7tg
二、 配置applicationContext.xmlapp

配置代碼xmlthis

<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">
    <bean id="Student" class="entity.Student">
        <property name="name">
            <value>tom</value>
        </property>
    </bean>
</beans>

三、新建兩個文件spa

Student.java
package entity; public class Student { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } }

DemoTest.javacode

package entity; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class DemoTest { public static void main(String arg[]) { ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml"); // 實例化Spring容器
        Student stu = (Student) ctx.getBean("Student"); System.out.println("name:" + stu.getName()); System.out.println("test main"); } }
相關文章
相關標籤/搜索