一、后端開(kāi)發(fā)的概念和技術(shù)棧
1.1 什么是后端開(kāi)發(fā)
-
JavaWeb掌握什么?
- 網(wǎng)絡(luò)通信協(xié)議:http
- 服務(wù)器:tomcat(開(kāi)源) jetty(嵌入式) weblogic(商用 性能出色) ngix apache
- 云服務(wù)器:阿里云 騰訊云
- serlet、過(guò)濾器、監(jiān)聽(tīng)器
- 其他:跨域、負(fù)載均衡、緩存、日志、git、maven
1.2 Java后端技術(shù)圖譜

image
二、Java EE概念
Java EE,Java 平臺(tái)企業(yè)版,之前稱(chēng)為J2EE,2018年2月26日Eclipse基金會(huì)社區(qū)正式將Java EE更名為 Jakarta EE。用來(lái)開(kāi)發(fā)B/S架構(gòu)軟件。Java EE 平臺(tái)目前已經(jīng)發(fā)展到了第8個(gè)大版本。
JavaEE 號(hào)稱(chēng)有十三種核心技術(shù)。它們分別是:JDBC、JNDI、EJB、RMI、Servlet、JSP、XML、JMS、Java IDL、JTS、JTA、JavaMail和JAF。
三、Spring框架特點(diǎn)及構(gòu)成
-
特點(diǎn):化繁為簡(jiǎn)
- 輕量級(jí)IoC容器(最重要的兩個(gè)特性之一)
- 采用AOP編程方式(最重要的兩個(gè)特性之一)
- 大量使用批注,簡(jiǎn)化了配置
- 避免重復(fù)“造輪子”,減少代碼重復(fù)使用
-
構(gòu)成
四、Spring的起步練習(xí)步驟
1. 準(zhǔn)備maven環(huán)境,并在idea中進(jìn)行配置
-
setting配置,指定阿里云鏡像
apache-maven-3.5.4\apache-maven-3.5.4\conf\settings.xml

TIM圖片20190226151757.png
- 注意:路徑不能有中文,要簡(jiǎn)單
- 配置環(huán)境
file-OtherSettings-Settings for new project-buld,excution,deployment-nuld Tools-Maven(不展開(kāi),點(diǎn)單詞)-Maven home-D\tools\apache maven 3.5.4 User settings file -Override(打鉤) Local repository-D\maven_jar - maven_jar下載框架
2. 建立項(xiàng)目,并添加maven支持
3. 在pom中添加SpringContext依賴(lài)
4. 編寫(xiě)HelloWorld類(lèi)
5. 編寫(xiě)beans.xml文件,注入一個(gè)bean并傳值
6. 編寫(xiě)主類(lèi),讀入配置文件中的bean并調(diào)用方法
7. 觀察運(yùn)行結(jié)果
-
Student和Phone練習(xí)
Student類(lèi)
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類(lèi)
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類(lèi)
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="淺艾藍(lán)"/>
<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>
五、學(xué)習(xí)建議
- 了解技術(shù)圖譜——有全局觀
- 大量的demo練習(xí)——打好基礎(chǔ)
- 基于項(xiàng)目的學(xué)習(xí)——融會(huì)貫通,提升綜合能力
- 及時(shí)高效的筆記——markdown語(yǔ)法,簡(jiǎn)書(shū)記錄
- 版本控制和代碼托管——git,github等
- 部署使用——阿里云服務(wù)器、項(xiàng)目部署運(yùn)用
六、零碎知識(shí)點(diǎn)
- 快捷鍵:
換行:ctrl+shift+上、下箭頭
idea常用快捷鍵 - groupID:com.soft1721
ArtifactID:spring - context:上下文
aop:面向切面編程
beans:對(duì)象管理
core:核心
expressio:表達(dá)式 - 在Spring的beans.xml配置中,通過(guò)constructor-arg和property傳值,同等條件下使用property。當(dāng)屬型類(lèi)型為基本類(lèi)型,如String、double,int,float等時(shí)用value,屬性是對(duì)象時(shí)用ref
- 代碼侵入性強(qiáng)
侵入性,一般指的是:使用一個(gè)新的技術(shù)不會(huì)或者基本不改變?cè)写a結(jié)構(gòu),原有代碼不作任何修改即可。
Spring是非侵入式框架。