spring框架创建helloworld
来源:互联网 发布:js arguments 回调函数 编辑:程序博客网 时间:2024/06/06 09:49
1.spring是一个容器,托管他的对象的生命周期
2.spring模块,中间这一块AOP Aspects instrumentation messaging,是一些思想。
官网
https://spring.io/
新建spring工程
1.通过maven来创建,新建工程
2.下一步,选择这个
3.输入项目名和包名
4.添加运行时的jar包,tomcat的包。
5.在main目录下新建java目录,
6.修改pom.xml中加入依赖
org.springframework
spring-context
4.3.8.RELEASE
新建package。包名com.sixstar.spring.charpter01
7.新建class,名叫HelloWorld,
public class HelloWorld {
private String userName;public HelloWorld() { // TODO Auto-generated constructor stub System.out.println("初始化helloworld");}public String getUserName() { return userName;}public void setUserName(String username) { System.out.println("设置属性值!!!"); this.userName = username;}public void sayHello(){ System.out.println(userName+"say hellow");}
}
8.新建Class ,Test。提供main方法
public class Test {
public static void main(String[] args) { HelloWorld helloWorld = new HelloWorld(); /** * 1.写一个JAVAbean 2.写一个bean配置文件 */ // 创建IOC容器 ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");// 加载bean文件 // 从spring容器中获取需要的Bean实例 HelloWorld h2 = (HelloWorld) ctx.getBean("helloWorld");}
}
9.在resources目录下,新建beans.xml文件。
0 0
- spring框架创建helloworld
- Spring框架HelloWorld程序
- Spring框架第一篇HelloWorld
- SSH:Struts1框架(创建HelloWorld应用)
- Spring框架学习笔记--HelloWorld(二)
- Spring框架学习——HelloWorld
- 创建一个Spring的HelloWorld程序
- 创建第一个Spring MVC程序helloworld
- 创建Spring第一个程序HelloWorld
- 3、SSM框架-Spring第一个Spring HelloWorld(3)
- [Spring实战系列](2)Maven创建Spring-HelloWorld项目
- Spring helloworld
- spring helloworld
- spring helloworld
- Spring -- HelloWorld
- spring helloworld
- Spring HelloWorld
- Spring--HelloWorld
- LeetCode | 23. Merge k Sorted Lists
- 正则表达式语法简介
- linux查找目录下的所有文件中是否含有某个字符串
- Android模仿通讯录
- C++11特性:auto关键字与基于范围的for循环
- spring框架创建helloworld
- spring <context:property-placeholder/> 配置详解
- 用Xshell部署javaweb项目
- Delphi启动/停止Windows服务,启动类型修改为"自动"
- Ionic2系列——Ionic 2 Guide 官方文档中文版
- SiteMesh简介
- Oracle 12C 创建用户连接pdb
- 字符串全排列算法
- 大数据量下MySQL插入方法的性能比较