立志存高遠,篤行踐初心
三更燈火五更雞,正是男兒讀書時, 黑發不知勤學早,白首方悔讀書遲,
立志,標定人生方向;奮斗,創造人生價值,二者相輔相成,互相促進,
大部分程式員的「 目標 」都是成為一名優秀的工程師,一名可以統覽全域的「 架構師 」,
千里之行始于足下
對于大部分普通人而言,成為一名優秀的架構師還是有一定難度的,「 千里之行始于足下,一步一個腳印,慢慢來 」,
🍅 粉絲專屬福利:包郵送書3本,如下書單四選一,
🍅 獲取方式:
1、參與文末投票,點贊,收藏即有機會獲得精美圖書一本;
1、評論區評論:獲取點贊最多者,獲取一本;
2、評論區評論:通過random函式,隨機抽取兩名;
【注意】想加入微信群聊,可以掃描主頁左側二維碼、私信與我、加本人微信guo_rui_
億級流量Java高并發與網路編程實戰
1、本書從并發的底層核心技術、互聯網應用框架、資料處理等三部分對高并發系列技術做了系統講解,
2、本書以實戰化訓練為宗旨,用詳盡且經典的案例闡述了 Java大資料及高級編程中的重點、難點,書中案例由真實專案演化而來,既體現了所述知識點的精華,又屏蔽了無關技術的干擾,
3、案例都是以“理論講解 環境搭建 完整代碼及分析 運行截圖”這種完善的結構進行講解,考慮到了讀者可能會遇到的各種問題,


很多小伙伴私下問我,沒有實際的開發經驗,自學成才、或者是培訓班出來的,簡歷上的專案經驗怎么寫?我覺得可以簡簡單單的寫一個SSM整合專案,
目錄
立志存高遠,篤行踐初心
千里之行始于足下
億級流量Java高并發與網路編程實戰
一、Spring思維導圖
二、Spring
1、基本概念
2、Spring的流程圖
3、spring的優點
4、spring的缺點
三、SpringMVC
1、基本概念
2、SpringMVC的優點
3、SpringMVC的缺點
四、mybatis
1、基本概念
2、mybatis的優點
五、前置知識總結
六、Java程式員簡歷上的第一個專案
Spring、SpringMVC、MyBatis整合
1、大體框架
2、引入jar包
3、配置
4、撰寫代碼
5、運行
一、Spring思維導圖

二、Spring
1、基本概念
spring是一個開源開發框架,是一個輕量級控制反轉(IoC)和面向切面(AOP)的容器框架,
spring主要用來開發java應用,構建J2EE平臺的web應用,其核心就是提供一種新的機制管理業務物件及其依賴關系,
2、Spring的流程圖

決議:上面是在Struts結構圖的基礎上加入了spring流程圖,在web.xml組態檔中加入了spring的監聽器,在struts.xml組態檔中添加
<constant name="struts.objectFactory" value="spring" />
是告知Struts2運行時使用spring來管理物件,spring在其中主要做的就是注入實體,所有需要類的實體都由spring管理,
3、spring的優點
容器:spring是一個容器,包含并管理物件的生命周期和配置,可以配置每個bean如何被創建,基于一個可配置原型prototype,你的bean可以創建一個單獨的實體或者每次需要時都生成一個新的實體,
支持AOP:spring提供對AOP的支持,它允許將一些通用任務,如安全、事物、日志等進行集中式處理,從而提高了程式的復用性,
輕量級框架:spring是輕量級框架,其基本的版本大約2M,
控制反轉:spring通過控制反轉實作松耦合,物件們給他們依賴,而不是物件本身,方便解耦,簡化開發,
方便程式測驗:spring提供了Junit4的支持,可以通過注解方便的測驗spring程式,
降低java EE API的使用難度:spring對java EE開發中非常難用的一些API(比如JDBC),都提供了封裝,使這些API應用難度大大降低,
方便集成各種優秀框架:spring內部提供了對各種優秀框架(如Struts、mybatis)的直接支持,
支持宣告式事務處理:只需要通過配置就可以完成對事務的管理,而無須手動編程,
4、spring的缺點
- 依賴反射,反射影響行程,
- 太過于依賴設計模式,
- 控制器過于靈活,
- 不支持分布式應用,
三、SpringMVC
1、基本概念
屬于spring框架的一部分,用來簡化MVC架構的web應用程式開發,
2、SpringMVC的優點
- 擁有強大的靈活性,非侵入性和可配置性
- 提供了一個前端控制器dispatcherServlet,開發者無需額外開發控制器物件
- 分工明確,包括控制器、驗證器、命令物件、模型物件、處理程式映射視圖決議器,每一個功能實作由一個專門的物件負責完成
- 可以自動系結用戶輸入,并正確的轉換資料型別
- 可重用的業務代碼:可以使用現有的業務物件作為命令或表單物件,而不需要去擴展某個特定框架的基類,
3、SpringMVC的缺點
- servlet API耦合難以脫離容器獨立運行
- 太過于細分,開發效率低
四、mybatis
1、基本概念
mybatis是一個簡化和實作了java資料持久層的開源框架,它抽象了大量的JDBC冗余代碼,并提供了一個簡單易用的API和資料庫互動,
2、mybatis的優點
- 與JDBC相比,減少了50%以上的代碼量,
- mybatis是最簡單的持久化框架,小巧并且簡單易學,
- mybatis靈活,不會對應用程式或者資料庫的限售設計強加任何影響,SQL寫在XML里,從程式代碼中徹底分離,降低耦合度,便于統一管理和優化,可重用,
- 提供XML標簽,支持撰寫動態SQL陳述句(XML中使用if,else),
- 提供映射標簽,支持物件與資料庫的ORM欄位關系映射(在XML中配置映射關系,也可以使用注解)
3、mybatis的缺點
- SQL陳述句的撰寫作業量較大,對開發人員的SQL陳述句撰寫有一定的水平要求,
- SQL陳述句過于依賴資料庫,不能隨意更換資料庫,
- 拼接復雜SQL陳述句時不靈活,
五、前置知識總結
Java框架總結
Spring AOP基礎知識總結
Spring常用注解(絕對經典)
SpringMVC中put和post如何選擇
@RequestParam、@ModelAttribute、@RequestBody的區別
mybatis常用注解(絕對經典)
【MyBatis 基礎知識總結 1】SQL注入
【MyBatis 基礎知識總結 2】MyBatis-Plus
【MyBatis 基礎知識總結 3】MyBatis一級快取和二級快取
【MyBatis 基礎知識總結 4】動態sql
【MyBatis 基礎知識總結 5】SqlSessionFactory和SqlSession
【MyBatis 基礎知識總結 6】Statement、PreparedStatement和CallableStatement
六、Java程式員簡歷上的第一個專案
Spring、SpringMVC、MyBatis整合
1、大體框架

2、引入jar包

3、配置
與spring整合時,mybatis的組態檔conf.xml(資料源+mapper.xml)可省,將其配置在applicationContext.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="config" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
<property name="locations">
<array>
<value>classpath:db.properties</value>
</array>
</property>
</bean>
<!-- 配置資料庫資訊(替代mybatis的組態檔confx.ml) -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${driver}"></property>
<property name="url" value="${url}"></property>
<property name="username" value="${username}"></property>
<property name="password" value="${password}"></property>
</bean>
<!-- 在springIOC中創建mybatis的核心類SqlSessionFactoryBean -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="mapperLocations" value="classpath:com/guor/mapper/*.xml"></property>
</bean>
<bean id="studentService" class="com.guor.service.impl.StudentServiceImpl">
<property name="studentMapper" ref="studentMapper"></property>
</bean>
<!-- 批量產生mapper物件在IOC中的id值默認就是介面名-->
<bean id="mappers" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
<!-- 指定批量產生哪個包的mapper物件 -->
<property name="basePackage" value="com.guor.mapper"></property>
</bean>
</beans>
資料庫配置
driver=oracle.jdbc.OracleDriver
url=jdbc:oracle:thin:@127.0.0.1:1521:ORCL
username=orcl
password=orcl
4、撰寫代碼
(1)entity
package com.guor.entity;
public class Student {
private int id;
private String name;
private int age;
...
}
(2)mapper
package com.guor.mapper;
import com.guor.entity.Student;
public interface StudentMapper {
public void addStudent(Student student);
public Student queryStudentByStuNo(int id);
}
StudentMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.guor.mapper.StudentMapper">
<select id="queryStudentByStuNo" parameterType="int" resultType="com.guor.entity.Student">
select * from student where id = #{stuNo}
</select>
<insert id="addStudent" parameterType="com.guor.entity.Student">
insert into student(id,name,age) values (#{id},#{name},#{age})
</insert>
</mapper>
(3)StudentService
package com.guor.service;
import com.guor.entity.Student;
public interface IStudentService {
public void addStudent(Student student);
public Student queryStudentByStuNo(int id);
}
StudentServiceImpl
package com.guor.service.impl;
import com.guor.entity.Student;
import com.guor.mapper.StudentMapper;
import com.guor.service.IStudentService;
public class StudentServiceImpl implements IStudentService {
private StudentMapper studentMapper;
public void setStudentMapper(StudentMapper studentMapper) {
this.studentMapper = studentMapper;
}
@Override
public void addStudent(Student student) {
studentMapper.addStudent(student);
}
@Override
public Student queryStudentByStuNo(int id) {
return studentMapper.queryStudentByStuNo(id);
}
}
(4)controller
package com.guor.controller;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import com.guor.entity.Student;
import com.guor.service.IStudentService;
@Controller
@RequestMapping("studentController")
public class StudentController {
@Autowired
@Qualifier("studentService")
private IStudentService studentService;
public void setStudentService(IStudentService studentService) {
this.studentService = studentService;
}
@RequestMapping("queryStudentByStuNo/{id}")//映射
public String queryStudentByStuNo(@PathVariable("id") Integer id,Map<String,Object> map) {
Student student = studentService.queryStudentByStuNo(id);
map.put("student", student);
return "result";
}
}
(5)組態檔
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- 掃描有注解的包 -->
<context:component-scan base-package="com.guor.controller"></context:component-scan>
<!-- 配置視圖決議器(InternalResourceViewResolver) -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/views/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!-- springMVC基礎配置、標配 -->
<mvc:annotation-driven></mvc:annotation-driven>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="mappingJacksonHttpMessageConverter" />
</list>
</property>
</bean>
<bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<!-- <property name="exceptionAttribute" value = "ex"></property> 例外變數的默認值是exception-->
<property name="exceptionMappings">
<props>
<!-- 相當于catch -->
<prop key="java.lang.ArithmeticException">
error
</prop>
<prop key="java.lang.NullPointException">
error
</prop>
</props>
</property>
</bean>
</beans>
3、index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<a href="studentController/queryStudentByStuNo/3">queryStudentByStuNo</a>
</body>
</html>
5、運行

🏀 Java學習路線思維導圖:Java學習路線思維導圖
🏀 Java學習路線配套文章:搬磚工逆襲Java架構師
🏀 Java經典面試題大全:10萬字208道Java經典面試題總結(附答案)
🏀 簡介:Java領域優質創作者🏆、CSDN哪吒公眾號作者? 、Java架構師奮斗者💪
🏀 掃描主頁左側二維碼,加入群聊,一起學習、一起進步
🏀 歡迎點贊 👍 收藏 ?留言 📝
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/317914.html
標籤:java
