当前位置: 首页 > news >正文

eclipse配置Spring

1、从eclipse下载Spring工具

进入 help – install new software… ,如下图:
图示一

点击 add ,按以下方式输入:

Name : Spring
Location : http://dist.springsource.com/release/TOOLS/update/e4.10/

图示二
之后点击 add ,等待一会儿会出现安装列表,我们选择带有 IDE 的四个组件进行安装。
图示三
安装完成后重启客户端。

二、下载Spring framework以及commons-logging
1、Spring framework下载

进入Spring framework下载对应的版本,如图:
版本号
选择对应的版本进入下载,此处选择 5.2.8.release
选择下载包
选择第一个下载包,等待下载。

2、commons-logging下载

进入 commons-logging-windows版下载支持windows的文件,若想下载其他类型,可以访问此处

三、eclipse环境配置

1、新建 Java Project 项目,右键选择项目,点击 Build Path – Configure Build Path
路径配置
2、添加commons-logging进入该项目路径

①点击 Libraries
②选择 Add External JARs
③进入文件夹,选择下载好的 commons-logging,解压进入文件目录,选择 commons-logging-x.x.jar

commons-logging添加

comons

3、添加Spring组件进入路径
依然按照上述顺序,点击 Add External JARs 进行文件路径选择,此时进入下载好的Spring framework 文件夹,如下图所示:
Spring主文件
进入 libs ,此时,如下图所示:
组件目录
我们需要将后缀形式为 RELEASE.jar 形式的包全部导入,导入结果如下图:
导入结果
此时,Spring的配置已经完成了。
注:jdk版本:JavaSE-1.8
eclipse版本:2020-06 (4.16.0)

四、验证Spring安装是否完成

按照如下格式新建文件:
hello
代码如下:
1、HelloWorld代码

package com.tutorialspoint;
public class HelloWorld {
   private String message;
   public void setMessage(String message){
      this.message  = message;
   }
   public void getMessage(){
      System.out.println("Your Message : " + message);
   }
}

2、MainApp代码

package com.tutorialspoint;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MainApp {
public static void main(String[] args) {
      ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
      HelloWorld obj = (HelloWorld) context.getBean("helloWorld");
      obj.getMessage();
   }
}

3、Beans.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"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

   <bean id="helloWorld" class="com.tutorialspoint.HelloWorld">
       <property name="message" value="Hello World!"/>
   </bean>

</beans>

注:该文件位于src文件下

运行MainApp,即可得到如下结果:
结果
配置完成!!!

相关文章:

  • 数据安全_笔记系列07:数据泄露防护(DLP)(监控与阻断敏感数据外泄)深度解析
  • AI创作教程:用deepseek和猫箱做互动故事游戏
  • NLP的预处理数据
  • 磁盘使用LVM方式挂载目录
  • 【xinference 词嵌入】embbeding 使用教程
  • 大白话Vue 双向数据绑定的实现原理与数据劫持技术
  • 【10】RUST的迭代器与闭包
  • Proof Beyond Boundaries: Hong Kong zkNight 活动精彩回顾
  • 零样本学习 zero-shot
  • LeetCodehot 力扣热题100 全排列
  • 《Keras 3 使用 PointNet 进行点云分类》:此文为AI自动翻译
  • Ubuntu指令(一)
  • SVT-AV1接入ffmpeg说明
  • SSM和SpringBoot有什么区别?
  • Spring 框架学习笔记:从零到精通的 21 个关键点
  • pyautogui库的screenshot()函数
  • python poetry添加某个git仓库的某个分支
  • 学习FreeRTOS推荐几篇质量高的文章
  • 6. grafana的graph简介
  • Android Realm数据库使用与集成指南
  • 玉渊谭天丨卢拉谈美国降低对华关税:中国的行动捍卫了主权
  • 商务部新闻发言人就暂停17家美国实体不可靠实体清单措施答记者问
  • 法治日报整版聚焦:儿童能否成为短视频主角?该如何监管?
  • 马上评丨岂能为流量拿自己的生命开玩笑
  • 外国游客“在华扫货”热:“带空箱子到中国!”
  • 印称印巴军事行动总指挥同意将局势降级