MyEclipse2017創(chuàng)建Spring項(xiàng)目的方法
MyEclipse2017創(chuàng)建Spring項(xiàng)目,供大家參考,具體內(nèi)容如下
1、創(chuàng)建一個(gè)Web Project

2、右擊項(xiàng)目-->Properties

3、搜索Spring -->Peoject Facets-->在右邊找到Spring,打勾并保存


4、測(cè)試
4.1 創(chuàng)建個(gè)類
package cn.spring.user;
/**
*
* @author Dzsom
* @date 2018年3月13日下午11:42:03
* @encoding UTF-8
* @version 1.0
**/
public class User {
private String uname;
private int age;
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
4.2 修改src下的配置文件applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.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/beans/spring-beans-4.1.xsd"> <!-- 將對(duì)象交給Spring管理 --> <bean name="user" class="cn.spring.user.User"></bean> </beans>
4.3 創(chuàng)建測(cè)試類(@Test需要導(dǎo)入junit包)
package cn.spring.test;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import cn.spring.user.User;
/**
*
* @author Dzsom
* @date 2018年3月14日上午9:35:19
* @encoding UTF-8
* @version 1.0
**/
public class Demo {
@Test
public void fun() {
//1.創(chuàng)建容器對(duì)象
ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
//2.向容器要對(duì)象
User user = (User) ac.getBean("user");
//3.打印
System.out.println(user);
}
}
4.4 右擊運(yùn)行測(cè)試,若有值輸出則Spring搭建成功

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- eclipse+maven+spring mvc項(xiàng)目基本搭建過程
- eclipse springboot工程打war包方法及再Tomcat中運(yùn)行的方法
- myeclipse安裝Spring Tool Suite(STS)插件的方法步驟
- 關(guān)于eclipse安裝spring插件報(bào)錯(cuò)An error occurred while collecting items to be installed...解決方案
- 在Eclipse安裝Spring boot插件的步驟(圖文)
- eclipse怎么引入spring boot項(xiàng)目插件的方法
- 只需兩步實(shí)現(xiàn)Eclipse+Maven快速構(gòu)建第一個(gè)Spring Boot項(xiàng)目
- eclipse下配置Spring環(huán)境的方法步驟
- 詳解eclipse下創(chuàng)建第一個(gè)spring boot項(xiàng)目
- Spring JPA配置文件Eclipse報(bào)錯(cuò)如何解決
相關(guān)文章
Java調(diào)用接口如何獲取json數(shù)據(jù)解析后保存到數(shù)據(jù)庫
這篇文章主要介紹了Java調(diào)用接口如何獲取json數(shù)據(jù)解析后保存到數(shù)據(jù)庫問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-03-03
Java 反射調(diào)用靜態(tài)方法的簡(jiǎn)單實(shí)例
下面小編就為大家?guī)硪黄狫ava 反射調(diào)用靜態(tài)方法的簡(jiǎn)單實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-06-06
springmvc下實(shí)現(xiàn)登錄驗(yàn)證碼功能示例
本篇文章主要介紹了springmvc下實(shí)現(xiàn)登錄驗(yàn)證碼功能示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-02-02
常用的Spring Boot調(diào)用外部接口方式實(shí)現(xiàn)數(shù)據(jù)交互
Spring Boot提供了多種調(diào)用外部接口的方式,可以方便地實(shí)現(xiàn)與其他系統(tǒng)的數(shù)據(jù)交互,提高系統(tǒng)的可擴(kuò)展性和數(shù)據(jù)共享能力,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧2023-04-04

