java實(shí)現(xiàn)Linux(centos) 中docker容器下命令交互的代碼(配置向?qū)В?/h1>
更新時(shí)間:2021年05月13日 15:14:57 作者:見(jiàn)賢思齊IT
小編在開(kāi)發(fā)項(xiàng)目時(shí)遇到個(gè)需求,因?yàn)橄到y(tǒng)部署每次都要多臺(tái)機(jī)器拆分部署,很麻煩,怎么配置比較方便呢,今天小編給大家介紹java實(shí)現(xiàn)Linux(centos) 中docker容器下命令交互的代碼(配置向?qū)В?,感興趣的朋友一起看看吧
開(kāi)發(fā)需求: 因系統(tǒng)程序部署時(shí),經(jīng)常是拆分部署(多臺(tái)機(jī)器) ,手工部署費(fèi)時(shí)費(fèi)力,且每次都要手工配置系統(tǒng)參數(shù)(系統(tǒng)提供配置向?qū)?。
如下圖所示:
1)進(jìn)行main容器 -> 2)執(zhí)行系統(tǒng)配置向?qū)?-> 3)選擇服務(wù)器模式 -> 4) 選擇web控制臺(tái)....然后進(jìn)行具體的服務(wù)器IP設(shè)置。

為了解放雙手,用java實(shí)現(xiàn)了Linux(centos) 下docker 應(yīng)用程序的命令交互。
具體代碼如下:
import java.io.*;
/**
* @author by dujiajun
* @date 2021/4/29.
*/
public class TestMain extends Thread{
//進(jìn)入docker main
private static String [] cmds = {"docker","exec","-i","main","bash"};
private Process pro;
//初始化各機(jī)器IP信息
private String role = "";
private String webIp = "";
private String redisIp = "";
private String beanstalkdIp = "";
private String pgIp = "";
//main應(yīng)用重啟
public static String [] cmdRestart = {"/bin/sh","-c","docker restart main"};
public void cmdRun(String[] machines) throws Exception {
//執(zhí)行xx系統(tǒng)配置向?qū)畈⑸蛇M(jìn)程
//pro = Runtime.getRuntime().exec(cmds);
ProcessBuilder pb = new ProcessBuilder(cmds);
/* pb.inheritIO();
pb.redirectErrorStream(true);*/
pro = pb.start();
System.out.println("執(zhí)行前pro1:" + pro.isAlive());
//解析machines信息
if (machines.length > 0) {
for (int i = 0; i < machines.length; i++) {
int strEndIndex = machines[i].indexOf(":");
String str = machines[i].substring(0, strEndIndex);
String content = machines[i].substring(strEndIndex + 1);
switch (str.trim()) {
case "role":
role = content;
break; //web服務(wù)器IP
case "webIp":
webIp = content;
break; //redis服務(wù)器IP
case "redisIp":
redisIp = content;
break; //redis服務(wù)器IP
case "beanstalkdIp":
beanstalkdIp = content;
break; //beanstalkd服務(wù)器IP
case "pgIp":
pgIp = content;
break; //beanstalkd服務(wù)器IP
default:
break;
}
}
}
new Thread() {
public void run() {
try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(pro.getOutputStream()))) {
if (role != null && role.equals("web-server")) {//系統(tǒng)web控制臺(tái)
System.out.println("*********進(jìn)入web控制臺(tái)配置向?qū)?********");
//系統(tǒng)配置向?qū)罴?web
String[] strCmdWeb = {
"python /opt/tools/skylar_cli/bin/skylar_cli.pyc",//系統(tǒng)配置向?qū)?
"server-type", //服務(wù)器模式
"web-server", //管理服務(wù)器:提供管理功能及應(yīng)用功能
"allow-deploy-api-server 0", //設(shè)置是否允許部署應(yīng)用服務(wù)器 1允許 0不允許
"cache-info " + redisIp + ":6379", //緩存服務(wù)器
"db-info " + pgIp + ":5432", //設(shè)置數(shù)據(jù)庫(kù)信息
"queue-info " + beanstalkdIp + ":11300", //設(shè)置隊(duì)列信息
"report-server-db-info " + pgIp + ":5432", //設(shè)置報(bào)表數(shù)據(jù)庫(kù)
"sfmg-db-info " + pgIp + ":5432", //設(shè)置軟件管家數(shù)據(jù)庫(kù)
"web-server-port " + webIp + ":8080",//設(shè)置管理服務(wù)器端口
"commit",//提交
"exit"
};
//查看進(jìn)程是否還存活
System.out.println("執(zhí)行前pro2:" + pro.isAlive());
for (String strWeb : strCmdWeb) {
synchronized (bw) {
bw.write(strWeb.trim());
bw.newLine();
System.out.println("step: " + strWeb);
bw.wait(1000);
}
}
//查看進(jìn)程是否還存活
System.out.println("pro3:" + pro.isAlive());
bw.flush();//緩存提交
System.out.println("緩存提交!");
bw.close();
System.out.println(" bw.close();");
System.out.println("web配置向?qū)гO(shè)置成功!");
} else if (role != null && role.equals("api-server")) {//系統(tǒng)app應(yīng)用
//系統(tǒng)配置向?qū)罴?APP
System.out.println("*********進(jìn)入APP服務(wù)器控制臺(tái)配置向?qū)?********");
String[] strCmdApp = {
"python /opt/tools/skylar_cli/bin/skylar_cli.pyc",//系統(tǒng)配置向?qū)?
"server-type", //服務(wù)器模式
"api-server", //APP服務(wù)器
"cache-info " + redisIp + ":6379", //緩存服務(wù)器
"db-info " + pgIp + ":5432", //設(shè)置數(shù)據(jù)庫(kù)信息
"queue-info " + beanstalkdIp + ":11300", //設(shè)置隊(duì)列信息
"web-server-info " + webIp + ":8080", //設(shè)置管理服務(wù)器端口
"commit",//提交配置
"exit"
};
for (String str : strCmdApp) {
synchronized (bw) {
bw.write(str.trim());
bw.newLine();
System.out.println("step: " + str);
bw.wait(1000);
}
}
//查看進(jìn)程是否還存活
System.out.println("pro3:" + pro.isAlive());
bw.flush();//緩存提交
System.out.println("緩存提交!");
System.out.println("app配置向?qū)гO(shè)置成功!");
bw.close();
} else if (role != null && role.equals("log-analyze-server")) {//系統(tǒng)日志分析服務(wù)器
//系統(tǒng)配置向?qū)罴?log-analyze-server
System.out.println("*********進(jìn)入日志分析服務(wù)器控制臺(tái)配置向?qū)?********");
String[] strCmdLog = {
"python /opt/tools/skylar_cli/bin/skylar_cli.pyc",//天擎配置向?qū)?
"server-type", //服務(wù)器模式
"log-analyze-server", //管理服務(wù)器:提供管理功能及應(yīng)用功能
"cache-info " + redisIp + ":6379", //緩存服務(wù)器
"db-info " + pgIp + ":5432", //設(shè)置數(shù)據(jù)庫(kù)信息
"queue-info " + beanstalkdIp + ":11300", //設(shè)置隊(duì)列信息
"web-server-info " + webIp + ":8080", //設(shè)置管理服務(wù)器端口
"sfmg-db-info " + pgIp + ":5432", //設(shè)置軟件管家數(shù)據(jù)庫(kù)
"commit",//提交配置
"exit"
};
//順序執(zhí)行配置向?qū)?
for (String str : strCmdLog) {
synchronized (bw) {
bw.write(str.trim());
bw.newLine();
System.out.println("step: " + str);
bw.wait(1000);
}
}
//測(cè)試進(jìn)程是否還存活
System.out.println("pro3:" + pro.isAlive());
bw.flush();//緩存提交
System.out.println("緩存提交!");
System.out.println("日志分析服務(wù)器配置向?qū)гO(shè)置成功!");
bw.close();
}
} catch (IOException | InterruptedException e) {
//pro.destroyForcibly();
e.printStackTrace();
//pro.destroy();
System.out.println("e.getMessage(): " + e.getMessage());
} finally {
try {
Process process = Runtime.getRuntime().exec(cmdRestart);//重啟main
System.out.println("process.isAlive:" + process.isAlive());
System.out.println("重啟main成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
}
}.start();
new Thread(){
public void run(){
BufferedReader br = new BufferedReader(new InputStreamReader(pro.getErrorStream()));
String cmdout = "";
try {
cmdout = br.readLine();
while(cmdout!= null&&(!cmdout.equals("exit"))){
System.out.println(cmdout);
}
} catch (IOException e) {
//System.out.println("br:pro.destroy();");
//pro.destroy();
e.printStackTrace();
System.out.println("e.printStackTrace();");
}
try {
System.out.println(" br.close();");
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
pro.waitFor();//進(jìn)程等待
}
public static void main(String[] args) throws Exception {
TestMain testMain = new TestMain();
/*
//測(cè)試用
String[] machines ={
"role:web-server",
"webIp:xx.xx.xx.110",
"redisIp:xx.xx.xx.211",
"beanstalkdIp:xx.xx.xx.211",
"pgIp:xx.xx.xx.212"
};*/
testMain.cmdRun(args);
/* System.exit(0);
System.out.println("System.exit(0);");*/
}
}
特別注意:
private static String [] cmds = {"docker","exec","-i","main","bash"};
一定要使用 docker exec -i main bash ,不要使用 -it ,否則會(huì)報(bào)錯(cuò) cannot enable tty mode on non tty input。
Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
Run a command in a running container
-i, --interactive=false Keep STDIN open even if not attached
-t, --tty=false Allocate a pseudo-TTY
打成jar包,執(zhí)行jar包:

終于看到久違的部署成功界面~

到此這篇關(guān)于java實(shí)現(xiàn)Linux(centos) 中docker容器下命令交互(配置向?qū)В┑奈恼戮徒榻B到這了,更多相關(guān)docker容器命令交互內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
-
導(dǎo)出maven項(xiàng)目依賴的jar包(圖文教程)
下面小編就為大家?guī)?lái)一篇導(dǎo)出maven項(xiàng)目依賴的jar包(圖文教程)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧 2017-10-10
-
深入了解Springboot核心知識(shí)點(diǎn)之?dāng)?shù)據(jù)訪問(wèn)配置
這篇文章主要為大家介紹了Springboot核心知識(shí)點(diǎn)中的數(shù)據(jù)訪問(wèn)配置,文中的示例代碼講解詳細(xì),對(duì)我們了解SpringBoot有一定幫助,快跟隨小編一起學(xué)習(xí)一下吧 2021-12-12
-
java實(shí)現(xiàn)簡(jiǎn)單的驗(yàn)證碼功能
這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)簡(jiǎn)單的驗(yàn)證碼功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下 2020-04-04
-
Mybatis?Plus分頁(yè)查詢返回total為0問(wèn)題解決
在使用MybatisPlus進(jìn)行分頁(yè)查詢時(shí),可能會(huì)遇到返回的總條數(shù)(total)為0的問(wèn)題,這通常是由于未配置MybatisPlus的分頁(yè)插件攔截器導(dǎo)致的,本文就來(lái)介紹一下解決方法,感興趣的可以了解一下 2024-10-10
-
一文帶你詳細(xì)認(rèn)識(shí)文件與Java中操作文件
文件處理是任何應(yīng)用程序的重要部分,Java 提供了許多用于創(chuàng)建、讀取、更新和刪除文件的方法,這篇文章主要給大家介紹了關(guān)于認(rèn)識(shí)文件與Java中操作文件的相關(guān)資料,需要的朋友可以參考下 2024-05-05
-
MybatisPlus實(shí)現(xiàn)分頁(yè)查詢和動(dòng)態(tài)SQL查詢的示例代碼
本文主要介紹了MybatisPlus實(shí)現(xiàn)分頁(yè)查詢和動(dòng)態(tài)SQL查詢的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下 2021-09-09
-
Java實(shí)現(xiàn)求二叉樹(shù)的深度和寬度
這篇文章主要介紹了Java實(shí)現(xiàn)求二叉樹(shù)的深度和寬度,本文分別給出代碼實(shí)例,需要的朋友可以參考下 2015-06-06
-
Java之使用POI教你玩轉(zhuǎn)Excel導(dǎo)入與導(dǎo)出
這篇文章主要介紹了Java之使用POI教你玩轉(zhuǎn)Excel導(dǎo)入與導(dǎo)出,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教 2022-10-10
-
Java8中Lambda表達(dá)式的理解與應(yīng)用
Java8最值得學(xué)習(xí)的特性就是Lambda表達(dá)式和Stream?API,如果有python或者javascript的語(yǔ)言基礎(chǔ),對(duì)理解Lambda表達(dá)式有很大幫助,下面這篇文章主要給大家介紹了關(guān)于Java8中Lambda表達(dá)式的相關(guān)資料,需要的朋友可以參考下 2022-02-02
最新評(píng)論
開(kāi)發(fā)需求: 因系統(tǒng)程序部署時(shí),經(jīng)常是拆分部署(多臺(tái)機(jī)器) ,手工部署費(fèi)時(shí)費(fèi)力,且每次都要手工配置系統(tǒng)參數(shù)(系統(tǒng)提供配置向?qū)?。
如下圖所示:
1)進(jìn)行main容器 -> 2)執(zhí)行系統(tǒng)配置向?qū)?-> 3)選擇服務(wù)器模式 -> 4) 選擇web控制臺(tái)....然后進(jìn)行具體的服務(wù)器IP設(shè)置。
為了解放雙手,用java實(shí)現(xiàn)了Linux(centos) 下docker 應(yīng)用程序的命令交互。
具體代碼如下:
import java.io.*; /** * @author by dujiajun * @date 2021/4/29. */ public class TestMain extends Thread{ //進(jìn)入docker main private static String [] cmds = {"docker","exec","-i","main","bash"}; private Process pro; //初始化各機(jī)器IP信息 private String role = ""; private String webIp = ""; private String redisIp = ""; private String beanstalkdIp = ""; private String pgIp = ""; //main應(yīng)用重啟 public static String [] cmdRestart = {"/bin/sh","-c","docker restart main"}; public void cmdRun(String[] machines) throws Exception { //執(zhí)行xx系統(tǒng)配置向?qū)畈⑸蛇M(jìn)程 //pro = Runtime.getRuntime().exec(cmds); ProcessBuilder pb = new ProcessBuilder(cmds); /* pb.inheritIO(); pb.redirectErrorStream(true);*/ pro = pb.start(); System.out.println("執(zhí)行前pro1:" + pro.isAlive()); //解析machines信息 if (machines.length > 0) { for (int i = 0; i < machines.length; i++) { int strEndIndex = machines[i].indexOf(":"); String str = machines[i].substring(0, strEndIndex); String content = machines[i].substring(strEndIndex + 1); switch (str.trim()) { case "role": role = content; break; //web服務(wù)器IP case "webIp": webIp = content; break; //redis服務(wù)器IP case "redisIp": redisIp = content; break; //redis服務(wù)器IP case "beanstalkdIp": beanstalkdIp = content; break; //beanstalkd服務(wù)器IP case "pgIp": pgIp = content; break; //beanstalkd服務(wù)器IP default: break; } } } new Thread() { public void run() { try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(pro.getOutputStream()))) { if (role != null && role.equals("web-server")) {//系統(tǒng)web控制臺(tái) System.out.println("*********進(jìn)入web控制臺(tái)配置向?qū)?********"); //系統(tǒng)配置向?qū)罴?web String[] strCmdWeb = { "python /opt/tools/skylar_cli/bin/skylar_cli.pyc",//系統(tǒng)配置向?qū)? "server-type", //服務(wù)器模式 "web-server", //管理服務(wù)器:提供管理功能及應(yīng)用功能 "allow-deploy-api-server 0", //設(shè)置是否允許部署應(yīng)用服務(wù)器 1允許 0不允許 "cache-info " + redisIp + ":6379", //緩存服務(wù)器 "db-info " + pgIp + ":5432", //設(shè)置數(shù)據(jù)庫(kù)信息 "queue-info " + beanstalkdIp + ":11300", //設(shè)置隊(duì)列信息 "report-server-db-info " + pgIp + ":5432", //設(shè)置報(bào)表數(shù)據(jù)庫(kù) "sfmg-db-info " + pgIp + ":5432", //設(shè)置軟件管家數(shù)據(jù)庫(kù) "web-server-port " + webIp + ":8080",//設(shè)置管理服務(wù)器端口 "commit",//提交 "exit" }; //查看進(jìn)程是否還存活 System.out.println("執(zhí)行前pro2:" + pro.isAlive()); for (String strWeb : strCmdWeb) { synchronized (bw) { bw.write(strWeb.trim()); bw.newLine(); System.out.println("step: " + strWeb); bw.wait(1000); } } //查看進(jìn)程是否還存活 System.out.println("pro3:" + pro.isAlive()); bw.flush();//緩存提交 System.out.println("緩存提交!"); bw.close(); System.out.println(" bw.close();"); System.out.println("web配置向?qū)гO(shè)置成功!"); } else if (role != null && role.equals("api-server")) {//系統(tǒng)app應(yīng)用 //系統(tǒng)配置向?qū)罴?APP System.out.println("*********進(jìn)入APP服務(wù)器控制臺(tái)配置向?qū)?********"); String[] strCmdApp = { "python /opt/tools/skylar_cli/bin/skylar_cli.pyc",//系統(tǒng)配置向?qū)? "server-type", //服務(wù)器模式 "api-server", //APP服務(wù)器 "cache-info " + redisIp + ":6379", //緩存服務(wù)器 "db-info " + pgIp + ":5432", //設(shè)置數(shù)據(jù)庫(kù)信息 "queue-info " + beanstalkdIp + ":11300", //設(shè)置隊(duì)列信息 "web-server-info " + webIp + ":8080", //設(shè)置管理服務(wù)器端口 "commit",//提交配置 "exit" }; for (String str : strCmdApp) { synchronized (bw) { bw.write(str.trim()); bw.newLine(); System.out.println("step: " + str); bw.wait(1000); } } //查看進(jìn)程是否還存活 System.out.println("pro3:" + pro.isAlive()); bw.flush();//緩存提交 System.out.println("緩存提交!"); System.out.println("app配置向?qū)гO(shè)置成功!"); bw.close(); } else if (role != null && role.equals("log-analyze-server")) {//系統(tǒng)日志分析服務(wù)器 //系統(tǒng)配置向?qū)罴?log-analyze-server System.out.println("*********進(jìn)入日志分析服務(wù)器控制臺(tái)配置向?qū)?********"); String[] strCmdLog = { "python /opt/tools/skylar_cli/bin/skylar_cli.pyc",//天擎配置向?qū)? "server-type", //服務(wù)器模式 "log-analyze-server", //管理服務(wù)器:提供管理功能及應(yīng)用功能 "cache-info " + redisIp + ":6379", //緩存服務(wù)器 "db-info " + pgIp + ":5432", //設(shè)置數(shù)據(jù)庫(kù)信息 "queue-info " + beanstalkdIp + ":11300", //設(shè)置隊(duì)列信息 "web-server-info " + webIp + ":8080", //設(shè)置管理服務(wù)器端口 "sfmg-db-info " + pgIp + ":5432", //設(shè)置軟件管家數(shù)據(jù)庫(kù) "commit",//提交配置 "exit" }; //順序執(zhí)行配置向?qū)? for (String str : strCmdLog) { synchronized (bw) { bw.write(str.trim()); bw.newLine(); System.out.println("step: " + str); bw.wait(1000); } } //測(cè)試進(jìn)程是否還存活 System.out.println("pro3:" + pro.isAlive()); bw.flush();//緩存提交 System.out.println("緩存提交!"); System.out.println("日志分析服務(wù)器配置向?qū)гO(shè)置成功!"); bw.close(); } } catch (IOException | InterruptedException e) { //pro.destroyForcibly(); e.printStackTrace(); //pro.destroy(); System.out.println("e.getMessage(): " + e.getMessage()); } finally { try { Process process = Runtime.getRuntime().exec(cmdRestart);//重啟main System.out.println("process.isAlive:" + process.isAlive()); System.out.println("重啟main成功!"); } catch (IOException e) { e.printStackTrace(); } } } }.start(); new Thread(){ public void run(){ BufferedReader br = new BufferedReader(new InputStreamReader(pro.getErrorStream())); String cmdout = ""; try { cmdout = br.readLine(); while(cmdout!= null&&(!cmdout.equals("exit"))){ System.out.println(cmdout); } } catch (IOException e) { //System.out.println("br:pro.destroy();"); //pro.destroy(); e.printStackTrace(); System.out.println("e.printStackTrace();"); } try { System.out.println(" br.close();"); br.close(); } catch (IOException e) { e.printStackTrace(); } } }.start(); pro.waitFor();//進(jìn)程等待 } public static void main(String[] args) throws Exception { TestMain testMain = new TestMain(); /* //測(cè)試用 String[] machines ={ "role:web-server", "webIp:xx.xx.xx.110", "redisIp:xx.xx.xx.211", "beanstalkdIp:xx.xx.xx.211", "pgIp:xx.xx.xx.212" };*/ testMain.cmdRun(args); /* System.exit(0); System.out.println("System.exit(0);");*/ } }
特別注意:
private static String [] cmds = {"docker","exec","-i","main","bash"};
一定要使用 docker exec -i main bash ,不要使用 -it ,否則會(huì)報(bào)錯(cuò) cannot enable tty mode on non tty input。
Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...] Run a command in a running container -i, --interactive=false Keep STDIN open even if not attached -t, --tty=false Allocate a pseudo-TTY
打成jar包,執(zhí)行jar包:
終于看到久違的部署成功界面~
到此這篇關(guān)于java實(shí)現(xiàn)Linux(centos) 中docker容器下命令交互(配置向?qū)В┑奈恼戮徒榻B到這了,更多相關(guān)docker容器命令交互內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
導(dǎo)出maven項(xiàng)目依賴的jar包(圖文教程)
下面小編就為大家?guī)?lái)一篇導(dǎo)出maven項(xiàng)目依賴的jar包(圖文教程)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-10-10深入了解Springboot核心知識(shí)點(diǎn)之?dāng)?shù)據(jù)訪問(wèn)配置
這篇文章主要為大家介紹了Springboot核心知識(shí)點(diǎn)中的數(shù)據(jù)訪問(wèn)配置,文中的示例代碼講解詳細(xì),對(duì)我們了解SpringBoot有一定幫助,快跟隨小編一起學(xué)習(xí)一下吧2021-12-12java實(shí)現(xiàn)簡(jiǎn)單的驗(yàn)證碼功能
這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)簡(jiǎn)單的驗(yàn)證碼功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-04-04Mybatis?Plus分頁(yè)查詢返回total為0問(wèn)題解決
在使用MybatisPlus進(jìn)行分頁(yè)查詢時(shí),可能會(huì)遇到返回的總條數(shù)(total)為0的問(wèn)題,這通常是由于未配置MybatisPlus的分頁(yè)插件攔截器導(dǎo)致的,本文就來(lái)介紹一下解決方法,感興趣的可以了解一下2024-10-10一文帶你詳細(xì)認(rèn)識(shí)文件與Java中操作文件
文件處理是任何應(yīng)用程序的重要部分,Java 提供了許多用于創(chuàng)建、讀取、更新和刪除文件的方法,這篇文章主要給大家介紹了關(guān)于認(rèn)識(shí)文件與Java中操作文件的相關(guān)資料,需要的朋友可以參考下2024-05-05MybatisPlus實(shí)現(xiàn)分頁(yè)查詢和動(dòng)態(tài)SQL查詢的示例代碼
本文主要介紹了MybatisPlus實(shí)現(xiàn)分頁(yè)查詢和動(dòng)態(tài)SQL查詢的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09Java實(shí)現(xiàn)求二叉樹(shù)的深度和寬度
這篇文章主要介紹了Java實(shí)現(xiàn)求二叉樹(shù)的深度和寬度,本文分別給出代碼實(shí)例,需要的朋友可以參考下2015-06-06Java之使用POI教你玩轉(zhuǎn)Excel導(dǎo)入與導(dǎo)出
這篇文章主要介紹了Java之使用POI教你玩轉(zhuǎn)Excel導(dǎo)入與導(dǎo)出,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-10-10Java8中Lambda表達(dá)式的理解與應(yīng)用
Java8最值得學(xué)習(xí)的特性就是Lambda表達(dá)式和Stream?API,如果有python或者javascript的語(yǔ)言基礎(chǔ),對(duì)理解Lambda表達(dá)式有很大幫助,下面這篇文章主要給大家介紹了關(guān)于Java8中Lambda表達(dá)式的相關(guān)資料,需要的朋友可以參考下2022-02-02