Day01 Spring起步

一、后端开发的概念和技术栈

1.1 什么是后端开发?

https://zhuanlan.zhihu.com/p/27067255

1.2 java后端技术图谱

技术图谱

二、javaEE概念

Java EE,Java 平台企业版(Java Platform Enterprise Edition),之前称为Java 2 Platform, Enterprise Edition (J2EE),2018年3月更名为 Jakarta EE(这个名称应该还没有得到群众认可)。是 Sun 公司为企业级应用推出的标准平台,用来开发B/S架构软件。Java EE 可以说是一个框架,也可以说是一种规范。

三、JavaWeb需要掌握什么?

  • 网络通信协议:http
  • 服务器:tomcat(开源),jetty(嵌入式),weblogic(商用),ngix(静态),apache(静态)
  • 云服务器:阿里云、腾讯云
  • servlet,过滤器,监听器
  • 其他:缓存、日志、git、maven、跨域、负载均衡

四、Spring框架特点及构成

4.1 Spring化繁为简主要的表现为以下几个方面。

  • 轻量级IoC容器。
  • 采用AOP编程方式。
  • 大量使用批注。
  • 避免重复“造轮子”,减少代码的重复性。

4.2 构成

  • Spring Core:核心容器,BeanFactory提供了组件生命周期的管理,组件的创建,装配,销毁等功能
  • SpringContext:ApplicationContext,扩展核心容器,提供事件处理、国际化等功能。它提供了一些企业级服务的功能,提供了JNDI,EJB,RMI的支持。
  • Spring AOP:提供切面支持
  • Spring DAO:提供事务支持,JDBC,DAO支持
  • Spring ORM:对流行的O/R Mapping封装或支持
  • Spring Web:提供Web应用上下文,对Web开发提供功能上的支持,如请求,表单,异常等。
  • Spring Web MVC:全功能MVC框架,作用等同于Struts。

Spring的起步练习步骤

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.10.RELEASE</version>
</dependency>
</dependencies>

  • 新建helloworld类

public class helloworld {
public String getHello(){
return "hello world";
}
}

  • 配置beans.xml

<bean id="helloworld" class="com.soft1721.spring.hello.helloworld"/>

  • 编写helloworldApp

public static void main(String[] args) {
// 读入xml文件
ApplicationContext context=new ClassPathXmlApplicationContext("/beans.xml");
// 读取配置好的bean
helloworld helloworld= (com.soft1721.spring.hello.helloworld) context.getBean("helloworld");
// 运行helloworld方法
System.out.println(helloworld.getHello());
}

  • 传入参数

<bean id="phone" class="com.soft1721.spring.hello.Phone">
<constructor-arg name="grand" value="小米"/>
<constructor-arg name="price" value="2999"/>
<constructor-arg name="size" value="6.4"/>
</bean>
<bean id="student" class="com.soft1721.spring.hello.student">
<property name="age" value="24"/>
<property name="name" value="Tomy"/>
<property name="phone" ref="phone"/>
</bean>

constructor-arg用于数据类型不是一般数据类型时,property用于一般数据类型适用范围较广

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 什么是后端开发? https://zhuanlan.zhihu.com/p/27067255 Java后端技术栈梳...
    六年的承诺阅读 420评论 2 11
  • 一、后端开发的概念和技术 1.1 什么是后端开发 https://zhuanlan.zhihu.com/p/270...
    youi_e050阅读 317评论 0 5
  • 一、后端开发的概念和技术栈 1.1 什么是后端开发? 什么是后端开发 1.2 Java后端技术图谱? 二、Java...
    国王兔子阅读 214评论 0 3
  • 1、什么是后端开发? 点击 了解什么是后端开发 点击 查看后端开发技术相关知识 2、作为一个前端或者后...
    Monica_b73c阅读 172评论 0 1
  • 他从来没有想过自己有一天会再次回到校园,毕业多年,早已习惯了俗世的生活,要想再放下一切,回到象牙塔里读研究生...
    金浩龙阅读 257评论 0 0