Spring学习(二)-----eclipse新建spring项目
一:准本工作(下载需要的jar包)
1.下载准备Spring-framework-4.2.0
链接为:
http://repo.springsource.org/libs-release-local/org/springframework/spring/
截图:

2.具体的spring-framework4.2.0

3.下载log
链接为:
http://commons.apache.org/proper/commons-logging/download_logging.cgi
截图:

二:建项目
1.新建普通的java项目

2.新建lib文件夹,并将jar包复制粘贴进去

3.将lib包进行buid path

然后将需要的jar从firstSpring中导入

然后reply和ok

4.这时的效果

5.新建包
类包:

XML包

6.新建类
第一个接口
1 package main.java.com.sommer.learn;
2
3 public interface HelloWorld {
4 public String sayHi();
5 }
实现类

1 package main.java.com.sommer.learn;
2
3 public class HelloWorldImpl implements HelloWorld{
4 @Override
5 public String sayHi() {
6 return "hahahahahha";
7 }
8
9 }

7.新建xml文件

1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans
3 xmlns="http://www.springframework.org/schema/beans"
4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5 xsi:schemaLocation="http://www.springframework.org/schema/beans
6 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
7
8 <bean id="helloWorld" class="main.java.com.sommer.learn.HelloWorldImpl"></bean>
9 </beans>

8.新建主函数

1 package main.java.com.sommer.learn;
2 import org.springframework.context.ApplicationContext;
3 import org.springframework.context.support.ClassPathXmlApplicationContext;
4
5 public class Main {
6 public static void main(String[] args) {
7 ApplicationContext apc = new ClassPathXmlApplicationContext("springXML/HelloWorld.xml");
8 HelloWorld hello = apc.getBean("helloWorld",HelloWorld.class);
9 System.out.println(hello.sayHi());
10 }
11 }

9.运行

自己写的源码:http://pan.baidu.com/s/1kV67rYf
Spring学习(二)-----eclipse新建spring项目的更多相关文章
- Spring学习(三)——Spring中的依赖注入的方式
[前面的话] Spring对我太重要了,做个关于web相关的项目都要使用Spring,每次去看Spring相关的知识,总是感觉一知半解,没有很好的系统去学习一下,现在抽点时间学习一下Spring.不知 ...
- Spring学习之——手写Spring源码V2.0(实现IOC、D、MVC、AOP)
前言 在上一篇<Spring学习之——手写Spring源码(V1.0)>中,我实现了一个Mini版本的Spring框架,在这几天,博主又看了不少关于Spring源码解析的视频,受益匪浅,也 ...
- eclipse新建maven项目:'Building' has encountered a problem. Errors occurred during the build.
二.eclipse 新建maven 项目报错(因为没有配置maven环境) 1.问题: ① 出现的问题1: Could not calculate build plan:Plugin org.apac ...
- spring 学习(四): spring 的 jdbcTemplate 操作
spring 学习(四): spring 的 jdbcTemplate 操作 spring 针对 javaee 的每一层,都提供了相应的解决技术,jdbcTemplate 的主要操作在 dao 层. ...
- eclipse新建maven项目(2)
本篇博文是继续之前的博文eclipse新建maven项目(1),那篇博文不在随笔在文章中.首先按照之前那篇博文进行创建maven项目操作,一系列操作下来之后发现刷新项目后会报错: 别急哈,可以解决. ...
- eclipse新建web项目,发布 run as 方式和 new server然后添加项目方式。 后者无法自动编译java 成class文件到classes包下。
eclipse新建web项目,发布 run as 方式和 new server然后添加项目方式. 后者无法自动编译java 成class文件到classes包下. 建议使用run as - run ...
- day 82 Vue学习二之vue结合项目简单使用、this指向问题
Vue学习二之vue结合项目简单使用.this指向问题 本节目录 一 阶段性项目流程梳理 二 vue切换图片 三 vue中使用ajax 四 vue实现音乐播放器 五 vue的计算属性和监听器 六 ...
- eclipse新建maven项目报错Could not resolve arachetype org.apache.maven.archetypes:mmaven-archetype-quickstart:1.1 from any of the configured repositories
使用eclipse新建maven项目,按下图所示选择后,报错 报错截图 报错详细信息 Could not resolve archetype org.apache.maven.archetypes:m ...
- day 81 Vue学习二之vue结合项目简单使用、this指向问题
Vue学习二之vue结合项目简单使用.this指向问题 本节目录 一 阶段性项目流程梳理 二 vue切换图片 三 vue中使用ajax 四 vue实现音乐播放器 五 vue的计算属性和监听器 六 ...
随机推荐
- hibernate二级缓存实例
hibernate.cfg.xml <?xml version='1.0' encoding='UTF-8'?><!DOCTYPE hibernate-configuration P ...
- MAC升级openssl
Mac OSX EI Capitan 10.11.6升级自带Openssl - 简书 Mac10.11升级安装openssl _ 刘春桂的博客 openssl_openssl_ TLS_SSL and ...
- Oracle 执行计划的查看方式
访问数据的方法:一.访问表的方法:1.全表扫描,2.ROWID扫描 二.访问索引的方法:1.索引唯一性扫描,2.索引范围扫描,3.索引全扫 ...
- Java并发编程(十一)常用工具
Java为开发提供了很多有用的工具类,这些工具类可以帮助我们更加高效的编写并发程序,本篇我们将介绍这些实用工具的用法. ThreadLocal ThreadLocal类用于解决多线程共享一个变量的问题 ...
- 初识ExtJS 6----自学笔记(一)
一.使用环境 这一点写在前面,是为了方便大家在找资料的时候可以直接定位环境版本. ExtJS版本 6.2 中文官方网站提供版本,网站地址http://extjs.org.cn/node/793 开发 ...
- Python的迭代器与装饰器
'''迭代器:两个基本方法:iter()和next()迭代器是一个可以记住遍历的位置的对象. 迭代器对象从集合等第一个元素开始访问,直到所有的元素被访问结束,迭代器只能往前不会后退. 迭代器有两个基本 ...
- L2-006 树的遍历 (后序中序求层序)
题目: 给定一棵二叉树的后序遍历和中序遍历,请你输出其层序遍历的序列.这里假设键值都是互不相等的正整数. 输入格式: 输入第一行给出一个正整数N(≤30),是二叉树中结点的个数.第二行给出其后序遍历序 ...
- 同步工具类-----循环栅栏:CyclicBarrier
import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.CyclicBarrier; impor ...
- sign
sign字段构成:登录类型(2Bytes) + userid(不定长,最长10Bytes,用户id或设备id) + time(10Bytes) + token(32Bytes).其中:token = ...
- 解决 vboxdrv.sh: failed: Cannot change group vboxusers for device /dev/vboxdrv.
来自:https://blog.csdn.net/su_cicada/article/details/86773043 virtualbox 报错 ,看提示让执行以下 sudo /sbin/vboxc ...