一、后端开发的概念和技术栈
1.1 什么是后端开发
-
JavaWeb掌握什么?
- 网络通信协议:http
- 服务器:tomcat(开源) jetty(嵌入式) weblogic(商用 性能出色) ngix apache
- 云服务器:阿里云 腾讯云
- serlet、过滤器、监听器
- 其他:跨域、负载均衡、缓存、日志、git、maven
1.2 Java后端技术图谱

二、Java EE概念
-
Java EE,Java 平台企业版,之前称为J2EE,2018年2月26日Eclipse基金会社区正式将Java EE更名为 Jakarta EE。用来开发B/S架构软件。Java EE 平台目前已经发展到了第8个大版本。
-
JavaEE 号称有十三种核心技术。它们分别是:JDBC、JNDI、EJB、RMI、Servlet、JSP、XML、JMS、Java IDL、JTS、JTA、JavaMail和JAF。
三、Spring框架特点及构成
-
特点:化繁为简
- 轻量级IoC容器(最重要的两个特性之一)
- 采用AOP编程方式(最重要的两个特性之一)
- 大量使用批注,简化了配置
- 避免重复“造轮子”,减少代码重复使用
-
构成
四、Spring的起步练习步骤
1. 准备maven环境,并在idea中进行配置
-
setting配置,指定阿里云镜像
apache-maven-3.5.4\apache-maven-3.5.4\conf\settings.xml

- 注意:路径不能有中文,要简单
- 配置环境
file-OtherSettings-Settings for new project-buld,excution,deployment-nuld Tools-Maven(不展开,点单词)-Maven home-D\tools\apache maven 3.5.4 User settings file -Override(打钩) Local repository-D\maven_jar - maven_jar下载框架
2. 建立项目,并添加maven支持
3. 在pom中添加SpringContext依赖
4. 编写HelloWorld类
5. 编写beans.xml文件,注入一个bean并传值
6. 编写主类,读入配置文件中的bean并调用方法
7. 观察运行结果
-
Student和Phone练习
Student类
package com.soft1721.spring.hello;
public class student {
private String name;
private int age;
private Phone phone;
public Phone getPhone() {
return phone;
}
public void setPhone(Phone phone) {
this.phone = phone;
}
public student() {
}
public student(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public String toString() {
return "student{" +
"name='" + name + '\'' +
", age=" + age +
'}';
}
}
Phone类
package com.soft1721.spring.hello;
public class Phone {
private String brand;
private String price;
private String color;
@Override
public String toString() {
return "Phone{" +
"brand='" + brand + '\'' +
", price='" + price + '\'' +
", color='" + color + '\'' +
'}';
}
public Phone(String brand, String price, String color) {
this.brand = brand;
this.price = price;
this.color = color;
}
public void setBrand(String brand) {
this.brand = brand;
}
public void setPrice(String price) {
this.price = price;
}
public void setColor(String color) {
this.color = color;
}
public String getBrand() {
return brand;
}
public String getPrice() {
return price;
}
public String getColor() {
return color;
}
}
StudentAPP类
package com.soft1721.spring.hello;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class studentAPP {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("/beans.xml");
student student = (student) context.getBean("student");
System.out.println(student.getName()+student.getAge()+student.getPhone());
}
}
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.xsd">
<bean id="helloWorld" class="com.soft1721.spring.hello.HelloWorld"/>
<bean id="phone" class="com.soft1721.spring.hello.Phone">
<constructor-arg name="brand" value="huawei"/>
<constructor-arg name="color" value="浅艾蓝"/>
<constructor-arg name="price" value="2799"/>
</bean>
<bean id="student" class="com.soft1721.spring.hello.student">
<property name="age" value="20"/>
<property name="name" value="Tom"/>
<property name="phone" ref="phone"/>
<!--<constructor-arg name="name" value="Tom"/>-->
<!--<constructor-arg name="age" value="21"/>-->
</bean>
</beans>
五、学习建议
- 了解技术图谱——有全局观
- 大量的demo练习——打好基础
- 基于项目的学习——融会贯通,提升综合能力
- 及时高效的笔记——markdown语法,简书记录
- 版本控制和代码托管——git,github等
- 部署使用——阿里云服务器、项目部署运用
六、零碎知识点
- 快捷键:
换行:ctrl+shift+上、下箭头
idea常用快捷键 - groupID:com.soft1721
ArtifactID:spring - context:上下文
aop:面向切面编程
beans:对象管理
core:核心
expressio:表达式 - 在Spring的beans.xml配置中,通过constructor-arg和property传值,同等条件下使用property。当属型类型为基本类型,如String、double,int,float等时用value,属性是对象时用ref
- 代码侵入性强
侵入性,一般指的是:使用一个新的技术不会或者基本不改变原有代码结构,原有代码不作任何修改即可。
Spring是非侵入式框架。
网友评论