Java實現(xiàn)讀取Excel數(shù)據(jù)并寫入到Word
讀取Excel 數(shù)據(jù)并寫入到Word
我們知道操作office 文檔一般常用的就是Apache POI 以及Easy POI.
Apache POI 是對office 早期的版本 .doc ,.xls 以及后期的*.docx 和*.xlsx API 的實現(xiàn)。
關(guān)于EasyPOI 據(jù)說是對Apache POI做了更好的封裝和功能擴(kuò)展,讓開發(fā)變得更加簡單。
好了廢話不多說,本篇博文將使用Apache POI 來讀取Excel 數(shù)據(jù)并寫入到word 文檔中。
最終效果如圖所示:

配置pom.xml
pom.xml 添加依賴如下:
<!-- 生產(chǎn)應(yīng)用監(jiān)控,可選,可以添加也可以不添加不影響當(dāng)前項目 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- 自定義配置文件要用 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- Web應(yīng)用開發(fā) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Apache POI -->
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.0</version>
</dependency>
<!-- thymeleaf 頁面模板引擎-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!--lombok 通過注解生成Getter Setter ToString 日志初始化等方法-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- Spring Boot Test Framework -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
完整的pom.xml 內(nèi)容如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- 設(shè)置當(dāng)前項目的父項目為Spring Boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<!-- 設(shè)置當(dāng)前項目的基本信息 -->
<groupId>com.xingyun</groupId>
<artifactId>transport-excel-data-to-word</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>transport-excel-data-to-word</name>
<description>Demo project for Spring Boot</description>
<properties>
<!-- 設(shè)置當(dāng)前項目源碼使用字符編碼為UTF-8 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- 設(shè)置當(dāng)前項目所需要的JDK版本 Open JDK下載地址:https://jdk.java.net/ -->
<java.version>1.8</java.version>
<!-- 設(shè)置當(dāng)前項目編譯所需要的JDK版本 Open JDK下載地址:https://jdk.java.net/ -->
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<!-- 設(shè)置maven編譯插件版本,可通過下面網(wǎng)址查看最新的版本-->
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<maven.compiler.plugin.version>3.5.1</maven.compiler.plugin.version>
<!-- 項目所使用第三方依賴jar包的版本,建議以后都使用這種方式,方便今后維護(hù)和升級 -->
<apache.poi.version>4.1.0</apache.poi.version>
</properties>
<dependencies>
<!-- 生產(chǎn)應(yīng)用監(jiān)控,可選,可以添加也可以不添加不影響當(dāng)前項目 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- 自定義配置文件要用 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- Web應(yīng)用開發(fā) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Apache POI -->
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${apache.poi.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${apache.poi.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>${apache.poi.version}</version>
</dependency>
<!-- thymeleaf 頁面模板引擎-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!--lombok 通過注解生成Getter Setter ToString 日志初始化等方法-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- Spring Boot Test Framework -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!--該插件可以讓我們通過maven命令將項目打包成一個可執(zhí)行的Jar-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--該插件限定Maven打包時所使用的版本,避免出現(xiàn)版本不匹配問題-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
配置 application.properties
application.properties
spring.profiles.active=dev
application-dev.properties
spring.application.name=transport-excel-data-to-word server.address=127.0.0.1 server.port=8080 server.servlet.context-path=/ spring.thymeleaf.prefix=classpath:/templates/bootstrap-ui-framework/ spring.thymeleaf.suffix=.html spring.thymeleaf.encoding=UTF-8 # 上次文件配置 com.xingyun.customize.upload-folder=C:/opt/upload # Servlet配置 # 連接超時設(shè)置為最大值 server.connection-timeout=999999999 spring.servlet.multipart.max-file-size=4096GB spring.servlet.multipart.max-request-size=4096GB spring.servlet.multipart.enabled=true # Tomcat配置 # 解決大文件上傳問題 # Tomcat針對中止上載將吞下的最大請求正文字節(jié)數(shù)(不包括傳輸編碼開銷) #中止上傳是指Tomcat知道請求體將被忽略但客戶端仍然發(fā)送它 # 如果Tomcat沒有吞下身體,則客戶端不太可能看到響應(yīng) # 如果未指定,將使用默認(rèn)值2097152(2兆字節(jié)) # 值小于零表示不應(yīng)強(qiáng)制執(zhí)行限制 server.tomcat.max-swallow-size=-1 server.tomcat.max-connections=10000 server.tomcat.max-http-post-size=4096GB
自定義配置屬性
由于上面com.xingyun.customize.upload-folder=C:/opt/upload
我們使用了一些自定義配置,因此按照最佳實踐來做,需要做點代碼配置支持。
創(chuàng)建一個Java Config 類,并激活配置屬性文件。
import com.xingyun.transportexceldatatoword.customize.SmartUploadProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @author 星云
* @功能
* @date 10/13/2019 12:00 PM
*/
@EnableConfigurationProperties({
SmartUploadProperties.class
})
@Configuration
public class CustomizePropertiesConfig {
}
然后創(chuàng)建一個自定義配置類
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* @author 星云
* @功能
* @date 10/13/2019 12:01 PM
*/
@Getter
@Setter
@ToString
@ConfigurationProperties(prefix="com.xingyun.customize")
public class SmartUploadProperties {
/**
* 注意"這里的變量名稱不可以有下劃線 否則會出錯
*/
private String uploadFolder;
}
注意:
這樣配置后,映射到配置文件就是
com.xingyun.customize.upload-folder=C:/opt/upload
配置首頁請求攔截并初始化文件夾
代碼如下:
import com.xingyun.transportexceldatatoword.customize.SmartUploadProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import java.io.File;
/**
* @author 星云
* @功能
* @date 10/13/2019 9:34 AM
*/
@Controller
public class HomePageController {
@Autowired
SmartUploadProperties smartUploadProperties;
@GetMapping(value = "/")
public String homePage(){
File file=new File(smartUploadProperties.getUploadFolder());
if(!file.exists()){
file.mkdirs();
}
return "index";
}
}
注意:這樣當(dāng)訪問首頁的時候就會初始化上傳文件夾了
配置上傳頁面
然后我們需要一個上傳頁面,編寫代碼如下:
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<!-- Required meta tags -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" th:href="@{../static/third-party/bootstrap-4.3.1-dist/css/bootstrap.min.css}" rel="external nofollow" >
<title>Excel Data To Word App</title>
</head>
<body>
<div align="center">
<h1>Excel Data To World App</h1>
</div>
<div class="jumbotron text-center">
<div align="left">
<form action="/upload.do" enctype="multipart/form-data" method="post">
<input th:type="file" name="uploadFileName" >
<input type="submit" value="提交">
</form>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script th:src="@{../static/third-party/jquery/jquery-3.3.1.slim.min.js}"></script>
<script th:src="@{../static/third-party/ajax/libs/popper.js/1.14.7/umd/popper.min.js}"/>
<script th:src="@{../static/third-party/bootstrap-4.3.1-dist/js/bootstrap.min.js}"/>
</body>
</html>
上傳文件
處理文件上傳的控制器編寫如下:
import com.xingyun.transportexceldatatoword.constant.CommonConstant;
import com.xingyun.transportexceldatatoword.customize.SmartUploadProperties;
import com.xingyun.transportexceldatatoword.util.SmartPoiExcelUtils;
import com.xingyun.transportexceldatatoword.util.SmartPoiWordUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
* @author 星云
* @功能
* @date 10/13/2019 9:43 AM
*/
@Slf4j
@Controller
public class UploadApiController {
@Autowired
SmartUploadProperties smartUploadProperties;
@PostMapping(value = "/upload.do")
public String upload(@RequestParam(value = "uploadFileName") MultipartFile multipartFile, HttpServletResponse response){
log.info(multipartFile.getOriginalFilename());
//構(gòu)建保存文件路徑
StringBuilder stringBuilder=new StringBuilder();
stringBuilder.append(smartUploadProperties.getUploadFolder());
stringBuilder.append(File.separator);
stringBuilder.append(multipartFile.getOriginalFilename());
//上傳文件路徑
String uploadFilePath=stringBuilder.toString();
//文件
File file=new File(uploadFilePath);
try {
//將上傳的文件保存下來
multipartFile.transferTo(file);
} catch (IOException e) {
log.error(e.getMessage(),e);
}
//將Excel中的數(shù)據(jù)進(jìn)行解析成對象
List<String> dataList= SmartPoiExcelUtils.parseExcelData(file.getAbsolutePath());
//生成World 的文件路徑
StringBuilder worldName=new StringBuilder();
worldName.append(smartUploadProperties.getUploadFolder());
worldName.append(File.separator);
worldName.append("data.docx");
//將數(shù)據(jù)寫入到文檔中
try {
SmartPoiWordUtils.writeDataToWord(worldName.toString(),dataList);
} catch (IOException e) {
log.error("IO Exception:",e);
}
//寫入完成后放入這個列表中
CommonConstant.shareFileMap.put("downloadFile",worldName.toString());
return "redirect:/api/v1/download.do";
}
}
這里使用了兩個工具類,將上傳的excel 文件保存到指定的路徑,然后將內(nèi)容寫入到word中,最后重定向到一個處理文件下載的控制器中。
讀取Excel 數(shù)據(jù)工具類
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.WorkbookUtil;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* @author 星云
* @功能
* @date 10/13/2019 10:01 AM
*/
@Slf4j
public final class SmartPoiExcelUtils {
private static final DataFormatter DATA_FORMATTER = new DataFormatter();
public static List<String> parseExcelData(String fileName){
List<String> dataList=new ArrayList<>();
try {
Workbook workbook= SmartPoiExcelUtils.createExcelWithXLSX(fileName);
for (Sheet sheetItem : workbook ) {
for (Row row : sheetItem) {
for (Cell cell : row) {
String text = DATA_FORMATTER.formatCellValue(cell);
log.info(text);
log.debug("cell type:{}",cell.getCellType());
dataList.add(text);
}
}
}
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
return dataList;
}
public static Workbook createExcelWithXLS(String fileName) throws IOException {
Workbook workbook = new HSSFWorkbook();
try (OutputStream fileOut = new FileOutputStream(fileName)) {
workbook.write(fileOut);
}
return workbook;
}
public static Workbook createExcelWithXLSX(String fileName) throws IOException {
Workbook workbook = WorkbookFactory.create(new File(fileName));
return workbook;
}
/**
* Note that sheet name is Excel must not exceed 31 characters
* and must not contain any of the any of the following characters:
* 0x0000
* 0x0003
* colon (:)
* backslash (\)
* asterisk (*)
* question mark (?)
* forward slash (/)
* opening square bracket ([)
* closing square bracket (])
* @param workbook
* @param sheetName
* @return
*/
public static Sheet createSheet(Workbook workbook,String sheetName){
// You can use org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)}
// for a safe way to create valid names, this utility replaces invalid characters with a space (' ')
// returns " O'Brien's sales "
String safeName = WorkbookUtil.createSafeSheetName(sheetName);
Sheet sheet = workbook.createSheet(safeName);
return sheet;
}
public static Cell createCell(Workbook workbook,Sheet sheet){
CreationHelper createHelper = workbook.getCreationHelper();
// Create a row and put some cells in it. Rows are 0 based.
Row row = sheet.createRow(0);
// Create a cell and put a value in it.
Cell cell = row.createCell(0);
cell.setCellValue(1);
// Or do it on one line.
row.createCell(1).setCellValue(1.2);
row.createCell(2).setCellValue(
createHelper.createRichTextString("This is a string"));
row.createCell(3).setCellValue(true);
// Create a cell and put a date value in it. The first cell is not styled
// as a date.
row.createCell(4).setCellValue(new Date());
// we style the second cell as a date (and time). It is important to
// create a new cell style from the workbook otherwise you can end up
// modifying the built in style and effecting not only this cell but other cells.
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setDataFormat(
createHelper.createDataFormat().getFormat("m/d/yy h:mm"));
cell = row.createCell(1);
cell.setCellValue(new Date());
cell.setCellStyle(cellStyle);
//you can also set date as java.util.Calendar
cell = row.createCell(2);
cell.setCellValue(Calendar.getInstance());
cell.setCellStyle(cellStyle);
row.createCell(0).setCellValue(1.1);
row.createCell(1).setCellValue(new Date());
row.createCell(2).setCellValue(Calendar.getInstance());
row.createCell(3).setCellValue("a string");
row.createCell(4).setCellValue(true);
return cell;
}
}
將List<String>寫入到word中工具類
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
/**
* @author 星云
* @功能
* @date 10/13/2019 12:22 PM
*/
public final class SmartPoiWordUtils {
public static void writeDataToWord(String fileName, List<String> dataListArg) throws IOException {
FileOutputStream out = new FileOutputStream(new File(fileName));
//創(chuàng)建一個文檔
XWPFDocument xwpfDocument=new XWPFDocument();
//創(chuàng)建一個段落
XWPFParagraph xwpfParagraph;
//創(chuàng)建一片區(qū)域
XWPFRun run;
for (String lineData:dataListArg
) {
xwpfParagraph= xwpfDocument.createParagraph();
run=xwpfParagraph.createRun();
run.setText(lineData);
}
xwpfDocument.write(out);
xwpfDocument.close();
out.close();
}
}
靜態(tài)值存儲
這里為了上傳和下載分開,將下載路徑暫時保存到一個靜態(tài)值中存儲。
import java.util.HashMap;
import java.util.Map;
/**
* @author 星云
* @功能
* @date 10/13/2019 2:59 PM
*/
public class CommonConstant {
/**
* 存儲查詢使用
*/
public static Map<String,String> shareFileMap=new HashMap<>();
}
處理下載模塊
import com.xingyun.transportexceldatatoword.constant.CommonConstant;
import com.xingyun.transportexceldatatoword.util.DownloadFileUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
/**
* @author 星云
* @功能
* @date 10/13/2019 2:56 PM
*/
@Slf4j
@RequestMapping(value = "/api/v1")
@RestController
public class DownloadController {
@GetMapping(value = "/download.do")
public void downloadFtpFileList(HttpServletResponse response) throws Exception{
String downloadFileName="download.docx";
//獲取下載文件路徑
String downloadFilePath= CommonConstant.shareFileMap.get("downloadFile");
log.info("下載文件名稱:"+downloadFileName);
log.info("下載文件路徑:"+downloadFilePath);
//執(zhí)行下載文件
Boolean downloadResult= DownloadFileUtils.downloadFile(downloadFilePath,downloadFileName,response);
if(downloadResult){
log.info("下載成功");
}else{
log.info("下載失敗");
}
}
}
文件下載工具類
import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
/**
* @author 星云
* @功能
* @date 10/13/2019 3:00 PM
*/
@Slf4j
public class DownloadFileUtils {
public final static Boolean downloadFile(String downloadFilePath, String downloadFileName, HttpServletResponse response){
//配置文件下載
try {
response.setHeader("content-type", "application/octet-stream");
response.setContentType("application/octet-stream");
// 下載文件能正常顯示中文
response.setHeader("Content-Disposition", "attachment;filename="+ URLEncoder.encode(downloadFileName, "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return false;
}
// 實現(xiàn)文件下載
byte[] buffer = new byte[1024];
FileInputStream fis = null;
BufferedInputStream bis = null;
try {
fis = new FileInputStream(downloadFilePath);
bis = new BufferedInputStream(fis);
OutputStream os = response.getOutputStream();
int i = bis.read(buffer); while (i != -1) {
os.write(buffer, 0, i); i = bis.read(buffer);
}
} catch (Exception e) {
log.error("Download the file failed!:{}",e.getMessage());
return false;
}finally {
//關(guān)閉流資源
if (bis != null) {
try {
bis.close();
}
catch (IOException e) {
e.printStackTrace();
log.error("關(guān)閉bis出錯:{}",e.getMessage());
return false;
}
}
if (fis != null) {
try { fis.close();
} catch (IOException e) {
e.printStackTrace();
log.error("關(guān)閉fis出錯:{}",e.getMessage());
return false;
}
}
}
return true;
}
}
最終項目結(jié)構(gòu)
最終項目結(jié)構(gòu)如下

源碼下載:https://github.com/geekxingyun/transport-excel-data-to-word
到此這篇關(guān)于Java實現(xiàn)讀取Excel數(shù)據(jù)并寫入到Word的文章就介紹到這了,更多相關(guān)Java讀取Excel數(shù)據(jù)寫入Word內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Java應(yīng)用程序CPU100%問題排查優(yōu)化實戰(zhàn)
這篇文章主要介紹了如何排查和優(yōu)化Java應(yīng)用程序CPU使用率達(dá)到100%的問題,文中通過代碼示例和圖文結(jié)合的方式講解的非常詳細(xì),具有一定的參考價值,需要的朋友可以參考下2025-02-02
Java日期轉(zhuǎn)換注解配置date?format時間失效
這篇文章主要為大家介紹了Java日期轉(zhuǎn)換注解配置date?format時間失效,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-12-12
java為什么使用BlockingQueue解決競態(tài)條件問題面試精講
這篇文章主要為大家介紹了java為什么使用BlockingQueue解決競態(tài)條件問題面試精講,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-10-10
MyBatis連接池、動態(tài) SQL 與多表關(guān)聯(lián)查詢的注意事項
本文將從連接池原理出發(fā),深入講解動態(tài) SQL 的常用標(biāo)簽,并通過實例演示一對多、多對多等復(fù)雜關(guān)聯(lián)查詢的實現(xiàn),幫助你掌握 MyBatis 的進(jìn)階用法,感興趣的朋友一起看看吧2025-07-07
深入淺出講解Spring框架中AOP及動態(tài)代理的應(yīng)用
在軟件業(yè),AOP為Aspect?Oriented?Programming的縮寫,意為:面向切面編程,通過預(yù)編譯方式和運(yùn)行期間動態(tài)代理實現(xiàn)程序功能的統(tǒng)一維護(hù)的一種技術(shù)2022-03-03
Java安全之Tomcat6 Filter內(nèi)存馬問題
這篇文章主要介紹了Java安全之Tomcat6 Filter內(nèi)存馬,通過本文探討下Tomcat6與Tomcat8之間的區(qū)別,主要看下tomcat6和tomcat8之間createFilterChain不相同的地方 看到ApplicationFilterFactory#createFilterChain,需要的朋友可以參考下2022-10-10
Springboot?異步任務(wù)和定時任務(wù)的異步處理
本文介紹了Springboot異步任務(wù)和定時任務(wù)的異步處理,Springboot?中,異步任務(wù)和定時任務(wù)是經(jīng)常遇到的處理問題方式,為了能夠用好這兩項配置,不干擾正常的業(yè)務(wù),需要對其進(jìn)行異步化配置。怎么設(shè)置合理的異步處理線程就是其核心和關(guān)鍵,下文詳情需要的朋友可以參考下2022-05-05

