mycpen-blog 0.0.0-fibiffajvp → 0.0.0-fibkdvavxi
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index.css +1 -1
- package/gallery/fe32.top/download.sh +1144 -0
- package/js/custom.js +1 -1
- package/js/fcircle.js +1 -1
- package/js/people.js +1 -1
- package/js/random.js +1 -1
- package/js/tianli_gpt.js +1 -1
- package/json/friend.json +1 -0
- package/json/link.json +1 -0
- package/json/tianli_gpt.json +1 -0
- package/manifest.json +1 -1
- package/music1/main.css +1 -1
- package/music1/manifest.json +2 -2
- package/package.json +1 -1
- package/search.xml +3 -3
- package/sitemap.xml +88 -88
- package/wechatOA/main.css +1 -1
- package/friend.json +0 -1
- package/link.json +0 -1
- package/song/AZA/345/276/256/345/224/261/345/233/242//344/273/216/345/210/253/345/220/216/song.lrc +0 -43
- package/song/S.H.E//344/270/200/347/234/274/344/270/207/345/271/264/song.lrc +0 -51
- package/song/The Chainsmokers/Something Just Like This/song.lrc +0 -65
- package/song//345/221/250/346/235/260/344/274/246//344/270/203/351/207/214/351/246/231/song.lrc +0 -39
- package/song//345/221/250/346/235/260/344/274/246//345/217/215/346/226/271/345/220/221/347/232/204/351/222/237/song.lrc +0 -61
- package/song//345/221/250/346/235/260/344/274/246//346/230/216/346/230/216/345/260/261/song.lrc +0 -46
- package/song//345/221/250/346/235/260/344/274/246//346/234/200/351/225/277/347/232/204/347/224/265/345/275/261/song.lrc +0 -51
- package/song//345/221/250/346/235/260/344/274/246//347/250/273/351/246/231/song.lrc +0 -53
- package/song//345/221/250/346/235/260/344/274/246//347/272/242/351/242/234/345/246/202/351/234/234/song.lrc +0 -57
- package/song//345/221/250/346/235/260/344/274/246//350/257/264/345/245/275/347/232/204/345/271/270/347/246/217/345/221/242/song.lrc +0 -70
- package/song//345/221/250/346/235/260/344/274/246//351/235/222/350/212/261/347/223/267/song.lrc +0 -45
- package/song//346/242/201/351/223/255/347/220/233//351/241/273/350/207/276/song.lrc +0 -71
- package/song//350/214/203/347/216/256/347/220/252//346/234/200/345/210/235/347/232/204/346/242/246/346/203/263/song.lrc +0 -63
- package/song//350/221/243/347/234/237//346/200/235/345/246/202/351/233/252/song.lrc +0 -48
package/search.xml
CHANGED
@@ -269,7 +269,7 @@
|
|
269
269
|
<link href="/posts/fe8dbc73.html"/>
|
270
270
|
<url>/posts/fe8dbc73.html</url>
|
271
271
|
|
272
|
-
<content type="html"><![CDATA[<h2 id="前言">前言<a class="header-anchor" href="#前言"></a></h2><p>记录一些遇到的问题</p><h2 id="01-Python-中文乱码-Git-Bash">01. Python 中文乱码 (Git Bash)<a class="header-anchor" href="#01-Python-中文乱码-Git-Bash"></a></h2><p>win终端正常运行但是在git bash 终端运行py文件中文乱码<br>在python命令前加 <code>winpty</code> 之后则可以正常显示中文</p><blockquote><p>winpty:一个 Windows 软件包,提供类似于 Unix pty-master 的接口,用于与 Windows 控制台程序通信。</p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2023/files/image/202303310016695.png" alt="image-20230331001601640" style="zoom: 25%;" /></blockquote><p>参考文章:</p><ol><li class="lvl-3"><p><a href="https://blog.csdn.net/sinat_42414027/article/details/127787059">【python中文乱码】git bash终端运行python文件中文乱码的问题</a></p></li><li class="lvl-3"><p><a href="https://github.com/rprichard/winpty">https://github.com/rprichard/winpty</a></p></li></ol><h2 id="02-gitignore-测试规则">02. .gitignore 测试规则<a class="header-anchor" href="#02-gitignore-测试规则"></a></h2><p>.gitignore 配置</p><blockquote><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line">*.a 表示忽略所有 .a 结尾的文件</span><br><span class="line">!lib.a 表示但lib.a除外</span><br><span class="line">doc/*.txt 表示会忽略doc/notes.txt但不包括 doc/server/arch.txt</span><br><span class="line">/TODO 表示仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TODO</span><br><span class="line">bin/ 表示忽略当前路径下的bin文件夹,该文件夹下的所有内容都会被忽略,不忽略 bin 文件</span><br><span class="line">**/foo: 表示忽略/foo,a/foo,a/b/foo等</span><br><span class="line">a/**/b: 表示忽略a/b, a/x/b,a/x/y/b等</span><br><span class="line">*.log: 表示忽略所有 .log 文件</span><br><span class="line">/mtk/ 表示过滤整个文件夹</span><br><span class="line">*.zip 表示过滤所有.zip文件</span><br><span class="line">--- 需要注意的是,gitignore还可以指定要将哪些文件添加到版本管理中,如下: ---</span><br><span class="line">!*.zip</span><br><span class="line">!/mtk/one.txt</span><br><span class="line">唯一的区别就是规则开头多了一个感叹号,Git会将满足这类规则的文件添加到版本管理中。为什么要有两种规则呢?</span><br><span class="line">想象一个场景:假如我们只需要管理/mtk/目录中的one.txt文件,</span><br><span class="line">这个目录中的其他文件都不需要管理,那么.gitignore规则应写为:</span><br><span class="line">/mtk/*</span><br><span class="line">!/mtk/one.txt</span><br><span class="line">假设我们只有过滤规则,而没有添加规则,</span><br><span class="line">那么我们就需要把/mtk/目录下除了one.txt以外的所有文件都写出来!</span><br><span class="line">注意上面的/mtk/*不能写为/mtk/,否则父目录被前面的规则排除掉了,</span><br><span class="line">one.txt文件虽然加了!过滤规则,也不会生效!</span><br><span class="line">--- 还有一些规则如下: ---</span><br><span class="line">fd1/*</span><br><span class="line">说明:忽略目录 fd1 下的全部内容;</span><br><span class="line">注意,不管是根目录下的 /fd1/ 目录,还是某个子目录 /child/fd1/ 目录,都会被忽略;</span><br><span class="line">/fd1/*</span><br><span class="line">说明:忽略根目录下的 /fd1/ 目录的全部内容;</span><br><span class="line">------</span><br><span class="line">/*</span><br><span class="line">!.gitignore</span><br><span class="line">!/fw/ </span><br><span class="line">/fw/*</span><br><span class="line">!/fw/bin/</span><br><span class="line">!/fw/sf/</span><br><span class="line">说明:忽略全部内容,但是不忽略 .gitignore 文件、根目录下的 /fw/bin/ 和 /fw/sf/ 目录;</span><br><span class="line">注意要先对bin/的父目录使用!规则,使其不被排除。</span><br><span class="line"></span><br></pre></td></tr></table></figure></blockquote><p><mark>*</mark> .gitignor 忽略规则查看</p><blockquote><p>有时候,确定为什么要忽略特定文件可能会很困难,尤其是当你使用多个.gitignore文件或复杂格式时。这是git check-ignore命令的用处,告诉git显示匹配模式的详细信息。</p><p>例如,要检查为什么忽略www/yarn.lock文件,可以运行:</p><p><code>git check-ignore -v www/yarn.lock</code></p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2023/files/image/202304041447156.png" alt="image-20230404144757129" style="zoom: 67%;" /></blockquote><p>显示所有被忽略的文件</p><blockquote><p>带有–ignored选项的git status命令显示所有被忽略文件的列表:</p><p><code>git status --ignored</code></p></blockquote><p>参考文章:</p><ol><li class="lvl-3"><p><a href="https://blog.csdn.net/stephenbruce/article/details/127355631">Git忽略提交规则 - .gitignore配置【学习】</a></p></li><li class="lvl-3"><p><a href="https://blog.csdn.net/m0_49448331/article/details/128655710">如何使用.gitignore忽略Git中的文件和目录</a></p></li></ol><h2 id="03-Windows-显示-无Internet">03. Windows 显示"无Internet"<a class="header-anchor" href="#03-Windows-显示-无Internet"></a></h2><p>情况:网络显示 “无Internet”,但是可以上网。以下措施没根本解决,最终用微软诊断工具,重置了 <code>以太网</code> 网络(万能的重装大法)…</p><blockquote><ol><li class="lvl-3"><p>向 <a href="http://dns.msftncsi.com">dns.msftncsi.com</a> 发送 DNS 查找请求,DNS 解析为 131.107.255.255</p></li><li class="lvl-3"><p>请求 <a href="http://www.msftconnecttest.com/connecttest.txt%EF%BC%8C%E5%A6%82%E6%9E%9C%E7%BD%91%E7%BB%9C%E6%AD%A3%E5%B8%B8%EF%BC%8C%E5%88%99%E6%AD%A4%E6%96%87%E4%BB%B6%E6%98%AF%E7%BA%AF%E6%96%87%E6%9C%AC%E6%96%87%E4%BB%B6%EF%BC%8C%E4%BB%85%E5%8C%85%E5%90%AB%E6%96%87%E6%9C%AC">http://www.msftconnecttest.com/connecttest.txt,如果网络正常,则此文件是纯文本文件,仅包含文本</a> Microsoft Connect Test</p></li></ol><p>如果过程1不正常,则提示“无法访问Internet”,如果1正常2不正常,则提示需要进行身份验证</p></blockquote><p><mark>以下措施没解决问题</mark></p><p>估计 DHCP 分配的 DNS 服务器(指向网关)有问题,<a href="https://github.com/oldj/SwitchHosts">SwitchHosts</a> 追加本地记录</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Microsoft</span></span><br><span class="line">dns.msftncsi.com 131.107.255.255</span><br></pre></td></tr></table></figure><p>开机自启 SwitchHosts(Win):</p><ul class="lvl-0"><li class="lvl-2"><p>快捷方式 复制到 => C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\</p></li><li class="lvl-2"><p>设置 => 选项 => 启动时隐藏 √</p></li></ul><p>参考文章:</p><ol><li class="lvl-3"><p><a href="https://blog.csdn.net/wangpeng246300/article/details/120230220">解决Windows有网络连接但是显示“无Internet”的问题</a></p></li><li class="lvl-3"><p><a href="https://github.com/oldj/SwitchHosts/issues/646#issuecomment-945391940">SwitchHosts/issues/646</a></p></li></ol><h2 id="04-Replit-Repl-ERR-SSL-PROTOCOL-ERROR">04. Replit Repl ERR_SSL_PROTOCOL_ERROR<a class="header-anchor" href="#04-Replit-Repl-ERR-SSL-PROTOCOL-ERROR"></a></h2><p>未解决,绑自定义域名后,未分配 SSL 证书</p><p>Replit 官方论坛:</p><ol><li class="lvl-3"><p><a href="https://ask.replit.com/t/err-ssl-protocol-error-for-all-sites/27775">https://ask.replit.com/t/err-ssl-protocol-error-for-all-sites/27775</a></p></li><li class="lvl-3"><p>问题搜索:<a href="https://ask.replit.com/search?q=ERR_SSL_PROTOCOL_ERROR">https://ask.replit.com/search?q=ERR_SSL_PROTOCOL_ERROR</a></p></li></ol><p>Replit 官方服务状态:</p><ol><li class="lvl-3"><p><a href="https://status.replit.com/notices/ggj8gbnshk50a6yz-ssl-certificates-issues">SSL 证书问题</a></p></li><li class="lvl-3"><p><a href="https://status.replit.com/notices/5pcyvknbltq1mrmg-new-custom-domains-with-deployments-are-experiencing-ssl-errors">部署的新自定义域遇到 SSL 错误</a></p></li></ol><p>临时方案:</p><ol><li class="lvl-3"><p><a href="https://ask.replit.com/t/err-ssl-protocol-error-for-all-sites/27775/4">https://ask.replit.com/t/err-ssl-protocol-error-for-all-sites/27775/4</a></p><blockquote><p>现在,更改“。” 在 url 中的 repl 名称和用户名之间添加到“–”就可以了。</p><p>例如,<a href="https://score-analyzer--enderparakeet.repl.co/">https://score-analyzer–enderparakeet.repl.co/ 3个</a>作品。</p></blockquote></li></ol><p>教程:</p><ol><li class="lvl-3"><p><a href="https://docs.replit.com/tutorials/html-css-js/building-a-nineties-inspired-website#custom-domain">Replit 绑自定义域名(官方)</a></p></li></ol><h2 id="05-Terminal-报错-4294967295">05. Terminal 报错: 4294967295<a class="header-anchor" href="#05-Terminal-报错-4294967295"></a></h2><p>wsl2 报错: <code>[已退出进程,代码为 4294967295 (0xffffffff)]</code>,终端无法打开</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 管理员身份 PowerShell</span></span><br><span class="line">netsh winsock reset</span><br><span class="line"></span><br><span class="line"><span class="comment"># 重新打开 terminal,无效则尝试重启后再打开</span></span><br></pre></td></tr></table></figure><p>参考:<a href="https://blog.csdn.net/weixin_53347816/article/details/123637289">打开wsl,显示 [已退出进程,代码为 4294967295] 的解决方案</a></p><p>后记:未根本解决,根本错误 wsl <code>Error: 0x80040326</code>,如下</p><h2 id="06-wsl2-Error-0x80040326">06. wsl2 Error: 0x80040326<a class="header-anchor" href="#06-wsl2-Error-0x80040326"></a></h2><p>无法打开终端,报错:</p><p><code>Error: 0x80040326 Error code: Wsl/Service/0x80040326</code></p><p>解决方法:powershell 管理员模式:<code>wsl --update</code></p><p>参考:</p><ol><li class="lvl-3"><p><a href="https://blog.csdn.net/minibirder/article/details/129863725">https://blog.csdn.net/minibirder/article/details/129863725</a></p></li><li class="lvl-3"><p><a href="https://blog.csdn.net/qq_37932051/article/details/129873314">https://blog.csdn.net/qq_37932051/article/details/129873314</a></p></li></ol><h2 id="07-crond-致-sendmail-大量进程">07. crond 致 sendmail 大量进程<a class="header-anchor" href="#07-crond-致-sendmail-大量进程"></a></h2><p>阿里云服务器监控显示 CPU 长期高负载,原因:<code>定时任务 crond 引发大量 sendmail 进程</code></p><p>参考:</p><ol><li class="lvl-3"><p><a href="https://blog.csdn.net/LQzhang_11/article/details/114323700">https://blog.csdn.net/LQzhang_11/article/details/114323700</a></p></li><li class="lvl-3"><p><a href="https://blog.51cto.com/ning235/2661806">https://blog.51cto.com/ning235/2661806</a></p></li></ol><p>处理方法:</p><ol><li class="lvl-3"><p>cron 后面添加 <code>&> /dev/null</code> 或 <code>> /dev/null 2>&1</code></p></li><li class="lvl-3"><p>禁止 cron 发用户邮件(未操作)</p><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2023/files/image/202309051546612.png" alt=""></p></li></ol><h2 id="08-Netlify-自动转换小写-URI">08. Netlify 自动转换小写 URI<a class="header-anchor" href="#08-Netlify-自动转换小写-URI"></a></h2><p>现象:原 URI <code>/tags/Error/</code> 转为 <code>/tags/error/</code></p><p>解决:配置中取消 <code>Pretty URLs</code> 美化 URL 的功能</p><ul class="lvl-0"><li class="lvl-2"><p><code>Site configuration</code> → <code>Post processing</code> → <code>Pretty URLs</code> → □ <code>Enable Pretty URLs</code></p></li></ul><p>示例:<a href="https://app.netlify.com/sites/mycpen-blog/configuration/deploys#pretty-urls">https://app.netlify.com/sites/mycpen-blog/configuration/deploys#pretty-urls</a></p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2023/files/image/202310042038361.png" alt="image-20231004203836279" style="zoom:25%;" />]]></content>
|
272
|
+
<content type="html"><![CDATA[<h2 id="前言">前言<a class="header-anchor" href="#前言"></a></h2><p>记录一些遇到的问题</p><h2 id="01-Python-中文乱码-Git-Bash">01. Python 中文乱码 (Git Bash)<a class="header-anchor" href="#01-Python-中文乱码-Git-Bash"></a></h2><p>win终端正常运行但是在git bash 终端运行py文件中文乱码<br>在python命令前加 <code>winpty</code> 之后则可以正常显示中文</p><blockquote><p>winpty:一个 Windows 软件包,提供类似于 Unix pty-master 的接口,用于与 Windows 控制台程序通信。</p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2023/files/image/202303310016695.png" alt="image-20230331001601640" style="zoom: 25%;" /></blockquote><p>参考文章:</p><ol><li class="lvl-3"><p><a href="https://blog.csdn.net/sinat_42414027/article/details/127787059">【python中文乱码】git bash终端运行python文件中文乱码的问题</a></p></li><li class="lvl-3"><p><a href="https://github.com/rprichard/winpty">https://github.com/rprichard/winpty</a></p></li></ol><h2 id="02-gitignore-测试规则">02. .gitignore 测试规则<a class="header-anchor" href="#02-gitignore-测试规则"></a></h2><p>.gitignore 配置</p><blockquote><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line">*.a 表示忽略所有 .a 结尾的文件</span><br><span class="line">!lib.a 表示但lib.a除外</span><br><span class="line">doc/*.txt 表示会忽略doc/notes.txt但不包括 doc/server/arch.txt</span><br><span class="line">/TODO 表示仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TODO</span><br><span class="line">bin/ 表示忽略当前路径下的bin文件夹,该文件夹下的所有内容都会被忽略,不忽略 bin 文件</span><br><span class="line">**/foo: 表示忽略/foo,a/foo,a/b/foo等</span><br><span class="line">a/**/b: 表示忽略a/b, a/x/b,a/x/y/b等</span><br><span class="line">*.log: 表示忽略所有 .log 文件</span><br><span class="line">/mtk/ 表示过滤整个文件夹</span><br><span class="line">*.zip 表示过滤所有.zip文件</span><br><span class="line">--- 需要注意的是,gitignore还可以指定要将哪些文件添加到版本管理中,如下: ---</span><br><span class="line">!*.zip</span><br><span class="line">!/mtk/one.txt</span><br><span class="line">唯一的区别就是规则开头多了一个感叹号,Git会将满足这类规则的文件添加到版本管理中。为什么要有两种规则呢?</span><br><span class="line">想象一个场景:假如我们只需要管理/mtk/目录中的one.txt文件,</span><br><span class="line">这个目录中的其他文件都不需要管理,那么.gitignore规则应写为:</span><br><span class="line">/mtk/*</span><br><span class="line">!/mtk/one.txt</span><br><span class="line">假设我们只有过滤规则,而没有添加规则,</span><br><span class="line">那么我们就需要把/mtk/目录下除了one.txt以外的所有文件都写出来!</span><br><span class="line">注意上面的/mtk/*不能写为/mtk/,否则父目录被前面的规则排除掉了,</span><br><span class="line">one.txt文件虽然加了!过滤规则,也不会生效!</span><br><span class="line">--- 还有一些规则如下: ---</span><br><span class="line">fd1/*</span><br><span class="line">说明:忽略目录 fd1 下的全部内容;</span><br><span class="line">注意,不管是根目录下的 /fd1/ 目录,还是某个子目录 /child/fd1/ 目录,都会被忽略;</span><br><span class="line">/fd1/*</span><br><span class="line">说明:忽略根目录下的 /fd1/ 目录的全部内容;</span><br><span class="line">------</span><br><span class="line">/*</span><br><span class="line">!.gitignore</span><br><span class="line">!/fw/ </span><br><span class="line">/fw/*</span><br><span class="line">!/fw/bin/</span><br><span class="line">!/fw/sf/</span><br><span class="line">说明:忽略全部内容,但是不忽略 .gitignore 文件、根目录下的 /fw/bin/ 和 /fw/sf/ 目录;</span><br><span class="line">注意要先对bin/的父目录使用!规则,使其不被排除。</span><br><span class="line"></span><br></pre></td></tr></table></figure></blockquote><p><mark>*</mark> .gitignor 忽略规则查看</p><blockquote><p>有时候,确定为什么要忽略特定文件可能会很困难,尤其是当你使用多个.gitignore文件或复杂格式时。这是git check-ignore命令的用处,告诉git显示匹配模式的详细信息。</p><p>例如,要检查为什么忽略www/yarn.lock文件,可以运行:</p><p><code>git check-ignore -v www/yarn.lock</code></p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2023/files/image/202304041447156.png" alt="image-20230404144757129" style="zoom: 67%;" /></blockquote><p>显示所有被忽略的文件</p><blockquote><p>带有–ignored选项的git status命令显示所有被忽略文件的列表:</p><p><code>git status --ignored</code></p></blockquote><p>参考文章:</p><ol><li class="lvl-3"><p><a href="https://blog.csdn.net/stephenbruce/article/details/127355631">Git忽略提交规则 - .gitignore配置【学习】</a></p></li><li class="lvl-3"><p><a href="https://blog.csdn.net/m0_49448331/article/details/128655710">如何使用.gitignore忽略Git中的文件和目录</a></p></li></ol><h2 id="03-Windows-显示-无Internet">03. Windows 显示"无Internet"<a class="header-anchor" href="#03-Windows-显示-无Internet"></a></h2><p>情况:网络显示 “无Internet”,但是可以上网。以下措施没根本解决,最终用微软诊断工具,重置了 <code>以太网</code> 网络(万能的重装大法)…</p><blockquote><ol><li class="lvl-3"><p>向 <a href="http://dns.msftncsi.com">dns.msftncsi.com</a> 发送 DNS 查找请求,DNS 解析为 131.107.255.255</p></li><li class="lvl-3"><p>请求 <a href="http://www.msftconnecttest.com/connecttest.txt%EF%BC%8C%E5%A6%82%E6%9E%9C%E7%BD%91%E7%BB%9C%E6%AD%A3%E5%B8%B8%EF%BC%8C%E5%88%99%E6%AD%A4%E6%96%87%E4%BB%B6%E6%98%AF%E7%BA%AF%E6%96%87%E6%9C%AC%E6%96%87%E4%BB%B6%EF%BC%8C%E4%BB%85%E5%8C%85%E5%90%AB%E6%96%87%E6%9C%AC">http://www.msftconnecttest.com/connecttest.txt,如果网络正常,则此文件是纯文本文件,仅包含文本</a> Microsoft Connect Test</p></li></ol><p>如果过程1不正常,则提示“无法访问Internet”,如果1正常2不正常,则提示需要进行身份验证</p></blockquote><p><mark>以下措施没解决问题</mark></p><p>估计 DHCP 分配的 DNS 服务器(指向网关)有问题,<a href="https://github.com/oldj/SwitchHosts">SwitchHosts</a> 追加本地记录</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Microsoft</span></span><br><span class="line">dns.msftncsi.com 131.107.255.255</span><br></pre></td></tr></table></figure><p>开机自启 SwitchHosts(Win):</p><ul class="lvl-0"><li class="lvl-2"><p>快捷方式 复制到 => C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\</p></li><li class="lvl-2"><p>设置 => 选项 => 启动时隐藏 √</p></li></ul><p>参考文章:</p><ol><li class="lvl-3"><p><a href="https://blog.csdn.net/wangpeng246300/article/details/120230220">解决Windows有网络连接但是显示“无Internet”的问题</a></p></li><li class="lvl-3"><p><a href="https://github.com/oldj/SwitchHosts/issues/646#issuecomment-945391940">SwitchHosts/issues/646</a></p></li></ol><h2 id="04-Replit-Repl-ERR-SSL-PROTOCOL-ERROR">04. Replit Repl ERR_SSL_PROTOCOL_ERROR<a class="header-anchor" href="#04-Replit-Repl-ERR-SSL-PROTOCOL-ERROR"></a></h2><p>未解决,绑自定义域名后,未分配 SSL 证书</p><p>Replit 官方论坛:</p><ol><li class="lvl-3"><p><a href="https://ask.replit.com/t/err-ssl-protocol-error-for-all-sites/27775">https://ask.replit.com/t/err-ssl-protocol-error-for-all-sites/27775</a></p></li><li class="lvl-3"><p>问题搜索:<a href="https://ask.replit.com/search?q=ERR_SSL_PROTOCOL_ERROR">https://ask.replit.com/search?q=ERR_SSL_PROTOCOL_ERROR</a></p></li></ol><p>Replit 官方服务状态:</p><ol><li class="lvl-3"><p><a href="https://status.replit.com/notices/ggj8gbnshk50a6yz-ssl-certificates-issues">SSL 证书问题</a></p></li><li class="lvl-3"><p><a href="https://status.replit.com/notices/5pcyvknbltq1mrmg-new-custom-domains-with-deployments-are-experiencing-ssl-errors">部署的新自定义域遇到 SSL 错误</a></p></li></ol><p>临时方案:</p><ol><li class="lvl-3"><p><a href="https://ask.replit.com/t/err-ssl-protocol-error-for-all-sites/27775/4">https://ask.replit.com/t/err-ssl-protocol-error-for-all-sites/27775/4</a></p><blockquote><p>现在,更改“。” 在 url 中的 repl 名称和用户名之间添加到“–”就可以了。</p><p>例如,<a href="https://score-analyzer--enderparakeet.repl.co/">https://score-analyzer–enderparakeet.repl.co/ 3个</a>作品。</p></blockquote></li></ol><p>教程:</p><ol><li class="lvl-3"><p><a href="https://docs.replit.com/tutorials/html-css-js/building-a-nineties-inspired-website#custom-domain">Replit 绑自定义域名(官方)</a></p></li></ol><h2 id="05-Terminal-报错-4294967295">05. Terminal 报错: 4294967295<a class="header-anchor" href="#05-Terminal-报错-4294967295"></a></h2><p>wsl2 报错: <code>[已退出进程,代码为 4294967295 (0xffffffff)]</code>,终端无法打开</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 管理员身份 PowerShell</span></span><br><span class="line">netsh winsock reset</span><br><span class="line"></span><br><span class="line"><span class="comment"># 重新打开 terminal,无效则尝试重启后再打开</span></span><br></pre></td></tr></table></figure><p>参考:<a href="https://blog.csdn.net/weixin_53347816/article/details/123637289">打开wsl,显示 [已退出进程,代码为 4294967295] 的解决方案</a></p><p>后记:未根本解决,根本错误 wsl <code>Error: 0x80040326</code>,如下</p><h2 id="06-wsl2-Error-0x80040326">06. wsl2 Error: 0x80040326<a class="header-anchor" href="#06-wsl2-Error-0x80040326"></a></h2><p>无法打开终端,报错:</p><p><code>Error: 0x80040326 Error code: Wsl/Service/0x80040326</code></p><p>解决方法:powershell 管理员模式:<code>wsl --update</code></p><p>参考:</p><ol><li class="lvl-3"><p><a href="https://blog.csdn.net/minibirder/article/details/129863725">https://blog.csdn.net/minibirder/article/details/129863725</a></p></li><li class="lvl-3"><p><a href="https://blog.csdn.net/qq_37932051/article/details/129873314">https://blog.csdn.net/qq_37932051/article/details/129873314</a></p></li></ol><h2 id="07-crond-致-sendmail-大量进程">07. crond 致 sendmail 大量进程<a class="header-anchor" href="#07-crond-致-sendmail-大量进程"></a></h2><p>阿里云服务器监控显示 CPU 长期高负载,原因:<code>定时任务 crond 引发大量 sendmail 进程</code></p><p>参考:</p><ol><li class="lvl-3"><p><a href="https://blog.csdn.net/LQzhang_11/article/details/114323700">https://blog.csdn.net/LQzhang_11/article/details/114323700</a></p></li><li class="lvl-3"><p><a href="https://blog.51cto.com/ning235/2661806">https://blog.51cto.com/ning235/2661806</a></p></li></ol><p>处理方法:</p><ol><li class="lvl-3"><p>cron 后面添加 <code>&> /dev/null</code> 或 <code>> /dev/null 2>&1</code></p></li><li class="lvl-3"><p>禁止 cron 发用户邮件(未操作)</p><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2023/files/image/202309051546612.png" alt=""></p></li></ol><h2 id="08-Netlify-自动转换小写-URI">08. Netlify 自动转换小写 URI<a class="header-anchor" href="#08-Netlify-自动转换小写-URI"></a></h2><p>现象:原 URI <code>/tags/Error/</code> 转为 <code>/tags/error/</code></p><p>解决:配置中取消 <code>Pretty URLs</code> 美化 URL 的功能</p><ul class="lvl-0"><li class="lvl-2"><p><code>Site configuration</code> → <code>Post processing</code> → <code>Pretty URLs</code> → □ <code>Enable Pretty URLs</code></p></li></ul><p>示例:<a href="https://app.netlify.com/sites/mycpen-blog/configuration/deploys#pretty-urls">https://app.netlify.com/sites/mycpen-blog/configuration/deploys#pretty-urls</a></p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2023/files/image/202310042038361.png" alt="image-20231004203836279" style="zoom:25%;" /><h2 id="09-pip-command-not-found">09. pip: command not found<a class="header-anchor" href="#09-pip-command-not-found"></a></h2><p>前言:电脑上已装 Python,且在 PATH 内,无法找到 pip 命令</p><p>报错:<code>pip: command not found</code> 或 <code>No module named pip</code></p><p>升级 pip:<code>python -m pip install --upgrade pip</code></p><p>办法:执行 <code>python -m ensurepip</code></p><blockquote><p><strong>来自 chatgpt</strong></p><p>在 Windows 系统上,如果您在运行 <code>python.exe</code> 时遇到 <code>No module named pip</code> 错误,这通常表示在您的 Python 安装中缺少了 <code>pip</code> 模块。<code>pip</code> 是 Python 的包管理工具,通常会随 Python 一起安装。</p><p>您可以按照以下步骤来解决这个问题:</p><ol><li class="lvl-3"><p>检查 Python 安装:</p></li></ol><p>首先,请确保您已经正确安装 Python。您可以在命令提示符下运行以下命令来检查 Python 的版本:</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">python --version</span><br></pre></td></tr></table></figure><ol start="2"><li class="lvl-3"><p>检查 <code>pip</code> 是否安装:</p></li></ol><p>在较新版本的 Python 中,<code>pip</code> 已经随 Python 一起安装。您可以尝试运行以下命令来安装 Python 包:</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">python -m ensurepip</span><br></pre></td></tr></table></figure><p>这将安装 <code>pip</code> 模块。如果 <code>pip</code> 已经安装,您可能会看到一条消息指示 <code>Requirement already satisfied</code>.</p><ol start="3"><li class="lvl-3"><p>添加 <code>pip</code> 到系统环境变量:</p></li></ol><p>如果 <code>pip</code> 已正确安装,但仍然无法正常使用,可能是因为 <code>pip</code> 不在系统的环境变量中。您可以手动将 <code>pip</code> 所在的路径添加到系统的 PATH 环境变量中。</p><p>默认情况下,在 Windows 系统上,<code>pip</code> 通常安装在 <code>Scripts</code> 文件夹中。您可以找到该文件夹的路径,然后将其添加到系统的 PATH 环境变量中。</p><ol start="4"><li class="lvl-3"><p>验证 <code>pip</code> 安装:</p></li></ol><p>最后,您可以在命令提示符下运行以下命令来验证 <code>pip</code> 是否安装成功:</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip --version</span><br></pre></td></tr></table></figure><p>如果 <code>pip</code> 安装成功,您应该看到 <code>pip</code> 的版本信息,而不再出现 <code>No module named pip</code> 错误。</p><p>通过按照上述步骤操作,您应该能够解决 <code>No module named pip</code> 错误,并成功使用 <code>pip</code> 来管理 Python 包。</p></blockquote><h2 id="10-git-fetch-unshallow">10. git fetch --unshallow<a class="header-anchor" href="#10-git-fetch-unshallow"></a></h2><p>github action 报错 <code>! [remote rejected] main -> main (shallow update not allowed)</code></p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">remote: Powered by GITEE.COM [GNK-6.4] </span><br><span class="line">To https://gitee.com/mycpen/image_bed.git</span><br><span class="line"> ! [remote rejected] main -> main (shallow update not allowed)</span><br><span class="line">error: failed to push some refs to <span class="string">'https://gitee.com/mycpen/image_bed.git'</span></span><br><span class="line">Error: Process completed with <span class="built_in">exit</span> code 1.</span><br></pre></td></tr></table></figure><img src="https://registry.npmmirror.com/mycpen-image-bed/latest/files/image/202405102346367.jpg" alt="image-20240510234628717" style="zoom: 50%;" /><p>解决:<code>git fetch --unshallow</code>,详见 <a href="https://github.com/mycpen/image_bed/blob/main/.github/workflows/sync-gitee.yml">link</a></p><blockquote><p>来自 chatgpt</p><p>这个错误是因为在尝试将代码推送到 Gitee 仓库时,Gitee 不允许进行浅层更新(shallow update)。浅层更新是指仓库中只包含部分历史记录,而不是完整的历史记录。为了解决这个问题,你可以尝试以下方法:</p><ol><li class="lvl-3"><p><strong>完整克隆</strong>:首先,你可以通过完整克隆仓库的方式来获取完整的历史记录,然后再进行推送。在克隆仓库时,不要使用 <code>--depth</code> 参数,这样可以确保克隆完整的历史记录。</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git <span class="built_in">clone</span> https://gitee.com/mycpen/CDN.git</span><br></pre></td></tr></table></figure></li><li class="lvl-3"><p><strong>移除浅层设置后重新克隆</strong>:如果你之前使用了浅层克隆,可以尝试移除浅层设置,然后重新克隆仓库。</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git fetch --unshallow</span><br><span class="line">git <span class="built_in">clone</span> https://gitee.com/mycpen/CDN.git</span><br></pre></td></tr></table></figure></li><li class="lvl-3"><p><strong>强制推送</strong>:如果你已经有本地完整的历史记录,可以尝试使用强制推送来覆盖远程仓库的内容。</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git push -f origin main</span><br></pre></td></tr></table></figure></li></ol><p>通过以上方法,你应该能够解决 Gitee 仓库不允许浅层更新的问题,并成功将代码推送到 Gitee 仓库中。如果你有任何其他问题或需要进一步帮助,请随时告诉我。</p></blockquote>]]></content>
|
273
273
|
|
274
274
|
|
275
275
|
<categories>
|
@@ -958,7 +958,7 @@
|
|
958
958
|
<link href="/posts/88a726.html"/>
|
959
959
|
<url>/posts/88a726.html</url>
|
960
960
|
|
961
|
-
<content type="html"><![CDATA[<h2 id="1-Supervisor-管理-Twikoo">1. Supervisor 管理 Twikoo<a class="header-anchor" href="#1-Supervisor-管理-Twikoo"></a></h2><h3 id="参考文章">参考文章<a class="header-anchor" href="#参考文章"></a></h3><blockquote><p>参考文章:</p><p><a href="https://blog.csdn.net/cyt0906/article/details/107344361">https://blog.csdn.net/cyt0906/article/details/107344361</a></p><p><a href="https://www.cnblogs.com/loveCrane/p/15954893.html">https://www.cnblogs.com/loveCrane/p/15954893.html</a></p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">yum install epel-release <span class="comment">#安装yum源</span></span><br><span class="line">yum install -y supervisor</span><br><span class="line"></span><br><span class="line">supervisord -c /etc/supervisord.conf</span><br><span class="line"></span><br></pre></td></tr></table></figure><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cat</span> /etc/supervisord.d/test.conf</span><br><span class="line"><span class="comment">#项目名</span></span><br><span class="line">[program:blog]</span><br><span class="line"><span class="comment">#脚本目录</span></span><br><span class="line">directory=/opt/bin</span><br><span class="line"><span class="comment">#脚本执行命令</span></span><br><span class="line"><span class="built_in">command</span>=/usr/bin/python /opt/bin/test.py</span><br><span class="line"></span><br><span class="line"><span class="comment">#supervisor启动的时候是否随着同时启动,默认True</span></span><br><span class="line">autostart=<span class="literal">true</span></span><br><span class="line"><span class="comment">#当程序exit的时候,这个program不会自动重启,默认unexpected,设置子进程挂掉后自动重启的情况,有三个选项,false,unexpected和true。如果为false的时候,无论什么情况下,都不会被重新启动,如果为unexpected,只有当进程的退出码不在下面的exitcodes里面定义的</span></span><br><span class="line">autorestart=<span class="literal">false</span></span><br><span class="line"><span class="comment">#这个选项是子进程启动多少秒之后,此时状态如果是running,则我们认为启动成功了。默认值为1</span></span><br><span class="line">startsecs=1</span><br><span class="line"></span><br><span class="line"><span class="comment">#脚本运行的用户身份 </span></span><br><span class="line">user = <span class="built_in">test</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#日志输出 </span></span><br><span class="line">stderr_logfile=/tmp/blog_stderr.log </span><br><span class="line">stdout_logfile=/tmp/blog_stdout.log </span><br><span class="line"><span class="comment">#把stderr重定向到stdout,默认 false</span></span><br><span class="line">redirect_stderr = <span class="literal">true</span></span><br><span class="line"><span class="comment">#stdout日志文件大小,默认 50MB</span></span><br><span class="line">stdout_logfile_maxbytes = 20MB</span><br><span class="line"><span class="comment">#stdout日志文件备份数</span></span><br><span class="line">stdout_logfile_backups = 20</span><br><span class="line"></span><br></pre></td></tr></table></figure><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">supervisorctl status //查看所有进程的状态</span><br><span class="line">supervisorctl stop es //停止es</span><br><span class="line">supervisorctl start es //启动es</span><br><span class="line">supervisorctl restart //重启es</span><br><span class="line">supervisorctl update //配置文件修改后使用该命令加载新的配置</span><br><span class="line">supervisorctl reload //重新启动配置中的所有程序</span><br><span class="line"></span><br></pre></td></tr></table></figure></blockquote><h3 id="个人样例">个人样例<a class="header-anchor" href="#个人样例"></a></h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># supervisor主配置文件</span></span><br><span class="line">$ <span class="built_in">cat</span> /etc/supervisord.conf</span><br><span class="line">...</span><br><span class="line">[include]</span><br><span class="line">files = supervisord.d/*.ini</span><br><span class="line">files = /root/sh_file/supervisord.d/*.ini</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">$ <span class="built_in">ls</span> /root/sh_file/supervisord.d/</span><br><span class="line">tkserver.ini</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># twikoo服务 配置</span></span><br><span class="line">$ <span class="built_in">cat</span> /root/sh_file/supervisord.d/tkserver.ini</span><br><span class="line"><span class="comment">#项目名</span></span><br><span class="line">[program:tkserver]</span><br><span class="line"><span class="comment">#脚本目录</span></span><br><span class="line">directory=/root/sh_file/twikoo</span><br><span class="line"><span class="comment">#脚本执行命令</span></span><br><span class="line"><span class="built_in">command</span>=/bin/bash /root/sh_file/twikoo/tkserver.sh</span><br><span class="line"></span><br><span class="line"><span class="comment">#supervisor启动的时候是否随着同时启动,默认True</span></span><br><span class="line">autostart=<span class="literal">true</span></span><br><span class="line"><span class="comment">#当程序exit的时候,这个program不会自动重启,默认unexpected,设置子进程挂掉后自动重启的情况,有三个选项,false,unexpected和true。如果为false的时候,无论什么情况下,都不会被重新启动,如果为unexpected,只有当进程的退出码不在下面的exitcodes里面定 义的</span></span><br><span class="line">autorestart=<span class="literal">false</span></span><br><span class="line"><span class="comment">#这个选项是子进程启动多少秒之后,此时状态如果是running,则我们认为启动成功了。默认值为1</span></span><br><span class="line">startsecs=1</span><br><span class="line"></span><br><span class="line"><span class="comment">#脚本运行的用户身份</span></span><br><span class="line">user = root</span><br><span class="line"></span><br><span class="line"><span class="comment">#日志输出</span></span><br><span class="line">stderr_logfile=/tmp/blog_stderr.log</span><br><span class="line">stdout_logfile=/tmp/blog_stdout.log</span><br><span class="line"><span class="comment">#把stderr重定向到stdout,默认 false</span></span><br><span class="line">redirect_stderr = <span class="literal">true</span></span><br><span class="line"><span class="comment">#stdout日志文件大小,默认 50MB</span></span><br><span class="line">stdout_logfile_maxbytes = 20MB</span><br><span class="line"><span class="comment">#stdout日志文件备份数</span></span><br><span class="line">stdout_logfile_backups = 20</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 运行twikoo的脚本</span></span><br><span class="line">$ <span class="built_in">cat</span> /root/sh_file/twikoo/tkserver.sh</span><br><span class="line"><span class="comment">#!/bin/bash</span></span><br><span class="line"></span><br><span class="line">tkserver</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 启动supervisord</span></span><br><span class="line">$ supervisord -c /etc/supervisord.conf</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">$ supervisorctl status</span><br><span class="line"></span><br></pre></td></tr></table></figure><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 相关命令</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 安装 supervisor</span></span><br><span class="line">yum install epel-release <span class="comment">#安装yum源</span></span><br><span class="line">yum install -y supervisor</span><br><span class="line"></span><br><span class="line"><span class="comment"># 启动 supervisor</span></span><br><span class="line">$ supervisord -c /etc/supervisord.conf</span><br><span class="line"></span><br><span class="line"><span class="comment"># supervisor 命令</span></span><br><span class="line">supervisorctl status <span class="comment"># 查看所有进程的状态</span></span><br><span class="line">supervisorctl stop tkserver <span class="comment"># 停止tkserver</span></span><br><span class="line">supervisorctl start tkserver <span class="comment"># 启动tkserver</span></span><br><span class="line">supervisorctl restart tkserver <span class="comment"># 重启tkserver</span></span><br><span class="line">supervisorctl update <span class="comment"># 配置文件修改后使用该命令加载新的配置</span></span><br><span class="line">supervisorctl reload <span class="comment"># 重新启动配置中的所有程序</span></span><br><span class="line"><span class="comment"># 注:把es换成all可以管理配置中的所有进程。直接输入supervisorctl进入supervisorctl的shell交互界面,此时上面的命令不带supervisorctl可直接使用。</span></span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure><hr><h2 id="2-Twikoo版本升级(私有部署)">2. Twikoo版本升级(私有部署)<a class="header-anchor" href="#2-Twikoo版本升级(私有部署)"></a></h2><h3 id="更新-1-6-22">更新 1.6.22<a class="header-anchor" href="#更新-1-6-22"></a></h3><p>时间:2023-10-10,版本 <strong>1.6.22</strong> <= 1.6.7</p><p>参考:<a href="https://twikoo.js.org/update.html#%E9%92%88%E5%AF%B9%E7%A7%81%E6%9C%89%E9%83%A8%E7%BD%B2%E7%9A%84%E6%9B%B4%E6%96%B0%E6%96%B9%E5%BC%8F">twikoo.js.org</a></p><p>1.6.22 支持评论/访问量数据 json 导出了</p><p>官网步骤:</p><ol><li class="lvl-3"><p>停止旧版本 <code>kill $(ps -ef | grep tkserver | grep -v 'grep' | awk '{print $2}')</code></p></li><li class="lvl-3"><p>拉取新版本 <code>npm i -g tkserver@latest</code></p></li><li class="lvl-3"><p>启动新版本 <code>nohup tkserver >> tkserver.log 2>&1 &</code></p></li></ol><p>我的步骤:</p><ol><li class="lvl-3"><p>先备份,我的数据路径 <strong>/root/sh_file/twikoo</strong>,<code>cp -r twikoo twikoo_bak</code></p></li><li class="lvl-3"><p>更新</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">supervisorctl status tkserver</span><br><span class="line"></span><br><span class="line">supervisorctl stop tkserver</span><br><span class="line"></span><br><span class="line">ps -ef | grep tkserver | grep -v <span class="string">'grep'</span> | awk <span class="string">'{print $2}'</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 1. 停止旧版本</span></span><br><span class="line"><span class="built_in">kill</span> $(ps -ef | grep tkserver | grep -v <span class="string">'grep'</span> | awk <span class="string">'{print $2}'</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 2. 拉取新版本</span></span><br><span class="line">npm i -g tkserver@latest</span><br><span class="line"></span><br><span class="line"><span class="comment"># 3. 启动新版本</span></span><br><span class="line">supervisorctl start tkserver</span><br><span class="line"></span><br><span class="line"><span class="built_in">rm</span> -rf twikoo_bak<span class="comment"># 删备份</span></span><br><span class="line"></span><br></pre></td></tr></table></figure></li><li class="lvl-3"><p>更新 butterfly 前端资源,CDN.option.twikoo,<a href="https://www.staticfile.org/">www.staticfile.org</a> 上查找</p></li></ol><h3 id="前言">前言<a class="header-anchor" href="#前言"></a></h3><p>乌龙事件,原本以为自己的 twikoo 版本过低,打算升级解决。后来发现是 butterfly 内置的 twikoo js 版本低,换个 js 就行。</p><p>主题配置文件 _config.butterfly.yml 新增 twikoo cdn</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">CDN:</span></span><br><span class="line"> <span class="attr">option:</span></span><br><span class="line"> <span class="attr">twikoo:</span> <span class="string">https://npm.elemecdn.com/twikoo@1.6.7/dist/twikoo.all.min.js</span></span><br></pre></td></tr></table></figure><h3 id="参考文章-2">参考文章<a class="header-anchor" href="#参考文章-2"></a></h3><p><strong>参考自</strong>:<a href="https://twikoo.js.org/quick-start.html#%E9%92%88%E5%AF%B9%E7%A7%81%E6%9C%89%E9%83%A8%E7%BD%B2%E7%9A%84%E6%9B%B4%E6%96%B0%E6%96%B9%E5%BC%8F">twikoo 官网</a></p><ol><li class="lvl-3"><p>停止旧版本 <code>kill $(ps -ef | grep tkserver | grep -v 'grep' | awk '{print $2}')</code></p></li><li class="lvl-3"><p>拉取新版本 <code>npm i -g tkserver@latest</code></p></li><li class="lvl-3"><p>启动新版本 <code>nohup tkserver >> tkserver.log 2>&1 &</code></p></li></ol><h3 id="个人样例-2">个人样例<a class="header-anchor" href="#个人样例-2"></a></h3><p><strong>个人步骤记录</strong></p><ol><li class="lvl-3"><p>检查是否异常</p></li></ol><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 发现 supervisor 未执行,启动程序</span></span><br><span class="line">$ supervisorctl status tkserver</span><br><span class="line">unix:///run/supervisor/supervisor.sock refused connection</span><br><span class="line"></span><br><span class="line">$ supervisord -c /etc/supervisord.conf</span><br><span class="line">Unlinking stale socket /run/supervisor/supervisor.sock</span><br><span class="line"></span><br><span class="line">$ supervisorctl status tkserver</span><br><span class="line">tkserver RUNNING pid 3268176, <span class="built_in">uptime</span> 0:00:03</span><br><span class="line"></span><br></pre></td></tr></table></figure><ol start="2"><li class="lvl-3"><p>停止旧版本 <code>supervisorctl stop tkserver</code> && <code>kill $(ps -ef | grep tkserver | grep -v 'grep' | awk '{print $2}')</code></p></li></ol><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 停止 twikoo 进程</span></span><br><span class="line">$ supervisorctl stop tkserver</span><br><span class="line">tkserver: ERROR (not running)</span><br><span class="line"></span><br><span class="line">$ supervisorctl status tkserver</span><br><span class="line">tkserver EXITED Nov 06 07:00 PM</span><br><span class="line"></span><br><span class="line">$ ps -ef | grep tkserver | grep -v <span class="string">'grep'</span> | awk <span class="string">'{print $2}'</span></span><br><span class="line">1618196</span><br><span class="line">1618197</span><br><span class="line"></span><br><span class="line"><span class="comment"># 停止旧版本</span></span><br><span class="line">$ <span class="built_in">kill</span> $(ps -ef | grep tkserver | grep -v <span class="string">'grep'</span> | awk <span class="string">'{print $2}'</span>)</span><br><span class="line"></span><br><span class="line">$ ps aux |grep twikoo</span><br><span class="line"></span><br></pre></td></tr></table></figure><ol start="3"><li class="lvl-3"><p>拉取新版本 <code>npm i -g tkserver@latest</code></p></li><li class="lvl-3"><p>启动新版本 <code>supervisorctl start tkserver</code></p></li></ol><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 拉取新版本</span></span><br><span class="line">$ <span class="built_in">pwd</span></span><br><span class="line">/root/sh_file/twikoo</span><br><span class="line"></span><br><span class="line">$ npm i -g tkserver@latest</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 启动新版本</span></span><br><span class="line">$ supervisorctl start tkserver</span><br><span class="line">tkserver: started</span><br><span class="line"></span><br><span class="line">$ ps aux |grep twikoo</span><br><span class="line">root 3308516 0.0 0.1 16956 2892 ? S 19:06 0:00 /bin/bash /root/sh_file/twikoo/tkserver.sh</span><br><span class="line"></span><br></pre></td></tr></table></figure>]]></content>
|
961
|
+
<content type="html"><![CDATA[<h2 id="1-Supervisor-管理-Twikoo">1. Supervisor 管理 Twikoo<a class="header-anchor" href="#1-Supervisor-管理-Twikoo"></a></h2><h3 id="参考文章">参考文章<a class="header-anchor" href="#参考文章"></a></h3><blockquote><p>参考文章:</p><p><a href="https://blog.csdn.net/cyt0906/article/details/107344361">https://blog.csdn.net/cyt0906/article/details/107344361</a></p><p><a href="https://www.cnblogs.com/loveCrane/p/15954893.html">https://www.cnblogs.com/loveCrane/p/15954893.html</a></p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">yum install epel-release <span class="comment">#安装yum源</span></span><br><span class="line">yum install -y supervisor</span><br><span class="line"></span><br><span class="line">supervisord -c /etc/supervisord.conf</span><br><span class="line"></span><br></pre></td></tr></table></figure><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cat</span> /etc/supervisord.d/test.conf</span><br><span class="line"><span class="comment">#项目名</span></span><br><span class="line">[program:blog]</span><br><span class="line"><span class="comment">#脚本目录</span></span><br><span class="line">directory=/opt/bin</span><br><span class="line"><span class="comment">#脚本执行命令</span></span><br><span class="line"><span class="built_in">command</span>=/usr/bin/python /opt/bin/test.py</span><br><span class="line"></span><br><span class="line"><span class="comment">#supervisor启动的时候是否随着同时启动,默认True</span></span><br><span class="line">autostart=<span class="literal">true</span></span><br><span class="line"><span class="comment">#当程序exit的时候,这个program不会自动重启,默认unexpected,设置子进程挂掉后自动重启的情况,有三个选项,false,unexpected和true。如果为false的时候,无论什么情况下,都不会被重新启动,如果为unexpected,只有当进程的退出码不在下面的exitcodes里面定义的</span></span><br><span class="line">autorestart=<span class="literal">false</span></span><br><span class="line"><span class="comment">#这个选项是子进程启动多少秒之后,此时状态如果是running,则我们认为启动成功了。默认值为1</span></span><br><span class="line">startsecs=1</span><br><span class="line"></span><br><span class="line"><span class="comment">#脚本运行的用户身份 </span></span><br><span class="line">user = <span class="built_in">test</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#日志输出 </span></span><br><span class="line">stderr_logfile=/tmp/blog_stderr.log </span><br><span class="line">stdout_logfile=/tmp/blog_stdout.log </span><br><span class="line"><span class="comment">#把stderr重定向到stdout,默认 false</span></span><br><span class="line">redirect_stderr = <span class="literal">true</span></span><br><span class="line"><span class="comment">#stdout日志文件大小,默认 50MB</span></span><br><span class="line">stdout_logfile_maxbytes = 20MB</span><br><span class="line"><span class="comment">#stdout日志文件备份数</span></span><br><span class="line">stdout_logfile_backups = 20</span><br><span class="line"></span><br></pre></td></tr></table></figure><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">supervisorctl status //查看所有进程的状态</span><br><span class="line">supervisorctl stop es //停止es</span><br><span class="line">supervisorctl start es //启动es</span><br><span class="line">supervisorctl restart //重启es</span><br><span class="line">supervisorctl update //配置文件修改后使用该命令加载新的配置</span><br><span class="line">supervisorctl reload //重新启动配置中的所有程序</span><br><span class="line"></span><br></pre></td></tr></table></figure></blockquote><h3 id="个人样例">个人样例<a class="header-anchor" href="#个人样例"></a></h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># supervisor主配置文件</span></span><br><span class="line">$ <span class="built_in">cat</span> /etc/supervisord.conf</span><br><span class="line">...</span><br><span class="line">[include]</span><br><span class="line">files = supervisord.d/*.ini</span><br><span class="line">files = /root/sh_file/supervisord.d/*.ini</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">$ <span class="built_in">ls</span> /root/sh_file/supervisord.d/</span><br><span class="line">tkserver.ini</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># twikoo服务 配置</span></span><br><span class="line">$ <span class="built_in">cat</span> /root/sh_file/supervisord.d/tkserver.ini</span><br><span class="line"><span class="comment">#项目名</span></span><br><span class="line">[program:tkserver]</span><br><span class="line"><span class="comment">#脚本目录</span></span><br><span class="line">directory=/root/sh_file/twikoo</span><br><span class="line"><span class="comment">#脚本执行命令</span></span><br><span class="line"><span class="built_in">command</span>=/bin/bash /root/sh_file/twikoo/tkserver.sh</span><br><span class="line"></span><br><span class="line"><span class="comment">#supervisor启动的时候是否随着同时启动,默认True</span></span><br><span class="line">autostart=<span class="literal">true</span></span><br><span class="line"><span class="comment">#当程序exit的时候,这个program不会自动重启,默认unexpected,设置子进程挂掉后自动重启的情况,有三个选项,false,unexpected和true。如果为false的时候,无论什么情况下,都不会被重新启动,如果为unexpected,只有当进程的退出码不在下面的exitcodes里面定 义的</span></span><br><span class="line">autorestart=<span class="literal">false</span></span><br><span class="line"><span class="comment">#这个选项是子进程启动多少秒之后,此时状态如果是running,则我们认为启动成功了。默认值为1</span></span><br><span class="line">startsecs=1</span><br><span class="line"></span><br><span class="line"><span class="comment">#脚本运行的用户身份</span></span><br><span class="line">user = root</span><br><span class="line"></span><br><span class="line"><span class="comment">#日志输出</span></span><br><span class="line">stderr_logfile=/tmp/blog_stderr.log</span><br><span class="line">stdout_logfile=/tmp/blog_stdout.log</span><br><span class="line"><span class="comment">#把stderr重定向到stdout,默认 false</span></span><br><span class="line">redirect_stderr = <span class="literal">true</span></span><br><span class="line"><span class="comment">#stdout日志文件大小,默认 50MB</span></span><br><span class="line">stdout_logfile_maxbytes = 20MB</span><br><span class="line"><span class="comment">#stdout日志文件备份数</span></span><br><span class="line">stdout_logfile_backups = 20</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 运行twikoo的脚本</span></span><br><span class="line">$ <span class="built_in">cat</span> /root/sh_file/twikoo/tkserver.sh</span><br><span class="line"><span class="comment">#!/bin/bash</span></span><br><span class="line"></span><br><span class="line">tkserver</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 启动supervisord</span></span><br><span class="line">$ supervisord -c /etc/supervisord.conf</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">$ supervisorctl status</span><br><span class="line"></span><br></pre></td></tr></table></figure><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 相关命令</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 安装 supervisor</span></span><br><span class="line">yum install epel-release <span class="comment">#安装yum源</span></span><br><span class="line">yum install -y supervisor</span><br><span class="line"></span><br><span class="line"><span class="comment"># 启动 supervisor</span></span><br><span class="line">$ supervisord -c /etc/supervisord.conf</span><br><span class="line"></span><br><span class="line"><span class="comment"># supervisor 命令</span></span><br><span class="line">supervisorctl status <span class="comment"># 查看所有进程的状态</span></span><br><span class="line">supervisorctl stop tkserver <span class="comment"># 停止tkserver</span></span><br><span class="line">supervisorctl start tkserver <span class="comment"># 启动tkserver</span></span><br><span class="line">supervisorctl restart tkserver <span class="comment"># 重启tkserver</span></span><br><span class="line">supervisorctl update <span class="comment"># 配置文件修改后使用该命令加载新的配置</span></span><br><span class="line">supervisorctl reload <span class="comment"># 重新启动配置中的所有程序</span></span><br><span class="line"><span class="comment"># 注:把es换成all可以管理配置中的所有进程。直接输入supervisorctl进入supervisorctl的shell交互界面,此时上面的命令不带supervisorctl可直接使用。</span></span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure><hr><h2 id="2-Twikoo版本升级(私有部署)">2. Twikoo版本升级(私有部署)<a class="header-anchor" href="#2-Twikoo版本升级(私有部署)"></a></h2><h3 id="更新-1-6-22">更新 1.6.22<a class="header-anchor" href="#更新-1-6-22"></a></h3><p>时间:2023-10-10,版本 <strong>1.6.22</strong> <= 1.6.7</p><p>参考:<a href="https://twikoo.js.org/update.html#%E9%92%88%E5%AF%B9%E7%A7%81%E6%9C%89%E9%83%A8%E7%BD%B2%E7%9A%84%E6%9B%B4%E6%96%B0%E6%96%B9%E5%BC%8F">twikoo.js.org</a></p><p>1.6.22 支持评论/访问量数据 json 导出了</p><p>官网步骤:</p><ol><li class="lvl-3"><p>停止旧版本 <code>kill $(ps -ef | grep tkserver | grep -v 'grep' | awk '{print $2}')</code></p></li><li class="lvl-3"><p>拉取新版本 <code>npm i -g tkserver@latest</code></p></li><li class="lvl-3"><p>启动新版本 <code>nohup tkserver >> tkserver.log 2>&1 &</code></p></li></ol><p>我的步骤:</p><ol><li class="lvl-3"><p>先备份,我的数据路径 <strong>/root/sh_file/twikoo</strong>,<code>cp -r twikoo twikoo_bak</code></p></li><li class="lvl-3"><p>更新</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">supervisorctl status tkserver</span><br><span class="line"></span><br><span class="line">supervisorctl stop tkserver</span><br><span class="line"></span><br><span class="line">ps -ef | grep tkserver | grep -v <span class="string">'grep'</span> | awk <span class="string">'{print $2}'</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 1. 停止旧版本</span></span><br><span class="line"><span class="built_in">kill</span> $(ps -ef | grep tkserver | grep -v <span class="string">'grep'</span> | awk <span class="string">'{print $2}'</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 2. 拉取新版本</span></span><br><span class="line">npm i -g tkserver@latest</span><br><span class="line"></span><br><span class="line"><span class="comment"># 3. 启动新版本</span></span><br><span class="line"><span class="comment"># kill $(ps -ef | grep tkserver | grep -v 'grep' | awk '{print $2}')</span></span><br><span class="line">supervisorctl start tkserver</span><br><span class="line"></span><br><span class="line"><span class="built_in">rm</span> -rf twikoo_bak<span class="comment"># 删备份</span></span><br><span class="line"></span><br></pre></td></tr></table></figure></li><li class="lvl-3"><p>更新 butterfly 前端资源,CDN.option.twikoo,<a href="https://www.staticfile.org/">www.staticfile.org</a> 上查找</p></li></ol><h3 id="前言">前言<a class="header-anchor" href="#前言"></a></h3><p>乌龙事件,原本以为自己的 twikoo 版本过低,打算升级解决。后来发现是 butterfly 内置的 twikoo js 版本低,换个 js 就行。</p><p>主题配置文件 _config.butterfly.yml 新增 twikoo cdn</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">CDN:</span></span><br><span class="line"> <span class="attr">option:</span></span><br><span class="line"> <span class="attr">twikoo:</span> <span class="string">https://npm.elemecdn.com/twikoo@1.6.7/dist/twikoo.all.min.js</span></span><br></pre></td></tr></table></figure><h3 id="参考文章-2">参考文章<a class="header-anchor" href="#参考文章-2"></a></h3><p><strong>参考自</strong>:<a href="https://twikoo.js.org/quick-start.html#%E9%92%88%E5%AF%B9%E7%A7%81%E6%9C%89%E9%83%A8%E7%BD%B2%E7%9A%84%E6%9B%B4%E6%96%B0%E6%96%B9%E5%BC%8F">twikoo 官网</a></p><ol><li class="lvl-3"><p>停止旧版本 <code>kill $(ps -ef | grep tkserver | grep -v 'grep' | awk '{print $2}')</code></p></li><li class="lvl-3"><p>拉取新版本 <code>npm i -g tkserver@latest</code></p></li><li class="lvl-3"><p>启动新版本 <code>nohup tkserver >> tkserver.log 2>&1 &</code></p></li></ol><h3 id="个人样例-2">个人样例<a class="header-anchor" href="#个人样例-2"></a></h3><p><strong>个人步骤记录</strong></p><ol><li class="lvl-3"><p>检查是否异常</p></li></ol><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 发现 supervisor 未执行,启动程序</span></span><br><span class="line">$ supervisorctl status tkserver</span><br><span class="line">unix:///run/supervisor/supervisor.sock refused connection</span><br><span class="line"></span><br><span class="line">$ supervisord -c /etc/supervisord.conf</span><br><span class="line">Unlinking stale socket /run/supervisor/supervisor.sock</span><br><span class="line"></span><br><span class="line">$ supervisorctl status tkserver</span><br><span class="line">tkserver RUNNING pid 3268176, <span class="built_in">uptime</span> 0:00:03</span><br><span class="line"></span><br></pre></td></tr></table></figure><ol start="2"><li class="lvl-3"><p>停止旧版本 <code>supervisorctl stop tkserver</code> && <code>kill $(ps -ef | grep tkserver | grep -v 'grep' | awk '{print $2}')</code></p></li></ol><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 停止 twikoo 进程</span></span><br><span class="line">$ supervisorctl stop tkserver</span><br><span class="line">tkserver: ERROR (not running)</span><br><span class="line"></span><br><span class="line">$ supervisorctl status tkserver</span><br><span class="line">tkserver EXITED Nov 06 07:00 PM</span><br><span class="line"></span><br><span class="line">$ ps -ef | grep tkserver | grep -v <span class="string">'grep'</span> | awk <span class="string">'{print $2}'</span></span><br><span class="line">1618196</span><br><span class="line">1618197</span><br><span class="line"></span><br><span class="line"><span class="comment"># 停止旧版本</span></span><br><span class="line">$ <span class="built_in">kill</span> $(ps -ef | grep tkserver | grep -v <span class="string">'grep'</span> | awk <span class="string">'{print $2}'</span>)</span><br><span class="line"></span><br><span class="line">$ ps aux |grep twikoo</span><br><span class="line"></span><br></pre></td></tr></table></figure><ol start="3"><li class="lvl-3"><p>拉取新版本 <code>npm i -g tkserver@latest</code></p></li><li class="lvl-3"><p>启动新版本 <code>supervisorctl start tkserver</code></p></li></ol><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 拉取新版本</span></span><br><span class="line">$ <span class="built_in">pwd</span></span><br><span class="line">/root/sh_file/twikoo</span><br><span class="line"></span><br><span class="line">$ npm i -g tkserver@latest</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 启动新版本</span></span><br><span class="line">$ supervisorctl start tkserver</span><br><span class="line">tkserver: started</span><br><span class="line"></span><br><span class="line">$ ps aux |grep twikoo</span><br><span class="line">root 3308516 0.0 0.1 16956 2892 ? S 19:06 0:00 /bin/bash /root/sh_file/twikoo/tkserver.sh</span><br><span class="line"></span><br></pre></td></tr></table></figure>]]></content>
|
962
962
|
|
963
963
|
|
964
964
|
<categories>
|
@@ -1493,7 +1493,7 @@
|
|
1493
1493
|
<link href="/posts/12907.html"/>
|
1494
1494
|
<url>/posts/12907.html</url>
|
1495
1495
|
|
1496
|
-
<content type="html"><![CDATA[<p><a href="https://www.bilibili.com/video/BV1fh411y7R8">视频链接:https://www.bilibili.com/video/BV1fh411y7R8</a></p><h2 id="一-就业方向">一. 就业方向<a class="header-anchor" href="#一-就业方向"></a></h2><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080320118.png" alt="image-20220508032024978" style="zoom:50%;" /><hr><h2 id="二-开发场景">二. 开发场景<a class="header-anchor" href="#二-开发场景"></a></h2><p>Java 开发场景举例 1-<code>SSM</code></p><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080322295.png" alt=""></p><p>Java 开发场景举例 2:<code>Android 核心代码</code></p><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080324796.png" alt=""></p><p>Java 开发场景举例 3:<code>大数据-hadoop </code></p><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080325177.png" alt=""></p><hr><h2 id="三-应用领域">三. 应用领域<a class="header-anchor" href="#三-应用领域"></a></h2><ul class="lvl-0"><li class="lvl-2"><p>企业级应用</p></li></ul><p>主要指复杂的大企业的**<code>软件系统</code><strong>、各种类型的</strong><code>网站</code>**。应用领域包括金融、电信、交通、电子商务等。</p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080327015.png" alt="image-20220508032702906" style="zoom:50%;" /><ul class="lvl-0"><li class="lvl-2"><p>Android 平台应用</p></li></ul><p>Android 应用程序使用 Java 语言编写。Android 开发水平的高低很大程度上取决于 Java 语言核心能力是否扎实。</p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080327181.png" alt="image-20220508032750052" style="zoom:50%;" /><ul class="lvl-0"><li class="lvl-2"><p>移动领域应用</p></li></ul><p>主要表现在消费和嵌入式领域,是指在各种小型设备上的应用,包括机顶盒、车载的大屏影音娱乐设备、汽车通信设备、扫码的 POS 机等。</p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080329788.png" alt="image-20220508032900704" style="zoom:50%;" /><hr><h2 id="四-程序举例">四. 程序举例<a class="header-anchor" href="#四-程序举例"></a></h2><ul class="lvl-0"><li class="lvl-2"><p><strong>什么是程序</strong></p></li></ul><p>程序:计算机执行某些操作或解决某个问题而 <strong><code>编写的一系列有序指令的集合</code></strong></p><p>举例说明:</p><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080343728.png" alt="image-20220508034312623" style="zoom:50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080343441.png" alt="image-20220508034326323" style="zoom: 67%;" /></blockquote><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//老师写的最简单的程序,完成 1+1, 体会</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Test</span> {</span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line"> <span class="type">int</span> <span class="variable">res</span> <span class="operator">=</span> <span class="number">1</span> + <span class="number">1</span>;</span><br><span class="line"> <span class="comment">// 显示</span></span><br><span class="line">System.out.print(<span class="string">"结果="</span> + res);</span><br><span class="line">}</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080403773.png" alt=""></p><hr><h2 id="五-故事">五. 故事<a class="header-anchor" href="#五-故事"></a></h2><ul class="lvl-0"><li class="lvl-2"><p>Java 诞生小故事</p></li></ul><ol><li class="lvl-3"><p><code>1995年 第1个版本</code></p></li><li class="lvl-3"><p><code>Java之父 gosling</code></p></li><li class="lvl-3"><p><code>最新版本:15</code></p></li><li class="lvl-3"><p><code>公司里用的最多的版本:8、11</code></p></li><li class="lvl-3"><p><code>Java 所有权:甲骨文</code></p></li></ol><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080344966.png" alt="image-20220508034456860" style="zoom: 67%;" /><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080408088.png" alt=""></p></blockquote><ul class="lvl-0"><li class="lvl-2"><p>Java 技术体系平台</p></li></ul><blockquote><p><code>标准版、企业版、小型版</code></p><p><code>Java SE、Java EE、Java ME</code></p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080412778.png" style="zoom:50%;" /></blockquote><hr><h2 id="六-特性">六. 特性<a class="header-anchor" href="#六-特性"></a></h2><ul class="lvl-0"><li class="lvl-2"><p><strong>Java 重要特点</strong></p></li></ul><ol><li class="lvl-3"><p>Java 语言是面向对象的(<strong><code>oop</code></strong>)</p></li><li class="lvl-3"><p>Java <code>语言是健壮的</code>。Java 的强类型机制、异常处理、垃圾的自动收集等是 Java 程序健壮性的重要保证</p></li><li class="lvl-3"><p>Java 语言是**<code>跨平台性的</code>**。[即: <strong>一个编译好的.class 文件可以在多个系统下运行,这种特性称为跨平台</strong>]</p></li></ol><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080415181.png" style="zoom:50%;" /></blockquote><ol start="4"><li class="lvl-3"><p>Java 语言是解释型的[了解]</p></li></ol><p><strong>解释性语言:javascript,PHP, java 编译性语言: c / c++</strong></p><p>区别是:<code>解释性语言</code>,编译后的代码,<code>不能直接被机器执行,需要解释器来执行</code>, <code>编译性语言</code>, 编译后的代码, 可以<code>直接被机器执行</code>, c /c++</p><hr><ul class="lvl-0"><li class="lvl-2"><p><strong>Java 的开发工具</strong></p><ul class="lvl-2"><li class="lvl-4"><p>工具选择</p><ul class="lvl-4"><li class="lvl-6"><p>如何选择开发工具</p><p>我们先选择用文本编辑器本 sublime,到大家对 java 有一定了解后,我们再使用 IDEA 和 Eclipse 开发工具。</p></li><li class="lvl-6"><p>这是为什么呢</p><p>更深刻的理解 java 技术,培养代码感。【面试时,往往程序员手写代码】</p><p>有利于公司面试</p><pre><code> > <img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080421152.png" alt="image-20220508042124961" style="zoom:50%;" /></code></pre></li></ul></li></ul></li></ul><hr><h2 id="七-jdk介绍、安装、配置">七. jdk介绍、安装、配置<a class="header-anchor" href="#七-jdk介绍、安装、配置"></a></h2><ul class="lvl-0"><li class="lvl-2"><p><strong>Java 运行机制及运行过程</strong></p><ul class="lvl-2"><li class="lvl-4"><p>Java 语言的特点:<code>跨平台性</code></p><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080428588.png" alt="image-20220508042849189" style="zoom:50%;" /></blockquote></li><li class="lvl-4"><p>Java 核心机制-Java 虚拟机 [<code>JVM</code> java virtual machine]</p></li></ul></li><li class="lvl-2"><p><code>Java 核心机制-Java 虚拟机 [JVM java virtual machine]</code></p></li></ul><p><strong>基本介绍</strong></p><ol><li class="lvl-3"><p>JVM 是一个虚拟的计算机,具有指令集并使用不同的存储区域。负责执行指令,管理数据、内存、寄存器,包含在 <strong><code>JDK 中</code></strong>.</p></li><li class="lvl-3"><p>对于不同的平台,有不同的虚拟机。</p></li><li class="lvl-3"><p>Java 虚拟机机制屏蔽了底层运行平台的差别,实现了“一次**<code>编译</code><strong>,到处</strong><code>运行</code>**” [说明]</p></li></ol><p><strong>示意图</strong></p><blockquote><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//指令</span></span><br><span class="line">javac<span class="comment">// 编译</span></span><br><span class="line">java<span class="comment">// 运行</span></span><br></pre></td></tr></table></figure><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080434503.png" alt="image-20220508043429400" style="zoom: 67%;" /></blockquote><hr><p><strong><code>什么是 JDK,JRE</code></strong></p><ul class="lvl-0"><li class="lvl-2"><p><code>JDK 基本介绍 </code></p></li></ul><ol><li class="lvl-3"><p>JDK 的全称(Java Development Kit <strong><code>Java 开发工具包</code></strong>)</p></li></ol><p>JDK = JRE + java 的开发工具 [java, javac,javadoc,javap 等]</p><ol start="2"><li class="lvl-3"><p>JDK 是提供给 Java 开发人员使用的,其中包含了 java 的开发工具,也包括了 JRE。所以安装了 JDK,就不用在单独安装 JRE 了。</p></li></ol><ul class="lvl-0"><li class="lvl-2"><p><code>JRE 基本介绍</code></p></li></ul><ol><li class="lvl-3"><p>JRE(Java Runtime Environment <code> Java 运行环境</code>)</p></li></ol><p>JRE = JVM + Java 的核心类库[类]</p><ol start="2"><li class="lvl-3"><p>包括 Java 虚拟机(JVM Java Virtual Machine)和 Java 程序所需的核心类库等,如果想要运行一个开发好的 Java 程序,计算机中只需要安装 JRE 即可。</p></li></ol><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080445424.png" style="zoom:67%;" /></blockquote><ul class="lvl-0"><li class="lvl-2"><p><code>JDK、JRE 和 JVM 的包含关系</code></p></li></ul><ol><li class="lvl-3"><p><strong><code>JDK = JRE + 开发工具集</code></strong>(例如 Javac,java 编译工具等)</p></li><li class="lvl-3"><p><strong><code>JRE = JVM + Java SE</code></strong> <strong><code>标准类库</code></strong>(java 核心类库)</p></li><li class="lvl-3"><p>如果只想运行开发好的 .class 文件 只需要 JRE</p></li></ol><hr><p><strong>下载、安装 JDK</strong></p><blockquote><p><a href="https://www.oracle.com/java/technologies/downloads/">https://www.oracle.com/java/technologies/downloads/</a></p><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080450598.png" alt=""></p></blockquote><p><strong>配置环境变量 path</strong></p><ul class="lvl-0"><li class="lvl-2"><p>为什么要配置 path</p><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080507309.png" alt="image-20220508050732153" style="zoom:50%;" /></blockquote></li><li class="lvl-2"><p>配置环境变量 path 的步骤</p></li></ul><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080512224.png" style="zoom:50%;" /></blockquote><hr><p>安装 JDK 的练习</p><blockquote><p>请同学们安装好 JDK,配置好 path 环境变量。可以在控制台下正确的执行, (10min)</p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080520103.png" alt="image-20220508052000041" style="zoom:50%;" /><p>环境变量配置细节说明:</p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080520181.png" alt="image-20220508052022102" style="zoom:50%;" /><hr><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080521628.png" alt="image-20220508052141440" style="zoom: 50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080528717.png" alt="image-20220508052824602" style="zoom:50%;" /><hr><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080529498.png" alt="image-20220508052931384" style="zoom:50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080533822.png" alt="image-20220508053340793" style="zoom: 67%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080534562.png" alt="image-20220508053443524" style="zoom:67%;" /></blockquote><hr><h2 id="八-快速入门">八. 快速入门<a class="header-anchor" href="#八-快速入门"></a></h2><ul class="lvl-0"><li class="lvl-2"><p>需求说明</p></li></ul><p>要求开发一个 Hello.java 程序,可以输出 “hello,world!”</p><ul class="lvl-0"><li class="lvl-2"><p>开发步骤</p></li></ul><ol><li class="lvl-3"><p>将 Java 代码编写到扩展名为 <code>Hello.java 的文件</code>中。[代码说明]</p></li><li class="lvl-3"><p>通过 <code>javac</code> 命令对该 java 文件进行<code>编译</code>,生成 <code>.class</code> 文件。</p></li><li class="lvl-3"><p>通过 <code>java</code> 命令对生成的 class 文件进行<code>运行</code>。</p></li></ol><ul class="lvl-0"><li class="lvl-2"><p>运行原理示意图</p></li></ul><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080545433.png" alt="image-20220508054554366" style="zoom: 67%;" /></blockquote><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080607424.png" alt="image-20220508060705278" style="zoom:50%;" /></blockquote><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//这是java的快速入门, 演示java的开发步骤</span></span><br><span class="line"><span class="comment">//对代码的相关说明</span></span><br><span class="line"><span class="comment">//1. public class Hello 表示Hello是一个类,是一个public公有的类</span></span><br><span class="line"><span class="comment">//2. Hello{ } 表示一个类的开始和结束</span></span><br><span class="line"><span class="comment">//3. public static void main(String[] args) 表示一个主方法,即我们程序的入口</span></span><br><span class="line"><span class="comment">//4. main() {} 表示方法的开始和结束</span></span><br><span class="line"><span class="comment">//5. System.out.println("hello,world~"); 表示输出"hello,world~"到屏幕</span></span><br><span class="line"><span class="comment">//6. ;表示语句结束</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Hello</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">//编写一个main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line">System.out.println(<span class="string">"韩顺平教育 hello"</span>);</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">//一个源文件中最多只能有一个public类。其它类的个数不限。[演示]</span></span><br><span class="line"><span class="comment">//Dog 是一个类</span></span><br><span class="line"><span class="comment">//编译后,每一个类,都对于一个.class</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Dog</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">//一个源文件中最多只能有一个public类。其它类的个数不限,也可以将main方法写在非public类中,</span></span><br><span class="line"><span class="comment">//然后指定运行非public 类,这样入口方法就是非public 的main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line">System.out.println(<span class="string">"hello, 小狗狗~"</span>);</span><br><span class="line">}</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Tiger</span> {</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line">System.out.println(<span class="string">"hello, 小老虎~"</span>);</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">}</span><br><span class="line"></span><br></pre></td></tr></table></figure><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080611636.png" alt="image-20220508061152606" style="zoom:67%;" /></blockquote><hr><h2 id="九-运行机制">九. 运行机制<a class="header-anchor" href="#九-运行机制"></a></h2><p><strong>Java 开发快速入门</strong></p><ul class="lvl-0"><li class="lvl-2"><p><code>Java执行流程分析</code></p></li></ul><blockquote><p>.java文件源文件</p><p>.class文件字节码文件</p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080612745.png" alt="image-20220508061231609" style="zoom: 67%;" /></blockquote><ul class="lvl-0"><li class="lvl-2"><p><code>什么是编译</code></p></li></ul><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080619173.png" alt="image-20220508061953033" style="zoom: 67%;" /></blockquote><ul class="lvl-0"><li class="lvl-2"><p><code>什么是运行</code></p></li></ul><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080623909.png" alt="image-20220508062339779" style="zoom:67%;" /></blockquote><hr><h2 id="十-开发细节">十. 开发细节<a class="header-anchor" href="#十-开发细节"></a></h2><ul class="lvl-0"><li class="lvl-2"><p><strong><code>Java开发注意事项和细节说明</code></strong></p></li></ul><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080627135.png" alt="image-20220508062754938" style="zoom: 50%;" /><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Hello</span> {</span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line">System.out.println(<span class="string">"韩顺平教育 hello"</span>);</span><br><span class="line">}</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">//一个源文件中最多只能有一个public类。其它类的个数不限。[演示]</span></span><br><span class="line"><span class="comment">//Dog 是一个类</span></span><br><span class="line"><span class="comment">//编译后,每一个类,都对于一个.class</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Dog</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">//一个源文件中最多只能有一个public类。其它类的个数不限,也可以将main方法写在非public类中,</span></span><br><span class="line"><span class="comment">//然后指定运行非public 类,这样入口方法就是非public 的main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line">System.out.println(<span class="string">"hello, 小狗狗~"</span>);</span><br><span class="line">}</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Tiger</span> {</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line">System.out.println(<span class="string">"hello, 小老虎~"</span>);</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">}</span><br><span class="line"></span><br></pre></td></tr></table></figure><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080638351.png" alt="image-20220508063831299" style="zoom: 67%;" /></blockquote><hr><h2 id="十一-学习方法">十一. 学习方法<a class="header-anchor" href="#十一-学习方法"></a></h2><blockquote><ul class="lvl-1"><li class="lvl-2"><p>老韩聊: 如何快速掌握技术或知识点</p></li></ul><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081310765.png" alt="image-20220508131030628" style="zoom: 80%;" /></blockquote><hr><h2 id="十二-转义字符">十二. 转义字符<a class="header-anchor" href="#十二-转义字符"></a></h2><p><strong>Java 转义字符</strong></p><ul class="lvl-0"><li class="lvl-2"><p><code>Java 常用的转义字符</code></p></li></ul><p>在控制台,输入 tab 键,可以实现命令补全</p><ol><li class="lvl-3"><p><code>\t</code> :一个<code>制表位</code>,实现对齐的功能</p></li><li class="lvl-3"><p><code>\n</code> :<code>换行符</code></p></li><li class="lvl-3"><p><code>\\</code> :<code>一个\ </code></p></li><li class="lvl-3"><p><code>\"</code> :<code>一个" </code></p></li><li class="lvl-3"><p><code>\'</code> :<code>一个' </code></p></li><li class="lvl-3"><p><strong><code>\r</code></strong> :<strong><code>一个回车</code></strong> System.out.println(“韩顺平教育\r 北京”);</p></li></ol><ul class="lvl-0"><li class="lvl-2"><p>说明</p></li></ul><p>应用实例</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//演示转义字符的使用</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">ChangeChar</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">//编写一个main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">// \t :一个制表位,实现对齐的功能</span></span><br><span class="line">System.out.println(<span class="string">"北京\t天津\t上海"</span>);</span><br><span class="line"><span class="comment">// \n :换行符</span></span><br><span class="line">System.out.println(<span class="string">"jack\nsmith\nmary"</span>);</span><br><span class="line"><span class="comment">// \\ :一个\ \\</span></span><br><span class="line">System.out.println(<span class="string">"C:\\Windows\\System32\\cmd.exe"</span>);</span><br><span class="line"><span class="comment">// \" :一个"</span></span><br><span class="line">System.out.println(<span class="string">"老韩说:\"要好好学习java,有前途\""</span>);</span><br><span class="line"><span class="comment">// \' :一个'</span></span><br><span class="line">System.out.println(<span class="string">"老韩说:\'要好好学习java,有前途\'"</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// \r :一个回车 System.out.println("韩顺平教育\r北京");</span></span><br><span class="line"><span class="comment">// 解读</span></span><br><span class="line"><span class="comment">// 1. 输出 韩顺平教育</span></span><br><span class="line"><span class="comment">// 2. \r表示回车 </span></span><br><span class="line">System.out.println(<span class="string">"韩顺平教育\r北京"</span>); <span class="comment">// 北京平教育</span></span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">}</span><br></pre></td></tr></table></figure><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081323663.png" alt="image-20220508132315623" style="zoom: 67%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081327844.png" alt="image-20220508132732792" style="zoom: 67%;" /><hr><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081328387.png" alt="image-20220508132852344" style="zoom:67%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081329085.png" alt="image-20220508132927045" style="zoom:67%;" /></blockquote><hr><ul class="lvl-0"><li class="lvl-2"><p>课堂练习</p></li></ul><p>要求:请使用一句输出语句,达到输入如下图形的效果 2min</p><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081331278.png" alt="image-20220508133105218" style="zoom:67%;" /></blockquote><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">ChangeCharExer01</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">//编写一个main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line"><span class="comment">//完成代码</span></span><br><span class="line">System.out.println(<span class="string">"书名\t作者\t价格\t销量\n三国\t罗贯中\t120\t1000"</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">//示意 => 可读性很好</span></span><br><span class="line"><span class="comment">//下面代码完成 两个数相加</span></span><br><span class="line"><span class="comment">//定义变量</span></span><br><span class="line"><span class="type">int</span> <span class="variable">n1</span> <span class="operator">=</span> <span class="number">10</span>;</span><br><span class="line"><span class="type">int</span> <span class="variable">n2</span> <span class="operator">=</span> <span class="number">30</span>;</span><br><span class="line"><span class="comment">//求和</span></span><br><span class="line"><span class="type">int</span> <span class="variable">sum</span> <span class="operator">=</span> n1 + n2;</span><br><span class="line"><span class="comment">//输出结果</span></span><br><span class="line">System.out.println(<span class="string">"结果="</span> + sum);</span><br><span class="line">}</span><br><span class="line">}</span><br></pre></td></tr></table></figure><hr><h2 id="十三-易犯错误">十三. 易犯错误<a class="header-anchor" href="#十三-易犯错误"></a></h2><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081335827.png" alt="image-20220508133503644" style="zoom: 50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081336546.png" alt="image-20220508133644384" style="zoom:50%;" /></blockquote><hr><h2 id="十四-注释">十四. 注释<a class="header-anchor" href="#十四-注释"></a></h2><p><strong>注释(comment)</strong></p><ul class="lvl-0"><li class="lvl-2"><p>介绍:</p></li></ul><p>用于注解说明解释程序的文字就是注释,注释提高了代码的阅读性(可读性);注释是<code>一个程序员必须要具有的良好编程习惯</code>。将自己的思想通过注释先整理出来,再用代码去体现。 [举例]</p><ul class="lvl-0"><li class="lvl-2"><p><strong><code>Java 中的注释类型</code></strong></p></li></ul><ol><li class="lvl-3"><p><code>单行注释 // </code></p></li><li class="lvl-3"><p><code>多行注释 /* */ </code></p></li><li class="lvl-3"><p><code>文档注释 /** */ </code></p></li></ol><ul class="lvl-0"><li class="lvl-2"><p><code>单行注释: </code></p></li></ul><p>基本格式</p><p>格式: //注释文字</p><ul class="lvl-0"><li class="lvl-2"><p><code>多行注释: </code></p></li></ul><p>基本格式</p><p>格式: /* 注释文字 */</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//演示注释使用</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Comment01</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">//编写一个main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">//单行注释</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//多行注释</span></span><br><span class="line"><span class="comment">/* 示意 => 可读性很好</span></span><br><span class="line"><span class="comment">下面代码完成 两个数相加</span></span><br><span class="line"><span class="comment">定义变量 </span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">注释</span></span><br><span class="line"><span class="comment">注释</span></span><br><span class="line"><span class="comment">int n1 = 10;... </span></span><br><span class="line"><span class="comment">System.out.println("ok~~");</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="type">int</span> <span class="variable">n1</span> <span class="operator">=</span> <span class="number">10</span>;</span><br><span class="line"><span class="type">int</span> <span class="variable">n2</span> <span class="operator">=</span> <span class="number">30</span>;</span><br><span class="line"><span class="comment">//求和</span></span><br><span class="line"><span class="type">int</span> <span class="variable">sum</span> <span class="operator">=</span> n1 + n2;</span><br><span class="line"><span class="comment">//输出结果</span></span><br><span class="line">System.out.println(<span class="string">"结果="</span> + sum);</span><br><span class="line">}</span><br><span class="line">}</span><br></pre></td></tr></table></figure><ul class="lvl-0"><li class="lvl-2"><p>使用细节</p></li></ul><ol><li class="lvl-3"><p>被注释的文字,不会被 JVM(java 虚拟机)解释执行</p></li><li class="lvl-3"><p>多行注释里面不允许有多行注释嵌套</p></li></ol><ul class="lvl-0"><li class="lvl-2"><p><code>文档注释:</code></p></li></ul><blockquote><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081402422.png" alt=""></p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span> 韩顺平</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@version</span> 1.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Comment02</span> { </span><br><span class="line"></span><br><span class="line"><span class="comment">//编写一个main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line">}</span><br><span class="line">}</span><br></pre></td></tr></table></figure><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081404635.png" alt="image-20220508140443548" style="zoom:50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081405177.png" alt="image-20220508140522118" style="zoom:50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081405617.png" alt="image-20220508140555554" style="zoom:50%;" /></blockquote><hr><ul class="lvl-0"><li class="lvl-2"><p><strong>javadoc 标签</strong></p></li></ul><p>javadoc 工具软件识别以下标签:</p><table><thead><tr><th>标签</th><th>描述</th><th>示例</th></tr></thead><tbody><tr><td>@author</td><td>标识一个类的作者</td><td>@author description</td></tr><tr><td>@deprecated</td><td>指名一个过期的类或成员</td><td>@deprecated description</td></tr><tr><td @docRoot=""></td><td>指明当前文档根目录的路径</td><td>Directory Path</td></tr><tr><td>@exception</td><td>标志一个类抛出的异常</td><td>@exception exception-name explanation</td></tr><tr><td @inheritDoc=""></td><td>从直接父类继承的注释</td><td>Inherits a comment from the immediate surperclass.</td></tr><tr @link="" name="" text=""><td @link=""></td><td>插入一个到另一个主题的链接</td><td></td></tr><tr><td @linkplain=""></td><td>插入一个到另一个主题的链接,但是该链接显示纯文本字体</td><td>Inserts an in-line link to another topic.</td></tr><tr><td>@param</td><td>说明一个方法的参数</td><td>@param parameter-name explanation</td></tr><tr><td>@return</td><td>说明返回值类型</td><td>@return explanation</td></tr><tr><td>@see</td><td>指定一个到另一个主题的链接</td><td>@see anchor</td></tr><tr><td>@serial</td><td>说明一个序列化属性</td><td>@serial description</td></tr><tr><td>@serialData</td><td>说明通过writeObject( ) 和 writeExternal( )方法写的数据</td><td>@serialData description</td></tr><tr><td>@serialField</td><td>说明一个ObjectStreamField组件</td><td>@serialField name type description</td></tr><tr><td>@since</td><td>标记当引入一个特定的变化时</td><td>@since release</td></tr><tr><td>@throws</td><td>和 @exception标签一样.</td><td>The @throws tag has the same meaning as the @exception tag.</td></tr><tr><td @value=""></td><td>显示常量的值,该常量必须是static属性。</td><td>Displays the value of a constant, which must be a static field.</td></tr><tr><td>@version</td><td>指定类的版本</td><td>@version info</td></tr></tbody></table><hr><ul class="lvl-0"><li class="lvl-2"><p>代码演示</p></li></ul><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081414164.png" alt="image-20220508141428106" style="zoom:50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081414376.png" alt="image-20220508141447322" style="zoom:50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081415068.png" alt="image-20220508141519015" style="zoom:50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081415355.png" alt="image-20220508141539312" style="zoom:50%;" /></blockquote><hr><h2 id="十五-代码规范">十五. 代码规范<a class="header-anchor" href="#十五-代码规范"></a></h2><ul class="lvl-0"><li class="lvl-2"><p><code>Java 代码规范</code></p></li></ul><blockquote><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081416659.png" alt=""></p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081421585.png" alt="image-20220508142107515" style="zoom:50%;" /></blockquote><hr><h2 id="十六-DOS原理-路径-DOS指令">十六. DOS原理-路径-DOS指令<a class="header-anchor" href="#十六-DOS原理-路径-DOS指令"></a></h2><ul class="lvl-0"><li class="lvl-2"><p>DOS 命令(了解)</p></li></ul><p>DOS 介绍</p><p>Dos: Disk Operating System 磁盘操作系统, 简单说一下 windows 的目录结构。[<strong>原理图</strong>]</p><blockquote><p><strong>原理图</strong></p><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081427390.png" alt=""></p></blockquote><ul class="lvl-0"><li class="lvl-2"><p>相关的知识补充: <strong><code>相对路径, 绝对路径</code></strong></p></li></ul><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081429068.png" alt="image-20220508142920905" style="zoom: 67%;" /></blockquote><ul class="lvl-0"><li class="lvl-2"><p><strong><code>常用的</code></strong> <code>dos 命令 </code></p></li></ul><ol><li class="lvl-3"><p>查看<code>当前目录是有什么内容</code> dir</p></li></ol><p>dir <code>dir d:\abc2\test200 </code></p><ol start="2"><li class="lvl-3"><p>切换到其他盘下:盘符号 cd : change directory</p></li></ol><p>案例演示:切换到 c 盘 <code>cd /D c: </code></p><ol start="3"><li class="lvl-3"><p>切换到当前盘的其他目录下 (使用相对路径和绝对路径演示), …\表示上一级目录</p></li></ol><p>案例演示: <code>cd d:\abc2\test200 </code>cd …\…\abc2\test200</p><ol start="4"><li class="lvl-3"><p>切换到上一级:</p></li></ol><p>案例演示: <code>cd .. </code></p><ol start="5"><li class="lvl-3"><p>切换到根目录:<code>cd \ </code></p></li></ol><p>案例演示:cd \</p><ol start="6"><li class="lvl-3"><p>查看指定的目录下所有的子级目录 <code>tree </code></p></li><li class="lvl-3"><p><code>清屏 cls</code></p></li><li class="lvl-3"><p>退出 DOS <code>exit </code></p></li><li class="lvl-3"><p>说明: <strong>因为小伙伴后面使用</strong> <strong>DOS</strong> <strong>非常少</strong>,所以对下面的几个指令,老韩给大家演示下, 大家了解即可 (<code>md[创建目录],rd[删除目录],copy[拷贝文件],del[删除文件],echo[输入内容到文件],type,move[剪切]</code>) => <strong>Linux</strong>,</p></li></ol><hr><h2 id="十七-本章作业">十七. 本章作业<a class="header-anchor" href="#十七-本章作业"></a></h2><ul class="lvl-0"><li class="lvl-2"><p>本章作业</p></li></ul><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081452380.png" alt="image-20220508145216238" style="zoom:50%;" /><hr><ul class="lvl-1"><li class="lvl-2"><p>1</p></li></ul></blockquote><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Homework01</span> { </span><br><span class="line"></span><br><span class="line"><span class="comment">//编写一个main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line"><span class="comment">//编写hello, world程序</span></span><br><span class="line">System.out.println(<span class="string">"hello,world"</span>); </span><br><span class="line">}</span><br><span class="line">}</span><br></pre></td></tr></table></figure><blockquote><ul class="lvl-1"><li class="lvl-2"><p>2</p></li></ul></blockquote><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//将个人的基本信息(姓名、性别、籍贯、住址)打印到控制台上输出。各条信息分别占一行</span></span><br><span class="line"><span class="comment">//</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Homework02</span> { </span><br><span class="line"></span><br><span class="line"><span class="comment">//编写一个main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line"><span class="comment">//考察对转义字符</span></span><br><span class="line">System.out.println(<span class="string">"姓名\t性别\t籍贯\t住址\n顺平\t男\t四川\t北京"</span>); </span><br><span class="line">}</span><br><span class="line">}</span><br></pre></td></tr></table></figure><blockquote><ul class="lvl-1"><li class="lvl-2"><p>3</p></li></ul><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//JDK,JRE,JVM的关系</span></span><br><span class="line"><span class="comment">//</span></span><br><span class="line">答:</span><br><span class="line"><span class="number">1.</span> JDK = JRE + java开发工具</span><br><span class="line"><span class="number">2.</span> JRE = JVM + 核心类库</span><br></pre></td></tr></table></figure><ul class="lvl-1"><li class="lvl-2"><p>4</p></li></ul><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//环境变量path配置及其作用</span></span><br><span class="line"><span class="number">1.</span> 环境变量的作用是为了在 dos 的任意目录,可以去使用 java 和 javac 命令</span><br><span class="line"><span class="number">2.</span> 先配置 JAVA_HOME = 指向 jdk 安装的主目录</span><br><span class="line"><span class="number">3.</span> 编辑 path 环境变量,增加 %JAVA_HOME%\bin </span><br></pre></td></tr></table></figure><ul class="lvl-1"><li class="lvl-2"><p>5</p></li></ul><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//Java编写步骤</span></span><br><span class="line"><span class="number">1.</span> 编写java的源代码</span><br><span class="line"><span class="number">2.</span> javac 编译 ,得到对应的 .class 字节码文件</span><br><span class="line"><span class="number">3.</span> java 运行, 本质就是把 .class 加载到 jvm 运行</span><br></pre></td></tr></table></figure><ul class="lvl-1"><li class="lvl-2"><p>6</p></li></ul><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//Java编写7个规范</span></span><br><span class="line"><span class="number">1.</span> 类,方法的注释,使用javadoc的方式,即文档注释</span><br><span class="line"><span class="number">2.</span> 非javadoc注释,往往是对代码的说明(给程序的维护者),说明如何修改,注意事项</span><br><span class="line"><span class="number">3.</span> 使用tab ,整体将代码右移, 使用 shift+tab 整体左移</span><br><span class="line"><span class="number">4.</span> 运算符和 = 的两边,给空格,代码看上去清楚 <span class="type">int</span> <span class="variable">n</span> <span class="operator">=</span> <span class="number">1</span> + <span class="number">4</span>;</span><br><span class="line"><span class="number">5.</span> 源码文件使用 utf-<span class="number">8</span> 编码</span><br><span class="line"><span class="number">6.</span> 行宽字符不要超过 <span class="number">80</span></span><br><span class="line"><span class="number">7.</span> 代码编程风格有两种 次行风格,行尾风格(推荐)</span><br></pre></td></tr></table></figure><ul class="lvl-1"><li class="lvl-2"><p>7</p></li></ul><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//初学者java易犯错误 </span></span><br><span class="line"><span class="number">1.</span> 编译或者运行时,找不到文件 javac Hell0.java, 把文件名或者目录找对</span><br><span class="line"><span class="number">2.</span> 主类名和文件名不一致 , 修改时保持一致即可</span><br><span class="line"><span class="number">3.</span> 缺少;</span><br><span class="line"><span class="number">4.</span> 拼写错误,比如 <span class="number">1</span> -> l <span class="number">0</span>-><span class="number">0</span>, <span class="keyword">void</span> -> viod , 要求写代码时,一定要小心</span><br><span class="line"></span><br><span class="line">强调: 先思考->自己练习->看老师评讲</span><br><span class="line"></span><br></pre></td></tr></table></figure></blockquote><hr>]]></content>
|
1496
|
+
<content type="html"><![CDATA[<p><a href="https://www.bilibili.com/video/BV1fh411y7R8">视频链接:https://www.bilibili.com/video/BV1fh411y7R8</a></p><h2 id="一-就业方向">一. 就业方向<a class="header-anchor" href="#一-就业方向"></a></h2><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080320118.png" alt="image-20220508032024978" style="zoom:50%;" /><hr><h2 id="二-开发场景">二. 开发场景<a class="header-anchor" href="#二-开发场景"></a></h2><p>Java 开发场景举例 1-<code>SSM</code></p><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080322295.png" alt=""></p><p>Java 开发场景举例 2:<code>Android 核心代码</code></p><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080324796.png" alt=""></p><p>Java 开发场景举例 3:<code>大数据-hadoop </code></p><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080325177.png" alt=""></p><hr><h2 id="三-应用领域">三. 应用领域<a class="header-anchor" href="#三-应用领域"></a></h2><ul class="lvl-0"><li class="lvl-2"><p>企业级应用</p></li></ul><p>主要指复杂的大企业的**<code>软件系统</code><strong>、各种类型的</strong><code>网站</code>**。应用领域包括金融、电信、交通、电子商务等。</p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080327015.png" alt="image-20220508032702906" style="zoom:50%;" /><ul class="lvl-0"><li class="lvl-2"><p>Android 平台应用</p></li></ul><p>Android 应用程序使用 Java 语言编写。Android 开发水平的高低很大程度上取决于 Java 语言核心能力是否扎实。</p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080327181.png" alt="image-20220508032750052" style="zoom:50%;" /><ul class="lvl-0"><li class="lvl-2"><p>移动领域应用</p></li></ul><p>主要表现在消费和嵌入式领域,是指在各种小型设备上的应用,包括机顶盒、车载的大屏影音娱乐设备、汽车通信设备、扫码的 POS 机等。</p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080329788.png" alt="image-20220508032900704" style="zoom:50%;" /><hr><h2 id="四-程序举例">四. 程序举例<a class="header-anchor" href="#四-程序举例"></a></h2><ul class="lvl-0"><li class="lvl-2"><p><strong>什么是程序</strong></p></li></ul><p>程序:计算机执行某些操作或解决某个问题而 <strong><code>编写的一系列有序指令的集合</code></strong></p><p>举例说明:</p><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080343728.png" alt="image-20220508034312623" style="zoom:50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080343441.png" alt="image-20220508034326323" style="zoom: 67%;" /></blockquote><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//老师写的最简单的程序,完成 1+1, 体会</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Test</span> {</span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line"> <span class="type">int</span> <span class="variable">res</span> <span class="operator">=</span> <span class="number">1</span> + <span class="number">1</span>;</span><br><span class="line"> <span class="comment">// 显示</span></span><br><span class="line">System.out.print(<span class="string">"结果="</span> + res);</span><br><span class="line">}</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080403773.png" alt=""></p><hr><h2 id="五-故事">五. 故事<a class="header-anchor" href="#五-故事"></a></h2><ul class="lvl-0"><li class="lvl-2"><p>Java 诞生小故事</p></li></ul><ol><li class="lvl-3"><p><code>1995年 第1个版本</code></p></li><li class="lvl-3"><p><code>Java之父 gosling</code></p></li><li class="lvl-3"><p><code>最新版本:15</code></p></li><li class="lvl-3"><p><code>公司里用的最多的版本:8、11</code></p></li><li class="lvl-3"><p><code>Java 所有权:甲骨文</code></p></li></ol><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080344966.png" alt="image-20220508034456860" style="zoom: 67%;" /><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080408088.png" alt=""></p></blockquote><ul class="lvl-0"><li class="lvl-2"><p>Java 技术体系平台</p></li></ul><blockquote><p><code>标准版、企业版、小型版</code></p><p><code>Java SE、Java EE、Java ME</code></p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080412778.png" style="zoom:50%;" /></blockquote><hr><h2 id="六-特性">六. 特性<a class="header-anchor" href="#六-特性"></a></h2><ul class="lvl-0"><li class="lvl-2"><p><strong>Java 重要特点</strong></p></li></ul><ol><li class="lvl-3"><p>Java 语言是面向对象的(<strong><code>oop</code></strong>)</p></li><li class="lvl-3"><p>Java <code>语言是健壮的</code>。Java 的强类型机制、异常处理、垃圾的自动收集等是 Java 程序健壮性的重要保证</p></li><li class="lvl-3"><p>Java 语言是**<code>跨平台性的</code>**。[即: <strong>一个编译好的.class 文件可以在多个系统下运行,这种特性称为跨平台</strong>]</p></li></ol><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080415181.png" style="zoom:50%;" /></blockquote><ol start="4"><li class="lvl-3"><p>Java 语言是解释型的[了解]</p></li></ol><p><strong>解释性语言:javascript,PHP, java 编译性语言: c / c++</strong></p><p>区别是:<code>解释性语言</code>,编译后的代码,<code>不能直接被机器执行,需要解释器来执行</code>, <code>编译性语言</code>, 编译后的代码, 可以<code>直接被机器执行</code>, c /c++</p><hr><ul class="lvl-0"><li class="lvl-2"><p><strong>Java 的开发工具</strong></p><ul class="lvl-2"><li class="lvl-4"><p>工具选择</p><ul class="lvl-4"><li class="lvl-6"><p>如何选择开发工具</p><p>我们先选择用文本编辑器本 sublime,到大家对 java 有一定了解后,我们再使用 IDEA 和 Eclipse 开发工具。</p></li><li class="lvl-6"><p>这是为什么呢</p><p>更深刻的理解 java 技术,培养代码感。【面试时,往往程序员手写代码】</p><p>有利于公司面试</p><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080421152.png" alt="image-20220508042124961" style="zoom:50%;" /></blockquote></li></ul></li></ul></li></ul><hr><h2 id="七-jdk介绍、安装、配置">七. jdk介绍、安装、配置<a class="header-anchor" href="#七-jdk介绍、安装、配置"></a></h2><ul class="lvl-0"><li class="lvl-2"><p><strong>Java 运行机制及运行过程</strong></p><ul class="lvl-2"><li class="lvl-4"><p>Java 语言的特点:<code>跨平台性</code></p><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080428588.png" alt="image-20220508042849189" style="zoom:50%;" /></blockquote></li><li class="lvl-4"><p>Java 核心机制-Java 虚拟机 [<code>JVM</code> java virtual machine]</p></li></ul></li><li class="lvl-2"><p><code>Java 核心机制-Java 虚拟机 [JVM java virtual machine]</code></p></li></ul><p><strong>基本介绍</strong></p><ol><li class="lvl-3"><p>JVM 是一个虚拟的计算机,具有指令集并使用不同的存储区域。负责执行指令,管理数据、内存、寄存器,包含在 <strong><code>JDK 中</code></strong>.</p></li><li class="lvl-3"><p>对于不同的平台,有不同的虚拟机。</p></li><li class="lvl-3"><p>Java 虚拟机机制屏蔽了底层运行平台的差别,实现了“一次**<code>编译</code><strong>,到处</strong><code>运行</code>**” [说明]</p></li></ol><p><strong>示意图</strong></p><blockquote><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//指令</span></span><br><span class="line">javac<span class="comment">// 编译</span></span><br><span class="line">java<span class="comment">// 运行</span></span><br></pre></td></tr></table></figure><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080434503.png" alt="image-20220508043429400" style="zoom: 67%;" /></blockquote><hr><p><strong><code>什么是 JDK,JRE</code></strong></p><ul class="lvl-0"><li class="lvl-2"><p><code>JDK 基本介绍 </code></p></li></ul><ol><li class="lvl-3"><p>JDK 的全称(Java Development Kit <strong><code>Java 开发工具包</code></strong>)</p></li></ol><p>JDK = JRE + java 的开发工具 [java, javac,javadoc,javap 等]</p><ol start="2"><li class="lvl-3"><p>JDK 是提供给 Java 开发人员使用的,其中包含了 java 的开发工具,也包括了 JRE。所以安装了 JDK,就不用在单独安装 JRE 了。</p></li></ol><ul class="lvl-0"><li class="lvl-2"><p><code>JRE 基本介绍</code></p></li></ul><ol><li class="lvl-3"><p>JRE(Java Runtime Environment <code> Java 运行环境</code>)</p></li></ol><p>JRE = JVM + Java 的核心类库[类]</p><ol start="2"><li class="lvl-3"><p>包括 Java 虚拟机(JVM Java Virtual Machine)和 Java 程序所需的核心类库等,如果想要运行一个开发好的 Java 程序,计算机中只需要安装 JRE 即可。</p></li></ol><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080445424.png" style="zoom:67%;" /></blockquote><ul class="lvl-0"><li class="lvl-2"><p><code>JDK、JRE 和 JVM 的包含关系</code></p></li></ul><ol><li class="lvl-3"><p><strong><code>JDK = JRE + 开发工具集</code></strong>(例如 Javac,java 编译工具等)</p></li><li class="lvl-3"><p><strong><code>JRE = JVM + Java SE</code></strong> <strong><code>标准类库</code></strong>(java 核心类库)</p></li><li class="lvl-3"><p>如果只想运行开发好的 .class 文件 只需要 JRE</p></li></ol><hr><p><strong>下载、安装 JDK</strong></p><blockquote><p><a href="https://www.oracle.com/java/technologies/downloads/">https://www.oracle.com/java/technologies/downloads/</a></p><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080450598.png" alt=""></p></blockquote><p><strong>配置环境变量 path</strong></p><ul class="lvl-0"><li class="lvl-2"><p>为什么要配置 path</p><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080507309.png" alt="image-20220508050732153" style="zoom:50%;" /></blockquote></li><li class="lvl-2"><p>配置环境变量 path 的步骤</p></li></ul><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080512224.png" style="zoom:50%;" /></blockquote><hr><p>安装 JDK 的练习</p><blockquote><p>请同学们安装好 JDK,配置好 path 环境变量。可以在控制台下正确的执行, (10min)</p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080520103.png" alt="image-20220508052000041" style="zoom:50%;" /><p>环境变量配置细节说明:</p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080520181.png" alt="image-20220508052022102" style="zoom:50%;" /><hr><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080521628.png" alt="image-20220508052141440" style="zoom: 50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080528717.png" alt="image-20220508052824602" style="zoom:50%;" /><hr><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080529498.png" alt="image-20220508052931384" style="zoom:50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080533822.png" alt="image-20220508053340793" style="zoom: 67%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080534562.png" alt="image-20220508053443524" style="zoom:67%;" /></blockquote><hr><h2 id="八-快速入门">八. 快速入门<a class="header-anchor" href="#八-快速入门"></a></h2><ul class="lvl-0"><li class="lvl-2"><p>需求说明</p></li></ul><p>要求开发一个 Hello.java 程序,可以输出 “hello,world!”</p><ul class="lvl-0"><li class="lvl-2"><p>开发步骤</p></li></ul><ol><li class="lvl-3"><p>将 Java 代码编写到扩展名为 <code>Hello.java 的文件</code>中。[代码说明]</p></li><li class="lvl-3"><p>通过 <code>javac</code> 命令对该 java 文件进行<code>编译</code>,生成 <code>.class</code> 文件。</p></li><li class="lvl-3"><p>通过 <code>java</code> 命令对生成的 class 文件进行<code>运行</code>。</p></li></ol><ul class="lvl-0"><li class="lvl-2"><p>运行原理示意图</p></li></ul><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080545433.png" alt="image-20220508054554366" style="zoom: 67%;" /></blockquote><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080607424.png" alt="image-20220508060705278" style="zoom:50%;" /></blockquote><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//这是java的快速入门, 演示java的开发步骤</span></span><br><span class="line"><span class="comment">//对代码的相关说明</span></span><br><span class="line"><span class="comment">//1. public class Hello 表示Hello是一个类,是一个public公有的类</span></span><br><span class="line"><span class="comment">//2. Hello{ } 表示一个类的开始和结束</span></span><br><span class="line"><span class="comment">//3. public static void main(String[] args) 表示一个主方法,即我们程序的入口</span></span><br><span class="line"><span class="comment">//4. main() {} 表示方法的开始和结束</span></span><br><span class="line"><span class="comment">//5. System.out.println("hello,world~"); 表示输出"hello,world~"到屏幕</span></span><br><span class="line"><span class="comment">//6. ;表示语句结束</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Hello</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">//编写一个main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line">System.out.println(<span class="string">"韩顺平教育 hello"</span>);</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">//一个源文件中最多只能有一个public类。其它类的个数不限。[演示]</span></span><br><span class="line"><span class="comment">//Dog 是一个类</span></span><br><span class="line"><span class="comment">//编译后,每一个类,都对于一个.class</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Dog</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">//一个源文件中最多只能有一个public类。其它类的个数不限,也可以将main方法写在非public类中,</span></span><br><span class="line"><span class="comment">//然后指定运行非public 类,这样入口方法就是非public 的main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line">System.out.println(<span class="string">"hello, 小狗狗~"</span>);</span><br><span class="line">}</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Tiger</span> {</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line">System.out.println(<span class="string">"hello, 小老虎~"</span>);</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">}</span><br><span class="line"></span><br></pre></td></tr></table></figure><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080611636.png" alt="image-20220508061152606" style="zoom:67%;" /></blockquote><hr><h2 id="九-运行机制">九. 运行机制<a class="header-anchor" href="#九-运行机制"></a></h2><p><strong>Java 开发快速入门</strong></p><ul class="lvl-0"><li class="lvl-2"><p><code>Java执行流程分析</code></p></li></ul><blockquote><p>.java文件源文件</p><p>.class文件字节码文件</p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080612745.png" alt="image-20220508061231609" style="zoom: 67%;" /></blockquote><ul class="lvl-0"><li class="lvl-2"><p><code>什么是编译</code></p></li></ul><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080619173.png" alt="image-20220508061953033" style="zoom: 67%;" /></blockquote><ul class="lvl-0"><li class="lvl-2"><p><code>什么是运行</code></p></li></ul><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080623909.png" alt="image-20220508062339779" style="zoom:67%;" /></blockquote><hr><h2 id="十-开发细节">十. 开发细节<a class="header-anchor" href="#十-开发细节"></a></h2><ul class="lvl-0"><li class="lvl-2"><p><strong><code>Java开发注意事项和细节说明</code></strong></p></li></ul><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080627135.png" alt="image-20220508062754938" style="zoom: 50%;" /><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Hello</span> {</span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line">System.out.println(<span class="string">"韩顺平教育 hello"</span>);</span><br><span class="line">}</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">//一个源文件中最多只能有一个public类。其它类的个数不限。[演示]</span></span><br><span class="line"><span class="comment">//Dog 是一个类</span></span><br><span class="line"><span class="comment">//编译后,每一个类,都对于一个.class</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Dog</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">//一个源文件中最多只能有一个public类。其它类的个数不限,也可以将main方法写在非public类中,</span></span><br><span class="line"><span class="comment">//然后指定运行非public 类,这样入口方法就是非public 的main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line">System.out.println(<span class="string">"hello, 小狗狗~"</span>);</span><br><span class="line">}</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Tiger</span> {</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line">System.out.println(<span class="string">"hello, 小老虎~"</span>);</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">}</span><br><span class="line"></span><br></pre></td></tr></table></figure><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205080638351.png" alt="image-20220508063831299" style="zoom: 67%;" /></blockquote><hr><h2 id="十一-学习方法">十一. 学习方法<a class="header-anchor" href="#十一-学习方法"></a></h2><blockquote><ul class="lvl-1"><li class="lvl-2"><p>老韩聊: 如何快速掌握技术或知识点</p></li></ul><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081310765.png" alt="image-20220508131030628" style="zoom: 80%;" /></blockquote><hr><h2 id="十二-转义字符">十二. 转义字符<a class="header-anchor" href="#十二-转义字符"></a></h2><p><strong>Java 转义字符</strong></p><ul class="lvl-0"><li class="lvl-2"><p><code>Java 常用的转义字符</code></p></li></ul><p>在控制台,输入 tab 键,可以实现命令补全</p><ol><li class="lvl-3"><p><code>\t</code> :一个<code>制表位</code>,实现对齐的功能</p></li><li class="lvl-3"><p><code>\n</code> :<code>换行符</code></p></li><li class="lvl-3"><p><code>\\</code> :<code>一个\ </code></p></li><li class="lvl-3"><p><code>\"</code> :<code>一个" </code></p></li><li class="lvl-3"><p><code>\'</code> :<code>一个' </code></p></li><li class="lvl-3"><p><strong><code>\r</code></strong> :<strong><code>一个回车</code></strong> System.out.println(“韩顺平教育\r 北京”);</p></li></ol><ul class="lvl-0"><li class="lvl-2"><p>说明</p></li></ul><p>应用实例</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//演示转义字符的使用</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">ChangeChar</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">//编写一个main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">// \t :一个制表位,实现对齐的功能</span></span><br><span class="line">System.out.println(<span class="string">"北京\t天津\t上海"</span>);</span><br><span class="line"><span class="comment">// \n :换行符</span></span><br><span class="line">System.out.println(<span class="string">"jack\nsmith\nmary"</span>);</span><br><span class="line"><span class="comment">// \\ :一个\ \\</span></span><br><span class="line">System.out.println(<span class="string">"C:\\Windows\\System32\\cmd.exe"</span>);</span><br><span class="line"><span class="comment">// \" :一个"</span></span><br><span class="line">System.out.println(<span class="string">"老韩说:\"要好好学习java,有前途\""</span>);</span><br><span class="line"><span class="comment">// \' :一个'</span></span><br><span class="line">System.out.println(<span class="string">"老韩说:\'要好好学习java,有前途\'"</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// \r :一个回车 System.out.println("韩顺平教育\r北京");</span></span><br><span class="line"><span class="comment">// 解读</span></span><br><span class="line"><span class="comment">// 1. 输出 韩顺平教育</span></span><br><span class="line"><span class="comment">// 2. \r表示回车 </span></span><br><span class="line">System.out.println(<span class="string">"韩顺平教育\r北京"</span>); <span class="comment">// 北京平教育</span></span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">}</span><br></pre></td></tr></table></figure><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081323663.png" alt="image-20220508132315623" style="zoom: 67%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081327844.png" alt="image-20220508132732792" style="zoom: 67%;" /><hr><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081328387.png" alt="image-20220508132852344" style="zoom:67%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081329085.png" alt="image-20220508132927045" style="zoom:67%;" /></blockquote><hr><ul class="lvl-0"><li class="lvl-2"><p>课堂练习</p></li></ul><p>要求:请使用一句输出语句,达到输入如下图形的效果 2min</p><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081331278.png" alt="image-20220508133105218" style="zoom:67%;" /></blockquote><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">ChangeCharExer01</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">//编写一个main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line"><span class="comment">//完成代码</span></span><br><span class="line">System.out.println(<span class="string">"书名\t作者\t价格\t销量\n三国\t罗贯中\t120\t1000"</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">//示意 => 可读性很好</span></span><br><span class="line"><span class="comment">//下面代码完成 两个数相加</span></span><br><span class="line"><span class="comment">//定义变量</span></span><br><span class="line"><span class="type">int</span> <span class="variable">n1</span> <span class="operator">=</span> <span class="number">10</span>;</span><br><span class="line"><span class="type">int</span> <span class="variable">n2</span> <span class="operator">=</span> <span class="number">30</span>;</span><br><span class="line"><span class="comment">//求和</span></span><br><span class="line"><span class="type">int</span> <span class="variable">sum</span> <span class="operator">=</span> n1 + n2;</span><br><span class="line"><span class="comment">//输出结果</span></span><br><span class="line">System.out.println(<span class="string">"结果="</span> + sum);</span><br><span class="line">}</span><br><span class="line">}</span><br></pre></td></tr></table></figure><hr><h2 id="十三-易犯错误">十三. 易犯错误<a class="header-anchor" href="#十三-易犯错误"></a></h2><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081335827.png" alt="image-20220508133503644" style="zoom: 50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081336546.png" alt="image-20220508133644384" style="zoom:50%;" /></blockquote><hr><h2 id="十四-注释">十四. 注释<a class="header-anchor" href="#十四-注释"></a></h2><p><strong>注释(comment)</strong></p><ul class="lvl-0"><li class="lvl-2"><p>介绍:</p></li></ul><p>用于注解说明解释程序的文字就是注释,注释提高了代码的阅读性(可读性);注释是<code>一个程序员必须要具有的良好编程习惯</code>。将自己的思想通过注释先整理出来,再用代码去体现。 [举例]</p><ul class="lvl-0"><li class="lvl-2"><p><strong><code>Java 中的注释类型</code></strong></p></li></ul><ol><li class="lvl-3"><p><code>单行注释 // </code></p></li><li class="lvl-3"><p><code>多行注释 /* */ </code></p></li><li class="lvl-3"><p><code>文档注释 /** */ </code></p></li></ol><ul class="lvl-0"><li class="lvl-2"><p><code>单行注释: </code></p></li></ul><p>基本格式</p><p>格式: //注释文字</p><ul class="lvl-0"><li class="lvl-2"><p><code>多行注释: </code></p></li></ul><p>基本格式</p><p>格式: /* 注释文字 */</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//演示注释使用</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Comment01</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">//编写一个main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line"></span><br><span class="line"><span class="comment">//单行注释</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//多行注释</span></span><br><span class="line"><span class="comment">/* 示意 => 可读性很好</span></span><br><span class="line"><span class="comment">下面代码完成 两个数相加</span></span><br><span class="line"><span class="comment">定义变量 </span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">注释</span></span><br><span class="line"><span class="comment">注释</span></span><br><span class="line"><span class="comment">int n1 = 10;... </span></span><br><span class="line"><span class="comment">System.out.println("ok~~");</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="type">int</span> <span class="variable">n1</span> <span class="operator">=</span> <span class="number">10</span>;</span><br><span class="line"><span class="type">int</span> <span class="variable">n2</span> <span class="operator">=</span> <span class="number">30</span>;</span><br><span class="line"><span class="comment">//求和</span></span><br><span class="line"><span class="type">int</span> <span class="variable">sum</span> <span class="operator">=</span> n1 + n2;</span><br><span class="line"><span class="comment">//输出结果</span></span><br><span class="line">System.out.println(<span class="string">"结果="</span> + sum);</span><br><span class="line">}</span><br><span class="line">}</span><br></pre></td></tr></table></figure><ul class="lvl-0"><li class="lvl-2"><p>使用细节</p></li></ul><ol><li class="lvl-3"><p>被注释的文字,不会被 JVM(java 虚拟机)解释执行</p></li><li class="lvl-3"><p>多行注释里面不允许有多行注释嵌套</p></li></ol><ul class="lvl-0"><li class="lvl-2"><p><code>文档注释:</code></p></li></ul><blockquote><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081402422.png" alt=""></p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span> 韩顺平</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@version</span> 1.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Comment02</span> { </span><br><span class="line"></span><br><span class="line"><span class="comment">//编写一个main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line">}</span><br><span class="line">}</span><br></pre></td></tr></table></figure><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081404635.png" alt="image-20220508140443548" style="zoom:50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081405177.png" alt="image-20220508140522118" style="zoom:50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081405617.png" alt="image-20220508140555554" style="zoom:50%;" /></blockquote><hr><ul class="lvl-0"><li class="lvl-2"><p><strong>javadoc 标签</strong></p></li></ul><p>javadoc 工具软件识别以下标签:</p><table><thead><tr><th>标签</th><th>描述</th><th>示例</th></tr></thead><tbody><tr><td>@author</td><td>标识一个类的作者</td><td>@author description</td></tr><tr><td>@deprecated</td><td>指名一个过期的类或成员</td><td>@deprecated description</td></tr><tr><td @docRoot=""></td><td>指明当前文档根目录的路径</td><td>Directory Path</td></tr><tr><td>@exception</td><td>标志一个类抛出的异常</td><td>@exception exception-name explanation</td></tr><tr><td @inheritDoc=""></td><td>从直接父类继承的注释</td><td>Inherits a comment from the immediate surperclass.</td></tr><tr @link="" name="" text=""><td @link=""></td><td>插入一个到另一个主题的链接</td><td></td></tr><tr><td @linkplain=""></td><td>插入一个到另一个主题的链接,但是该链接显示纯文本字体</td><td>Inserts an in-line link to another topic.</td></tr><tr><td>@param</td><td>说明一个方法的参数</td><td>@param parameter-name explanation</td></tr><tr><td>@return</td><td>说明返回值类型</td><td>@return explanation</td></tr><tr><td>@see</td><td>指定一个到另一个主题的链接</td><td>@see anchor</td></tr><tr><td>@serial</td><td>说明一个序列化属性</td><td>@serial description</td></tr><tr><td>@serialData</td><td>说明通过writeObject( ) 和 writeExternal( )方法写的数据</td><td>@serialData description</td></tr><tr><td>@serialField</td><td>说明一个ObjectStreamField组件</td><td>@serialField name type description</td></tr><tr><td>@since</td><td>标记当引入一个特定的变化时</td><td>@since release</td></tr><tr><td>@throws</td><td>和 @exception标签一样.</td><td>The @throws tag has the same meaning as the @exception tag.</td></tr><tr><td @value=""></td><td>显示常量的值,该常量必须是static属性。</td><td>Displays the value of a constant, which must be a static field.</td></tr><tr><td>@version</td><td>指定类的版本</td><td>@version info</td></tr></tbody></table><hr><ul class="lvl-0"><li class="lvl-2"><p>代码演示</p></li></ul><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081414164.png" alt="image-20220508141428106" style="zoom:50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081414376.png" alt="image-20220508141447322" style="zoom:50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081415068.png" alt="image-20220508141519015" style="zoom:50%;" /><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081415355.png" alt="image-20220508141539312" style="zoom:50%;" /></blockquote><hr><h2 id="十五-代码规范">十五. 代码规范<a class="header-anchor" href="#十五-代码规范"></a></h2><ul class="lvl-0"><li class="lvl-2"><p><code>Java 代码规范</code></p></li></ul><blockquote><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081416659.png" alt=""></p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081421585.png" alt="image-20220508142107515" style="zoom:50%;" /></blockquote><hr><h2 id="十六-DOS原理-路径-DOS指令">十六. DOS原理-路径-DOS指令<a class="header-anchor" href="#十六-DOS原理-路径-DOS指令"></a></h2><ul class="lvl-0"><li class="lvl-2"><p>DOS 命令(了解)</p></li></ul><p>DOS 介绍</p><p>Dos: Disk Operating System 磁盘操作系统, 简单说一下 windows 的目录结构。[<strong>原理图</strong>]</p><blockquote><p><strong>原理图</strong></p><p><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081427390.png" alt=""></p></blockquote><ul class="lvl-0"><li class="lvl-2"><p>相关的知识补充: <strong><code>相对路径, 绝对路径</code></strong></p></li></ul><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081429068.png" alt="image-20220508142920905" style="zoom: 67%;" /></blockquote><ul class="lvl-0"><li class="lvl-2"><p><strong><code>常用的</code></strong> <code>dos 命令 </code></p></li></ul><ol><li class="lvl-3"><p>查看<code>当前目录是有什么内容</code> dir</p></li></ol><p>dir <code>dir d:\abc2\test200 </code></p><ol start="2"><li class="lvl-3"><p>切换到其他盘下:盘符号 cd : change directory</p></li></ol><p>案例演示:切换到 c 盘 <code>cd /D c: </code></p><ol start="3"><li class="lvl-3"><p>切换到当前盘的其他目录下 (使用相对路径和绝对路径演示), …\表示上一级目录</p></li></ol><p>案例演示: <code>cd d:\abc2\test200 </code>cd …\…\abc2\test200</p><ol start="4"><li class="lvl-3"><p>切换到上一级:</p></li></ol><p>案例演示: <code>cd .. </code></p><ol start="5"><li class="lvl-3"><p>切换到根目录:<code>cd \ </code></p></li></ol><p>案例演示:cd \</p><ol start="6"><li class="lvl-3"><p>查看指定的目录下所有的子级目录 <code>tree </code></p></li><li class="lvl-3"><p><code>清屏 cls</code></p></li><li class="lvl-3"><p>退出 DOS <code>exit </code></p></li><li class="lvl-3"><p>说明: <strong>因为小伙伴后面使用</strong> <strong>DOS</strong> <strong>非常少</strong>,所以对下面的几个指令,老韩给大家演示下, 大家了解即可 (<code>md[创建目录],rd[删除目录],copy[拷贝文件],del[删除文件],echo[输入内容到文件],type,move[剪切]</code>) => <strong>Linux</strong>,</p></li></ol><hr><h2 id="十七-本章作业">十七. 本章作业<a class="header-anchor" href="#十七-本章作业"></a></h2><ul class="lvl-0"><li class="lvl-2"><p>本章作业</p></li></ul><blockquote><img src="https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2022/files/image/202205081452380.png" alt="image-20220508145216238" style="zoom:50%;" /><hr><ul class="lvl-1"><li class="lvl-2"><p>1</p></li></ul></blockquote><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Homework01</span> { </span><br><span class="line"></span><br><span class="line"><span class="comment">//编写一个main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line"><span class="comment">//编写hello, world程序</span></span><br><span class="line">System.out.println(<span class="string">"hello,world"</span>); </span><br><span class="line">}</span><br><span class="line">}</span><br></pre></td></tr></table></figure><blockquote><ul class="lvl-1"><li class="lvl-2"><p>2</p></li></ul></blockquote><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//将个人的基本信息(姓名、性别、籍贯、住址)打印到控制台上输出。各条信息分别占一行</span></span><br><span class="line"><span class="comment">//</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Homework02</span> { </span><br><span class="line"></span><br><span class="line"><span class="comment">//编写一个main方法</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line"><span class="comment">//考察对转义字符</span></span><br><span class="line">System.out.println(<span class="string">"姓名\t性别\t籍贯\t住址\n顺平\t男\t四川\t北京"</span>); </span><br><span class="line">}</span><br><span class="line">}</span><br></pre></td></tr></table></figure><blockquote><ul class="lvl-1"><li class="lvl-2"><p>3</p></li></ul><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//JDK,JRE,JVM的关系</span></span><br><span class="line"><span class="comment">//</span></span><br><span class="line">答:</span><br><span class="line"><span class="number">1.</span> JDK = JRE + java开发工具</span><br><span class="line"><span class="number">2.</span> JRE = JVM + 核心类库</span><br></pre></td></tr></table></figure><ul class="lvl-1"><li class="lvl-2"><p>4</p></li></ul><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//环境变量path配置及其作用</span></span><br><span class="line"><span class="number">1.</span> 环境变量的作用是为了在 dos 的任意目录,可以去使用 java 和 javac 命令</span><br><span class="line"><span class="number">2.</span> 先配置 JAVA_HOME = 指向 jdk 安装的主目录</span><br><span class="line"><span class="number">3.</span> 编辑 path 环境变量,增加 %JAVA_HOME%\bin </span><br></pre></td></tr></table></figure><ul class="lvl-1"><li class="lvl-2"><p>5</p></li></ul><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//Java编写步骤</span></span><br><span class="line"><span class="number">1.</span> 编写java的源代码</span><br><span class="line"><span class="number">2.</span> javac 编译 ,得到对应的 .class 字节码文件</span><br><span class="line"><span class="number">3.</span> java 运行, 本质就是把 .class 加载到 jvm 运行</span><br></pre></td></tr></table></figure><ul class="lvl-1"><li class="lvl-2"><p>6</p></li></ul><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//Java编写7个规范</span></span><br><span class="line"><span class="number">1.</span> 类,方法的注释,使用javadoc的方式,即文档注释</span><br><span class="line"><span class="number">2.</span> 非javadoc注释,往往是对代码的说明(给程序的维护者),说明如何修改,注意事项</span><br><span class="line"><span class="number">3.</span> 使用tab ,整体将代码右移, 使用 shift+tab 整体左移</span><br><span class="line"><span class="number">4.</span> 运算符和 = 的两边,给空格,代码看上去清楚 <span class="type">int</span> <span class="variable">n</span> <span class="operator">=</span> <span class="number">1</span> + <span class="number">4</span>;</span><br><span class="line"><span class="number">5.</span> 源码文件使用 utf-<span class="number">8</span> 编码</span><br><span class="line"><span class="number">6.</span> 行宽字符不要超过 <span class="number">80</span></span><br><span class="line"><span class="number">7.</span> 代码编程风格有两种 次行风格,行尾风格(推荐)</span><br></pre></td></tr></table></figure><ul class="lvl-1"><li class="lvl-2"><p>7</p></li></ul><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//初学者java易犯错误 </span></span><br><span class="line"><span class="number">1.</span> 编译或者运行时,找不到文件 javac Hell0.java, 把文件名或者目录找对</span><br><span class="line"><span class="number">2.</span> 主类名和文件名不一致 , 修改时保持一致即可</span><br><span class="line"><span class="number">3.</span> 缺少;</span><br><span class="line"><span class="number">4.</span> 拼写错误,比如 <span class="number">1</span> -> l <span class="number">0</span>-><span class="number">0</span>, <span class="keyword">void</span> -> viod , 要求写代码时,一定要小心</span><br><span class="line"></span><br><span class="line">强调: 先思考->自己练习->看老师评讲</span><br><span class="line"></span><br></pre></td></tr></table></figure></blockquote><hr>]]></content>
|
1497
1497
|
|
1498
1498
|
|
1499
1499
|
<categories>
|