Myeclipse2017 참조를위한 Spring Project를 만들었습니다. 특정 내용은 다음과 같습니다
1. 웹 프로젝트를 만듭니다
2. 프로젝트를 마우스 오른쪽 버튼으로 클릭하십시오-> 속성
3. 스프링 검색 -> peoject 패킷 -> 오른쪽에서 스프링을 찾아 확인하고 저장하십시오.
4. 테스트
4.1 수업을 만듭니다
패키지 cn.spring.user;/**** @author dzsom* @date 2018 년 3 월 13 일 오후 11:42:03* @encoding utf-8* @version 1.0 **/public class user {private string uname; 사적인 int 연령; public String getUname () {return Uname; } public void setuname (String Uname) {this.uname = uname; } public int getage () {반환 연령; } public void 설정 (int Age) {this.age = age; }}4.2 SRC에서 구성 파일 ApplicationContext.xml을 수정하십시오
<? xml 버전 = "1.0"alcoding = "utf-8"?> <beans xmlns = "http://www.springframework.org/schema/beans"xmlns : xsi = "http://ww.w.w3.org/2001/xmlschema-instance" xmlns : p = "http://www.springframework.org/schema/p"xsi : schemalocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/schema/sprone--1.sd.sdecema/schema/schema/schema/schema/schema/schema. 물체를 스프링 관리-> <bean name = "user"> </bean> </beans>에 둡니다
4.3 테스트 클래스 생성 (@Test는 Junit 패키지 가져 오기가 필요합니다)
패키지 cn.spring.test; import org.junit.test; import org.springframework.context.applicationcontext; import org.sprameframework.context.support.classpathxmlapplicationcontext; import cn.spring.user.user;/**** @author dzsom* @date 14, at marning 14, at at at author dzsom. 9:35:19 am* @encoding utf-8* @version 1.0 **/public class demo {@test public void fun () {// 1. 컨테이너 개체 ApplicationContext AC = New ClassPathXmlApplicationContext ( "ApplicationContext.xml"); // 2. 객체 사용자 user = (사용자) ac.getBean ( "user")에 대해 컨테이너에게 문의하십시오. // 3. Print System.out.println (사용자); }}4.4 마우스 오른쪽 버튼을 클릭하여 테스트를 실행하십시오. 값 출력이 있으면 스프링이 성공적으로 구축됩니다.
위는이 기사의 모든 내용입니다. 모든 사람의 학습에 도움이되기를 바랍니다. 모든 사람이 wulin.com을 더 지원하기를 바랍니다.